pub struct ScrollView {
pub axis: ScrollAxis,
pub scrollbar: ScrollbarStyle,
/* private fields */
}Expand description
A scrollable viewport. The child can exceed the available size; content is painted at the scroll offset and clipped to the viewport bounds.
Scrolls by default (D101): the position lives on the widget’s render-tree
node and survives rebuilds — no wiring needed. Pass a
ScrollController (::controlled / .controller()) only when the app
needs programmatic control.
The GPU-composited layer path (D090) is now the TRANSPARENT DEFAULT for
plain ScrollView::new scroll views: once content is measured, a scroll
view whose content actually overflows the viewport on the scroll axis and
stays within MAX_TL_DIM automatically composites as a placed GPU layer
(scrolling becomes a compositor UV shift, zero component repaint) — no
.gpu_layer() call needed. Content that doesn’t overflow, or that exceeds
MAX_TL_DIM, uses the base (CPU-painted) path automatically. ::fixed
and ::controlled always use the base path — programmatic control and
snapshot modes need exact, un-composited semantics.
Fields§
§axis: ScrollAxis§scrollbar: ScrollbarStyleImplementations§
Source§impl ScrollView
impl ScrollView
Sourcepub fn new(child: impl Widget + 'static) -> Self
pub fn new(child: impl Widget + 'static) -> Self
A vertical scroll view. Just scrolls — position is implicit per-node
state (D101). Automatically GPU-composited once content overflows the
viewport and fits within MAX_TL_DIM (see struct docs) — no
.gpu_layer() call needed for the common case.
Sourcepub fn physics(self, p: ScrollPhysics) -> Self
pub fn physics(self, p: ScrollPhysics) -> Self
Override the scroll physics (drag-to-pan momentum + overscroll
behavior) regardless of the platform default — see
resolve_physics. Base (CPU) path only; no effect in GPU-layer
mode, which doesn’t yet have drag-to-pan (D108/Phase 26 Step 2).
Sourcepub fn gpu(child: impl Widget + 'static) -> Self
pub fn gpu(child: impl Widget + 'static) -> Self
Force the GPU-layer path on regardless of the automatic size
heuristic (see struct docs — ScrollView::new already auto-detects
the common case). Content is capped at MAX_TL_DIM; taller content
silently falls back to the base path (windowing is not yet built).
Sourcepub fn gpu_layer(self) -> Self
pub fn gpu_layer(self) -> Self
Force GPU-layer compositing on (see ScrollView::gpu).
Sourcepub fn horizontal(child: impl Widget + 'static) -> Self
pub fn horizontal(child: impl Widget + 'static) -> Self
A horizontal scroll view — carousels, chip rows, code blocks.
Sourcepub fn fixed(child: impl Widget + 'static) -> Self
pub fn fixed(child: impl Widget + 'static) -> Self
A snapshot viewport — never responds to input. Set the offset with
.offset(px). For golden tests and static mockups.
Sourcepub fn controlled(
child: impl Widget + 'static,
controller: ScrollController,
) -> Self
pub fn controlled( child: impl Widget + 'static, controller: ScrollController, ) -> Self
A scroll view driven by an explicit ScrollController —
programmatic scroll_to / scroll_by / scroll_to_top / scroll_to_bottom.
Create the controller with ScrollController::for_ctx(ctx).
Sourcepub fn controller(self, c: ScrollController) -> Self
pub fn controller(self, c: ScrollController) -> Self
Attach an explicit controller (same as ScrollView::controlled).
Sourcepub fn offset(self, o: f32) -> Self
pub fn offset(self, o: f32) -> Self
Fixed-mode offset in logical pixels (only meaningful with fixed).
pub fn axis(self, a: ScrollAxis) -> Self
pub fn no_scrollbar(self) -> Self
pub fn scrollbar_color(self, c: Color) -> Self
Sourcepub fn scrollbar_style(self, s: ScrollbarStyle) -> Self
pub fn scrollbar_style(self, s: ScrollbarStyle) -> Self
Full scrollbar style (visibility mode, color, track, thickness, radius, inset, minimum thumb length) in one call.
Sourcepub fn scrollbar_visibility(self, v: ScrollbarVisibility) -> Self
pub fn scrollbar_visibility(self, v: ScrollbarVisibility) -> Self
Just the visibility mode — shorthand for .scrollbar_style(..) when
only that needs to change.
Trait Implementations§
Source§impl Widget for ScrollView
impl Widget for ScrollView
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
ctx.constraints and return a size within them. Read more