diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 9e49093c54..71fd9f5183 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -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", diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 24e9d42f42..03511680a7 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -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", diff --git a/crates/ui-egui/src/panel_docking/native_tests.rs b/crates/ui-egui/src/panel_docking/native_tests.rs index 543c06998e..6516f7132c 100644 --- a/crates/ui-egui/src/panel_docking/native_tests.rs +++ b/crates/ui-egui/src/panel_docking/native_tests.rs @@ -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() { diff --git a/docs/mcp.md b/docs/mcp.md index d8cc1ef488..dd3196b159 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -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::` (`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