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>
impl<A: 'static> ScrollView<A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a vertical viewport.
§Examples
use ailloli_ui_widgets::layout::ScrollView;
let scroll: ScrollView<()> = ScrollView::new();
let _ = scroll;Sourcepub fn vertical() -> Self
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;Sourcepub fn horizontal() -> Self
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;Sourcepub fn both() -> Self
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;Sourcepub fn initial_offset(self, offset: Offset) -> Self
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;Sourcepub fn initial_scroll_y(self, scroll_y: f32) -> Self
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;Sourcepub fn scroll_y(self, scroll_y: f32) -> Self
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;Sourcepub fn wheel_line_px(self, line_px: f32) -> Self
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;Sourcepub fn follow_end(self, enabled: bool) -> Self
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;Sourcepub fn scrollbars(self, enabled: bool) -> Self
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;Sourcepub fn scrollbar_style(self, style: ScrollbarStyle) -> Self
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;Trait Implementations§
Source§impl<A: 'static> Default for ScrollView<A>
Creates the same vertical viewport as ScrollView::new.
impl<A: 'static> Default for ScrollView<A>
Creates the same vertical viewport as ScrollView::new.