aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/panel
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-06-05 14:48:31 +0200
committerRobert Jaros <rjaros@finn.pl>2020-06-05 14:48:31 +0200
commit8f1e8cf6b68c19120e176ae181118f1f88074b33 (patch)
tree9094c3847cae354205cb96a3dcd857c0aa264785 /src/main/kotlin/pl/treksoft/kvision/panel
parentb7901e371f148bedd105b1f91c5485ec6e9a2f48 (diff)
downloadkvision-8f1e8cf6b68c19120e176ae181118f1f88074b33.tar.gz
kvision-8f1e8cf6b68c19120e176ae181118f1f88074b33.tar.bz2
kvision-8f1e8cf6b68c19120e176ae181118f1f88074b33.zip
New DSL builders for DockPanel
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/panel')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt
index 52239032..835b9986 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt
@@ -108,6 +108,67 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit
}
/**
+ * DSL function to add components at the UP position.
+ * @param builder DSL builder function
+ */
+ open fun up(builder: Container.() -> Unit) {
+ object : Container by this@DockPanel {
+ override fun add(child: Component): Container {
+ return add(child, Side.UP)
+ }
+ }.builder()
+ }
+
+ /**
+ * DSL function to add components at the DOWN position.
+ * @param builder DSL builder function
+ */
+ open fun down(builder: Container.() -> Unit) {
+ object : Container by this@DockPanel {
+ override fun add(child: Component): Container {
+ return add(child, Side.DOWN)
+ }
+ }.builder()
+ }
+
+ /**
+ * DSL function to add components on the LEFT side.
+ * @param builder DSL builder function
+ */
+ open fun left(builder: Container.() -> Unit) {
+ object : Container by this@DockPanel {
+ override fun add(child: Component): Container {
+ return add(child, Side.LEFT)
+ }
+ }.builder()
+ }
+
+ /**
+ * DSL function to add components on the RIGHT side.
+ * @param builder DSL builder function
+ */
+ open fun right(builder: Container.() -> Unit) {
+ object : Container by this@DockPanel {
+ override fun add(child: Component): Container {
+ return add(child, Side.RIGHT)
+ }
+ }.builder()
+ }
+
+ /**
+ * DSL function to add components in CENTER.
+ * @param builder DSL builder function
+ */
+ open fun center(builder: Container.() -> Unit) {
+ val tempPanel = object : Container by this@DockPanel {
+ override fun add(child: Component): Container {
+ return add(child, Side.CENTER)
+ }
+ }
+ tempPanel.builder()
+ }
+
+ /**
* Adds a component to the dock container.
* @param child child component
* @param position position in the dock