pub struct MaterialCarousel<'a> { /* private fields */ }Expand description
A Material Design 3 Carousel component.
Carousels display a horizontally scrollable list of items where edge items compress to a smaller size, creating a peek effect.
§Example
let mut offset = 0.0f32;
ui.add(MaterialCarousel::new(&mut offset)
.item_text("Item 0")
.item_text("Item 1")
.item_text("Item 2"));Implementations§
Source§impl<'a> MaterialCarousel<'a>
impl<'a> MaterialCarousel<'a>
Sourcepub fn new(scroll_offset: &'a mut f32) -> Self
pub fn new(scroll_offset: &'a mut f32) -> Self
Create a new carousel widget.
§Arguments
scroll_offset- Mutable reference to persistent scroll state
Sourcepub fn item(self, content: impl FnOnce(&mut Ui, Rect) + 'a) -> Self
pub fn item(self, content: impl FnOnce(&mut Ui, Rect) + 'a) -> Self
Add a custom item with a rendering closure.
The closure receives (&mut Ui, Rect) where Rect is the available area.
Sourcepub fn item_extent(self, extent: f32) -> Self
pub fn item_extent(self, extent: f32) -> Self
Set the full-size width of each item (default: 180.0).
Sourcepub fn shrink_extent(self, extent: f32) -> Self
pub fn shrink_extent(self, extent: f32) -> Self
Set the minimum width for edge items (default: 100.0).
Sourcepub fn corner_radius(self, radius: f32) -> Self
pub fn corner_radius(self, radius: f32) -> Self
Set the corner radius for item shapes (default: 10.0).
Sourcepub fn item_snapping(self, snapping: bool) -> Self
pub fn item_snapping(self, snapping: bool) -> Self
Enable or disable item snapping (default: false).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for MaterialCarousel<'a>
impl<'a> !RefUnwindSafe for MaterialCarousel<'a>
impl<'a> !Send for MaterialCarousel<'a>
impl<'a> !Sync for MaterialCarousel<'a>
impl<'a> Unpin for MaterialCarousel<'a>
impl<'a> UnsafeUnpin for MaterialCarousel<'a>
impl<'a> !UnwindSafe for MaterialCarousel<'a>
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