diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-02-04 21:49:23 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-02-04 21:49:23 +0100 |
commit | 70d2f14d4a34f841a3161482eec5d355cbd755f6 (patch) | |
tree | 847cb461a2f261f6f2b3a6b0ebbc6918f1da0467 /src/main/kotlin/pl/treksoft/kvision/panel | |
parent | 9665fe692681bc958e55d00cc0d0b238b7aee694 (diff) | |
download | kvision-70d2f14d4a34f841a3161482eec5d355cbd755f6.tar.gz kvision-70d2f14d4a34f841a3161482eec5d355cbd755f6.tar.bz2 kvision-70d2f14d4a34f841a3161482eec5d355cbd755f6.zip |
Refactoring packages layout
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/panel')
4 files changed, 63 insertions, 3 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt index 66f2d422..ad3522ea 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt @@ -3,7 +3,7 @@ package pl.treksoft.kvision.panel import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.StyledComponent import pl.treksoft.kvision.core.WidgetWrapper -import pl.treksoft.kvision.snabbdom.StringPair +import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.utils.px enum class FLEXDIR(val dir: String) { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt index 3b226102..549f7631 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt @@ -2,7 +2,7 @@ package pl.treksoft.kvision.panel import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.WidgetWrapper -import pl.treksoft.kvision.snabbdom.StringPair +import pl.treksoft.kvision.core.StringPair enum class GRIDJUSTIFY(val justify: String) { START("start"), diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt new file mode 100644 index 00000000..88634bea --- /dev/null +++ b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt @@ -0,0 +1,60 @@ +package pl.treksoft.kvision.panel + +import com.github.snabbdom.VNode +import pl.treksoft.kvision.KVManager +import pl.treksoft.kvision.modal.Modal +import pl.treksoft.kvision.core.StringBoolPair + +class Root(id: String, private val fixed: Boolean = false) : SimplePanel() { + private val modals: MutableList<Modal> = mutableListOf() + private var rootVnode: VNode = renderVNode() + + internal var renderDisabled = false + + init { + rootVnode = KVManager.patch(id, this.renderVNode()) + this.id = id + roots.add(this) + } + + override fun render(): VNode { + return kvh("div#" + id, childrenVNodes() + modalsVNodes()) + } + + internal fun addModal(modal: Modal) { + modals.add(modal) + modal.parent = this + refresh() + } + + private fun modalsVNodes(): Array<VNode> { + return modals.filter { it.visible }.map { it.renderVNode() }.toTypedArray() + } + + override fun getSnClass(): List<StringBoolPair> { + val css = if (!fixed) "container-fluid" else "container" + return super.getSnClass() + (css to true) + } + + internal fun reRender(): Root { + if (!renderDisabled) { + rootVnode = KVManager.patch(rootVnode, renderVNode()) + } + return this + } + + override fun getRoot(): Root? { + return this + } + + companion object { + private val roots: MutableList<Root> = mutableListOf() + + internal fun getLastRoot(): Root? { + return if (roots.size > 0) + roots[roots.size - 1] + else + null + } + } +} diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index 722f60e6..10595a37 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -7,7 +7,7 @@ import pl.treksoft.kvision.core.StyledComponent import pl.treksoft.kvision.core.UNIT import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag -import pl.treksoft.kvision.snabbdom.obj +import pl.treksoft.kvision.utils.obj enum class DIRECTION(val dir: String) { HORIZONTAL("horizontal"), |