From 4a819ed5bb85ff6572199c74e6ec8cd7592ec97e Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Tue, 4 Feb 2020 13:54:29 +0100 Subject: [PATCH] Add collapsible panels to orx-gui --- orx-gui/src/main/kotlin/Gui.kt | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/orx-gui/src/main/kotlin/Gui.kt b/orx-gui/src/main/kotlin/Gui.kt index cbed63e3..d03a7a69 100644 --- a/orx-gui/src/main/kotlin/Gui.kt +++ b/orx-gui/src/main/kotlin/Gui.kt @@ -39,6 +39,10 @@ class GUI : Extension { this.height = 100.percent } + styleSheet(has class_ "collapsed") { + this.display = Display.NONE + } + styleSheet(has class_ "sidebar") { this.width = 200.px this.paddingBottom = 20.px @@ -48,10 +52,23 @@ class GUI : Extension { this.marginRight = 2.px this.height = 100.percent this.background = Color.RGBa(ColorRGBa.GRAY.copy(a = 0.2)) + this.overflow = Overflow.Scroll descendant(has type "colorpicker-button") { this.width = 175.px } + + descendant(has type "slider") { + this.width = 175.px + } + + descendant(has type "button") { + this.width = 175.px + } + + descendant(has type "textfield") { + this.width = 175.px + } } styleSheet(has type "dropdown-button") { @@ -72,10 +89,19 @@ class GUI : Extension { div("sidebar") { id = "sidebar" for ((obj, parameters) in trackedParams) { - h3 { obj.title() ?: "untitled" } - - for (parameter in parameters) { - addControl(obj, parameter) + val header = h3 { obj.title() ?: "untitled" } + val collapsible = div { + for (parameter in parameters) { + addControl(obj, parameter) + } + } + header.mouse.pressed.subscribe { + val c = ElementClass("collapsed") + if (c in collapsible.classes) { + collapsible.classes.remove(c) + } else { + collapsible.classes.add(c) + } } } }