Merge pull request #9282 from dotCooCoo/fix/floating-panels-open-at-their-size

Panels: a panel the Window menu floats opens at its own size again
This commit is contained in:
BFlat authored and GitHub committed 2026-11-25 19:33:59 +07:00
commit d0b332dc71
2 files changed
+68 -8

No files matched your search

+26 -8
View File
@@ -1055,16 +1055,34 @@ fn result(app: &VectorcraftApp, closed: Vec<String>) -> 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<String> {
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.
+42
View File
@@ -905,6 +905,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]