-
Notifications
You must be signed in to change notification settings - Fork 272
Adding an option to make drawer with horizontal text #1283
base: master
Are you sure you want to change the base?
Changes from all commits
c3a48f4
90c779b
20b7344
8f525d9
9899c11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -20,10 +21,11 @@ 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) : BorderPane() { | ||
class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean, isHorizontal: Boolean) : BorderPane() { | ||
val dockingSideProperty: ObjectProperty<Side> = SimpleObjectProperty(side) | ||
var dockingSide by dockingSideProperty | ||
|
||
|
@@ -151,10 +153,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 | ||
} | ||
} | ||
|
||
|
@@ -321,7 +327,10 @@ class DrawerItem(val drawer: Drawer, title: ObservableValue<String?>? = null, ic | |
if (change.wasAdded()) { | ||
change.addedSubList.asSequence() | ||
.filter { VBox.getVgrow(it) == null } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no check HBox.getHgrow(it) == null |
||
.forEach { VBox.setVgrow(it, Priority.ALWAYS) } | ||
.forEach { | ||
VBox.setVgrow(it, Priority.ALWAYS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a potential increase in memory. You need to think about how to check which type of Panel is used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I add a check for horizontal item here? In that case, I think I need to add a parameter for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be worth redesigning ExpandedDrawerContentArea itself |
||
HBox.setHgrow(it, Priority.ALWAYS) | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -334,6 +343,7 @@ class DrawerStyles : Stylesheet() { | |
val drawerItem by cssclass() | ||
val buttonArea by cssclass() | ||
val contentArea by cssclass() | ||
val horizontalDrawerItem by cssclass() | ||
} | ||
|
||
init { | ||
|
@@ -364,5 +374,9 @@ class DrawerStyles : Stylesheet() { | |
borderColor += box(Color.TRANSPARENT) | ||
} | ||
} | ||
horizontalDrawerItem { | ||
minWidth = 200.px | ||
alignment = Pos.CENTER_LEFT | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
append parameter
horizontalItem