pub trait Layout: ThemeExt {
// Provided methods
fn disclosure(&self, expanded: bool) -> Svg { ... }
fn collapsible_header(
&self,
label: impl Into<SharedString>,
expanded: bool,
) -> Div { ... }
fn nav_row(
&self,
icon: Option<Icon>,
label: impl Into<SharedString>,
selected: bool,
fade: Fade,
) -> Div { ... }
fn split_handle(&self, axis: Axis, style: SplitStyle) -> Div { ... }
fn tab_bar(&self) -> Div { ... }
fn tab(&self, label: impl Into<SharedString>, active: bool) -> Div { ... }
}Provided Methods§
Sourcefn disclosure(&self, expanded: bool) -> Svg
fn disclosure(&self, expanded: bool) -> Svg
The disclosure chevron: right when collapsed, down when expanded.
Two assets rather than one rotated: gpui has no transform for divs at
the pinned rev, and an SVG rotation would need a transform on the
element.
Sourcefn collapsible_header(
&self,
label: impl Into<SharedString>,
expanded: bool,
) -> Div
fn collapsible_header( &self, label: impl Into<SharedString>, expanded: bool, ) -> Div
Header row of a collapsible section: chevron plus title. The caller owns
expanded and renders the body itself — a container that swallowed its
children would have to re-implement layout for them. Hover is
caller-owned (gpui panics on a second hover); the default wash is
Theme::element_hover.
A navigation row: leading icon, truncating label, and whatever the
caller appends — a count, a chevron, a control that shows on hover.
shadcn calls it SidebarMenuButton, MUI ListItemButton.
The label is a parameter rather than a child because it carries the
truncation, and a caller that has to remember min_w_0().flex_1()
forgets it on the first long project name — which pushes the trailing
content off the row instead of shortening the label.
fade must be stable across frames. It is also how a trailing control
reveals itself on row hover: paint it with
motion::hover_blend on this same fade, rather than adding an
on_hover of its own — gpui allows only one per element, and this row
has claimed it.
Sourcefn split_handle(&self, axis: Axis, style: SplitStyle) -> Div
fn split_handle(&self, axis: Axis, style: SplitStyle) -> Div
The divider between two panes: a hairline centred in a grab strip, lit while dragged.
The gesture stays with the caller, which owns the fraction — the handle is dragged with gpui’s null-preview drag, and the container reads the pointer:
div()
.id("split")
.on_drag_move(cx.listener(|view, event: &DragMoveEvent<SplitDrag>, _, cx| {
view.fraction = axis_fraction(event.event.position, event.bounds, Axis::Horizontal, 0.15);
cx.notify();
}))
.child(div().w(relative(self.fraction)).child(left))
.child(
theme.split_handle(Axis::Horizontal, SplitStyle::Line { dragging: self.dragging })
.id("split-handle")
.on_drag(SplitDrag, |_, _, _, cx| cx.new(|_| gpui::Empty)),
)
.child(div().flex_1().child(right))Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".