Expand description
Tabs — an ordered strip of open things, one of them in front.
Not toggle_group, which picks a
value out of a fixed set, and not
tab_bar, which switches between
sections of one page. A tab here has identity: it arrives, it can be closed,
it can be dragged past its neighbour, and the strip outlives any particular
membership.
Strip is the order and the activation, and imports no gpui — closing,
cycling and reordering are Vec arithmetic, testable without a window. The
paint is bar, tab and close.
What a tab holds never enters this module. Id is the caller’s key, and
the body it opens is the caller’s match on that key.
ⓘ
ui::tabs::bar("panel-tabs").children(self.strip.tabs().iter().map(|id| {
let key = SharedString::from(format!("panel-{id}"));
let state = match self.strip.active() == Some(id) {
true => tabs::State::Focused,
false => tabs::State::Resting,
};
tabs::tab(&theme, key.clone(), self.label(id), state)
.on_click(cx.listener(move |view, _, _, cx| view.show(id, cx)))
.child(
tabs::close(&theme, key, tabs::Close::OnHover)
.on_click(cx.listener(move |view, _, _, cx| view.close(id, cx))),
)
}))Structs§
Enums§
Constants§
- MARK_
SIZE - The box
Label::markpaints in. Lucide’scircle-smallinks 14 of its 24 units, which puts a solid one at 6px across. - MAX_
WIDTH - How wide one tab grows before its label truncates.
Functions§
- bar
- The strip. Tabs go in it; a
+, a···and anything else on the row are the caller’s, outside this. - close
- A tab’s
×, for thekeyitstabwas built with. The click is the caller’s, and has to stop propagating or the tab under it takes the press as well. - tab
- One tab, up to the
×: pass the samekeytocloseand chain the result on as a child.