Skip to main content

ToolSpec

Struct ToolSpec 

Source
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: ToolId

Stable application-facing id.

§label: String

Visible 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: ToolDisplay

Icon/text presentation preference.

§enabled: bool

Whether the tool can be activated; disabled tools report as disabled rather than disappearing.

§visible: bool

Whether the tool is shown. Hidden tools keep their id and state.

§checkable: bool

Whether the tool carries a checked state (radio member or toggle).

§checked: bool

Current 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: bool

Whether activating the tool requests its dropdown menu (the app composes the menu with the existing menu API after ToolDropdown).

Implementations§

Source§

impl ToolSpec

Source

pub fn new(id: ToolId, label: impl Into<String>) -> Self

Creates an enabled, visible, plain tool with the default display mode.

Source

pub fn with_tooltip(self, tooltip: impl Into<String>) -> Self

Sets the tooltip/short help text.

Source

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.

Source

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:

  1. ToolSpec::accessible_label when it is set and not blank;
  2. otherwise ToolSpec::label when it is not blank — the visible text doubles as the accessible name;
  3. otherwise tool <id> (for example tool 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.

Source

pub fn with_icon(self, icon: IconRole) -> Self

Sets the stock-art role.

Source

pub fn with_display(self, display: ToolDisplay) -> Self

Sets the icon/text presentation preference.

Source

pub fn with_enabled(self, enabled: bool) -> Self

Sets the enabled state.

Source

pub fn with_visible(self, visible: bool) -> Self

Sets the visible state.

Source

pub fn with_checkable(self) -> Self

Makes the tool checkable.

Source

pub fn with_checked(self, checked: bool) -> Self

Sets the initial checked state (only meaningful for checkable tools).

Source

pub fn with_radio_group(self, owner: ToolId) -> Self

Joins a radio group; owner is the id of the group’s first member.

Source

pub fn with_dropdown(self) -> Self

Marks the tool as a dropdown (menu) tool.

Trait Implementations§

Source§

impl Clone for ToolSpec

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ToolSpec

Source§

impl PartialEq for ToolSpec

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ToolSpec

Auto Trait Implementations§

§

impl Forget for ToolSpec

§

impl Freeze for ToolSpec
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for ToolSpec

§

impl RefUnwindSafe for ToolSpec

§

impl Send for ToolSpec
where RawVecInner: Send,

§

impl Sync for ToolSpec
where RawVecInner: Sync,

§

impl Unpin for ToolSpec
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for ToolSpec

§

impl UnwindSafe for ToolSpec
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.