pub enum ToolbarItemKind {
Button,
Toggle {
on: bool,
},
Menu {
items: Vec<MenuItem>,
},
Search {
text: String,
placeholder: String,
suggestions: Vec<String>,
},
Segmented {
segments: Vec<ToolbarSegment>,
selected: usize,
},
Label,
Separator,
}Expand description
What a toolbar item is. The variants are the vocabulary every desktop toolbar shares; each backend realizes one with its native control, never with a drawn imitation.
Variants§
Button
A push button running the item’s action.
Toggle
A two-state button. on seeds it; the user flipping it emits
ToolbarValue::On, and the app’s own writes arrive as ToolbarPatch::On.
Menu
A button that drops a menu: the same MenuItem model the menu bar uses, so a
toolbar menu and its menu-bar twin are one list of commands.
Search
A search field. Edits emit ToolbarValue::Text; the app’s own writes arrive as
ToolbarPatch::Text.
Day creates this item itself, from a .searchable() surface whose placement resolved to
the toolbar (docs/search.md); apps declare search on the surface, never here.
Fields
Segmented
A row of mutually exclusive choices drawn as one control: the native segmented control
(NSSegmentedControl, a linked GTK/Qt button box, a XAML toggle strip, .day-segmented
on the web).
This is what a set of related toolbar toggles should be when exactly one of them is on at
a time: three separate toggles say “three independent switches” to the eye and to a screen
reader, and leave the app to keep them exclusive. Choosing a segment emits
ToolbarValue::Selected; the app’s own writes arrive as ToolbarPatch::Selected.
Fields
segments: Vec<ToolbarSegment>One entry per segment. A segment with an icon draws it in place of its title where the platform does that, and keeps the title as its accessible name.
Label
Static text, for a status or a caption.
Separator
A divider between neighbors in the same placement bucket, where the platform draws one
(macOS toolbars have no separator, so AppKit renders it as a fixed space,
docs/toolbars.md). Grouping is all it does: alignment is ToolbarPlacement’s job.
Trait Implementations§
Source§impl Clone for ToolbarItemKind
impl Clone for ToolbarItemKind
Source§fn clone(&self) -> ToolbarItemKind
fn clone(&self) -> ToolbarItemKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolbarItemKind
impl Debug for ToolbarItemKind
Source§impl PartialEq for ToolbarItemKind
impl PartialEq for ToolbarItemKind
impl StructuralPartialEq for ToolbarItemKind
Auto Trait Implementations§
impl Freeze for ToolbarItemKind
impl RefUnwindSafe for ToolbarItemKind
impl Send for ToolbarItemKind
impl Sync for ToolbarItemKind
impl Unpin for ToolbarItemKind
impl UnsafeUnpin for ToolbarItemKind
impl UnwindSafe for ToolbarItemKind
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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