feat(fx): add resizable split groups and asynchronous tab close
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# Asynchronous tab close
|
||||
|
||||
Use `Dockable.setCloseCheck` to supply a `CompletionStage<CloseConsent>`.
|
||||
The callback receives the request scope and the JavaFX window hosting the
|
||||
content. It can show a nonblocking confirmation or await a save. Return ALLOW
|
||||
to close or VETO to keep the content available. A failed check is reported as
|
||||
a veto with its cause. The manager resumes completion on the FX thread.
|
||||
|
||||
The tab's close control, context-menu action and `requestTabClose(id)` use the
|
||||
same workflow. No tab content is removed while consent is pending. Repeated
|
||||
requests covering that tab share the pending outcome and do not repeat prompts.
|
||||
`closingScopeProperty()` reports affected IDs until the request and resource
|
||||
release finish. Conflicting structural operations return `CLOSE_IN_PROGRESS`;
|
||||
application prompts and content input can continue.
|
||||
|
||||
`setOnClosed` releases resources after an actual close. It is separate from
|
||||
`setOnDiscarded`, which releases factory-prepared content that never opened.
|
||||
Moving or vetoing a close calls neither close cleanup nor unused-content cleanup.
|
||||
A cleanup exception is reported in `CloseResult.Closed.cleanupFailures()`;
|
||||
it does not undo a completed close. Closing the active tab selects its group's
|
||||
replacement or the most recently active visible Dockable, or clears the active
|
||||
value if none is visible.
|
||||
|
||||
The `CloseDockingMain` launcher in the example module shows a pending close
|
||||
without a nested event loop. Choose Close Notes, then Keep open and continue
|
||||
editing. Request close again and choose Allow close. Until that decision, Notes
|
||||
remains open; after approval its resource callback runs. The same demonstration
|
||||
works through the tab's close control. Window-wide shutdown is added by the
|
||||
later lifecycle slices; this example demonstrates individual tab consent.
|
||||
+17
-2
@@ -5,6 +5,18 @@ a tab strip inserts at the displayed marker, including when reordering within
|
||||
the same group. The tab's text/icon bindings and its live content stay intact.
|
||||
All four tab sides are supported.
|
||||
|
||||
Dropping near a content edge creates an adjacent group and previews the half
|
||||
that will receive the tab. The target group's allowed split directions,
|
||||
minimum dimensions and application placement rule determine whether the split
|
||||
is available. A rejected edge split falls back to joining that group. Moving
|
||||
the sole tab to its own group's edge is an explicit no-change operation.
|
||||
The tab strip always retains its insertion behavior.
|
||||
|
||||
Persistent empty groups remain drop destinations. When they release their
|
||||
space, a narrow drop indicator appears at their configured outer edge during
|
||||
the gesture. Their content remains hidden until a tab is actually placed there.
|
||||
An invisible group that keeps its space accepts drops in its reserved area.
|
||||
|
||||
The move preview uses the same `checkMove` rules as an application command.
|
||||
Placement is checked again on release. A rejected location has no marker;
|
||||
a move that would leave the tab where it is uses a muted marker. Escape
|
||||
@@ -15,13 +27,16 @@ Every tab also provides a **Move to** context submenu. It lists the currently
|
||||
available groups and the selected content's current title. Rejected targets
|
||||
are disabled with their reason; selecting an enabled item invokes the same
|
||||
manager move operation and rechecks the destination.
|
||||
The **Split** submenu offers the four directions for the tab's current group,
|
||||
with unavailable directions disabled and explained. These explicit commands
|
||||
request a split without the pointer gesture's join fallback.
|
||||
|
||||
The preview is mouse-transparent and has CSS class `dock-drop-indicator`.
|
||||
Its `no-change` pseudo-class identifies a preview that leaves the current
|
||||
placement intact. Applications may style its fill and stroke using JavaFX CSS.
|
||||
|
||||
This slice covers the main window. Splitting, floating, cross-window pointer
|
||||
delivery and edge overlays extend these gestures in their respective tickets.
|
||||
This slice covers the main window. Floating and cross-window pointer delivery
|
||||
extend these gestures in their respective tickets.
|
||||
The gesture regression tests fire JavaFX events at visible tab headers and
|
||||
observe the public manager state. Those tests do not by themselves establish
|
||||
native mouse delivery across windows; that has a separate desktop acceptance
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# Split groups and predefined destinations
|
||||
|
||||
A `DockGroupDefinition` is one named group. A `DockSplitDefinition` is a named
|
||||
binary branch with `first`, `second`, an `Orientation` and an initial `position`
|
||||
between zero and one. Either branch can itself be a split. Both definitions
|
||||
implement `DockLayoutNode`, so Java and ordinary FXML describe the same tree.
|
||||
Each initial destination name must be unique across the complete layout.
|
||||
|
||||
Move an open Dockable with `DockTarget.split(groupId, Side.RIGHT)` (or another
|
||||
side). The manager checks the target and application placement policy before
|
||||
allocating a new group identity. `SplitDirections` permits `ALL`, `NONE`,
|
||||
`HORIZONTAL` (left/right), or `VERTICAL` (top/bottom). The new group starts with
|
||||
the target's tab presentation, size constraints and splitting policy. The two
|
||||
groups can subsequently be configured independently.
|
||||
|
||||
Group minimum dimensions default to 80 pixels each and are configurable through
|
||||
`minimumWidth` and `minimumHeight`. Splitting requires both minima plus the
|
||||
divider to fit. A dynamic split starts evenly. A drop near a disabled or
|
||||
ineligible edge falls back to tab insertion when insertion is allowed; an
|
||||
explicit API split request returns its rejection instead. Dropping a group's
|
||||
only tab on its own edge makes no change.
|
||||
|
||||
When either branch loses its last Dockable, that split dissolves and its sibling
|
||||
fills the area. Nested splits inside the surviving branch remain. The emptied
|
||||
concrete group ID no longer resolves. The predefined area ID remains usable and
|
||||
now names the surviving group or branch. An area containing multiple groups
|
||||
chooses the most recently active eligible group, then the first eligible group
|
||||
in visual order. Callers can still name a concrete group to control placement
|
||||
precisely. Initially empty branches elsewhere in the layout are unaffected by
|
||||
an unrelated move.
|
||||
|
||||
`DockLayoutView.Area.groups()` lists its leaf groups in visual order. `root()`
|
||||
exposes the immutable hierarchy as `DockLayoutView.Group` and
|
||||
`DockLayoutView.Split`, including the published divider proportion. Named nested
|
||||
destinations appear as areas as well; one concrete group can consequently be
|
||||
reachable through several area IDs.
|
||||
|
||||
Groups are persistent by default. Outside an emptied split, an empty persistent
|
||||
group keeps its destination and initial space. Set `visibleWhenEmpty=false` to
|
||||
hide its empty content, and `releaseSpaceWhenEmpty=true` to give that space back.
|
||||
Releasing space also hides the empty content, regardless of `visibleWhenEmpty`.
|
||||
An empty side destination remains available as a narrow drop target at that
|
||||
edge; a hidden group that retains its space accepts drops in its reserved bounds.
|
||||
The last occupied side extent is retained when content returns. A root with
|
||||
`persistent=false` disappears after its last Dockable leaves, including its
|
||||
destination IDs. These settings are captured at attachment and inherited by a
|
||||
newly split group.
|
||||
|
||||
Run `DockingMain --splits` for a Java-defined nested editor layout, or
|
||||
`DockingMain --splits --fxml` for its ordinary FXML equivalent. The explicit
|
||||
split button, tab context menu and edge drops share the same split checks.
|
||||
Move the Project tab away to release the tool area, then drag it back to the
|
||||
right edge to fill its persistent target again. The ordinary `--fxml` mode and
|
||||
Java default still start with one editor group.
|
||||
|
||||
The split tests exercise both emptied-branch directions, nested ordinary FXML,
|
||||
minimum-size and direction rejections, and area fallback after a placement
|
||||
policy changes. The companion docking example demonstrates these interactions
|
||||
through public operations.
|
||||
|
||||
## Resize boundaries
|
||||
|
||||
Both split dividers and the inner boundaries of predefined side areas are
|
||||
draggable. Horizontal resizing uses the left/right cursor; vertical resizing
|
||||
uses the up/down cursor. The content follows the pointer while group minima
|
||||
remain in force. A boundary covered by a pending close request cannot resize;
|
||||
unrelated areas remain available.
|
||||
|
||||
The read-only layout keeps its previously published geometry during the drag.
|
||||
Releasing the pointer publishes the completed size or proportion once.
|
||||
`Area.preferredWidth()` holds a left/right area's remembered content width;
|
||||
`preferredHeight()` holds a top/bottom area's remembered content height. The
|
||||
other dimension is `-1`, meaning it follows the available space. The five-pixel
|
||||
outer divider is separate from the content extent. A side area's remembered
|
||||
extent survives replacement of its split branch and temporary hiding.
|
||||
|
||||
The surrounding region has style class `dock-edge-area`; its resize handle has
|
||||
`dock-area-divider`. The ordinary JavaFX `split-pane-divider` style class applies
|
||||
to split dividers. These handles do not replace or recreate the application
|
||||
content when resizing.
|
||||
+3
-2
@@ -38,8 +38,9 @@ application actions. Moving keyboard focus to a global button preserves it.
|
||||
`activate(id)` selects the Dockable and requests focus within its content.
|
||||
The content instance remains owned by the application. A supplied
|
||||
`setFocusTarget` chooses a Node within the content; otherwise the manager tries
|
||||
the previously focused descendant. Future slices add splits, close consent
|
||||
and restoration.
|
||||
the previously focused descendant. See [split groups](docking-splits.md) for
|
||||
nested layouts and resizing and [close consent](docking-close.md) for asynchronous
|
||||
close checks. Restoration is supplied by a later slice.
|
||||
|
||||
## Move and check placement
|
||||
|
||||
|
||||
Reference in New Issue
Block a user