pub struct Carousel<Msg: Clone> {
pub children: Vec<Element<Msg>>,
pub id: Option<WidgetId>,
pub focused_width_frac: f32,
pub gap: f32,
pub offset: f32,
}Fields§
§children: Vec<Element<Msg>>Child widgets in display order, left-to-right.
id: Option<WidgetId>Optional stable identifier — used by the host as the key for its drag / inertia / snap state.
focused_width_frac: f32Each child’s width as a fraction of the viewport width. 0.8 leaves 10% on each side for the neighbours to peek out.
gap: f32Horizontal gap between adjacent children, in logical pixels.
offset: f32Logical-pixel offset applied to every child. Positive values shift children to the right (revealing later tiles). The host clamps, snaps and animates this value.
Implementations§
Source§impl<Msg: Clone> Carousel<Msg>
impl<Msg: Clone> Carousel<Msg>
pub fn push(self, child: impl Into<Element<Msg>>) -> Self
pub fn id(self, id: WidgetId) -> Self
pub fn focused_width_frac(self, f: f32) -> Self
pub fn gap(self, g: f32) -> Self
pub fn offset(self, o: f32) -> Self
pub fn preferred_size(&self, max_width: f32, canvas: &Canvas) -> (f32, f32)
Sourcepub fn snap_offset(&self, viewport_w: f32, idx: usize) -> f32
pub fn snap_offset(&self, viewport_w: f32, idx: usize) -> f32
Snap-target offset that centres idx in the viewport. Positive
values shift the carousel content right — i.e. the negation of
the natural “scroll x” so callers can pass it straight back into
offset().
Sourcepub fn focused_index(&self, viewport_w: f32) -> usize
pub fn focused_index(&self, viewport_w: f32) -> usize
Index of the child whose centre is closest to the viewport centre,
given the current offset. Used by the host to decide which tile a
release should snap to and to compute the keyboard-navigation target.
pub fn layout(&self, rect: Rect, _canvas: &Canvas) -> Vec<(Rect, usize)>
pub fn draw(&self)
Trait Implementations§
Auto Trait Implementations§
impl<Msg> Freeze for Carousel<Msg>
impl<Msg> !RefUnwindSafe for Carousel<Msg>
impl<Msg> !Send for Carousel<Msg>
impl<Msg> !Sync for Carousel<Msg>
impl<Msg> Unpin for Carousel<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for Carousel<Msg>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’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>
§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>
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>
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