Struct rat_widget::scrolled::ScrollState
source · pub struct ScrollState {
pub area: Rect,
pub core: ScrollCore,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
Holds the Scrolled-State.
The current visible page is represented as the pair (offset, page_len). The limit for scrolling is given as max_offset, which is the maximum offset where a full page can still be displayed. Note that the total length of the widgets data is NOT max_offset + page_len. The page_len can be different for every offset selected. Only if the offset is set to max_offset and after the next round of rendering len == max_offset + page_len will hold true.
Fields§
§area: Rect§core: ScrollCore§mouse: MouseFlags§non_exhaustive: NonExhaustiveImplementations§
source§impl ScrollState
impl ScrollState
pub fn new() -> ScrollState
sourcepub fn set_offset(&mut self, offset: usize) -> bool
pub fn set_offset(&mut self, offset: usize) -> bool
Change the offset. Limits the offset to max_v_offset + v_overscroll.
Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.
sourcepub fn scroll_to_pos(&mut self, pos: usize) -> bool
pub fn scroll_to_pos(&mut self, pos: usize) -> bool
Scroll to row.
pub fn scroll_up(&mut self, delta: usize) -> bool
pub fn scroll_down(&mut self, delta: usize) -> bool
pub fn scroll_left(&mut self, delta: usize) -> bool
pub fn scroll_right(&mut self, delta: usize) -> bool
sourcepub fn limit_offset(&self, offset: usize) -> usize
pub fn limit_offset(&self, offset: usize) -> usize
Calculate the offset limited to max_offset+overscroll_by.
sourcepub fn max_offset(&self) -> usize
pub fn max_offset(&self) -> usize
Maximum offset that is accessible with scrolling.
This is shorter than the length of the content by whatever fills the last page. This is the base for the scrollbar content_length.
sourcepub fn set_max_offset(&mut self, max: usize)
pub fn set_max_offset(&mut self, max: usize)
Maximum offset that is accessible with scrolling.
This is shorter than the length of the content by whatever fills the last page. This is the base for the scrollbar content_length.
sourcepub fn set_page_len(&mut self, page: usize)
pub fn set_page_len(&mut self, page: usize)
Page-size at the current offset.
sourcepub fn scroll_by(&self) -> usize
pub fn scroll_by(&self) -> usize
Suggested scroll per scroll-event. Defaults to 1/10 of the page
sourcepub fn set_scroll_by(&mut self, scroll: Option<usize>)
pub fn set_scroll_by(&mut self, scroll: Option<usize>)
Suggested scroll per scroll-event. Defaults to 1/10 of the page
Trait Implementations§
source§impl Clone for ScrollState
impl Clone for ScrollState
source§fn clone(&self) -> ScrollState
fn clone(&self) -> ScrollState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
source§impl HandleEvent<Event, MouseOnly, ScrollOutcome> for ScrollState
impl HandleEvent<Event, MouseOnly, ScrollOutcome> for ScrollState
source§impl PartialEq for ScrollState
impl PartialEq for ScrollState
source§fn eq(&self, other: &ScrollState) -> bool
fn eq(&self, other: &ScrollState) -> bool
self and other values to be equal, and is used
by ==.impl Eq for ScrollState
impl StructuralPartialEq for ScrollState
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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