-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00223b8
commit 10e9621
Showing
53 changed files
with
1,771 additions
and
877 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
...commonMain/kotlin/org/hexworks/zircon/api/builder/component/HorizontalScrollBarBuilder.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
....core/src/commonMain/kotlin/org/hexworks/zircon/api/builder/component/ScrollBarBuilder.kt
This file was deleted.
Oops, something went wrong.
50 changes: 29 additions & 21 deletions
50
...c/commonMain/kotlin/org/hexworks/zircon/api/builder/component/VerticalScrollBarBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,49 @@ | ||
package org.hexworks.zircon.api.builder.component | ||
|
||
import org.hexworks.zircon.api.behavior.Scrollable | ||
import org.hexworks.zircon.api.builder.data.size | ||
import org.hexworks.zircon.api.component.ScrollBar | ||
import org.hexworks.zircon.api.component.builder.base.BaseComponentBuilder | ||
import org.hexworks.zircon.api.component.builder.base.BaseContainerBuilder | ||
import org.hexworks.zircon.api.dsl.buildChildFor | ||
import org.hexworks.zircon.internal.component.impl.DefaultVerticalScrollBar | ||
import org.hexworks.zircon.internal.component.renderer.VerticalScrollBarRenderer | ||
import org.hexworks.zircon.internal.component.renderer.DefaultVerticalScrollBarRenderer | ||
import org.hexworks.zircon.internal.dsl.ZirconDsl | ||
|
||
/** | ||
* Builder for a vertical [ScrollBar]. By default, it creates a [ScrollBar] with | ||
* - [itemsShownAtOnce]: `1` | ||
* - [numberOfScrollableItems]: `100` | ||
*/ | ||
@ZirconDsl | ||
class VerticalScrollBarBuilder : | ||
ScrollBarBuilder<ScrollBar>(VerticalScrollBarRenderer()) { | ||
class VerticalScrollBarBuilder( | ||
initialScrollable: Scrollable | ||
) : BaseComponentBuilder<ScrollBar>( | ||
initialRenderer = DefaultVerticalScrollBarRenderer() | ||
) { | ||
|
||
var scrollable: Scrollable = initialScrollable | ||
|
||
override fun build(): ScrollBar = DefaultVerticalScrollBar( | ||
componentMetadata = createMetadata(), | ||
renderingStrategy = createRenderingStrategy(), | ||
minValue = 0, | ||
maxValue = numberOfScrollableItems, | ||
itemsShownAtOnce = itemsShownAtOnce, | ||
numberOfSteps = size.height, | ||
).attachListeners() | ||
override fun build(): ScrollBar { | ||
val visibleSize = scrollable.visibleSize | ||
preferredSize = size { | ||
width = 1 | ||
height = visibleSize.height | ||
} | ||
return DefaultVerticalScrollBar( | ||
componentMetadata = createMetadata(), | ||
renderingStrategy = createRenderingStrategy(), | ||
scrollable = scrollable | ||
).attachListeners() | ||
} | ||
} | ||
|
||
/** | ||
* Creates a new [ScrollBar] using the component builder DSL and returns it. | ||
* Creates a new vertical [ScrollBar] using the component builder DSL and returns it. | ||
*/ | ||
fun buildVerticalScrollBar(init: VerticalScrollBarBuilder.() -> Unit): ScrollBar = | ||
VerticalScrollBarBuilder().apply(init).build() | ||
fun buildVerticalScrollBar(scrollable: Scrollable, init: VerticalScrollBarBuilder.() -> Unit): ScrollBar = | ||
VerticalScrollBarBuilder(scrollable).apply(init).build() | ||
|
||
/** | ||
* Creates a new [ScrollBar] using the component builder DSL, adds it to the | ||
* Creates a new vertical [ScrollBar] using the component builder DSL, adds it to the | ||
* receiver [BaseContainerBuilder] it and returns the [ScrollBar]. | ||
*/ | ||
fun <T : BaseContainerBuilder<*>> T.verticalScrollBar( | ||
scrollable: Scrollable, | ||
init: VerticalScrollBarBuilder.() -> Unit | ||
): ScrollBar = buildChildFor(this, VerticalScrollBarBuilder(), init) | ||
): ScrollBar = buildChildFor(this, VerticalScrollBarBuilder(scrollable), init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.