VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Panels: a double-click on a tab of a group beside another no longer reports an error
Marco Arnulfo35104e10edd2
diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rsindex c1808694e..2789c4648 100644--- a/crates/ui-egui/src/panel_docking.rs+++ b/crates/ui-egui/src/panel_docking.rs@@ -1067,10 +1067,12 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) -> bool {None => dock(ui),};// A double-click on a tab of the dock's tree collapses its group to its tabs, or expands it.+ // A group beside another doesn't collapse, so its tabs ignore it rather than report an error.if let Some(root) = &drawn.root {let tabs = Layout { root: Some(root.clone()), floating: Vec::new() };if let Some(panel) =tabs.panels().into_iter().find(|p| ui.ctx().read_response(area.with(("tab", *p))).is_some_and(|r| r.double_clicked()))+ && tab_group_shortens(&tabs, panel) == Some(true){content.commands.push(("window.panel.collapse", json!({"panel": panel})));}diff --git a/crates/ui-egui/src/panel_docking_tests.rs b/crates/ui-egui/src/panel_docking_tests.rsindex 6c2ed6e29..3f4a9e5a2 100644--- a/crates/ui-egui/src/panel_docking_tests.rs+++ b/crates/ui-egui/src/panel_docking_tests.rs@@ -1012,6 +1012,27 @@ fn a_double_click_on_a_dock_tab_collapses_its_group_to_its_tabs_and_another_expaassert!(valid(h.state().ui.docking.as_ref().unwrap()));}+/// A double-click on a tab of a group beside another does nothing, and leaves no error in the+/// status bar: that group doesn't collapse (`a_group_beside_another_does_not_collapse`).+#[test]+fn a_double_click_on_a_tab_of_a_group_beside_another_does_nothing() {+ let mut app = app();+ app.run("file.new", json!({"width": 400, "height": 300})).unwrap();+ app.run("window.panel.move", json!({"panel":"swatches", "anchor":"layers", "zone":"left"})).unwrap();+ let saved = app.ui.docking.clone();+ let mut h = harness(app, vec2(1280.0, 800.0));+ let status = h.state().ui.status.clone();+ let shown: Vec<&str> = root_groups(&h).iter().map(|g| g.shown).collect();+ assert_eq!(shown.len(), 2, "{shown:?}");+ for panel in shown {+ let at = tab_center(&h, panel);+ double_click(&mut h, at);+ assert_eq!(h.state().ui.status, status, "no error: {panel}");+ assert!(h.state().ui.docking_collapsed.is_empty(), "{panel}");+ assert_eq!(h.state().ui.docking, saved, "{panel}");+ }+}+/// A double-click on a tab of the legacy dock collapses the tabbed group to its tabs.#[test]fn a_double_click_on_a_legacy_dock_tab_collapses_the_tabbed_group() {