Skip to main content

CarouselState

Struct CarouselState 

Source
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

Source

pub fn new<L: Into<SharedString>>( labels: impl IntoIterator<Item = L>, cx: &mut Context<'_, Self>, ) -> Self

Source

pub fn looping(self, looping: bool) -> Self

Source

pub fn slides_per_view(self, count: usize) -> Self

Shows count slides per view; panics when count is zero.

Source

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.

Source

pub fn selected_index(&self) -> Option<usize>

The leading visible slide.

Source

pub fn visible_range(&self) -> Range<usize> ⓘ

The slides currently mounted, in order.

Source

pub fn snap_count(&self) -> usize

The number of distinct leading positions, one per full view.

Source

pub fn labels(&self) -> &[SharedString]

Source

pub fn focus_handle(&self) -> &FocusHandle

Source

pub fn can_previous(&self) -> bool

Source

pub fn can_next(&self) -> bool

Source

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.

Source

pub fn previous( &mut self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool

Source

pub fn next(&mut self, window: &mut Window, cx: &mut Context<'_, Self>) -> bool

Source

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.

Source

pub fn is_autoplaying(&self) -> bool

Trait Implementations§

Auto Trait Implementations§

§

impl !RefUnwindSafe for CarouselState

§

impl !UnwindSafe for CarouselState

§

impl Forget for CarouselState

§

impl Freeze for CarouselState
where *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
where RawVecInner: Send, &'static str: Send, Arc<str>: Send, NonZero<u32>: Send, Arc<RwLock<RawRwLock, FocusMap>>: Send, Task<(), RunnableMeta>: Send, BoxRaw<Task<Box<dyn Any + Sync + Send>>>: Send, Arc<Mutex<RawMutex, RendezvousState<()>>>: Send,

§

impl Sync for CarouselState
where RawVecInner: Sync, Arc<str>: Sync, NonZero<u32>: Sync, Arc<RwLock<RawRwLock, FocusMap>>: Sync, Task<(), RunnableMeta>: Sync, BoxRaw<Task<Box<dyn Any + Sync + Send>>>: Sync, Arc<Mutex<RawMutex, RendezvousState<()>>>: Sync,

§

impl Unpin for CarouselState
where *const u8 is !null: Unpin, &'static str: Unpin, Arc<str>: Unpin, NonZero<u32>: Unpin, Arc<RwLock<RawRwLock, FocusMap>>: Unpin, Task<(), RunnableMeta>: Unpin, Box<Task<Box<dyn Any + Sync + Send>>>: Unpin, Arc<Mutex<RawMutex, RendezvousState<()>>>: Unpin,

§

impl UnsafeUnpin for CarouselState
where *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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more