Struct ScrollView

Source
pub struct ScrollView<A = ()> { /* private fields */ }
Expand description

Single-child viewport for content larger than its visible bounds.

The default scrolls vertically, begins at zero, shows scrollbars, maps one wheel line to 48 logical pixels, and does not follow the content end. The content is clipped and receives a virtual viewport hint containing the current offset. Visible bars support thumb drag and centered track clicks; wheel events bubble when the viewport is already at its requested limit.

§Examples

use ailloli_ui_widgets::{layout::ScrollView, text::Text};
let scroll: ScrollView<()> = ScrollView::vertical().child(Text::new("content"));
let _ = scroll;

Implementations§

Source§

impl<A: 'static> ScrollView<A>

Source

pub fn new() -> Self

Creates a vertical viewport.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::new();
let _ = scroll;
Source

pub fn vertical() -> Self

Creates a vertical-only viewport.

Horizontal initial/wheel offsets are filtered to zero.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::vertical();
let _ = scroll;
Source

pub fn horizontal() -> Self

Creates a horizontal-only viewport.

Vertical initial/wheel offsets are filtered to zero.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::horizontal();
let _ = scroll;
Source

pub fn both() -> Self

Creates a viewport scrollable on both axes.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::both();
let _ = scroll;
Source

pub fn initial_offset(self, offset: Offset) -> Self

Sets the initial non-persisted logical-pixel content offset.

Disabled axes are filtered to zero. The first bounded layout clamps the retained state to content limits.

§Examples
use ailloli_ui_core::Offset;
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::both().initial_offset(Offset::new(10.0, 20.0));
let _ = scroll;
Source

pub fn initial_scroll_y(self, scroll_y: f32) -> Self

Sets a non-negative initial vertical offset in logical pixels.

Negative and NaN inputs become zero via floating-point max.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::vertical().initial_scroll_y(120.0);
let _ = scroll;
Source

pub fn scroll_y(self, scroll_y: f32) -> Self

Legacy builder kept for old tests/apps where this value represented child paint offset.

The legacy value is negated: -40.0 becomes a retained y offset of 40.0, while positive and NaN values become zero. Prefer Self::initial_scroll_y for new code.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let legacy: ScrollView<()> = ScrollView::vertical().scroll_y(-40.0);
let _ = legacy;
Source

pub fn wheel_line_px(self, line_px: f32) -> Self

Sets logical pixels represented by one wheel line.

Values are clamped to at least one; NaN and negative infinity become one, while positive infinity remains infinite.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::vertical().wheel_line_px(24.0);
let _ = scroll;
Source

pub fn follow_end(self, enabled: bool) -> Self

Enables or disables sticky scrolling at the enabled-axis end.

When enabled, content growth follows the end until a manual wheel scroll moves farther than one logical pixel away. Reaching the end reactivates it.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let log: ScrollView<()> = ScrollView::vertical().follow_end(true);
let _ = log;
Source

pub fn scrollbars(self, enabled: bool) -> Self

Shows or hides interactive overflow scrollbars.

Hidden bars expose no pointer hit regions; wheel scrolling and clipping remain active.

§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::vertical().scrollbars(false);
let _ = scroll;
Source

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

Replaces scrollbar colors and geometry.

§Examples
use ailloli_ui_widgets::layout::{ScrollbarStyle, ScrollView};
let style = ScrollbarStyle { thickness: 8.0, ..Default::default() };
let scroll: ScrollView<()> = ScrollView::vertical().scrollbar_style(style);
let _ = scroll;
Source

pub fn child(self, child: impl IntoView<A>) -> Self

Sets the single scroll content child, replacing any previous child.

§Examples
use ailloli_ui_widgets::{layout::ScrollView, text::Text};
let scroll: ScrollView<()> = ScrollView::vertical().child(Text::new("content"));
let _ = scroll;

Trait Implementations§

Source§

impl<A: 'static> Default for ScrollView<A>

Creates the same vertical viewport as ScrollView::new.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A: 'static> IntoView<A> for ScrollView<A>

Converts the builder into a component with default flex-shrink weight one.

Source§

fn into_view(self) -> View<A>

Consumes a builder/value and returns its declarative view tree. Read more

Auto Trait Implementations§

§

impl<A> Freeze for ScrollView<A>

§

impl<A = ()> !RefUnwindSafe for ScrollView<A>

§

impl<A = ()> !Send for ScrollView<A>

§

impl<A = ()> !Sync for ScrollView<A>

§

impl<A> Unpin for ScrollView<A>

§

impl<A = ()> !UnwindSafe for ScrollView<A>

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<T, A> FlexItemExt<A> for T
where T: IntoView<A>,

Source§

fn flex_grow(self) -> View<A>

Sets flex-grow weight to one. Read more
Source§

fn flex_grow_by(self, value: f32) -> View<A>

Sets the dimensionless flex-grow weight. Read more
Source§

fn flex_shrink(self, value: f32) -> View<A>

Sets the dimensionless flex-shrink weight. Read more
Source§

fn flex_basis(self, value: impl Into<Length>) -> View<A>

Sets the preferred main-axis flex basis. Read more
Source§

fn align_self(self, value: AlignItems) -> View<A>

Overrides the parent cross-axis alignment for this view. Read more
Source§

fn fill_width(self) -> View<A>

Marks width as parent-fill in the view size hint. Read more
Source§

fn fill_height(self) -> View<A>

Marks height as parent-fill in the view size hint. Read more
Source§

fn fill(self) -> View<A>

Marks both axes as parent-fill in the view size hint. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T, A> IntoViewKeyExt<A> for T
where T: IntoView<A>,

§

fn key(self, key: impl Into<String>) -> View<A>

Converts self, assigns the owned key, and returns the view. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,