pub struct Filmstrip { /* private fields */ }Expand description
A horizontal strip of thumbnails that builds only what shows, so thousands cost the same as a few. Each cell comes from whoever uses it, with its own image, stars or badges; the strip draws the frame around it. A click selects alone, Ctrl or Cmd adds, and Shift takes a range; the arrows, Home and End move and keep the selected cell in view, Space adds, Enter activates. Arrows appear on the ends that have more to show.
use std::collections::BTreeSet;
use ravenrs_reactive::State;
use ravenrs_widgets::{Filmstrip, FilmstripCell, SelectionMode, Text, Ui};
let selected = State::new(BTreeSet::from([0_usize]));
let strip = Filmstrip::new(5_000, |cell: FilmstripCell| Text::new(format!("{}", cell.index + 1)))
.selection(selected.binding())
.mode(SelectionMode::Multiple);
let mut ui = Ui::new(strip, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl Filmstrip
impl Filmstrip
Sourcepub fn new<V: View + 'static>(
count: usize,
cell: impl Fn(FilmstripCell) -> V + 'static,
) -> Self
pub fn new<V: View + 'static>( count: usize, cell: impl Fn(FilmstripCell) -> V + 'static, ) -> Self
A strip of count cells, with cell making the view of each one when it shows.
Sourcepub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> Self
pub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> Self
What identifies a cell, which is its position by default.
Sourcepub fn selection(self, selection: Binding<BTreeSet<usize>>) -> Self
pub fn selection(self, selection: Binding<BTreeSet<usize>>) -> Self
The selected cells, to read and to change from outside. A single one that changes from outside is brought into view.
Sourcepub fn mode(self, mode: SelectionMode) -> Self
pub fn mode(self, mode: SelectionMode) -> Self
How cells can be selected (SelectionMode::Single by default).
Sourcepub fn on_activate(self, handler: impl Fn(usize) + 'static) -> Self
pub fn on_activate(self, handler: impl Fn(usize) + 'static) -> Self
Called with a cell on a double click or on Enter.
Sourcepub fn cell_name(self, name: impl Fn(usize) -> String + 'static) -> Self
pub fn cell_name(self, name: impl Fn(usize) -> String + 'static) -> Self
What screen readers call each cell.
Sourcepub fn cell_width(self, width: f32) -> Self
pub fn cell_width(self, width: f32) -> Self
The width of each cell (96 by default).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Filmstrip
impl !Send for Filmstrip
impl !Sync for Filmstrip
impl !UnwindSafe for Filmstrip
impl Freeze for Filmstrip
impl Unpin for Filmstrip
impl UnsafeUnpin for Filmstrip
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
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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.