pub struct ToolbarView<State: 'static> { /* private fields */ }Expand description
A declarative M3X toolbar. See the module docs.
Implementations§
Source§impl<State: 'static> ToolbarView<State>
impl<State: 'static> ToolbarView<State>
Sourcepub fn leading(self, leading: Vec<AnyView<State>>) -> Self
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.
Sourcepub fn center(self, center: Vec<AnyView<State>>) -> Self
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.
Sourcepub fn trailing(self, trailing: Vec<AnyView<State>>) -> Self
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).
Sourcepub fn fab(self, fab: AnyView<State>) -> Self
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).
Sourcepub fn actions(self, actions: Vec<ToolbarAction<State>>) -> Self
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.
Sourcepub fn max_inline_actions(self, max: usize) -> Self
pub fn max_inline_actions(self, max: usize) -> Self
How many actions stay inline before overflowing (maxInlineActions,
default TOOLBAR_MAX_INLINE_ACTIONS).
Sourcepub fn overflow_icon(self, icon: IconSource) -> Self
pub fn overflow_icon(self, icon: IconSource) -> Self
Replace the overflow trigger’s glyph (overflowIcon, default
more_vert).
Sourcepub fn overflow_label(self, label: impl Into<String>) -> Self
pub fn overflow_label(self, label: impl Into<String>) -> Self
Replace the overflow trigger’s accessible name (upstream’s own
'More options').
Sourcepub fn on_overflow<F: Fn(&mut State) + 'static>(self, on_overflow: F) -> Self
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.
Sourcepub fn overflow_anchor(self, anchor: &OverlayAnchor) -> Self
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.
Sourcepub fn color_style(self, style: ToolbarColorStyle) -> Self
pub fn color_style(self, style: ToolbarColorStyle) -> Self
Pick the standard or vibrant color resolution (colorStyle).
Sourcepub fn elevation(self, elevation: ToolbarElevation) -> Self
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.
Sourcepub fn size(self, size: ToolbarSize) -> Self
pub fn size(self, size: ToolbarSize) -> Self
The icon-button density typed actions render at (size).
Sourcepub fn expanded(self, expanded: bool) -> Self
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.
Sourcepub fn fab_expands_toolbar(self, expands: bool) -> Self
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.
Sourcepub fn fab_position(self, position: ToolbarFabPosition) -> Self
pub fn fab_position(self, position: ToolbarFabPosition) -> Self
Which edge an adjacent FAB occupies (fabPosition, default
ToolbarFabPosition::End).
Sourcepub fn visible(self, visible: bool) -> Self
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.
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.
Sourcepub fn exit_direction(self, direction: ToolbarExitDirection) -> Self
pub fn exit_direction(self, direction: ToolbarExitDirection) -> Self
The direction the bar slides while hidden (exitDirection, default
ToolbarExitDirection::Bottom).
Sourcepub fn exit_extent(self, extent: Option<f64>) -> Self
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.
Sourcepub fn semantic_label(self, label: impl Into<String>) -> Self
pub fn semantic_label(self, label: impl Into<String>) -> Self
The accessible name of the bar as a whole (semanticLabel).
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>
impl<State: 'static> View<State> for ToolbarView<State>
Source§type Element = ToolbarWidget
type Element = ToolbarWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> ToolbarWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> ToolbarWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut ToolbarWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut ToolbarWidget, 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 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>
impl<State> Unpin for ToolbarView<State>
impl<State> UnsafeUnpin for ToolbarView<State>where
Vec<AnyView<State>>: UnsafeUnpin,
Option<AnyView<State>>: UnsafeUnpin,
Vec<ToolbarAction<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.