EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Dock: a click anywhere on a stacked panel's header bar expands or collapses it (#301)
Claude7b38d4d74e82
diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rsindex b586e8c95..d0daa86d9 100644--- a/crates/ui-egui/src/dock.rs+++ b/crates/ui-egui/src/dock.rs@@ -1177,6 +1177,21 @@ pub fn draw_group_chrome(ui: &mut egui::Ui, g: &Group, t: &Tokens, reg: &mut cra}x += w + 8.0;}+ // A stacked panel's whole header bar expands/collapses it, not just its name (as in After+ // Effects). A stack group holds one panel, so the rest of the strip is unambiguous.+ if g.stacked.is_some()+ && let Some(e) = entries.first()+ {+ let rest = Rect::from_min_max(pos2((x - 8.0).max(strip.min.x), strip.min.y), strip.max);+ if rest.width() > 0.0 {+ let resp = ui.interact(rest, egui::Id::new(("tab-rest", g.path.clone())), Sense::click());+ reg.add(&format!("panel.header.{}", e.panel.id()), rest, &e.label);+ if resp.clicked() {+ out.actions.push(DockAction::ToggleStacked(e.panel));+ out.actions.push(DockAction::Focus(e.panel));+ }+ }+ }}// clicking anywhere in the panel focuses itif let Some(p) = active_paneldiff --git a/crates/ui-egui/tests/ui_tabs.rs b/crates/ui-egui/tests/ui_tabs.rsindex 207e5cf48..8b52a72a6 100644--- a/crates/ui-egui/tests/ui_tabs.rs+++ b/crates/ui-egui/tests/ui_tabs.rs@@ -325,3 +325,23 @@ fn dragging_the_viewer_timeline_divider_far_up_does_not_crash() {drag(&mut h, g2.center(), g2.center() + egui::vec2(0.0, 3000.0));h.run_steps(2);}++/// Issue #301: clicking anywhere on a stacked panel's header bar expands/collapses it, not only+/// its name; the panel menu button keeps its own click.+#[test]+fn a_stacked_panels_whole_header_bar_toggles_it() {+ let (mut h, _, _) = harness();+ let open = |h: &Harness<'_, EffectcraftApp>| h.state().ui.dock.is_visible(PanelKind::Preview);+ assert!(open(&h));+ let bar = rect(&h, "panel.header.Preview");+ let tab = rect(&h, "panel.tab.Preview");+ assert!(bar.min.x >= tab.max.x - 1.0 && bar.width() > 40.0, "{bar:?} {tab:?}");+ click_n(&mut h, pos2(bar.max.x - 6.0, bar.center().y), 1);+ assert!(!open(&h), "a click at the bar's right end collapses Preview");+ let bar = rect(&h, "panel.header.Preview");+ click_n(&mut h, bar.center(), 1);+ assert!(open(&h), "and expands it again");+ let menu = rect(&h, "panel.menu.Preview");+ click_n(&mut h, menu.center(), 1);+ assert!(open(&h), "the panel menu button doesn't toggle the panel");+}