pub struct ScrollMetrics { /* private fields */ }Expand description
Precomputed values for proportional scrollbars.
All positions are tracked in subcell units (1/8 of a terminal cell). Use this type to compute thumb length, travel, and hit testing without rendering anything. The inputs are:
content_lenandviewport_lenin logical units (zero treated as 1)track_cellsin terminal cells
Implementations§
Source§impl ScrollMetrics
impl ScrollMetrics
Sourcepub fn from_lengths(
lengths: ScrollLengths,
offset: usize,
track_cells: u16,
) -> Self
pub fn from_lengths( lengths: ScrollLengths, offset: usize, track_cells: u16, ) -> Self
Build metrics using a crate::ScrollLengths helper.
Sourcepub fn new(lengths: ScrollLengths, offset: usize, track_cells: u16) -> Self
pub fn new(lengths: ScrollLengths, offset: usize, track_cells: u16) -> Self
Build metrics for the given content and viewport lengths.
The track_cells parameter is the number of terminal cells available for the track
(height for vertical scrollbars, width for horizontal). The lengths are logical units.
When content_len is smaller than viewport_len, the thumb fills the track to indicate no
scrolling. Zero lengths are treated as 1.
Sourcepub const fn content_len(&self) -> usize
pub const fn content_len(&self) -> usize
Returns the current content length in logical units.
Sourcepub const fn viewport_len(&self) -> usize
pub const fn viewport_len(&self) -> usize
Returns the current viewport length in logical units.
Sourcepub const fn track_cells(&self) -> usize
pub const fn track_cells(&self) -> usize
Returns the track length in terminal cells.
Sourcepub const fn thumb_start(&self) -> usize
pub const fn thumb_start(&self) -> usize
Returns the thumb start position in subcells.
Sourcepub const fn max_offset(&self) -> usize
pub const fn max_offset(&self) -> usize
Returns the maximum scrollable offset in subcells.
Sourcepub const fn thumb_travel(&self) -> usize
pub const fn thumb_travel(&self) -> usize
Returns the maximum thumb travel in subcells.
Sourcepub const fn thumb_range(&self) -> Range<usize>
pub const fn thumb_range(&self) -> Range<usize>
Returns the thumb range in subcell coordinates.
Sourcepub const fn hit_test(&self, position: usize) -> HitTest
pub const fn hit_test(&self, position: usize) -> HitTest
Returns whether a subcell position hits the thumb or the track.
Sourcepub fn thumb_start_for_offset(&self, offset: usize) -> usize
pub fn thumb_start_for_offset(&self, offset: usize) -> usize
Converts an offset (in subcells) to a thumb start position (in subcells).
Larger offsets move the thumb toward the end of the track, clamped to the maximum travel.
Sourcepub fn offset_for_thumb_start(&self, thumb_start: usize) -> usize
pub fn offset_for_thumb_start(&self, thumb_start: usize) -> usize
Converts a thumb start position (in subcells) to an offset (in subcells).
Thumb positions beyond the end of travel are clamped to the maximum offset.
Trait Implementations§
Source§impl Clone for ScrollMetrics
impl Clone for ScrollMetrics
Source§fn clone(&self) -> ScrollMetrics
fn clone(&self) -> ScrollMetrics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScrollMetrics
impl Debug for ScrollMetrics
Source§impl PartialEq for ScrollMetrics
impl PartialEq for ScrollMetrics
impl Copy for ScrollMetrics
impl Eq for ScrollMetrics
impl StructuralPartialEq for ScrollMetrics
Auto Trait Implementations§
impl Freeze for ScrollMetrics
impl RefUnwindSafe for ScrollMetrics
impl Send for ScrollMetrics
impl Sync for ScrollMetrics
impl Unpin for ScrollMetrics
impl UnwindSafe for ScrollMetrics
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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