From 93775c8bd7f71518e31eaad21f359fbd2c4f9316 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 22:40:03 -0800 Subject: [PATCH] Panels: a panel the Window menu floats opens at its own size again, as production opened it A panel shown from the Window menu with no place in the dock floated at the dock's default float size (192 x 240 pt), which clipped its content: Asset Export and Image Trace showed only part of their controls. The space commands float panels into now carries each Window-menu panel's float size again, whether or not the dock area has drawn: 260 x 360 pt by default, with the larger sizes Properties, Layers, Libraries, Anchor Inspector and Fold Preview had before. Image Trace opens 420 pt tall, which shows its controls down to its Advanced section. Floats dragged out of the dock keep the size they had there. --- crates/ui-egui/src/panel_docking.rs | 34 +++++++++++++----- crates/ui-egui/src/panel_docking/tests.rs | 42 +++++++++++++++++++++++ 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index 11d157bd41..ef1306b90c 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -1055,16 +1055,34 @@ fn result(app: &VectorcraftApp, closed: Vec) -> Value { } /// Where a command floats a panel, group or column it gives no rect: inside the dock area as last -/// drawn, else inside [`HEADLESS_AREA`] at the theme's float size. +/// drawn, else inside [`HEADLESS_AREA`]. Each Window-menu panel floats at its [`floating_size`], +/// also one the area never drew; a tool rail floats at the theme's float size. fn command_space(app: &VectorcraftApp) -> FloatSpace { - if let Some(space) = &app.dock_rt.space { - return space.clone(); - } - let sizes = match &app.ui_ctx { - Some(ctx) => DockSizes::of(ctx), - None => DockSizes::of(&egui::Context::default()), + let space = match &app.dock_rt.space { + Some(space) => space.clone(), + None => { + let sizes = match &app.ui_ctx { + Some(ctx) => DockSizes::of(ctx), + None => DockSizes::of(&egui::Context::default()), + }; + FloatSpace::new(HEADLESS_AREA, &sizes) + } }; - FloatSpace::new(HEADLESS_AREA, &sizes) + crate::state::all_panels().fold(space, |space, (id, _)| space.with_panel_size(id.to_owned(), floating_size(id))) +} + +/// The size a Window-menu panel opens at when a command floats it. +pub(crate) fn floating_size(panel: &str) -> egui::Vec2 { + match panel { + "properties" | "layers" | "libraries" => egui::vec2(300.0, 420.0), + // Tall enough to show its Corners and Shared Edges sections, last in it, which the Corner + // Tool's and Shared Edge Merge Tool's menu items open. + crate::addons::pathtools::ID => egui::vec2(260.0, 660.0), + // Tall enough to show every control above its Advanced section, and that section's heading. + "imageTrace" => egui::vec2(260.0, 420.0), + crate::addons::packaging::preview::ID => egui::vec2(520.0, 440.0), + _ => egui::vec2(260.0, 360.0), + } } /// The height of `panel`'s window while it floats, else the height [`place_floating`] gives a new one. diff --git a/crates/ui-egui/src/panel_docking/tests.rs b/crates/ui-egui/src/panel_docking/tests.rs index 2544e8756a..783977de81 100644 --- a/crates/ui-egui/src/panel_docking/tests.rs +++ b/crates/ui-egui/src/panel_docking/tests.rs @@ -881,6 +881,48 @@ fn cycle_options_steps_through_the_sizes_and_returns_to_the_largest() { assert!(!crate::panels::part_hidden(&h.app, "tr-hide-thumbs"), "the largest size shows the thumbnails"); } +/// A panel the Window menu floats opens tall enough for its content: every control of Asset Export, +/// and every Image Trace control down to the top of its Advanced section, lies between the body's +/// top and bottom, none scrolled or clipped away. +#[test] +fn window_menu_floats_open_tall_enough_for_their_content() { + for (panel, title, until) in [("assetExport", "Asset Export", None), ("imageTrace", "Image Trace", Some("Advanced"))] { + let mut h = Harness::new(); + h.app.run("window.panel", json!({"panel": panel})).unwrap(); + assert!(floating_window(&h.layout(), panel).is_some(), "{panel} floats"); + h.frames(3); + let nodes: HashMap<_, _> = h.nodes.iter().map(|(id, node)| (*id, node)).collect(); + let rect = + |node: &egui::accesskit::Node| node.bounds().map(|b| Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32))); + let (body_id, body) = h + .nodes + .iter() + .find(|(_, node)| node.role() == egui::accesskit::Role::TabPanel && node.label() == Some(title)) + .and_then(|(id, node)| Some((*id, rect(node)?))) + .unwrap_or_else(|| panic!("{panel}'s body is drawn")); + // Every node drawn under the panel's body; its controls are the ones without children. + let mut drawn = Vec::new(); + let mut stack = vec![body_id]; + while let Some(id) = stack.pop() { + let Some(node) = nodes.get(&id) else { continue }; + stack.extend(node.children().iter().copied()); + if let Some(r) = rect(node).filter(|r| r.is_positive()) { + drawn.push((node, r)); + } + } + let limit = until.map_or(f32::INFINITY, |section| { + let found = drawn.iter().find(|(node, _)| node.role() == egui::accesskit::Role::Group && node.label() == Some(section)); + found.unwrap_or_else(|| panic!("{panel} draws its {section} section")).1.top() + }); + let outside: Vec<_> = drawn + .iter() + .filter(|(node, r)| node.children().is_empty() && r.top() <= limit && (r.top() < body.top() - 0.5 || r.bottom() > body.bottom() + 0.5)) + .map(|(node, r)| (node.role(), node.label().map(str::to_owned), *r)) + .collect(); + assert!(outside.is_empty(), "{panel}: controls outside its body {body:?}: {outside:?}"); + } +} + /// An unknown panel, a panel without display sizes or a missing `panel` is an error, and the /// panels keep their sizes. #[test]