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 more