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: f32Implementations§
Source§impl ScrollView
impl ScrollView
Sourcepub fn new(viewport_w: f32, viewport_h: f32) -> Self
pub fn new(viewport_w: f32, viewport_h: f32) -> Self
Create a new ScrollView sized to the given viewport dimensions.
pub fn direction(self, d: ScrollDirection) -> Self
pub fn physics(self, p: ScrollPhysics) -> Self
pub fn show_scrollbar(self, s: bool) -> Self
pub fn content_size(self, w: f32, h: f32) -> Self
Sourcepub fn tick(&mut self, dt: f32)
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.
Sourcepub fn on_scroll(&mut self, dx: f32, dy: f32)
pub fn on_scroll(&mut self, dx: f32, dy: f32)
Call on a pointer/mouse drag event with the delta since the last event.
Sourcepub fn render_chrome(&self, canvas: &mut SkiaCanvas, x: f32, y: f32)
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().
Sourcepub fn scroll_offset(&self) -> [f32; 2]
pub fn scroll_offset(&self) -> [f32; 2]
Returns the current [offset_x, offset_y] to subtract from the content
drawing origin.
pub fn controller(&self) -> &ScrollController
Auto Trait Implementations§
impl Freeze for ScrollView
impl RefUnwindSafe for ScrollView
impl Send for ScrollView
impl Sync for ScrollView
impl Unpin for ScrollView
impl UnsafeUnpin for ScrollView
impl UnwindSafe for ScrollView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more