pub struct ScrollbarState {
pub content_length: usize,
pub position: usize,
pub viewport_length: usize,
}Expand description
Mutable state for a Scrollbar widget.
Fields§
§content_length: usizeTotal number of scrollable content units.
position: usizeCurrent scroll position within the content.
viewport_length: usizeNumber of content units visible in the viewport.
Implementations§
Source§impl ScrollbarState
impl ScrollbarState
Sourcepub fn new(
content_length: usize,
position: usize,
viewport_length: usize,
) -> Self
pub fn new( content_length: usize, position: usize, viewport_length: usize, ) -> Self
Create a new scrollbar state with given content, position, and viewport sizes.
Sourcepub fn handle_mouse(
&mut self,
event: &MouseEvent,
hit: Option<(HitId, HitRegion, u64)>,
expected_id: HitId,
) -> MouseResult
pub fn handle_mouse( &mut self, event: &MouseEvent, hit: Option<(HitId, HitRegion, u64)>, expected_id: HitId, ) -> MouseResult
Handle a mouse event for this scrollbar.
§Hit data convention
The hit data (u64) is encoded as (part << 56) | track_position where
part is one of SCROLLBAR_PART_* and track_position is the index
within the rendered track.
§Arguments
event— the mouse event from the terminalhit— result offrame.hit_test(event.x, event.y), if availableexpected_id— theHitIdthis scrollbar was rendered with
Sourcepub fn scroll_down(&mut self, lines: usize)
pub fn scroll_down(&mut self, lines: usize)
Scroll the content down by the given number of lines.
Clamps so that the viewport stays within content bounds.
Trait Implementations§
Source§impl Clone for ScrollbarState
impl Clone for ScrollbarState
Source§fn clone(&self) -> ScrollbarState
fn clone(&self) -> ScrollbarState
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 ScrollbarState
impl Debug for ScrollbarState
Source§impl Default for ScrollbarState
impl Default for ScrollbarState
Source§fn default() -> ScrollbarState
fn default() -> ScrollbarState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ScrollbarState
impl RefUnwindSafe for ScrollbarState
impl Send for ScrollbarState
impl Sync for ScrollbarState
impl Unpin for ScrollbarState
impl UnwindSafe for ScrollbarState
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