pub struct CarouselState { /* private fields */ }Expand description
Retained state for a fixed ordered set of slides. Labels name each slide.
A view shows slides_per_view consecutive slides starting at the selected
(leading) slide; one is the default. Only those slides are mounted, and the
application sizes them, for example with relative(1. / n) widths. Each
step moves by one slide, and the last view is always full: the leading index
ranges over snap_count positions. Looping wraps between
the last full view and the first. Application entities retain slide data;
there is no autoplay, timer, or focus movement merely because data changes.
Implementations§
Source§impl CarouselState
impl CarouselState
pub fn new<L: Into<SharedString>>( labels: impl IntoIterator<Item = L>, cx: &mut Context<'_, Self>, ) -> Self
pub fn looping(self, looping: bool) -> Self
Sourcepub fn slides_per_view(self, count: usize) -> Self
pub fn slides_per_view(self, count: usize) -> Self
Shows count slides per view; panics when count is zero.
Sourcepub fn set_slides_per_view(
&mut self,
count: usize,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn set_slides_per_view( &mut self, count: usize, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Changes the view size, keeping the leading slide where possible and moving focus out of slides that leave the view.
Sourcepub fn selected_index(&self) -> Option<usize>
pub fn selected_index(&self) -> Option<usize>
The leading visible slide.
Sourcepub fn visible_range(&self) -> Range<usize> ⓘ
pub fn visible_range(&self) -> Range<usize> ⓘ
The slides currently mounted, in order.
Sourcepub fn snap_count(&self) -> usize
pub fn snap_count(&self) -> usize
The number of distinct leading positions, one per full view.
pub fn labels(&self) -> &[SharedString]
pub fn focus_handle(&self) -> &FocusHandle
pub fn can_previous(&self) -> bool
pub fn can_next(&self) -> bool
Sourcepub fn select(
&mut self,
index: usize,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn select( &mut self, index: usize, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Makes index the leading slide when it starts a full view. Focus inside
slides leaving the view returns to the carousel scope before that content
is unmounted; focus in slides that remain visible or outside stays put.
pub fn previous( &mut self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
pub fn next(&mut self, window: &mut Window, cx: &mut Context<'_, Self>) -> bool
Sourcepub fn set_autoplay(
&mut self,
interval: Option<Duration>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_autoplay( &mut self, interval: Option<Duration>, window: &mut Window, cx: &mut Context<'_, Self>, )
Starts or stops automatic advancing. Each interval moves one slide
forward, wrapping from the last view to the first. Rotation pauses while
the pointer is over the carousel, focus is inside it, the window is
inactive, or the application asks for reduced motion. Keyboard, swipe and
CarouselControl navigation stop it, as does None. Render a visible
control that calls this method so people can stop or restart rotation.
pub fn is_autoplaying(&self) -> bool
Trait Implementations§
impl EventEmitter<CarouselEvent> for CarouselState
Auto Trait Implementations§
impl !RefUnwindSafe for CarouselState
impl !UnwindSafe for CarouselState
impl Forget for CarouselState
impl Freeze for CarouselStatewhere
*const u8 is !null: Freeze,
PhantomData<SharedString>: Freeze,
NonZero<u32>: Freeze,
*const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: Freeze,
PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: Freeze,
PhantomData<FocusHandle>: Freeze,
*const () is !null: Freeze,
PhantomData<((), RunnableMeta)>: Freeze,
*const Task<Box<dyn Any + Sync + Send>> is !null: Freeze,
PhantomData<Task<Box<dyn Any + Sync + Send>>>: Freeze,
PhantomData<fn()>: Freeze,
*const ArcInner<Mutex<RawMutex, RendezvousState<()>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<RawMutex, RendezvousState<()>>>>: Freeze,
impl Move for CarouselState
impl Send for CarouselState
impl Sync for CarouselState
impl Unpin for CarouselState
impl UnsafeUnpin for CarouselStatewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<SharedString>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: UnsafeUnpin,
PhantomData<FocusHandle>: UnsafeUnpin,
*const () is !null: UnsafeUnpin,
PhantomData<((), RunnableMeta)>: UnsafeUnpin,
*const Task<Box<dyn Any + Sync + Send>> is !null: UnsafeUnpin,
PhantomData<Task<Box<dyn Any + Sync + Send>>>: UnsafeUnpin,
PhantomData<fn()>: UnsafeUnpin,
*const ArcInner<Mutex<RawMutex, RendezvousState<()>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<RawMutex, RendezvousState<()>>>>: UnsafeUnpin,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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