Skip to main content

VirtualList

Struct VirtualList 

Source
pub struct VirtualList {
    pub estimate: f64,
    pub gap: f64,
    /* private fields */
}
Expand description

A virtualized list: only the rows in (or near) the viewport are built and laid out; spacers stand for the rest. Row heights start at an estimate and are learned from laid-out rows (VirtualList::measure), so long chats stay cheap.

Fields§

§estimate: f64

Height of a row not measured yet.

§gap: f64

Gap between rows.

Implementations§

Source§

impl VirtualList

Source

pub fn new(len: usize, estimate: f64) -> VirtualList

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn set_len(&mut self, n: usize)

Grow or shrink to n rows (new rows unmeasured; kept rows keep their height).

Source

pub fn invalidate(&mut self, i: usize)

Forget a row’s height (its content changed).

Source

pub fn total(&self) -> f64

The whole list’s height (measured rows plus estimates).

Source

pub fn offset_of(&self, i: usize) -> f64

Top of row i in list coordinates.

Source

pub fn index_at(&self, y: f64) -> usize

The row at list y.

Source

pub fn window(&self, scroll: f64, view: f64, overscan: f64) -> Window

The rows covering scroll .. scroll + view, plus overscan pixels each way.

Source

pub fn el(&self, container: El, w: Window, row: impl FnMut(usize) -> El) -> El

The list element: container holding spacers and the rows row(i) for w. A container column gap must equal VirtualList::gap (spacers are emitted only when they stand for rows, so the gap is not doubled).

Source

pub fn measure( &mut self, dom: &Dom, w: Window, id_of: impl Fn(usize) -> String, ) -> bool

Learn the shown rows’ heights from a laid-out tree: row i’s element has id id_of(i). Returns whether any height changed (re-lay out to settle).

Trait Implementations§

Source§

impl Clone for VirtualList

Source§

fn clone(&self) -> VirtualList

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 VirtualList

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for VirtualList

Source§

fn default() -> VirtualList

Returns the “default value” for a type. Read more
Source§

impl PartialEq for VirtualList

Source§

fn eq(&self, other: &VirtualList) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for VirtualList

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.