Components / layout
DockTree builder
Draws a recursive DockTopology without owning it.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::layout::DockTree;
Reviewed in dock-tree dock-floating.
Construct
new(ident: impl Into<Ident>, topology: DockTopology) -> Self
Options
Chain onto the value.
panel(panel: DockPanel) -> Self
floating(tiles: impl IntoIterator<Item = FloatingDock>) -> Result<Self, DockRecordError>
panels(panels: impl IntoIterator<Item = DockPanel>) -> Self
on_event(handler: impl Fn(DockTreeEvent, &mut Window, &mut App) + 'static) -> Self
Reports
The variants of the event it emits. It never applies the change itself.
- FloatingRaised
- FloatingChanged
- FloatingCancelled
- PanelSelected
- PanelMoved
- PanelSplit
- SplitResized
- StackCollapsed
Example · dock-tree
fn dock_tree(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let topology = DockTopology::vertical(
"root",
0.78,
DockTopology::horizontal(
"workspace",
0.28,
DockTopology::Stack(DockStack::new("source", ["files", "search"]).active("files")),
DockTopology::horizontal(
"editing",
0.9,
DockTopology::stack("editor", ["main"]),
DockTopology::Stack(DockStack::new("outline", ["symbols"]).collapsed(true)),
),
),
DockTopology::stack("terminal", std::iter::empty::<&str>()),
);
stack(&theme)
.w(px(900.0))
.child(caption(
&theme,
"recursive caller topology; tab groups, empty destinations, rails, and split dividers share existing primitives",
))
.child(
div()
.h(px(600.0))
.surface(&theme, Surface::Panel)
.radius(&theme, Radius::Card)
.overflow_hidden()
.child(
DockTree::new("scene.dock-tree", topology)
.panels([
DockPanel::new("files", "Files")
.icon(Icon::Folder)
.content(filler(&theme, "Workspace", 12)),
DockPanel::new("search", "Search")
.icon(Icon::Magnifier)
.badge("12"),
DockPanel::new("main", "main.rs")
.icon(Icon::Document)
.content(filler(&theme, "fn main()", 15)),
DockPanel::new("symbols", "Outline").icon(Icon::List),
])
.on_event(|_, _, _| {}),
),
)
.into_any_element()
}