pub struct CumulativeHeights { /* private fields */ }Expand description
Prefix-sum cache for variable-height row scroll lookups.
Build once per frame (or whenever the row set changes) with
CumulativeHeights::build, then call row_at_offset
and visible_range as needed during rendering.
Implementations§
Source§impl CumulativeHeights
impl CumulativeHeights
Sourcepub fn build<S: RowSource + ?Sized>(source: &S) -> Self
pub fn build<S: RowSource + ?Sized>(source: &S) -> Self
Build the prefix-sum array from a RowSource.
Calls RowSource::row_height once per row and accumulates the results.
Sourcepub fn total_height(&self) -> f32
pub fn total_height(&self) -> f32
Total height of all rows in logical pixels.
Sourcepub fn row_at_offset(&self, scroll_offset: f32) -> usize
pub fn row_at_offset(&self, scroll_offset: f32) -> usize
Return the index of the first row whose top edge is at or before
scroll_offset.
Uses a binary search for O(log n) lookup.
Auto Trait Implementations§
impl Freeze for CumulativeHeights
impl RefUnwindSafe for CumulativeHeights
impl Send for CumulativeHeights
impl Sync for CumulativeHeights
impl Unpin for CumulativeHeights
impl UnsafeUnpin for CumulativeHeights
impl UnwindSafe for CumulativeHeights
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> 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