mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 17:15:56 +00:00
Merge pull request #9281 from dotCooCoo/fix/float-panel-keeps-docked-tab
Panels: a panel that opens in a window of its own leaves the docked group's front tab as it was
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user