Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions src/main/java/tornadofx/Drawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class Drawer(side: Side, multiselect: Boolean, floatingContent: Boolean) : Borde
val buttonBounds = buttonArea.layoutBounds
when (dockingSide) {
Side.RIGHT -> contentArea.resizeRelocate(buttonBounds.minX - contentArea.prefWidth(-1.0), buttonBounds.minY, contentArea.prefWidth(-1.0), buttonBounds.height)
Side.BOTTOM -> contentArea.resizeRelocate(buttonBounds.minX, buttonBounds.minY - contentArea.prefHeight(-1.0), buttonBounds.width, contentArea.prefHeight(-1.0))
else -> contentArea.resizeRelocate(buttonBounds.maxX, buttonBounds.minY, contentArea.prefWidth(-1.0), buttonBounds.height)
}
}
Expand All @@ -287,8 +288,8 @@ class ExpandedDrawerContentArea : VBox() {
while (change.next()) {
if (change.wasAdded()) {
change.addedSubList.asSequence()
.filter { VBox.getVgrow(it) == null }
.forEach { VBox.setVgrow(it, Priority.ALWAYS) }
.filter { getVgrow(it) == null }
.forEach { setVgrow(it, Priority.ALWAYS) }
}
}
}
Expand Down Expand Up @@ -320,8 +321,8 @@ class DrawerItem(val drawer: Drawer, title: ObservableValue<String?>? = null, ic
while (change.next()) {
if (change.wasAdded()) {
change.addedSubList.asSequence()
.filter { VBox.getVgrow(it) == null }
.forEach { VBox.setVgrow(it, Priority.ALWAYS) }
.filter { getVgrow(it) == null }
.forEach { setVgrow(it, Priority.ALWAYS) }
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/tornadofx/FX.kt
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,28 @@ fun EventTarget.addChildIfPossible(node: Node, index: Int? = null) {
header.items.add(targetIndex, node)
}
}
is Footer -> {
// Decide if the component should be tracked for removal on undock
(parent?.uiComponent<UIComponent>() as? Workspace)?.apply {
if (root.dynamicComponentMode) {
root.dynamicComponents.add(node)
}
}

if (node is MenuBar) {
// MenuBar is added below the toolbar and is not considered dynamic
children.add(node)
} else {
if (node is ButtonBase) {
// Add buttons after last button
val targetIndex = container.children.indexOfLast { it is Button } + 1
container.children.add(targetIndex, node)
} else {
container.children.add(node)
}
}

}
is Workspace -> {
root.addChildIfPossible(node, index)
}
Expand Down
47 changes: 33 additions & 14 deletions src/main/java/tornadofx/Workspace.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import javafx.scene.control.ToolBar
import javafx.scene.input.KeyCode
import javafx.scene.input.KeyCodeCombination
import javafx.scene.input.KeyCombination
import javafx.scene.layout.BorderPane
import javafx.scene.layout.HBox
import javafx.scene.layout.StackPane
import javafx.scene.layout.*
import tornadofx.Workspace.NavigationMode.Stack
import tornadofx.Workspace.NavigationMode.Tabs
import kotlin.reflect.KClass
Expand All @@ -30,6 +28,17 @@ class HeadingContainer : HBox() {
}
}

class Footer : VBox() {
internal var bottomDrawer: Drawer? = null
internal var container: HBox = HBox()

init {
addClass("footer")
container.addClass("footer-container")
children.add(container)
}
}

class WorkspaceArea : BorderPane() {
internal var dynamicComponentMode: Boolean = false
internal val dynamicComponents = FXCollections.observableArrayList<Node>()
Expand Down Expand Up @@ -71,6 +80,9 @@ open class Workspace(title: String = "Workspace", navigationMode: NavigationMode
val dockedComponentProperty: ObjectProperty<UIComponent> = SimpleObjectProperty()
val dockedComponent: UIComponent? get() = dockedComponentProperty.value

val showFooterProperty = SimpleBooleanProperty(false)
var showFooter by showFooterProperty

private val viewPos = integerBinding(viewStack, dockedComponentProperty) { viewStack.indexOf(dockedComponent) }

val leftDrawer: Drawer
Expand All @@ -86,9 +98,16 @@ open class Workspace(title: String = "Workspace", navigationMode: NavigationMode
}

val bottomDrawer: Drawer
get() = (root.bottom as? Drawer) ?: Drawer(Side.BOTTOM, false, false).also {
get() = (root.bottom as? Footer)?.bottomDrawer ?: Drawer(Side.BOTTOM, false, false).also {
footer.bottomDrawer = it
footer.children.add(0, it)
}

val footer: Footer
get() = (root.bottom as? Footer) ?: Footer().also {
it.container.visibleWhen(showFooterProperty)
it.container.managedWhen(showFooterProperty)
root.bottom = it
it.toFront()
}

companion object {
Expand Down Expand Up @@ -335,26 +354,26 @@ open class Workspace(title: String = "Workspace", navigationMode: NavigationMode

override fun onSave() {
dockedComponentProperty.value
?.takeIf { it.effectiveSavable.value }
?.onSave()
?.takeIf { it.effectiveSavable.value }
?.onSave()
}

override fun onDelete() {
dockedComponentProperty.value
?.takeIf { it.effectiveDeletable.value }
?.onDelete()
?.takeIf { it.effectiveDeletable.value }
?.onDelete()
}

override fun onCreate() {
dockedComponentProperty.value
?.takeIf { it.effectiveCreatable.value }
?.onCreate()
?.takeIf { it.effectiveCreatable.value }
?.onCreate()
}

override fun onRefresh() {
dockedComponentProperty.value
?.takeIf { it.effectiveRefreshable.value }
?.onRefresh()
?.takeIf { it.effectiveRefreshable.value }
?.onRefresh()
}

inline fun <reified T : UIComponent> dock(scope: Scope = this@Workspace.scope, params: Map<*, Any?>? = null) = dock(find<T>(scope, params))
Expand All @@ -364,7 +383,7 @@ open class Workspace(title: String = "Workspace", navigationMode: NavigationMode
if (child == dockedComponent) return

// Remove everything after viewpos if moving forward
if (forward) while (viewPos.get() < viewStack.size -1) viewStack.removeAt(viewPos.get() + 1)
if (forward) while (viewPos.get() < viewStack.size - 1) viewStack.removeAt(viewPos.get() + 1)

val addToStack = contentContainer == stackContainer && maxViewStackDepth > 0 && child !in viewStack

Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/tornadofx/workspace.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@

.workspace .header .icon.delete {
-fx-shape: "M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"
}
}

.workspace .footer .footer-container {
-fx-alignment: center-left;
-fx-padding: 0.2em;
-fx-spacing: 0.5em;
-fx-background-color: #e7e7e7;
}