pub struct CardView { /* private fields */ }Expand description
Records as cards, in as many columns as fit, of which only those in sight are built. Arrows move between cards, Enter opens one and Space selects it.
use ravenrs_widgets::{AnyView, CardView, Text, Ui};
let cards = CardView::new(10_000, |i| Box::new(Text::new(format!("Card {i}"))) as AnyView).height(400.0);
let mut ui = Ui::new(cards, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl CardView
impl CardView
Sourcepub fn new(count: usize, card: impl Fn(usize) -> AnyView + 'static) -> Self
pub fn new(count: usize, card: impl Fn(usize) -> AnyView + 'static) -> Self
count cards, each the view card gives for its index.
Sourcepub fn card_width(self, width: f32) -> Self
pub fn card_width(self, width: f32) -> Self
The narrowest a card gets; they share what is left over. 240 by default.
Sourcepub fn card_height(self, height: f32) -> Self
pub fn card_height(self, height: f32) -> Self
Height of every card in logical pixels. 160 by default.
Sourcepub fn height(self, height: f32) -> Self
pub fn height(self, height: f32) -> Self
Scrolls inside this height. Without it, the view fills what its parent gives.
Sourcepub fn selection_mode(self, mode: SelectionMode) -> Self
pub fn selection_mode(self, mode: SelectionMode) -> Self
How cards are selected. One at a time by default.
Sourcepub fn on_open(self, handler: impl Fn(usize) + 'static) -> Self
pub fn on_open(self, handler: impl Fn(usize) + 'static) -> Self
Runs with the index on Enter or on a double click.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CardView
impl !Send for CardView
impl !Sync for CardView
impl !UnwindSafe for CardView
impl Freeze for CardView
impl Unpin for CardView
impl UnsafeUnpin for CardView
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<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>
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.