Dock: a click anywhere on a stacked panel's header bar expands or collapses it (#301)

In the right-hand panel stack only the tab (the name plus its padding) answered clicks, so
the rest of the header bar did nothing, a small target for short names like Audio. As in
After Effects, the rest of the strip now toggles the panel too and focuses it. A stack group
holds one panel, so the bar is unambiguous; the panel menu keeps its own click. The bar
registers the automation id `panel.header.<Panel>`.

Test: a kittest clicks near the right end of Preview's header bar (collapses), its middle
(expands) and its panel menu button (stays open).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
Claude committed 2026-10-10 19:54:17 +00:00
1 parent f440adbb5a
commit 7b38d4d74e
2 files changed
+35

No files matched your search

+15
View File
@@ -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 it
if let Some(p) = active_panel
+20
View File
@@ -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");
}