pub struct ScrollState {
pub position: usize,
pub follow_bottom: bool,
pub content_size: usize,
pub viewport_size: usize,
}Expand description
A scrollable state for managing UI scrolling and positioning
Fields§
§position: usizeCurrent scroll position (0 = top of content)
follow_bottom: boolFlag indicating if content should auto-scroll to bottom on new content
content_size: usizeTotal content size (in lines) - updated by each render cycle
viewport_size: usizeVisible area size (in lines) - updated by each render cycle
Implementations§
Source§impl ScrollState
impl ScrollState
Sourcepub fn update_dimensions(&mut self, content_size: usize, viewport_size: usize)
pub fn update_dimensions(&mut self, content_size: usize, viewport_size: usize)
Update the content and viewport sizes
Sourcepub fn max_scroll(&self) -> usize
pub fn max_scroll(&self) -> usize
Get the maximum valid scroll position
Sourcepub fn clamp_position(&mut self)
pub fn clamp_position(&mut self)
Ensure scroll position is within valid bounds
Sourcepub fn scroll_down(&mut self, amount: usize)
pub fn scroll_down(&mut self, amount: usize)
Scroll down by the specified amount
Sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Scroll to the top of the content
Sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Scroll to the bottom of the content
Sourcepub fn has_more_above(&self) -> bool
pub fn has_more_above(&self) -> bool
Determine if we need to show the “more above” indicator
Sourcepub fn has_more_below(&self) -> bool
pub fn has_more_below(&self) -> bool
Determine if we need to show the “more below” indicator
Trait Implementations§
Source§impl Clone for ScrollState
impl Clone for ScrollState
Source§fn clone(&self) -> ScrollState
fn clone(&self) -> ScrollState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScrollState
impl Debug for ScrollState
Source§impl Default for ScrollState
impl Default for ScrollState
Source§fn default() -> ScrollState
fn default() -> ScrollState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ScrollState
impl RefUnwindSafe for ScrollState
impl Send for ScrollState
impl Sync for ScrollState
impl Unpin for ScrollState
impl UnwindSafe for ScrollState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more