Skip to main content

Module toolbar

Module toolbar 

Source
Expand description

Portable toolbar model.

Shared, backend-agnostic model for WidgetKind::Toolbar per docs/widget-expansion-roadmap.md §14: stable ToolIds that survive rebuilds and reorders, separators, icon/text display modes, checkable and exclusive radio tools, dropdown tools, and the pure rules every lane must agree on.

The rules are functions, not a second state store: Ui owns the item list on the widget spec, applies these helpers, and forwards the resulting list to the backend. Keeping them here means the Mock oracle and the native toolbars cannot drift on the two behaviours that are easy to get wrong:

  • radio exclusivity — checking one member of a group unchecks the other members, and a user toggle reports one ToolToggled per changed tool (never a single “group” event);
  • programmatic vs user edits — set_tool_state is silent by design (no activation echo), while click_tool is the user path that produces the events.

The native compositions (GTK gtk::Box, Win32 TOOLBARCLASSNAME, Cocoa NSToolbar) land later; until then every backend refuses the kind and the toolbar setters with the typed unsupported error instead of faking a toolbar.

Structs§

ToolId
Stable, application-facing identifier of one toolbar tool.
ToolSpec
One toolbar tool.
ToolUpdate
Partial in-place update applied by crate::Ui::update_tool.

Enums§

ToolDisplay
How a tool presents its label and icon where the lane supports both.
ToolInteraction
The events a user click on a tool produces, decided by the shared rules so every lane reports the same interaction.
ToolbarError
A model rule violation, surfaced by the Ui setters as GuiError::Backend with this message.
ToolbarItem
One row of a toolbar.
ToolbarOrientation
Toolbar stacking orientation.

Functions§

apply_tool_update
Applies a partial ToolUpdate to one tool.
click_tool
Applies a user click to the toolbar model.
find_tool
Finds a tool by id.
find_tool_mut
Mutable lookup by id.
set_tool_state
Applies a programmatic checked-state change.
validate_toolbar_items
Validates a toolbar item list.