Panels: clicking a tab of a collapsed panel expands it (#1868)

A single click on a tab of a collapsed panel group (or a pick from its overflow menu) now
expands the group and shows that tab, as in Photoshop; double-click still collapses. The tab
strip reports clicks through StripOut/CardResponse. Tested in both themes, with the
workspace locked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Jason XiangandClaude Opus 5.5 authored and GitHub committed 2026-10-09 12:28:49 -04:00
1 parent 941b84a748
commit c645f951b0
4 files changed
+51 -4

No files matched your search

+1 -1
View File
@@ -392,7 +392,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, shown: &[Group], mut bod
if sel != before {
*g.tab_mut(&mut app.ui.dock_tabs) = sel.min(tabs.len().saturating_sub(1));
}
if resp.strip.double_clicked() || resp.tab_double_clicked {
if resp.strip.double_clicked() || resp.tab_double_clicked || (collapsed && resp.tab_clicked) {
actions.push(Action::ToggleCollapse(g));
}
if !locked && resp.strip.dragged() {
+27
View File
@@ -210,6 +210,33 @@ fn reset_workspace_restores_the_default_layout_and_new_workspaces_keep_theirs()
assert_eq!(h.state().ui.dock, mine);
}
#[test]
fn a_single_tab_click_expands_a_collapsed_panel() {
for theme in [ThemeKind::ProMedium, ThemeKind::Studio] {
for tab_index in [0, 1] {
let (mut app, _, _) = app_with_layers();
app.ui.dock_tabs.color = 0;
app.ui.dock.set_collapsed(Group::Color, true);
// Locking prevents rearrangement, not opening an existing panel.
app.session.prefs.edit(|p| p.workspace_locked = true);
let mut h = harness(app, vec2(1200.0, 800.0), theme);
let collapsed_height = rect_of(&h, Group::Color).height();
let strips = last_strips(&h.ctx);
let strip = strips.iter().find(|s| s.group == Group::Color).unwrap();
let tab = strip.tabs.iter().find(|(i, _)| *i == tab_index).unwrap().1.center();
h.event(egui::Event::PointerMoved(tab));
h.run_steps(1);
h.event(egui::Event::PointerButton { pos: tab, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });
h.step();
h.event(egui::Event::PointerButton { pos: tab, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });
h.run_steps(3);
assert!(!h.state().ui.dock.is_collapsed(Group::Color), "{theme:?}: tab {tab_index}");
assert_eq!(h.state().ui.dock_tabs.color, tab_index);
assert!(rect_of(&h, Group::Color).height() > collapsed_height);
}
}
}
#[test]
fn double_clicking_a_tab_collapses_and_dragging_a_strip_reorders() {
let (app, _, _) = app_with_layers();
+5 -1
View File
@@ -86,6 +86,8 @@ pub fn elided(ui: &Ui, text: &str, font: egui::FontId, color: egui::Color32, max
/// What a strip reported this frame.
pub struct StripOut {
/// A tab was activated, including a choice from the overflow menu.
pub clicked: bool,
pub double_clicked: bool,
/// Rects of the tabs on the strip, `(tab index, rect)`.
pub tabs: Vec<(usize, Rect)>,
@@ -142,7 +144,7 @@ fn tabs_in(
let natural: Vec<f32> = tabs.iter().map(|n| ui.painter().layout_no_wrap((*n).to_owned(), font.clone(), t.text).size().x + pad).collect();
let f = fit(&natural, *selected, area.width(), min_w, CHEVRON_W);
let mut x = area.left();
let mut out = StripOut { double_clicked: false, tabs: Vec::with_capacity(f.shown.len()), chevron: None };
let mut out = StripOut { clicked: false, double_clicked: false, tabs: Vec::with_capacity(f.shown.len()), chevron: None };
for &(i, w) in &f.shown {
let Some(name) = tabs.get(i) else { continue };
let r = Rect::from_min_size(pos2(x, area.top()), vec2(w, area.height()));
@@ -154,6 +156,7 @@ fn tabs_in(
let resp = if cut { resp.on_hover_text(*name) } else { resp };
out.double_clicked |= resp.double_clicked();
if resp.clicked() {
out.clicked = true;
*selected = i;
}
out.tabs.push((i, r));
@@ -164,6 +167,7 @@ fn tabs_in(
let mut picked = None;
overflow_button(ui, id.with("tab-overflow"), r, tl!("More panels"), tabs, &f.overflow, &mut picked);
if let Some(i) = picked {
out.clicked = true;
*selected = i;
}
out.chevron = Some(r);
+18 -2
View File
@@ -47,6 +47,8 @@ pub struct CardResponse {
pub strip: Response,
/// The panel menu button (hamburger in Pro, ellipsis in Studio).
pub menu: Response,
/// A tab was clicked or chosen from the overflow menu.
pub tab_clicked: bool,
/// A tab was double-clicked (Photoshop collapses the group).
pub tab_double_clicked: bool,
/// Rects of the tabs on the strip, `(tab index, rect)`; tabs that don't fit are in the
@@ -85,7 +87,14 @@ pub fn card_ex(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, colla
ui.add_space(6.0);
body(ui, *selected);
}
CardResponse { strip, menu, tab_double_clicked: tabs_out.double_clicked, tabs: tabs_out.tabs, chevron: tabs_out.chevron }
CardResponse {
strip,
menu,
tab_clicked: tabs_out.clicked,
tab_double_clicked: tabs_out.double_clicked,
tabs: tabs_out.tabs,
chevron: tabs_out.chevron,
}
})
.inner;
ui.add_space(6.0);
@@ -149,7 +158,14 @@ fn pro_panel(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, collaps
});
}
ui.add_space(2.0);
CardResponse { strip: strip_resp, menu: mresp, tab_double_clicked: tabs_out.double_clicked, tabs: tabs_out.tabs, chevron: tabs_out.chevron }
CardResponse {
strip: strip_resp,
menu: mresp,
tab_clicked: tabs_out.clicked,
tab_double_clicked: tabs_out.double_clicked,
tabs: tabs_out.tabs,
chevron: tabs_out.chevron,
}
}
pub fn pill_tab(ui: &mut Ui, label: &str, selected: bool) -> Response {