pub struct SortableList { /* private fields */ }Expand description
A list that reorders by dragging a row, with a line showing where it will land, or with Alt
and the arrows, Home and End. The arrows alone move between rows, and each move is announced to
screen readers. The order belongs to the app, which applies what
on_reorder tells it.
use ravenrs_reactive::State;
use ravenrs_widgets::{SortableList, Text, Ui};
let items = State::new(vec!["Warm", "Cool", "Matte"]);
let shown = items.get();
let moved = items.clone();
let list = SortableList::new(shown.len(), move |i| Text::new(shown[i]))
.on_reorder(move |from, to| moved.update(|v| {
let item = v.remove(from);
v.insert(to, item);
}));
let mut ui = Ui::new(list, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl SortableList
impl SortableList
Sourcepub fn new<V>(count: usize, item: impl Fn(usize) -> V + 'static) -> SortableListwhere
V: View + 'static,
pub fn new<V>(count: usize, item: impl Fn(usize) -> V + 'static) -> SortableListwhere
V: View + 'static,
A list of count rows, in the order the app keeps.
Sourcepub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> SortableList
pub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> SortableList
What identifies a row, which is its position by default. With it, what a row keeps of its own goes with it when it moves.
Sourcepub fn on_reorder(
self,
handler: impl Fn(usize, usize) + 'static,
) -> SortableList
pub fn on_reorder( self, handler: impl Fn(usize, usize) + 'static, ) -> SortableList
Called with where a row was and where it should go.
Sourcepub fn row_name(self, name: impl Fn(usize) -> String + 'static) -> SortableList
pub fn row_name(self, name: impl Fn(usize) -> String + 'static) -> SortableList
What screen readers call each row, for rows whose content does not say it.
Sourcepub fn spacing(self, spacing: f32) -> SortableList
pub fn spacing(self, spacing: f32) -> SortableList
Gap between rows (2 by default).
Sourcepub fn label(self, label: impl Into<String>) -> SortableList
pub fn label(self, label: impl Into<String>) -> SortableList
What screen readers call the list, instead of the name in Labels.
Sourcepub fn grip(self, grip: bool) -> SortableList
pub fn grip(self, grip: bool) -> SortableList
Whether a row shows the mark that says it can be dragged (on by default).
Trait Implementations§
Source§impl Debug for SortableList
impl Debug for SortableList
Auto Trait Implementations§
impl !RefUnwindSafe for SortableList
impl !Send for SortableList
impl !Sync for SortableList
impl !UnwindSafe for SortableList
impl Freeze for SortableList
impl Unpin for SortableList
impl UnsafeUnpin for SortableList
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
Mutably borrows from an owned value. Read more
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>
Adds padding inside the box, in logical pixels.
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Paints a background behind the content.
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
Fixes the width and/or height in logical pixels;
None keeps the content size.