Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Panels: a double-click on the strip of a group beside another does nothing

Marco Arnulfo777930fcd267
diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs
index 73452c485..48426a45a 100644
--- a/crates/ui-egui/src/panel_docking.rs
+++ b/crates/ui-egui/src/panel_docking.rs
@@ -896,7 +896,8 @@ fn root_groups(ctx: &egui::Context, layout: &Layout<String>, content: egui::Rect
/// and left of its panel menu, from which Illustrator also collapses the group
/// (<https://helpx.adobe.com/illustrator/using/customizing-workspace.html>). Most of it has no
/// widget of its own, so the press is read from the input; `layer` is the dock's, so a press on a
-/// floating group or a menu over the strip doesn't count. Accordions are left out.
+/// floating group or a menu over the strip doesn't count. Accordions, and groups beside another
+/// (which don't collapse), are left out.
fn tab_area_double_clicked(
ctx: &egui::Context,
layer: egui::LayerId,
@@ -909,7 +910,9 @@ fn tab_area_double_clicked(
return None;
}
let group = groups.iter().find(|g| g.strip.contains(at))?;
- tab_group_shortens(layout, group.shown)?;
+ if tab_group_shortens(layout, group.shown) != Some(true) {
+ return None;
+ }
let area = egui::Id::new("vectorcraft-panel-docking");
let right = |id: egui::Id| ctx.read_response(id).map(|r| r.rect.right());
let tabs = group
diff --git a/crates/ui-egui/src/panel_docking_tests.rs b/crates/ui-egui/src/panel_docking_tests.rs
index 1579f4683..e1b89c2b4 100644
--- a/crates/ui-egui/src/panel_docking_tests.rs
+++ b/crates/ui-egui/src/panel_docking_tests.rs
@@ -1200,3 +1200,23 @@ fn a_group_beside_another_does_not_collapse() {
crate::panel_docking::prune_collapsed(&mut app.ui);
assert!(app.ui.docking_collapsed.is_empty());
}
+
+/// A double-click on the strip of a group beside another does nothing, and leaves no error in the
+/// status bar.
+#[test]
+fn a_double_click_on_the_strip_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 strip = root_groups(&h).into_iter().find(|g| g.shown == "swatches").unwrap().strip;
+ let tab = h.ctx.read_response(egui::Id::new("vectorcraft-panel-docking").with(("tab", &"swatches".to_string()))).unwrap().rect;
+ let gap = pos2(tab.right() + 4.0, strip.center().y);
+ assert!(gap.x < strip.right() - 24.0, "{tab:?} {strip:?}");
+ double_click(&mut h, gap);
+ assert_eq!(h.state().ui.status, status, "no error");
+ assert!(h.state().ui.docking_collapsed.is_empty());
+ assert_eq!(h.state().ui.docking, saved);
+}