split-tree
Builds Icon SplitTree Toggle ToggleGroup Tree


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn split_tree(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let layout = SplitLayout::horizontal(
"workspace",
0.26,
SplitLayout::leaf(SplitPaneSpec::new("files").min_width(140.0)),
SplitLayout::horizontal(
"body",
0.74,
SplitLayout::vertical(
"editing",
0.6,
SplitLayout::leaf(SplitPaneSpec::new("editor").min_height(90.0)),
SplitLayout::leaf(SplitPaneSpec::new("terminal").min_height(70.0)),
),
// A collapsed leaf is drawn at its rail, and the divider beside it
// is not offered: a fixed extent has no ratio to trade.
SplitLayout::leaf(SplitPaneSpec::new("outline").rail(40.0).collapsed(true)),
),
);
stack(&theme)
.w(px(680.0))
.child(
div()
.h(px(340.0))
.hairline(&theme)
.radius(&theme, Radius::Card)
.overflow_hidden()
.child(
SplitTree::new("scene.tree.workspace")
.layout(layout)
.pane("files", filler(&theme, "Files", 6))
.pane("editor", filler(&theme, "main.rs", 6))
.pane("terminal", filler(&theme, "Terminal", 2))
// The rail is narrower than any label, so the collapsed
// leaf is drawn as the room it still holds.
.pane("outline", div())
.on_change(|_, _, _| {}),
),
)
.child(caption(
&theme,
"A divider high in the tree stops where a leaf far below it would \
run out of room.",
))
.into_any_element()
}