Merge pull request #9964 from dotCooCoo/fix/floating-group-from-icons

Docking: a group dragged out of the icon column floats expanded and its tabs switch
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-28 13:36:53 -08:00
commit d07b1abca4
2 files changed
+58 -1

No files matched your search

+24 -1
View File
@@ -518,6 +518,22 @@ fn flyout_tab(layout: &Layout<String>, panel: &str) -> Option<String> {
.map(|front| front.to_string())
}
/// The actions that expand each floating window the pass made from part of a column collapsed to
/// icons, so a group or tab dragged out of an icon column floats as an expanded panel with its tabs
/// in the window. A whole icon column floated stays collapsed.
fn floated_from_icons(before: &Layout<String>, after: &Layout<String>) -> Vec<Action<String>> {
after
.floating
.iter()
.filter(|window| window.column.iconic && !before.floating.iter().any(|old| old.id == window.id))
.filter_map(|window| {
let first = window.panels().next()?;
let (_, column) = column_of(before, first)?;
(column.iconic && column.panels().count() > window.panels().count()).then(|| Action::set_iconic(first.clone(), false))
})
.collect()
}
/// Show `panel` as `window.panel` does, but leave it be when it can be seen already ([`visible`]):
/// a command that opens a panel to work in (Edit › Color Settings…) never puts it away. A flyout
/// keeps the name of the icon that opened it after another of its tabs is clicked, so a panel whose
@@ -1374,13 +1390,20 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, keeps_tools: boo
app.dock_rt.rails = rails;
// A workspace a command switched to or changed in this pass (`Workspace::replace`) stays; the
// pass's edits were to the one it replaced.
let mut expand = Vec::new();
if app.ui.dock_workspace.revision() == revision {
app.ui.dock_workspace = workspace;
let before = std::mem::replace(&mut app.ui.dock_workspace, workspace);
expand = floated_from_icons(before.layout(), layout_of(&app.ui));
}
// A command of this pass that opened or closed a flyout wins over the area's own change.
if app.ui.open_panel == flyout_before {
app.ui.open_panel = flyout;
}
if !expand.is_empty()
&& let Err(error) = apply(app, None, expand)
{
app.status(error);
}
if output.error.is_some() {
Arc::make_mut(&mut app.ui.dock_workspace).replace(default_workspace(&[]));
app.status(tl!("Invalid panel layout; restored the default dock").to_string());
+34
View File
@@ -1105,3 +1105,37 @@ fn a_docked_column_is_never_narrower_than_the_panel_minimum() {
h.frames(3);
assert!(body_width(&h, "Properties") >= PANEL_MIN_WIDTH - 0.5, "saved 100 pt wide: {}", body_width(&h, "Properties"));
}
/// A tab group dragged out of the icon column by its grip floats as an expanded panel: its tabs show
/// in the window, and a click on each tab shows that panel.
#[test]
fn a_group_dragged_out_of_the_icon_column_floats_expanded_and_its_tabs_switch() {
for (icon, tabs) in [("stroke", ["gradient", "transparency", "stroke"]), ("transform", ["align", "pathfinder", "transform"])] {
let mut h = Harness::new();
h.click(h.icon(icon).expect("the icon column is drawn").center());
h.frames(2);
let tab = h.tab(icon).expect("the flyout's tabs are drawn");
let grip = h
.nodes
.iter()
.filter(|(_, node)| node.label() == Some("Move tab group"))
.filter_map(|(_, 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)))
.filter(|grip| (grip.center().y - tab.center().y).abs() < 20.0)
.last()
.expect("the flyout's grip");
h.drag(grip.center(), h.canvas().center());
h.frames(2);
let layout = h.layout();
let window = floating_window(&layout, icon).unwrap_or_else(|| panic!("{icon}: the group floats"));
assert_eq!(window_panels(window).len(), 3, "{icon}: the whole group floats");
assert!(!window.column.iconic, "{icon}: the window is expanded");
assert!(in_iconic_column(&layout, "swatches"), "{icon}: the icon column stays collapsed");
for panel in tabs {
let tab = h.tab(panel).unwrap_or_else(|| panic!("{icon}: the {panel} tab is drawn"));
h.click(tab.center());
h.frames(1);
assert!(showing(&h.app.ui, panel), "{icon}: a click on the {panel} tab shows it");
}
}
}