pub struct DataView<T: 'static> { /* private fields */ }Expand description
A signal-bound collection view. Create with
cx.new(|cx| DataView::new(cx, &signal).item(...)).
Implementations§
Source§impl<T: 'static> DataView<T>
impl<T: 'static> DataView<T>
Sourcepub fn new(cx: &mut Context<'_, Self>, source: &Signal<Vec<T>>) -> Self
pub fn new(cx: &mut Context<'_, Self>, source: &Signal<Vec<T>>) -> Self
Bind the view to a collection signal. Every set/update on the
signal repaints the view.
Sourcepub fn item<E>(
self,
template: impl Fn(&T, usize, &mut Window, &mut App) -> E + 'static,
) -> Selfwhere
E: IntoElement,
pub fn item<E>(
self,
template: impl Fn(&T, usize, &mut Window, &mut App) -> E + 'static,
) -> Selfwhere
E: IntoElement,
The item template, re-invoked every frame with the borrowed item and its source index — items always show live data.
Sourcepub fn filter(self, pred: impl Fn(&T) -> bool + 'static) -> Self
pub fn filter(self, pred: impl Fn(&T) -> bool + 'static) -> Self
Show only the items matching pred. A projection: the source vector
is untouched.
Sourcepub fn sort_by(self, cmp: impl Fn(&T, &T) -> Ordering + 'static) -> Self
pub fn sort_by(self, cmp: impl Fn(&T, &T) -> Ordering + 'static) -> Self
Display order (stable sort). A projection: the source vector is untouched.
pub fn layout(self, layout: DataViewLayout) -> Self
Sourcepub fn empty<E>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Selfwhere
E: IntoElement,
pub fn empty<E>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Selfwhere
E: IntoElement,
Shown when the projection yields nothing (empty source or everything filtered out). Rebuilt each render.
Sourcepub fn selectable(self) -> Self
pub fn selectable(self) -> Self
Enable single selection: items get hover/selected styling and clicks
emit DataViewEvent::Selected.
Sourcepub fn selected_index(&self) -> Option<usize>
pub fn selected_index(&self) -> Option<usize>
The selected source index, if any.
Trait Implementations§
impl<T: 'static> EventEmitter<DataViewEvent> for DataView<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for DataView<T>
impl<T> !Send for DataView<T>
impl<T> !Sync for DataView<T>
impl<T> !UnwindSafe for DataView<T>
impl<T> Freeze for DataView<T>
impl<T> Unpin for DataView<T>
impl<T> UnsafeUnpin for DataView<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more