From c3a48f4e427abfd8dfec32a758c4d097e781e458 Mon Sep 17 00:00:00 2001 From: Huy-Ngo Date: Wed, 26 Aug 2020 14:03:20 +0700 Subject: [PATCH 1/5] Add horizontalItem as a parameter and not rotate in the case --- src/main/java/tornadofx/Drawer.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/tornadofx/Drawer.kt b/src/main/java/tornadofx/Drawer.kt index f6a0c1956..9916f9d11 100644 --- a/src/main/java/tornadofx/Drawer.kt +++ b/src/main/java/tornadofx/Drawer.kt @@ -23,7 +23,7 @@ fun EventTarget.drawer( op: Drawer.() -> Unit ) = Drawer(side, multiselect, floatingContent).attachTo(this, op) -class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean) : BorderPane() { +class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean, horizontalItem: Boolean) : BorderPane() { val dockingSideProperty: ObjectProperty = SimpleObjectProperty(side) var dockingSide by dockingSideProperty @@ -151,10 +151,14 @@ class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean) : Borde } private fun configureRotation(button: ToggleButton) { - button.rotate = when (dockingSide) { - Side.LEFT -> -90.0 - Side.RIGHT -> 90.0 - else -> 0.0 + button.rotate = if (this.horizontalItem) { + when (dockingSide) { + Side.LEFT -> -90.0 + Side.RIGHT -> 90.0 + else -> 0.0 + } + } else { + 0.0 } } From 90c779b60b4d7cec48b71362113d69578eb95b33 Mon Sep 17 00:00:00 2001 From: Huy-Ngo Date: Wed, 26 Aug 2020 14:11:33 +0700 Subject: [PATCH 2/5] Set the toggle buttons in drawer's HGrow to always --- src/main/java/tornadofx/Drawer.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/tornadofx/Drawer.kt b/src/main/java/tornadofx/Drawer.kt index 9916f9d11..bfe4e319a 100644 --- a/src/main/java/tornadofx/Drawer.kt +++ b/src/main/java/tornadofx/Drawer.kt @@ -325,7 +325,10 @@ class DrawerItem(val drawer: Drawer, title: ObservableValue? = null, ic if (change.wasAdded()) { change.addedSubList.asSequence() .filter { VBox.getVgrow(it) == null } - .forEach { VBox.setVgrow(it, Priority.ALWAYS) } + .forEach { + VBox.setVgrow(it, Priority.ALWAYS) + HBox.setHgrow(it, Priority.ALWAYS) + } } } } @@ -369,4 +372,4 @@ class DrawerStyles : Stylesheet() { } } } -} \ No newline at end of file +} From 20b73448c2592a49004e0a16f19e99ecc5592b4c Mon Sep 17 00:00:00 2001 From: Huy-Ngo Date: Fri, 11 Sep 2020 20:15:20 +0700 Subject: [PATCH 3/5] Expand drawer's item to fill up the drawer This is a temporary solution. The size of each button is fixed to 150px, which can be too wide or too narrow for someone else. Preferable solutions would be: - Make the drawer resizable and the items to fill the drawer - Make the drawer items' width to always be equal to the widest one Either solution sounds good to me, though for now I can't think of a way to implement either --- src/main/java/tornadofx/Drawer.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/tornadofx/Drawer.kt b/src/main/java/tornadofx/Drawer.kt index bfe4e319a..a1f59e7e0 100644 --- a/src/main/java/tornadofx/Drawer.kt +++ b/src/main/java/tornadofx/Drawer.kt @@ -5,6 +5,7 @@ import javafx.beans.value.ObservableValue import javafx.collections.FXCollections import javafx.event.EventTarget import javafx.geometry.Orientation +import javafx.geometry.Pos import javafx.geometry.Side import javafx.scene.Group import javafx.scene.Node @@ -341,6 +342,7 @@ class DrawerStyles : Stylesheet() { val drawerItem by cssclass() val buttonArea by cssclass() val contentArea by cssclass() + val horizontalDrawerItem by cssclass() } init { @@ -371,5 +373,9 @@ class DrawerStyles : Stylesheet() { borderColor += box(Color.TRANSPARENT) } } + horizontalDrawerItem { + minWidth = 200.px + alignment = Pos.CENTER_LEFT + } } } From 8f525d9b1195e6eff71758acfbaf75cdc0542fc8 Mon Sep 17 00:00:00 2001 From: Huy-Ngo Date: Mon, 5 Oct 2020 09:06:42 +0700 Subject: [PATCH 4/5] Rename horizontalItem to isHorizontal --- src/main/java/tornadofx/Drawer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tornadofx/Drawer.kt b/src/main/java/tornadofx/Drawer.kt index a1f59e7e0..78687bae8 100644 --- a/src/main/java/tornadofx/Drawer.kt +++ b/src/main/java/tornadofx/Drawer.kt @@ -24,7 +24,7 @@ fun EventTarget.drawer( op: Drawer.() -> Unit ) = Drawer(side, multiselect, floatingContent).attachTo(this, op) -class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean, horizontalItem: Boolean) : BorderPane() { +class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean, isHorizontal: Boolean) : BorderPane() { val dockingSideProperty: ObjectProperty = SimpleObjectProperty(side) var dockingSide by dockingSideProperty From 9899c1177f82ff97423a9732638d259577e397e2 Mon Sep 17 00:00:00 2001 From: Huy-Ngo Date: Mon, 5 Oct 2020 09:24:48 +0700 Subject: [PATCH 5/5] Add the new parameters to EventTarget --- src/main/java/tornadofx/Drawer.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/tornadofx/Drawer.kt b/src/main/java/tornadofx/Drawer.kt index 78687bae8..369d22f15 100644 --- a/src/main/java/tornadofx/Drawer.kt +++ b/src/main/java/tornadofx/Drawer.kt @@ -21,8 +21,9 @@ fun EventTarget.drawer( side: Side = Side.LEFT, multiselect: Boolean = false, floatingContent: Boolean = false, + isHorizontal: Boolean = false, op: Drawer.() -> Unit -) = Drawer(side, multiselect, floatingContent).attachTo(this, op) +) = Drawer(side, multiselect, floatingContent, isHorizontal).attachTo(this, op) class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean, isHorizontal: Boolean) : BorderPane() { val dockingSideProperty: ObjectProperty = SimpleObjectProperty(side)