pub struct ToggleButtonView<State: 'static> { /* private fields */ }Expand description
A declarative M3 Expressive toggle button. See the module docs.
Implementations§
Source§impl<State: 'static> ToggleButtonView<State>
impl<State: 'static> ToggleButtonView<State>
Sourcepub fn variant(self, variant: ButtonVariant) -> Self
pub fn variant(self, variant: ButtonVariant) -> Self
Set the container treatment (the module docs’ Variants table).
Sourcepub fn size(self, size: ToggleButtonSize) -> Self
pub fn size(self, size: ToggleButtonSize) -> Self
Set the size tier (the module docs’ Sizes table).
Sourcepub fn enabled(self, enabled: bool) -> Self
pub fn enabled(self, enabled: bool) -> Self
Whether the toggle button accepts a press. A disabled button paints the 38%/12% disabled roles and reports disabled semantics.
Sourcepub fn icon(self, icon: impl View<State>) -> Self
pub fn icon(self, icon: impl View<State>) -> Self
Icon shown while unchecked (and while checked too, if
Self::checked_icon is unset).
Sourcepub fn checked_icon(self, icon: impl View<State>) -> Self
pub fn checked_icon(self, icon: impl View<State>) -> Self
Icon shown while checked. Falls back to Self::icon when unset.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
Label shown while unchecked (and while checked too, if
Self::checked_label is unset).
Sourcepub fn checked_label(self, label: impl Into<String>) -> Self
pub fn checked_label(self, label: impl Into<String>) -> Self
Label shown while checked. Falls back to Self::label when unset.
Sourcepub fn group_connected(self, connected: bool) -> Self
pub fn group_connected(self, connected: bool) -> Self
Whether this button is part of a connected group — the module docs’ Group-connection corner asymmetry section. Plumbing for the upcoming button-group rework.
Sourcepub fn first_in_group(self, first: bool) -> Self
pub fn first_in_group(self, first: bool) -> Self
Whether this is the first (leading) member of a connected group —
only consulted while Self::group_connected is true. Defaults to
true (a standalone button behaves as if it were both ends).
Sourcepub fn last_in_group(self, last: bool) -> Self
pub fn last_in_group(self, last: bool) -> Self
Whether this is the last (trailing) member of a connected group —
only consulted while Self::group_connected is true. Defaults to
true.
Sourcepub fn haptic(self, haptic: HapticSignal) -> Self
pub fn haptic(self, haptic: HapticSignal) -> Self
The haptic signal to fire on a confirmed checked-toggle. Defaults to
HapticSignal::None (the module docs’ Haptics section).
Sourcepub fn on_long_press<F: Fn(&mut State) + 'static>(
self,
on_long_press: F,
) -> Self
pub fn on_long_press<F: Fn(&mut State) + 'static>( self, on_long_press: F, ) -> Self
Fire on_long_press when a press is held past the threshold — the
module docs’ Long-press section documents the exact firing
contract (deferred to the next pointer event, not immediate).
Trait Implementations§
Source§impl<State: 'static> View<State> for ToggleButtonView<State>
impl<State: 'static> View<State> for ToggleButtonView<State>
Source§type Element = ToggleButtonWidget
type Element = ToggleButtonWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> ToggleButtonWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> ToggleButtonWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut ToggleButtonWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut ToggleButtonWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.Auto Trait Implementations§
impl<State> !RefUnwindSafe for ToggleButtonView<State>
impl<State> !Send for ToggleButtonView<State>
impl<State> !Sync for ToggleButtonView<State>
impl<State> !UnwindSafe for ToggleButtonView<State>
impl<State> Freeze for ToggleButtonView<State>
impl<State> Unpin for ToggleButtonView<State>
impl<State> UnsafeUnpin for ToggleButtonView<State>where
Rc<dyn Fn(&mut State, bool)>: UnsafeUnpin,
Option<AnyView<State>>: UnsafeUnpin,
Option<Rc<dyn Fn(&mut State)>>: 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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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> 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> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
Source§fn extend_views(self, out: &mut Vec<AnyView<State>>)
fn extend_views(self, out: &mut Vec<AnyView<State>>)
out — erasing each
with AnyView::new (a no-op for an element already an AnyView).