pub struct ToolSpec {
pub id: ToolId,
pub label: String,
pub accessible_label: Option<String>,
pub tooltip: Option<String>,
pub icon: Option<IconRole>,
pub display: ToolDisplay,
pub enabled: bool,
pub visible: bool,
pub checkable: bool,
pub checked: bool,
pub radio_group: Option<ToolId>,
pub dropdown: bool,
}Expand description
One toolbar tool.
Fields§
§id: ToolIdStable application-facing id.
label: StringVisible label (also the accessible name unless overridden by
ToolSpec::accessible_label).
accessible_label: Option<String>Optional accessible name for assistive technology, for tools whose visible
label is absent or not meaningful —
most importantly icon-only tools. ToolSpec::accessible_name
resolves the announcement as this value, else ToolSpec::label,
else a documented tool <id> default, so a tool never announces
nothing.
tooltip: Option<String>Optional tooltip/short help text.
icon: Option<IconRole>Optional stock-art role; the artprov lane resolves it per DPI.
display: ToolDisplayIcon/text presentation preference.
enabled: boolWhether the tool can be activated; disabled tools report as disabled rather than disappearing.
visible: boolWhether the tool is shown. Hidden tools keep their id and state.
checkable: boolWhether the tool carries a checked state (radio member or toggle).
checked: boolCurrent checked state for checkable tools.
radio_group: Option<ToolId>Radio-group owner id: the id of the first tool of the group. Members share the same owner value, and checking one unchecks the rest.
dropdown: boolWhether activating the tool requests its dropdown menu (the app
composes the menu with the existing menu API after ToolDropdown).
Implementations§
Source§impl ToolSpec
impl ToolSpec
Sourcepub fn new(id: ToolId, label: impl Into<String>) -> Self
pub fn new(id: ToolId, label: impl Into<String>) -> Self
Creates an enabled, visible, plain tool with the default display mode.
Sourcepub fn with_tooltip(self, tooltip: impl Into<String>) -> Self
pub fn with_tooltip(self, tooltip: impl Into<String>) -> Self
Sets the tooltip/short help text.
Sourcepub fn with_accessible_label(self, label: impl Into<String>) -> Self
pub fn with_accessible_label(self, label: impl Into<String>) -> Self
Sets the assistive-technology name, overriding ToolSpec::label for
icon-only or abbreviated tools.
Sourcepub fn accessible_name(&self) -> String
pub fn accessible_name(&self) -> String
Resolves the name assistive technology should announce for this tool.
The fallback order is fixed so every lane announces the same string:
ToolSpec::accessible_labelwhen it is set and not blank;- otherwise
ToolSpec::labelwhen it is not blank — the visible text doubles as the accessible name; - otherwise
tool <id>(for exampletool 7), so an icon-only tool with no label still announces something stable and identifiable instead of reaching a screen reader as an unlabelled control.
The result is never empty.
Sourcepub fn with_display(self, display: ToolDisplay) -> Self
pub fn with_display(self, display: ToolDisplay) -> Self
Sets the icon/text presentation preference.
Sourcepub fn with_enabled(self, enabled: bool) -> Self
pub fn with_enabled(self, enabled: bool) -> Self
Sets the enabled state.
Sourcepub fn with_visible(self, visible: bool) -> Self
pub fn with_visible(self, visible: bool) -> Self
Sets the visible state.
Sourcepub fn with_checkable(self) -> Self
pub fn with_checkable(self) -> Self
Makes the tool checkable.
Sourcepub fn with_checked(self, checked: bool) -> Self
pub fn with_checked(self, checked: bool) -> Self
Sets the initial checked state (only meaningful for checkable tools).
Sourcepub fn with_radio_group(self, owner: ToolId) -> Self
pub fn with_radio_group(self, owner: ToolId) -> Self
Joins a radio group; owner is the id of the group’s first member.
Sourcepub fn with_dropdown(self) -> Self
pub fn with_dropdown(self) -> Self
Marks the tool as a dropdown (menu) tool.