tabs: add overflow popover for tabs that do not fit

This commit is contained in:
2026-11-14 19:27:50 +07:00
parent 4b70df452a
commit 33f8856bc2
5 changed files with 414 additions and 22 deletions
+28 -1
View File
@@ -146,6 +146,7 @@ struct Pane {
key: u64,
tabs: Vec<PanelTab>,
active: Option<SharedString>,
overflow_open: bool,
}
/// An internal node: two children along an axis.
@@ -183,6 +184,7 @@ impl DockState {
key: 0,
tabs: Vec::new(),
active: None,
overflow_open: false,
}),
panels: HashMap::new(),
active_pane: 0,
@@ -321,6 +323,17 @@ impl DockState {
cx.notify();
}
/// Shows or hides the pane's overflow popover.
pub fn set_pane_overflow_open(&mut self, key: u64, open: bool, cx: &mut Context<Self>) {
let Some(pane) = self.pane_mut(key) else {
return;
};
if pane.overflow_open != open {
pane.overflow_open = open;
cx.notify();
}
}
/// Closes every other tab in the panel's pane, keeping this one active.
pub fn close_others(&mut self, id: &str, cx: &mut Context<Self>) {
let Some((pane_key, _)) = self.locate(id) else {
@@ -437,6 +450,7 @@ impl DockState {
key: new_key,
tabs: vec![tab],
active: Some(SharedString::from(id)),
overflow_open: false,
});
Self::wrap_in(&mut self.root, target_key, new_pane, direction, split_key);
@@ -693,6 +707,7 @@ impl DockState {
})
.collect(),
active: pane.active.clone(),
overflow_open: pane.overflow_open,
}),
Node::Split(split) => TreeView::Split(SplitView {
key: split.key,
@@ -740,6 +755,7 @@ impl DockState {
key: u64::MAX,
tabs: Vec::new(),
active: None,
overflow_open: false,
}),
)
}
@@ -757,6 +773,7 @@ struct PaneView {
key: u64,
tabs: Vec<TabView>,
active: Option<SharedString>,
overflow_open: bool,
}
struct SplitView {
@@ -1064,7 +1081,17 @@ fn render_pane(
pane.key
)))
.variant(TabsVariant::Pill)
.overflow_scroll(true)
.overflow_popover(true)
.overflow_open(pane.overflow_open)
.on_overflow_open({
let state = state.clone();
let pane_key = pane.key;
move |open, _, cx| {
state.update(cx, |dock, cx| {
dock.set_pane_overflow_open(pane_key, open, cx)
});
}
})
.selected(selected)
.tabs({
let tabs = pane.tabs.clone();