Trait rat_widget::scrolled::ScrollingState
source · pub trait ScrollingState {
Show 14 methods
// Required methods
fn vertical_max_offset(&self) -> usize;
fn vertical_offset(&self) -> usize;
fn vertical_page(&self) -> usize;
fn horizontal_max_offset(&self) -> usize;
fn horizontal_offset(&self) -> usize;
fn horizontal_page(&self) -> usize;
fn set_vertical_offset(&mut self, offset: usize) -> bool;
fn set_horizontal_offset(&mut self, offset: usize) -> bool;
// Provided methods
fn vertical_scroll(&self) -> usize { ... }
fn horizontal_scroll(&self) -> usize { ... }
fn scroll_up(&mut self, n: usize) -> bool { ... }
fn scroll_down(&mut self, n: usize) -> bool { ... }
fn scroll_left(&mut self, n: usize) -> bool { ... }
fn scroll_right(&mut self, n: usize) -> bool { ... }
}Expand description
Trait for the widget-state of a scrollable widget.
This trait works purely in item-space, none of the values correspond to screen coordinates.
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.
The offset can be set to any value possible for usize. It’s the widgets job to limit the value if necessary. Of course, it’s possible for a user of this trait to set their own limits.
Required Methods§
sourcefn vertical_max_offset(&self) -> usize
fn vertical_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.
sourcefn vertical_offset(&self) -> usize
fn vertical_offset(&self) -> usize
Current vertical offset.
sourcefn vertical_page(&self) -> usize
fn vertical_page(&self) -> usize
Vertical page-size at the current offset.
sourcefn horizontal_max_offset(&self) -> usize
fn horizontal_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.
sourcefn horizontal_offset(&self) -> usize
fn horizontal_offset(&self) -> usize
Current horizontal offset.
sourcefn horizontal_page(&self) -> usize
fn horizontal_page(&self) -> usize
Horizontal page-size at the current offset.
sourcefn set_vertical_offset(&mut self, offset: usize) -> bool
fn set_vertical_offset(&mut self, offset: usize) -> bool
Change the vertical offset.
Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.
The widget returns true if the offset changed at all.
sourcefn set_horizontal_offset(&mut self, offset: usize) -> bool
fn set_horizontal_offset(&mut self, offset: usize) -> bool
Change the horizontal offset.
Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.
The widget returns true if the offset changed at all.
Provided Methods§
sourcefn vertical_scroll(&self) -> usize
fn vertical_scroll(&self) -> usize
Suggested scroll per scroll-event.
sourcefn horizontal_scroll(&self) -> usize
fn horizontal_scroll(&self) -> usize
Suggested scroll per scroll-event.
sourcefn scroll_up(&mut self, n: usize) -> bool
fn scroll_up(&mut self, n: usize) -> bool
Scroll up by n items. The widget returns true if the offset changed at all.
sourcefn scroll_down(&mut self, n: usize) -> bool
fn scroll_down(&mut self, n: usize) -> bool
Scroll down by n items. The widget returns true if the offset changed at all.
sourcefn scroll_left(&mut self, n: usize) -> bool
fn scroll_left(&mut self, n: usize) -> bool
Scroll up by n items. The widget returns true if the offset changed at all.
sourcefn scroll_right(&mut self, n: usize) -> bool
fn scroll_right(&mut self, n: usize) -> bool
Scroll down by n items. The widget returns true if the offset changed at all.