diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-10-01 15:16:11 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-10-01 15:17:53 +0200 |
commit | a61948c5b79d2fb3402e14ee69a9a8f2a18c02b4 (patch) | |
tree | 4f51345d2050b141111e3f6ef4bb3d16d4c23e7f /src/main/kotlin/pl/treksoft/kvision/panel | |
parent | d732f672bfbfa565c6ec4fc037381554de251ad3 (diff) | |
download | kvision-a61948c5b79d2fb3402e14ee69a9a8f2a18c02b4.tar.gz kvision-a61948c5b79d2fb3402e14ee69a9a8f2a18c02b4.tar.bz2 kvision-a61948c5b79d2fb3402e14ee69a9a8f2a18c02b4.zip |
Widget wrapper used inside the containers
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/panel')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt | 19 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt | 4 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt index 243d1442..f7adfe8f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt @@ -3,6 +3,7 @@ package pl.treksoft.kvision.panel import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Widget +import pl.treksoft.kvision.core.WidgetWrapper import pl.treksoft.kvision.html.ALIGN import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag @@ -27,7 +28,7 @@ internal data class WidgetParam(val widget: Widget, val size: Int, val offset: I open class GridPanel(private val gridtype: GRIDTYPE = GRIDTYPE.BOOTSTRAP, private val gridsize: GRIDSIZE = GRIDSIZE.MD, protected var rows: Int = 0, protected var cols: Int = 0, align: ALIGN = ALIGN.NONE, classes: Set<String> = setOf()) : Container(classes) { - var align = align + private var align = align set(value) { field = value refresh() @@ -97,7 +98,8 @@ open class GridPanel(private val gridtype: GRIDTYPE = GRIDTYPE.BOOTSTRAP, privat if (row != null) { for (j in 0 until cols) { val wp = row[j] - val widget = wp?.widget?.addCssClass("dsgcol") ?: Tag(TAG.DIV, classes = setOf("dsgcol")) + val widget = wp?.widget?.let { WidgetWrapper(it, setOf("dsgcol")) } ?: + Tag(TAG.DIV, classes = setOf("dsgcol")) widget.widthPercent = num if (align != ALIGN.NONE) { widget.addCssClass(align.className) @@ -121,8 +123,9 @@ open class GridPanel(private val gridtype: GRIDTYPE = GRIDTYPE.BOOTSTRAP, privat for (j in 0 until cols) { val wp = row[j] if (auto) { - val widget = wp?.widget?.addCssClass("col-" + gridsize.size + "-" + num) ?: - Tag(TAG.DIV, classes = setOf("col-" + gridsize.size + "-" + num)) + val widget = wp?.widget?.let { + WidgetWrapper(it, setOf("col-" + gridsize.size + "-" + num)) + } ?: Tag(TAG.DIV, classes = setOf("col-" + gridsize.size + "-" + num)) if (align != ALIGN.NONE) { widget.addCssClass(align.className) } @@ -130,14 +133,14 @@ open class GridPanel(private val gridtype: GRIDTYPE = GRIDTYPE.BOOTSTRAP, privat } else { if (wp != null) { val s = if (wp.size > 0) wp.size else num - wp.widget.addCssClass("col-" + gridsize.size + "-" + s) + val widget = WidgetWrapper(wp.widget, setOf("col-" + gridsize.size + "-" + s)) if (wp.offset > 0) { - wp.widget.addCssClass("col-" + gridsize.size + "-offset-" + wp.offset) + widget.addCssClass("col-" + gridsize.size + "-offset-" + wp.offset) } if (align != ALIGN.NONE) { - wp.widget.addCssClass(align.className) + widget.addCssClass(align.className) } - rowContainer.add(wp.widget) + rowContainer.add(widget) } } } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt index 685cfc87..3d1db0e7 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt @@ -3,6 +3,7 @@ package pl.treksoft.kvision.panel import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Widget +import pl.treksoft.kvision.core.WidgetWrapper import pl.treksoft.kvision.html.ALIGN import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag @@ -21,7 +22,8 @@ open class HPanel(align: ALIGN = ALIGN.NONE, classes: Set<String> = setOf()) : G if (row != null) { for (j in 0 until cols) { val wp = row[j] - val widget = wp?.widget?.addCssClass("dsgcolf") ?: Tag(TAG.DIV, classes = setOf("dsgcolf")) + val widget = wp?.widget?.let { WidgetWrapper(it, setOf("dsgcolf")) } ?: + Tag(TAG.DIV, classes = setOf("dsgcolf")) rowContainer.add(widget) } } |