Skip to main content

ToolbarView

Struct ToolbarView 

Source
pub struct ToolbarView<State: 'static> { /* private fields */ }
Expand description

A declarative M3X toolbar. See the module docs.

Implementations§

Source§

impl<State: 'static> ToolbarView<State>

Source

pub fn leading(self, leading: Vec<AnyView<State>>) -> Self

Attach leading slot children, in reading order (hugs the leading edge). Tint/styling is each supplied view’s own responsibility.

Source

pub fn center(self, center: Vec<AnyView<State>>) -> Self

Attach center slot children, in reading order — upstream’s inline M3EToolbarWidget items, which never overflow. They lead the typed Self::actions within the same center group.

Source

pub fn trailing(self, trailing: Vec<AnyView<State>>) -> Self

Attach trailing slot children, in reading order (hugs the trailing edge, or the fab slot if also attached).

Source

pub fn fab(self, fab: AnyView<State>) -> Self

Attach the optional adjacent FAB — upstream’s floatingActionButton. On a floating bar this takes the adjacent morph layout described in the module docs; on a docked one it simply trails the row, as it always has (upstream has no docked FAB at all).

Source

pub fn actions(self, actions: Vec<ToolbarAction<State>>) -> Self

Attach the typed action list — upstream’s actions, the only slot subject to the overflow split.

Source

pub fn max_inline_actions(self, max: usize) -> Self

How many actions stay inline before overflowing (maxInlineActions, default TOOLBAR_MAX_INLINE_ACTIONS).

Source

pub fn overflow_icon(self, icon: IconSource) -> Self

Replace the overflow trigger’s glyph (overflowIcon, default more_vert).

Source

pub fn overflow_label(self, label: impl Into<String>) -> Self

Replace the overflow trigger’s accessible name (upstream’s own 'More options').

Source

pub fn on_overflow<F: Fn(&mut State) + 'static>(self, on_overflow: F) -> Self

Fired when the overflow trigger is pressed — where an app flips the open flag it hands Self::overflow_menu.

Source

pub fn overflow_anchor(self, anchor: &OverlayAnchor) -> Self

Capture the overflow trigger’s window rect into anchor on every paint, so Self::overflow_menu has a rect to place against — the same OverlayAnchor handoff crate::button_group’s own popup overflow takes.

Source

pub fn color_style(self, style: ToolbarColorStyle) -> Self

Pick the standard or vibrant color resolution (colorStyle).

Source

pub fn elevation(self, elevation: ToolbarElevation) -> Self

Override the resting elevation (upstream’s elevation). Unset, a bar rests at ToolbarElevation::None, or ToolbarElevation::Level1 once a FAB is attached.

Source

pub fn size(self, size: ToolbarSize) -> Self

The icon-button density typed actions render at (size).

Source

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

Whether the pill is expanded (expanded, default true) — the controlled prop driving the FAB morph and pill reveal. See the module docs for who owns the toggle.

Source

pub fn fab_expands_toolbar(self, expands: bool) -> Self

Whether an adjacent FAB morphs with the pill (fabExpandsToolbar, default true). Set false to pin the pill open and the FAB at TOOLBAR_FAB_BASELINE.

Source

pub fn fab_position(self, position: ToolbarFabPosition) -> Self

Which edge an adjacent FAB occupies (fabPosition, default ToolbarFabPosition::End).

Source

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

Whether the bar is shown (show()/hide(), default true) — sprung on TOOLBAR_EXPAND_SPRING. Ignored while Self::hidden_fraction pins a value.

Source

pub fn hidden_fraction(self, fraction: Option<f64>) -> Self

Pin the hidden fraction directly, 0.0 visible through 1.0 hidden — upstream’s plain offset setter during a scroll drag. Some(f) overrides Self::visible and applies with no spring; None (the default) hands the ramp back to visible, resuming from wherever the pin left it.

Source

pub fn exit_direction(self, direction: ToolbarExitDirection) -> Self

The direction the bar slides while hidden (exitDirection, default ToolbarExitDirection::Bottom).

Source

pub fn exit_extent(self, extent: Option<f64>) -> Self

Override the hide travel distance (exitExtent). Unset, the bar measures its own cross extent and adds TOOLBAR_SCREEN_OFFSET.

Source

pub fn semantic_label(self, label: impl Into<String>) -> Self

The accessible name of the bar as a whole (semanticLabel).

Source

pub fn overflow_menu(&self, open: bool) -> AnyView<State>

The anchored overflow panel for the actions that did not fit — mount this separately as the top of the app’s own frust::Stack, anchored to the same OverlayAnchor handed to Self::overflow_anchor, and toggle open rather than unmounting it (the kept-mounted pattern crate::overlay::anchored documents).

Each overflowed action becomes a crate::menu::MenuEntry row led by its own glyph; activating one runs that action’s on_press, exactly as its inline button would. The placement is upstream’s own M3EMenuAnchorPosition.bottomEnd.

Trait Implementations§

Source§

impl<State: 'static> View<State> for ToolbarView<State>

Source§

type Element = ToolbarWidget

The retained widget this view produces.
Source§

fn build(&self, ctx: &mut BuildCtx<'_>) -> ToolbarWidget

Materialise a fresh widget for this view.
Source§

fn rebuild( &self, prev: &Self, element: &mut ToolbarWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags

Reconcile prev (the previous view of the same type) against the live element, mutating it in place and reporting what changed.
Source§

fn teardown(&self, element: &mut ToolbarWidget, ctx: &mut BuildCtx<'_>)

Tear down element when this view is being removed. Read more
Source§

fn message(&self, _element: &mut Self::Element, _state: &mut State)

Deliver an event message to this view, mutating application state. Read more

Auto Trait Implementations§

§

impl<State> !RefUnwindSafe for ToolbarView<State>

§

impl<State> !Send for ToolbarView<State>

§

impl<State> !Sync for ToolbarView<State>

§

impl<State> !UnwindSafe for ToolbarView<State>

§

impl<State> Freeze for ToolbarView<State>
where Vec<AnyView<State>>: Freeze, Option<AnyView<State>>: Freeze, Vec<ToolbarAction<State>>: Freeze, Option<Rc<dyn Fn(&mut State)>>: Freeze,

§

impl<State> Unpin for ToolbarView<State>
where Vec<AnyView<State>>: Unpin, Option<AnyView<State>>: Unpin, Vec<ToolbarAction<State>>: Unpin, Option<Rc<dyn Fn(&mut State)>>: Unpin,

§

impl<State> UnsafeUnpin for ToolbarView<State>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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<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