pub struct ButtonView<State: 'static> { /* private fields */ }Expand description
A declarative M3 Expressive button. See the module docs.
Implementations§
Source§impl<State: 'static> ButtonView<State>
impl<State: 'static> ButtonView<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: ButtonSize) -> Self
pub fn size(self, size: ButtonSize) -> Self
Set the size tier (the module docs’ Sizes table).
Sourcepub fn shape(self, shape: ButtonShape) -> Self
pub fn shape(self, shape: ButtonShape) -> Self
Set the corner-radius family (pill vs. per-size token radius).
Sourcepub fn enabled(self, enabled: bool) -> Self
pub fn enabled(self, enabled: bool) -> Self
Whether the button accepts a press. A disabled button paints the 38% /
12% disabled roles, reports disabled semantics, and swallows nothing —
it simply never arms (m3e_button_content.dart:174’s null
onPressed).
Sourcepub fn icon(self, icon: impl View<State>) -> Self
pub fn icon(self, icon: impl View<State>) -> Self
Attach a leading icon (see button_with_icon).
Sourcepub fn icon_alignment(self, alignment: IconAlignment) -> Self
pub fn icon_alignment(self, alignment: IconAlignment) -> Self
Put the icon on the trailing side instead of the leading one.
Sourcepub fn corner_radius(self, radius: f64) -> Self
pub fn corner_radius(self, radius: f64) -> Self
Override the resting corner radius, ignoring both the shape family and
the per-size token — the reference’s M3EButtonDecoration.borderRadius
(m3e_button_content.dart:42). It also becomes the hovered radius, and
the pressed one unless ButtonView::pressed_radius is set too, since
that is the precedence _resolveShapes applies.
Sourcepub fn pressed_radius(self, radius: f64) -> Self
pub fn pressed_radius(self, radius: f64) -> Self
Override the pressed corner radius — the reference’s
M3EButtonDecoration.pressedRadius, the highest-precedence pressed
input.
Sourcepub fn haptic(self, haptic: HapticSignal) -> Self
pub fn haptic(self, haptic: HapticSignal) -> Self
The haptic signal to fire on a press. Defaults to
HapticSignal::None — matching the reference, where a button is
silent unless its decoration names a signal (the module docs’
Haptics section).
Sourcepub fn decoration(self, decoration: Rc<dyn ButtonDecoration>) -> Self
pub fn decoration(self, decoration: Rc<dyn ButtonDecoration>) -> Self
Install a paint-time decoration layer (the module docs’ Seams section).
Sourcepub fn overflow_observer(self, observer: Rc<dyn OverflowObserver>) -> Self
pub fn overflow_observer(self, observer: Rc<dyn OverflowObserver>) -> Self
Install a layout-time content-measurement observer (the module docs’ Seams section).
Sourcepub fn overflow(self, strategy: OverflowStrategy) -> Self
pub fn overflow(self, strategy: OverflowStrategy) -> Self
Select which strategy an overflowing label uses —
OverflowStrategy::None (the default) by default. See
OverflowStrategy’s own docs for the full three-way contract, and
ButtonView::overflow_observer for the hook
OverflowStrategy::BottomSheet calls into.
Trait Implementations§
Source§impl<State: 'static> View<State> for ButtonView<State>
impl<State: 'static> View<State> for ButtonView<State>
Source§type Element = ButtonWidget
type Element = ButtonWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> ButtonWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> ButtonWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut ButtonWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut ButtonWidget, 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 ButtonView<State>
impl<State> !Send for ButtonView<State>
impl<State> !Sync for ButtonView<State>
impl<State> !UnwindSafe for ButtonView<State>
impl<State> Freeze for ButtonView<State>
impl<State> Unpin for ButtonView<State>
impl<State> UnsafeUnpin for ButtonView<State>
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).