Skip to main content

ScrollView

Struct ScrollView 

Source
pub struct ScrollView {
    pub direction: ScrollDirection,
    pub physics: ScrollPhysics,
    pub show_scrollbar: bool,
    pub controller: ScrollController,
    pub content_width: f32,
    pub content_height: f32,
    pub viewport_width: f32,
    pub viewport_height: f32,
    /* private fields */
}
Expand description

A scrollable viewport widget.

The caller is responsible for rendering content at an origin offset by scroll_offset(). ScrollView manages momentum physics, clamping, scrollbar visibility, and fade-out.

Fields§

§direction: ScrollDirection§physics: ScrollPhysics§show_scrollbar: bool§controller: ScrollController§content_width: f32§content_height: f32§viewport_width: f32§viewport_height: f32

Implementations§

Source§

impl ScrollView

Source

pub fn new(viewport_w: f32, viewport_h: f32) -> Self

Create a new ScrollView sized to the given viewport dimensions.

Source

pub fn direction(self, d: ScrollDirection) -> Self

Source

pub fn physics(self, p: ScrollPhysics) -> Self

Source

pub fn show_scrollbar(self, s: bool) -> Self

Source

pub fn content_size(self, w: f32, h: f32) -> Self

Source

pub fn tick(&mut self, dt: f32)

Call each frame (with elapsed seconds dt) to advance momentum and fade the scrollbar out after a period of inactivity.

Source

pub fn on_scroll(&mut self, dx: f32, dy: f32)

Call on a pointer/mouse drag event with the delta since the last event.

Source

pub fn render_chrome(&self, canvas: &mut SkiaCanvas, x: f32, y: f32)

Render the scroll chrome (scrollbar only).

Content must be rendered by the caller, translated by -scroll_offset().

Source

pub fn scroll_offset(&self) -> [f32; 2]

Returns the current [offset_x, offset_y] to subtract from the content drawing origin.

Source

pub fn controller(&self) -> &ScrollController

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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