pub struct TabsState { /* private fields */ }
Expand description
Holds the mutable state used by the tabs
component.
Create and share this value across UI parts with Arc<RwLock<TabsState>>
. The state tracks the
active tab index, previous index, animation progress and cached values used to animate the
indicator and content scrolling. The component mutates parts of this state when a tab is
switched; callers may also read the active tab via TabsState::active_tab
.
Implementations§
Source§impl TabsState
impl TabsState
Sourcepub fn new(initial_tab: usize) -> Self
pub fn new(initial_tab: usize) -> Self
Create a new state with the specified initial active tab.
Sourcepub fn set_active_tab(&mut self, index: usize)
pub fn set_active_tab(&mut self, index: usize)
Set the active tab index and initiate the transition animation.
If the requested index equals the current active tab this is a no-op. Otherwise the method updates cached indicator/content positions and resets the animation progress so the component will animate to the new active tab.
Sourcepub fn active_tab(&self) -> usize
pub fn active_tab(&self) -> usize
Returns the currently active tab index.
Sourcepub fn prev_active_tab(&self) -> usize
pub fn prev_active_tab(&self) -> usize
Returns the previously active tab index (useful during animated transitions).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TabsState
impl RefUnwindSafe for TabsState
impl Send for TabsState
impl Sync for TabsState
impl Unpin for TabsState
impl UnwindSafe for TabsState
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> DowncastSync for T
impl<T> DowncastSync for T
§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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.