Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Adding an option to make drawer with horizontal text #1283

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/main/java/tornadofx/Drawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +24,7 @@ fun EventTarget.drawer(
op: Drawer.() -> Unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

append parameter horizontalItem

) = Drawer(side, multiselect, floatingContent).attachTo(this, op)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old constructor is not used here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

append default value


class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean) : BorderPane() {
class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean, horizontalItem: Boolean) : BorderPane() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be worth renaming. For example, by adding the prefix ʻis, it is possible to remove ʻItem.

val dockingSideProperty: ObjectProperty<Side> = SimpleObjectProperty(side)
var dockingSide by dockingSideProperty

Expand Down Expand Up @@ -151,10 +152,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
}
}

Expand Down Expand Up @@ -321,7 +326,10 @@ class DrawerItem(val drawer: Drawer, title: ObservableValue<String?>? = null, ic
if (change.wasAdded()) {
change.addedSubList.asSequence()
.filter { VBox.getVgrow(it) == null }
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Author

Choose a reason for hiding this comment

The 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 DrawerItem in order to check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth redesigning ExpandedDrawerContentArea itself

HBox.setHgrow(it, Priority.ALWAYS)
}
}
}
}
Expand All @@ -334,6 +342,7 @@ class DrawerStyles : Stylesheet() {
val drawerItem by cssclass()
val buttonArea by cssclass()
val contentArea by cssclass()
val horizontalDrawerItem by cssclass()
}

init {
Expand Down Expand Up @@ -364,5 +373,9 @@ class DrawerStyles : Stylesheet() {
borderColor += box(Color.TRANSPARENT)
}
}
horizontalDrawerItem {
minWidth = 200.px
alignment = Pos.CENTER_LEFT
}
}
}
}