Merge pull request #8915 from dotCooCoo/fix/native-geometry-accordion-replay

Document native panel geometry and test tab-group reuse
This commit is contained in:
BFlat authored and GitHub committed 2026-11-27 05:09:48 +07:00
commit 8f30d9c47c
4 files changed
+31 -5

No files matched your search

+1 -1
View File
@@ -771,7 +771,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"window.panel.float",
"Float Panel",
"",
"{panel: id or \"tools\", x?, y?, width?, height?, group?: bool, column?: bool or n, onto?: id, above?: id, below?: id, collapsed?: bool} float a panel (with `group`, its whole group; with `column`, its whole dock column or floating window) as a floating window with its top-left corner at x, y in window points (default: inside the dock area, cascaded), as dragging its tab out does; a whole floating window keeps its rect unless given one. Supplied geometry also moves or resizes an existing native window; omitted components keep their current values. `onto` makes it a tab of the floating group holding that panel instead; `above` / `below` a group of its own above or below the group holding that panel, in its floating window or dock column. `collapsed` then minimizes (true) or restores (false) its window or group. A hidden panel shows first. \"tools\" floats the Tools panel at x, y. Returns {layout, closed, floating}",
"{panel: id or \"tools\", x?, y?, width?, height?, group?: bool, column?: bool or n, onto?: id, above?: id, below?: id, collapsed?: bool} float a panel (with `group`, its whole group; with `column`, its whole dock column or floating window) as a floating window with its top-left corner at x, y in window points (default: inside the dock area, cascaded), as dragging its tab out does; a whole floating window keeps its rect unless given one. Supplied geometry also moves or resizes an existing native window when the float takes the whole window (a panel alone in it, `column`, or `group` on a tab group that fills it); omitted components keep their current values. A panel that shares its native window floats into a new window instead, and the shared window keeps its other panels. `onto` makes it a tab of the floating group holding that panel instead; `above` / `below` a group of its own above or below the group holding that panel, in its floating window or dock column. `collapsed` then minimizes (true) or restores (false) its window or group. A hidden panel shows first. \"tools\" floats the Tools panel at x, y. Returns {layout, closed, floating}",
),
(
"window.panel.dock",
+1 -1
View File
@@ -772,7 +772,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"window.panel.float",
"Float Panel",
"",
"{panel: id or \"tools\", x?, y?, width?, height?, group?: bool, column?: bool or n, onto?: id, above?: id, below?: id, collapsed?: bool} float a panel (with `group`, its whole group; with `column`, its whole dock column or floating window) as a floating window with its top-left corner at x, y in window points (default: inside the dock area, cascaded), as dragging its tab out does; a whole floating window keeps its rect unless given one. Supplied geometry also moves or resizes an existing native window; omitted components keep their current values. `onto` makes it a tab of the floating group holding that panel instead; `above` / `below` a group of its own above or below the group holding that panel, in its floating window or dock column. `collapsed` then minimizes (true) or restores (false) its window or group. A hidden panel shows first. \"tools\" floats the Tools panel at x, y. Returns {layout, closed, floating}",
"{panel: id or \"tools\", x?, y?, width?, height?, group?: bool, column?: bool or n, onto?: id, above?: id, below?: id, collapsed?: bool} float a panel (with `group`, its whole group; with `column`, its whole dock column or floating window) as a floating window with its top-left corner at x, y in window points (default: inside the dock area, cascaded), as dragging its tab out does; a whole floating window keeps its rect unless given one. Supplied geometry also moves or resizes an existing native window when the float takes the whole window (a panel alone in it, `column`, or `group` on a tab group that fills it); omitted components keep their current values. A panel that shares its native window floats into a new window instead, and the shared window keeps its other panels. `onto` makes it a tab of the floating group holding that panel instead; `above` / `below` a group of its own above or below the group holding that panel, in its floating window or dock column. `collapsed` then minimizes (true) or restores (false) its window or group. A hidden panel shows first. \"tools\" floats the Tools panel at x, y. Returns {layout, closed, floating}",
),
(
"window.panel.dock",
@@ -242,6 +242,28 @@ fn an_explicit_float_command_updates_an_existing_native_windows_geometry() {
}
}
/// Swatches and Color as tabs of one native window, with its OS window drawn.
fn native_tab_group(h: &mut Harness) -> ViewportId {
let viewport = h.float("swatches");
h.app.run("window.panel.float", json!({"panel": "color", "onto": "swatches"})).unwrap();
h.frames(3);
assert_eq!(h.viewport("color"), viewport);
viewport
}
#[test]
fn a_group_float_of_a_tab_group_resizes_its_native_window() {
let mut h = Harness::new();
let viewport = native_tab_group(&mut h);
let id = floating_window(layout_of(&h.app.ui), "swatches").unwrap().id;
let before = h.host.borrow().windows[&viewport].rect;
h.app.run("window.panel.float", json!({"panel": "swatches", "group": true, "width": 400})).unwrap();
h.frames(3);
assert_eq!(floating_window(layout_of(&h.app.ui), "swatches").unwrap().id, id);
assert_eq!(h.viewport("color"), viewport);
assert_eq!(h.host.borrow().windows[&viewport].rect, Rect::from_min_size(before.min, vec2(400.0, before.height())));
}
/// `window.toolbar.float` with x, y moves the OS window a toolbar made with New Toolbar already has.
#[test]
fn floating_a_toolbar_at_a_point_moves_its_native_window() {
+7 -3
View File
@@ -6375,9 +6375,13 @@ and several can be open at once. `window.swatchLibrary {library}`, `window.graph
`{open, panel, name, count}`; `library: null` closes every panel of that kind. The panel id is
`library:<kind>:<library id>` (`library:swatches:pastels`, `library:graphicStyles:hand-drawn`,
`library:swatches:loaded/C:/Palettes/Brand.ase`), and the panel commands take it like any other panel's:
`window.panel.float {panel, onto?, x?, y?, width?, height?}` groups, moves or resizes it. Supplied
geometry also updates an existing native panel window. Positions are relative to the main window's
content origin; omitted coordinates and dimensions keep the native window's current values.
`window.panel.float {panel, onto}` makes it a tab of the floating group holding `onto`, and
`window.panel.float {panel, x?, y?, width?, height?}` moves or resizes it; `onto` takes no geometry.
Positions are relative to the main window's content origin. When the panel is alone in a native panel
window, or `column: true` (or `group: true` on a tab group that fills the window) names the whole window,
supplied geometry updates that window and omitted coordinates and dimensions keep its current values.
A panel that shares a native window with other panels floats into a new window instead, which takes the
supplied geometry, and the shared window keeps the other panels, its place and its size.
`window.panel.dock {panel}` docks it,
`window.panel.close {panel}` closes it. `window.swatchLibrary.other {path}`, `window.graphicStyleLibrary.other
{path}`, `window.symbolLibrary.other {path}` and `window.brushLibrary.other {path}` load a file and open it the same