feat(fx): add overlay groups and atomic floating window close

This commit is contained in:
2026-11-15 23:06:34 +01:00
parent 0aa9f7fae3
commit bff6257dfe
32 changed files with 2220 additions and 142 deletions
+44 -2
View File
@@ -1,4 +1,4 @@
# Asynchronous tab close
# Asynchronous tab and floating-window close
Use `Dockable.setCloseCheck` to supply a `CompletionStage<CloseConsent>`.
The callback receives the request scope and the JavaFX window hosting the
@@ -25,5 +25,47 @@ 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
works through the tab's close control. Main-window shutdown is added by the
later lifecycle slices; this example demonstrates individual tab consent.
## Closing a floating window
`requestFloatingWindowClose(windowId)` and the floating Stage's window close
control use one atomic workflow. The manager snapshots the window's Dockables
in layout/tab order and asks each sequentially, including after a veto or failed
check. Every callback receives the same `FLOATING_WINDOW` scope and the owning
floating Stage. No tab is detached before all answers allow closure. Application
saves already completed by a callback remain saved if a later callback vetoes.
The running scope protects the entire window against structural changes.
Duplicate window requests and tab requests covered by that running window
request share its outcome. Independent requests queue in order; a veto does not
cancel the next independent window. Content remains editable while decisions
are pending. There is no blocking wait or nested JavaFX event loop.
After unanimous consent, all affected content is detached and the completed
layout is published once. Then every `onClosed` callback runs, even if an earlier
cleanup fails. `Closed.cleanupFailures()` reports those failures. The scope stays
observable until cleanup finishes. Unknown/already closed floating IDs return
`NoChange`; the main-window ID is rejected by this floating-only entry point.
Main-window and manager shutdown, including the shutdown snapshot callback,
belong to the later shutdown slices.
The example launcher is
`de.neitzel.fx.example.docking.FloatingCloseDockingMain`. It creates First and
Second in one floating window plus Other in an independent window. Its saves
are in-memory demonstration snapshots in the log, not filesystem writes.
1. Choose **Close Editors**, then **Save and allow** for First and **Keep open**
for Second. Both editors remain open and First's saved text stays in the log.
2. Close Editors again; veto First. Second is still asked. Answer it to finish
the request without closing either editor.
3. While a decision is pending, use **Repeat Editors close** and **Close Second
tab**. They report the same result without additional prompts.
4. During that pending request, choose **Close Other window**. Its prompt starts
after the Editors request ends, including when Editors was vetoed.
5. Approve both Editors. The window disappears before either release log entry.
The floating window's native close control follows the same sequence.
The demo's main Stage is only a control panel; closing it hides its demonstration
windows. This is separate from the future application-wide shutdown protocol.
+3 -2
View File
@@ -43,8 +43,9 @@ module for a desktop demonstration:
6. Open Project's tab menu to inspect the disabled Float command.
The buttons and tab menus use the same manager operations. This example covers
command-based transfers. Native drag-and-drop between windows and the full
multi-tab window-close workflow are supplied by their subsequent tickets.
command-based transfers. Native drag-and-drop between windows is supplied by its subsequent ticket.
The [floating-window close guide](docking-close.md#closing-a-floating-window)
describes shared consent for all tabs in a window.
## Native keyboard qualification
+4 -3
View File
@@ -42,9 +42,10 @@ remain possible. The initial definition supplied at attachment remains
independent of live updates.
`DockGroupChanges` covers tab side, preferred/minimum width and height,
persistence, empty visibility, empty-space release, collapsibility and split
directions. Each new split receives its own copy of its target's settings.
Overlay display is provided by the subsequent overlay slice.
persistence, empty visibility, empty-space release, collapsibility, display mode
and split directions. Each new split receives its own copy of its target's settings.
See [overlay and pinned groups](docking-overlays.md) for shared dimensions,
keyboard pinning and temporary display above the docked content.
Run `DockingMain` (or `--fxml`) and select Project. Click it again to collapse,
then click Changed files to reopen the same group. The toolbar also exposes
+63
View File
@@ -0,0 +1,63 @@
# Overlay and pinned tool groups
`DockGroupMode.OVERLAY` lets an expanded tool group cover the editor while only
its tab rail reserves space. `DOCKED` pins the group into the layout and reserves
its full extent. Mode and remembered dimensions belong to the whole group;
selecting another tab does not change them. Overlay mode requires a collapsible
group, and initial overlay groups start collapsed.
Configure an ordinary JavaFX/FXML group with `mode="OVERLAY"` and
`collapsible="true"`. The same configuration is available through
`DockGroupDefinition.setMode`. For a live group, use the public atomic update:
```java
manager.updateGroup(groupId, DockGroupChanges.builder()
.mode(DockGroupMode.DOCKED)
.build());
```
Opening an overlay, selecting one of its tabs or activating a contained Dockable
closes the previous overlay in the same window. Pinned groups stay open. Clicking
outside an expanded overlay within a managed JavaFX Scene collapses it; Escape
from its content also collapses it and returns focus to its header. This is not
a global desktop mouse hook: clicks in other applications are outside that
observation boundary. A pending close protects affected groups against these
conflicting changes.
Dragging toward a collapsed overlay rail shows a drop preview without opening
the group. Escape cancels that preview. A successful drop opens the target,
activates the moved content, preserves its group mode and size, and collapses
the previous overlay in that window. These behaviors are verified for all four
edge directions through live JavaFX controls and public manager state.
Each tab's context menu provides **Pin group**, also available through keyboard
context-menu navigation. The action changes the entire group. An invalid
combination, such as an overlay that cannot collapse, is rejected without
changing the layout.
## Runnable FXML example
Launch `de.neitzel.fx.example.docking.OverlayDockingMain` in the `fx-example`
module. It loads `OverlayDocking.fxml` directly and uses no MVVM services. The
center editor remains docked; Project and Changes start as collapsed overlays
with remembered widths of 240 and 260 pixels.
1. Choose **Show Project**, then **Show Changes**. Only the most recent overlay
stays expanded. The status line reports both groups.
2. Click inside the editor or press Escape inside an overlay to collapse it.
3. Show Project and choose **Pin Project**. It now reserves layout space.
Showing Changes leaves the pinned Project group expanded.
4. Choose **Unpin Project** to return it to overlay mode without changing the
content instance or remembered width.
5. Focus a tool-tab header, open its context menu with the platform keyboard
context-menu command, and select **Pin group**.
6. Drag a tab onto the opposite overlay rail. Cancel one preview with Escape;
complete the next drop to inspect selection, overlay arbitration and size.
Build the example and its actual-FXML integration check without installing
runtime artifacts:
```sh
./mvnw -pl fx-example -am -Dtest=OverlayDockingExampleTest \
-Dsurefire.failIfNoSpecifiedTests=false test
```
+3 -2
View File
@@ -39,8 +39,9 @@ application actions. Moving keyboard focus to a global button preserves it.
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. See [split groups](docking-splits.md) for
nested layouts and resizing, [group presentation](docking-groups.md) for
collapse and atomic configuration, and [close consent](docking-close.md) for
nested layouts and resizing, [group presentation](docking-groups.md) for collapse
and atomic configuration, [overlay groups](docking-overlays.md) for pinning,
and [close consent](docking-close.md) for
asynchronous close checks. Restoration is supplied by a later slice.
## Move and check placement