Panels: a panel that opens in a window of its own floats there directly instead of docking at the end of the main group first, so the docked group keeps Properties in front, as production did

window.panel and place_floating opened a panel that has no place in the dock at the end of the
main tab group and then floated it out. Opening it made it the group's front tab, and floating
it out left the group's last tab, Libraries, in front instead of Properties.
This commit is contained in:
dotCooCoo
2026-11-24 22:31:49 -08:00
parent 461e758fe7
commit 5038c1e01a
2 changed files with 28 additions and 2 deletions
+4 -2
View File
@@ -934,7 +934,7 @@ fn show_actions(ws: &Workspace<String>, space: &FloatSpace<String>, panel: &str,
(None, true) => vec![Action::open(id, first_dock_panel(layout, panel))],
(None, false) => {
let rect = space.place(space.size_of(&DragUnit::Panel(id.clone()), None));
vec![Action::open(id.clone(), None), Action::float(id, rect)]
vec![Action::float(id, rect)]
}
}
}
@@ -1088,7 +1088,9 @@ pub(crate) fn place_floating(app: &mut VectorcraftApp, panel: &str, pos: egui::P
let rect = egui::Rect::from_min_size(pos, egui::vec2(width, floating_height(app, &id)));
let layout = layout_of(&app.ui);
let mut actions = Vec::new();
if !layout.contains(&id) {
// A hidden panel goes back to its place first, so Dock Panel returns it there; any other panel floats without joining a
// docked group, which would change that group's front tab.
if !layout.contains(&id) && app.ui.dock_workspace.hidden().iter().any(|(p, _)| p == &id) {
actions.push(Action::open(id.clone(), None));
}
// A rail's window is a stepped column, which the dock fits to the rail's grid; it keeps the steps it had.
+24
View File
@@ -711,6 +711,30 @@ fn window_menu_panels_without_a_place_open_in_their_icon_group_or_float() {
assert!(h.tab("openType").is_some());
}
/// The tab in front of the docked group that holds `panel`.
fn front_of_group(layout: &Layout<String>, panel: &str) -> Option<String> {
dock_columns(layout).into_iter().flat_map(|c| &c.groups).find(|g| g.panels.iter().any(|p| p == panel)).and_then(|g| g.active_panel()).cloned()
}
#[test]
fn a_panel_that_opens_floating_leaves_the_docked_tabs_as_they_were() {
let mut h = Harness::new();
assert_eq!(front_of_group(&h.layout(), "properties").as_deref(), Some("properties"));
for panel in ["openType", "docInfo", "attributes", "imageTrace"] {
h.app.run("window.panel", json!({"panel": panel})).unwrap();
h.frame(vec![]);
let layout = h.layout();
assert!(floating_window(&layout, panel).is_some(), "{panel} floats");
assert_eq!(main_panels(&layout), ["properties", "layers", "libraries"], "after {panel}");
assert_eq!(front_of_group(&layout, "properties").as_deref(), Some("properties"), "Properties stays in front after {panel}");
}
// A panel placed in a window of its own at a point leaves them as well.
place_floating(&mut h.app, "magicWand", pos2(200.0, 200.0), 0.0).unwrap();
let layout = h.layout();
assert!(floating_window(&layout, "magicWand").is_some());
assert_eq!(front_of_group(&layout, "properties").as_deref(), Some("properties"), "Properties stays in front after a placed panel");
}
#[test]
fn f7_restores_only_tabs_hidden_with_the_group() {
let mut h = Harness::new();