Dock Splitter
A draggable boundary between dock regions.
Basic use
use xgpui_luma_look_radix as radix;
use gpui::{Context};
use xgpui_luma::controls::dock_splitter::SplitterOrientation;
struct Example {
control: gpui::Entity<xgpui_luma::controls::dock_splitter::DockSplitter>,
resize_delta: f32,
}
impl Example {
fn new(cx: &mut Context<Self>) -> Self {
let look = radix::Look::built_in();
let control = radix::dock_splitter_builder(&look, "sidebar-resize", SplitterOrientation::Vertical)
.on_resize_delta(cx, |app, total_delta, cx| {
app.resize_delta = total_delta;
cx.notify();
})
.spawn(cx);
Self { control, resize_delta: 0.0 }
}
}Integration snippet, checked against the current SDK and Radix crates. cx is the initialized owner context. The control retains its callbacks; callback owners are held weakly. Render self.control.clone() in the owner’s view.
Radix styling
dock_splitter_builder(&look, id, orientation) retains SDK pointer and keyboard resizing. Use .template(radix::dock_splitter_template(true)) for a vertical grip; the theme resolves live Radix colors and shared hit-target geometry.
Pass an explicit Look, including forks. Theme adapters retain that binding; notify affected controls and their owners after palette, mode, or stylesheet edits. Resolved look values are snapshots and must be resolved again during render.
See the Radix control support table for adapter and utility status.
SDK behavior & customization
Resize reports a total delta. The host applies it to the corresponding layout dimensions.
Relevant contracts: DockSplitterRenderModel, DockSplitterTemplateHandlers, DockSplitterTemplateModifier, DockSplitterTemplate.
Use the module’s template contract for structural changes. Builder modifiers and item templates vary by control.
Events
Callbacks follow the existing SDK event stream. Registrations append, hold the owner weakly, and live until the control is released. cx.notify() requests an owner redraw. Compound payloads are borrowed; scalar values are passed by value.
| Event / payload | Callback |
|---|---|
ResizeStart | .on_resize_start(cx, |app, cx| { … }) |
Resize { total_delta: f32 } | .on_resize_delta(cx, |app, total_delta, cx| { … }) |
ResizeEnd | .on_resize_end(cx, |app, cx| { … }) |
FocusChanged { focused: bool } | .on_focus_changed(cx, |app, focused, cx| { … }) |
HoverChanged { hovered: bool } | .on_hover_changed(cx, |app, hovered, cx| { … }) |
EnabledChanged { enabled: bool } | .on_enabled_changed(cx, |app, enabled, cx| { … }) |
Use .on_event(cx, |app, event, cx| { … }) for all events. Factory-created controls support the same callbacks through DockSplitterEventExt. Existing cx.subscribe observers remain supported.
.on_resize_delta handles the semantic Resize event. The existing .on_resize builder hook receives the Window during template input handling.