Components / layout
SplitPane builder
Two panes separated by a divider.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::layout::SplitPane;
Reviewed in split-pane.
Construct
new(ident: impl Into<Ident>) -> Self
Options
Chain onto the value.
axis(axis: SplitAxis) -> Self
horizontal() -> Self
vertical() -> Self
ratio(ratio: f32) -> Self
min_sizes(start: f32, end: f32) -> Self
step(step: f32) -> Self
collapsible(collapsible: bool) -> Self
handle_label(label: impl Into<SharedString>) -> Self
start(pane: impl IntoElement) -> Self
end(pane: impl IntoElement) -> Self
on_resize(handler: impl Fn(f32, &mut Window, &mut App) + 'static) -> Self
on_collapse(handler: impl Fn(SplitSide, &mut Window, &mut App) + 'static) -> Self
Example · split-pane
fn split_pane(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(620.0))
.h(px(380.0))
.child(
div()
.h(px(320.0))
.surface(&theme, Surface::Panel)
.radius(&theme, Radius::Card)
.overflow_hidden()
.child(
SplitPane::new("scene.split.workspace")
.horizontal()
.ratio(0.34)
.min_sizes(120.0, 200.0)
.collapsible(true)
.handle_label("Resize the file tree")
.start(pane(
&theme,
"Files",
&[
"src/",
" main.rs",
" theme.rs",
" layout/",
" split.rs",
" scroll.rs",
"Cargo.toml",
],
))
.end(pane(
&theme,
"split.rs",
&[
"pub struct SplitPane {",
" ratio: f32,",
" min_start: f32,",
" min_end: f32,",
"}",
"",
"// The divider reports the ratio a drag",
"// asked for; the caller decides it.",
],
))
.on_resize(|_, _, _| {})
.on_collapse(|_, _, _| {}),
),
)
.into_any_element()
}