Skip to main content

ScrollView

Struct ScrollView 

Source
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: ScrollbarStyle

Implementations§

Source§

impl ScrollView

Source

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.

Source

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).

Source

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).

Source

pub fn gpu_layer(self) -> Self

Force GPU-layer compositing on (see ScrollView::gpu).

Source

pub fn horizontal(child: impl Widget + 'static) -> Self

A horizontal scroll view — carousels, chip rows, code blocks.

Source

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.

Source

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).

Source

pub fn controller(self, c: ScrollController) -> Self

Attach an explicit controller (same as ScrollView::controlled).

Source

pub fn offset(self, o: f32) -> Self

Fixed-mode offset in logical pixels (only meaningful with fixed).

Source

pub fn axis(self, a: ScrollAxis) -> Self

Source

pub fn no_scrollbar(self) -> Self

Source

pub fn scrollbar_color(self, c: Color) -> Self

Source

pub fn scrollbar_style(self, s: ScrollbarStyle) -> Self

Full scrollbar style (visibility mode, color, track, thickness, radius, inset, minimum thumb length) in one call.

Source

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

Source§

fn layout(&self, ctx: &LayoutCtx<'_>) -> Size

Measure under ctx.constraints and return a size within them. Read more
Source§

fn paint(&self, ctx: &mut PaintCtx<'_>)

Record draw commands for ctx.rect. Read more
Source§

fn children(&self) -> Children<'_>

Declare this widget’s children. Drives every default below.
Source§

fn flex_factor(&self) -> f32

Flex weight inside Row/Column. Wrappers are transparent by default.
Source§

fn into_element(self) -> Element
where Self: Sized + 'static,

Wrap this widget in an Element so it can be returned from Component::build().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<W> FocusApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn focus_node(self, node: FocusNode) -> WithFocus<Self>

Attach a focus node. This enables focus-ring rendering and explicit neighbor wiring.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<W> HeroApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn hero_tag(self, tag: impl Into<String>) -> Hero<Self>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> OverlayApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn dropdown( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn sheet( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn dialog( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn rich_tooltip( self, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn toast( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

impl<W> PressApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn on_press(self, f: impl Fn() + Send + Sync + 'static) -> Pressable<Self>

Source§

fn on_long_press( self, f: impl Fn() + Send + Sync + 'static, ) -> LongPressable<Self>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<W> WidgetExt for W
where W: Widget + 'static,

Source§

fn tooltip(self, label: impl Into<String>) -> Tooltip

Show label while the pointer hovers this widget.