pub struct VirtualList { /* private fields */ }Expand description
A list of any length that builds only the rows that show, with rows of any height. They
are laid out and measured as they appear, and what was measured is kept by key, so going
back finds them at the right size. It can jump to a row, stay at the end as a chat does,
and keep what is on screen still when rows come in above it. With nothing to select, the
arrows, Page Up, Page Down, Home and End scroll; with a selection or
on_activate, they move between rows, and Enter or Space activates.
Rows of the same height, told with row_height, need no measuring.
use ravenrs_reactive::State;
use ravenrs_widgets::{Text, Ui, VirtualList};
let chosen = State::new(None::<usize>);
let list = VirtualList::new(10_000, |index| Text::new(format!("Row {index}")))
.key(|index| index as u64)
.selection(chosen.binding())
.height(320.0);
let mut ui = Ui::new(list, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl VirtualList
impl VirtualList
Sourcepub fn new<V>(count: usize, item: impl Fn(usize) -> V + 'static) -> VirtualListwhere
V: View + 'static,
pub fn new<V>(count: usize, item: impl Fn(usize) -> V + 'static) -> VirtualListwhere
V: View + 'static,
A list of count rows, with item making the view of each one when it shows.
Sourcepub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> VirtualList
pub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> VirtualList
What identifies a row, which is its position by default. With it, a row keeps its measured height and what is on screen stays still when rows come in above. It is asked for every row on each build, so it should only read a value.
Sourcepub fn estimated_height(self, height: f32) -> VirtualList
pub fn estimated_height(self, height: f32) -> VirtualList
How tall a row probably is until it has been measured (40 by default).
Sourcepub fn row_height(self, height: f32) -> VirtualList
pub fn row_height(self, height: f32) -> VirtualList
Every row has this height, and nothing has to be measured.
Sourcepub fn row_heights(self, height: impl Fn(usize) -> f32 + 'static) -> VirtualList
pub fn row_heights(self, height: impl Fn(usize) -> f32 + 'static) -> VirtualList
The height of each row is known, as with the pages of a document. It is asked for every row on each build.
Sourcepub fn spacing(self, spacing: f32) -> VirtualList
pub fn spacing(self, spacing: f32) -> VirtualList
Gap between rows, in logical pixels.
Sourcepub fn follow_end(self, follow: bool) -> VirtualList
pub fn follow_end(self, follow: bool) -> VirtualList
Starts at the end and stays there as rows arrive, as a chat does, until the user scrolls away; coming back to the end takes it up again.
Sourcepub fn scroll_to(self, index: Binding<Option<usize>>) -> VirtualList
pub fn scroll_to(self, index: Binding<Option<usize>>) -> VirtualList
Set it to a row to bring that row to the start of the view. It goes back to None.
Sourcepub fn selection(self, selected: Binding<Option<usize>>) -> VirtualList
pub fn selection(self, selected: Binding<Option<usize>>) -> VirtualList
Makes the rows selectable, one at a time, with the pointer and the arrows.
Sourcepub fn on_activate(self, handler: impl Fn(usize) + 'static) -> VirtualList
pub fn on_activate(self, handler: impl Fn(usize) + 'static) -> VirtualList
Called with a row on a double click, or on Enter or Space.
Sourcepub fn on_visible(self, handler: impl Fn(Range<usize>) + 'static) -> VirtualList
pub fn on_visible(self, handler: impl Fn(Range<usize>) + 'static) -> VirtualList
Called with the rows that show whenever they change, as for loading what comes next.
Sourcepub fn row_name(self, name: impl Fn(usize) -> String + 'static) -> VirtualList
pub fn row_name(self, name: impl Fn(usize) -> String + 'static) -> VirtualList
What screen readers call each row, for rows whose content does not say it.
Sourcepub fn label(self, label: impl Into<String>) -> VirtualList
pub fn label(self, label: impl Into<String>) -> VirtualList
What screen readers call the list, instead of the name in Labels.
Sourcepub fn height(self, height: f32) -> VirtualList
pub fn height(self, height: f32) -> VirtualList
A fixed height. It takes the height its parent gives it by default.
Sourcepub fn horizontal(self) -> VirtualList
pub fn horizontal(self) -> VirtualList
Runs from left to right; the sizes above are then widths, and the height is across.
Trait Implementations§
Source§impl Debug for VirtualList
impl Debug for VirtualList
Auto Trait Implementations§
impl !RefUnwindSafe for VirtualList
impl !Send for VirtualList
impl !Sync for VirtualList
impl !UnwindSafe for VirtualList
impl Freeze for VirtualList
impl Unpin for VirtualList
impl UnsafeUnpin for VirtualList
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.