Skip to main content

pane

Function pane 

Source
pub fn pane(id: impl Into<ElementId>, axes: Axes) -> Stateful<Div>
Expand description

A scroll container, with the axis as an argument rather than a modifier you can forget.

scroll::pane("log", Axes::Vertical)
    .size_full()
    .track_scroll(&self.scroll)
    .child(content)

Returns an element for the caller to fill, the way crate::stack::row does — it takes no children and lays nothing out, so the pane stays the app’s and only its scroll behaviour is decided here. The id is gpui’s requirement, not ours: a scroll container has state to track.

§Why this exists rather than div().overflow_y_scroll()

gpui makes scrollability a late-bound style field with no default, and then has to guess what to do when a gesture’s axis is not one the container scrolls: it remaps the delta onto whichever axis the container can scroll. A sideways swipe over a vertical list scrolls it down; a downward swipe over a wide table pans it sideways. restrict_scroll_to_axis turns that off, but it is opt-in per element, so every pane that forgets it is wrong and nothing says so.

SwiftUI has no such case to guess at — ScrollView(.vertical) takes its axis at construction, so there is no container whose axis is unstated. This is that: ask for an axis, get a pane that answers only to it.

A horizontal pane also contains a sideways gesture (contain_sideways), because the pane it is nested in usually belongs to a consumer and is not ours to restrict.

Axes::Both inherits gpui’s dominant-axis lock — a diagonal gesture moves one axis, not two. gpui exposes no builder for allow_concurrent_scroll.