pub struct ListView { /* private fields */ }Expand description
A scrolling list of rows of one height that builds only the rows in
view, so a list of thousands costs what a screenful does. Offsets are
f32, which stays exact to about 16 million pixels: some 700,000 rows
of 24 pixels. It follows a
list of items as children_keyed does: each
row is kept while its item’s key stays in the list.
use crabshell_ui::{ListView, Text};
let apps = ListView::new(
|| (1..=500).map(|n| format!("app {n}")).collect::<Vec<_>>(),
|name| name.clone(),
|_cx, name| Text::new(move || name.get()),
)
.row_height(28)
.height(280);Implementations§
Source§impl ListView
impl ListView
Sourcepub const DEFAULT_ROW_HEIGHT: u32 = 24
pub const DEFAULT_ROW_HEIGHT: u32 = 24
The default row height and list height, in logical pixels.
Sourcepub const DEFAULT_HEIGHT: u32 = 240
pub const DEFAULT_HEIGHT: u32 = 240
The default height of the list, in logical pixels.
Sourcepub fn new<T, K, W>(
items: impl FnMut() -> Vec<T> + 'static,
key: impl FnMut(&T) -> K + 'static,
view: impl FnMut(&Cx, Memo<T>) -> W + 'static,
) -> ListView
pub fn new<T, K, W>( items: impl FnMut() -> Vec<T> + 'static, key: impl FnMut(&T) -> K + 'static, view: impl FnMut(&Cx, Memo<T>) -> W + 'static, ) -> ListView
A list with a row for each of items, built by view and kept by
key, as in children_keyed.
Sourcepub fn row_height(self, height: impl IntoProp<u32>) -> ListView
pub fn row_height(self, height: impl IntoProp<u32>) -> ListView
Sets every row’s height in logical pixels.
Sourcepub fn height(self, height: impl IntoProp<u32>) -> ListView
pub fn height(self, height: impl IntoProp<u32>) -> ListView
Sets the list’s height in logical pixels.
Sourcepub fn current(self, index: impl IntoProp<Option<usize>>) -> ListView
pub fn current(self, index: impl IntoProp<Option<usize>>) -> ListView
Keeps the row at this index in view, scrolling as little as needed
whenever it changes. None scrolls nothing.
Trait Implementations§
Source§impl Widget for ListView
impl Widget for ListView
Source§fn into_element(self: Box<Self>) -> Element
fn into_element(self: Box<Self>) -> Element
Turns the description, and everything inside it, into the element
the window builds nodes from. It runs when the window is created or a
list item first appears, before the window’s tree is touched and
without recording what it reads, so it only describes.
Auto Trait Implementations§
impl !RefUnwindSafe for ListView
impl !Send for ListView
impl !Sync for ListView
impl !UnwindSafe for ListView
impl Forget for ListView
impl Freeze for ListView
impl Move for ListView
impl Unpin for ListView
impl UnsafeUnpin for ListView
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