Skip to main content

ListWindow

Struct ListWindow 

Source
pub struct ListWindow {
    pub estimated_item_height: f32,
    pub overscan: usize,
    pub gap: f32,
    pub scroll_offset: f32,
    /* private fields */
}

Fields§

§estimated_item_height: f32§overscan: usize§gap: f32§scroll_offset: f32

Implementations§

Source§

impl ListWindow

Source

pub fn new(estimated_item_height: f32, overscan: usize, gap: f32) -> ListWindow

Source

pub fn record(&mut self, key: &str, height: f32) -> bool

Remember one row’s laid-out height. Returns true when it changed.

Source

pub fn estimate(&self) -> f32

The extent of an unmeasured item (item_extents): the mean measured extent once any item was measured (keeps the scroll extent stable, so a fling lands on the real end in one pass), else estimated_item_height (the theme’s $control.row, round 2 §5).

Source

pub fn measured_mean(&self) -> Option<f32>

The mean measured extent (None before the first pass).

Source

pub fn extents<'a>(&self, keys: impl Iterator<Item = &'a str>) -> Vec<f64>

Every item’s extent in key order (measured, else the estimate).

Source

pub fn height_of(&self, key: &str) -> f32

Source

pub fn forget(&mut self, key: &str)

Source

pub fn clear(&mut self)

Source

pub fn offsets_cached(&mut self, keys: &Arc<Vec<String>>) -> Arc<Vec<f32>> ⓘ

Self::offsets memoized per keys list (by identity) until a height or the gap changes: a scroll step reuses them (O(log n) per step).

Source

pub fn sticky_header_cached( &mut self, keys: &Arc<Vec<String>>, header_rows: &[usize], scroll: f64, ) -> Option<(StickyHeader, f64)>

The pinned header (sticky_header) on the memoized offsets (Self::offsets_cached): a row’s extent = the next offset − the gap, so nothing per row is recomputed. Header rows past the keys are ignored; header_rows ascending. Returns the pin and the row’s own offset.

Source

pub fn offsets<'a>(&self, keys: impl Iterator<Item = &'a str>) -> Vec<f32>

Offsets of every row’s top plus the total height at the end. Linear in the row count (one pass, no allocation per row beyond the output); the surface calls it once per layout pass.

Source

pub fn content_height<'a>(&self, keys: impl Iterator<Item = &'a str>) -> f32

Total content height for count rows (estimated where unmeasured).

Source

pub fn visible_range(&self, offsets: &[f32], viewport: f32) -> VisibleRange

The items to lay out for a viewport of viewport (on the list’s axis) at the current scroll offset, overscan on both ends: every item intersecting [scroll, scroll + viewport) (an item ending exactly at scroll counts), virtual_window on memoized offsets, O(log n). offsets = Self::offsets.

Trait Implementations§

Source§

impl Clone for ListWindow

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ListWindow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.