pub struct Annotation<'a, R: RoleKind = AnyRole> { /* private fields */ }Expand description
What an annotation says about a node: its role, name, states and relations.
The role is part of the type, starting at AnyRole. Annotation::role moves it to a
concrete role once, and the setters for capability states compile only for roles with that
capability, so .checked(..) on a button is a type error.
Apps build these through semantic. Widget authors who write their own
operate build one with Annotation::new and send it with report.
With the semantics feature off it holds nothing and every method does nothing.
Implementations§
Source§impl<'a, R: RoleKind> Annotation<'a, R>
impl<'a, R: RoleKind> Annotation<'a, R>
Sourcepub fn role<R2: RoleType>(self, role: R2) -> Annotation<'a, R2>where
R: Untyped,
pub fn role<R2: RoleType>(self, role: R2) -> Annotation<'a, R2>where
R: Untyped,
Gives the node a role. Only once: a second call does not compile.
Sourcepub fn to_static(&self) -> Annotation<'static, AnyRole>
pub fn to_static(&self) -> Annotation<'static, AnyRole>
The same annotation with its strings owned and its role type erased, which is what
report sends.
Sourcepub fn text_geometry(
self,
carets: impl IntoIterator<Item = (usize, Point)>,
) -> Self
pub fn text_geometry( self, carets: impl IntoIterator<Item = (usize, Point)>, ) -> Self
The caret position of each byte offset, for widgets that draw editable or selectable text. Sorted by offset when recorded.
Sourcepub fn cursor_seen(self, seen: impl Into<Option<CursorSeen>>) -> Self
pub fn cursor_seen(self, seen: impl Into<Option<CursorSeen>>) -> Self
The kind of cursor the widget was handed for its last mouse event this frame.
Source§impl<'a, R: RoleKind> Annotation<'a, R>
impl<'a, R: RoleKind> Annotation<'a, R>
Sourcepub fn name(self, name: impl IntoFragment<'a>) -> Self
pub fn name(self, name: impl IntoFragment<'a>) -> Self
The accessible name.
Sourcepub fn description(self, text: impl IntoFragment<'a>) -> Self
pub fn description(self, text: impl IntoFragment<'a>) -> Self
A longer description.
Sourcepub fn tooltip(self, text: impl IntoFragment<'a>) -> Self
pub fn tooltip(self, text: impl IntoFragment<'a>) -> Self
The tooltip text, which names an otherwise unnamed node.
Sourcepub fn test_id(self, id: impl IntoTestId<'a>) -> Self
pub fn test_id(self, id: impl IntoTestId<'a>) -> Self
A test id, typed through TestId or a string built at run time.
Sourcepub fn kind(self, kind: &'static str) -> Self
pub fn kind(self, kind: &'static str) -> Self
What reported the node, for of_type and the inspector. "app" when unset.
Sourcepub fn component(self, kind: &'static str) -> Self
pub fn component(self, kind: &'static str) -> Self
Marks the annotation as a component library’s, such as "iced_cube::tree". App
annotations at the same bounds take precedence over it.
Sourcepub fn prop(self, key: &'static str, value: impl IntoFragment<'a>) -> Self
pub fn prop(self, key: &'static str, value: impl IntoFragment<'a>) -> Self
A free-form property, such as a tab’s unsaved.
Sourcepub fn click_clock(self, clock: ClickClock) -> Self
pub fn click_clock(self, clock: ClickClock) -> Self
Which clock counts multiple clicks.
Sourcepub fn caret_clock(self, clock: CaretClock) -> Self
pub fn caret_clock(self, clock: CaretClock) -> Self
Which clock blinks the caret.
Sourcepub fn current(self, on: bool) -> Self
pub fn current(self, on: bool) -> Self
The current item in a set, such as the open page in a sidebar.
The node is not shown, such as a hover-only control while the pointer is elsewhere.
Sourcepub fn position(self, index: u32, of: u32) -> Self
pub fn position(self, index: u32, of: u32) -> Self
The position in its set, counted from 1, and the size of the set.
Sourcepub fn labelled_by(self, key: impl Into<Key>) -> Self
pub fn labelled_by(self, key: impl Into<Key>) -> Self
The node whose name labels this one.
Sourcepub fn described_by(self, key: impl Into<Key>) -> Self
pub fn described_by(self, key: impl Into<Key>) -> Self
The node whose text describes this one.
Sourcepub fn controls(self, key: impl Into<Key>) -> Self
pub fn controls(self, key: impl Into<Key>) -> Self
The node this one controls, such as the panel a disclosure button opens.
Sourcepub fn owns(self, key: impl Into<Key>) -> Self
pub fn owns(self, key: impl Into<Key>) -> Self
A node that is this one’s logical child although it lives elsewhere, such as an overlay panel.
Sourcepub fn checked(self, state: impl Into<Checked>) -> Selfwhere
R: Checkable,
pub fn checked(self, state: impl Into<Checked>) -> Selfwhere
R: Checkable,
Checked, unchecked or mixed.
Sourcepub fn expanded(self, on: bool) -> Selfwhere
R: Expandable,
pub fn expanded(self, on: bool) -> Selfwhere
R: Expandable,
Whether the node’s content or popup is shown.
Sourcepub fn selected(self, on: bool) -> Selfwhere
R: SelectableItem,
pub fn selected(self, on: bool) -> Selfwhere
R: SelectableItem,
Whether the item is selected in its container.
Sourcepub fn level(self, level: u16) -> Selfwhere
R: Leveled,
pub fn level(self, level: u16) -> Selfwhere
R: Leveled,
The nesting level, from 1. A 0 is reported as a tree warning.
Sourcepub fn value(self, text: impl IntoFragment<'a>) -> Selfwhere
R: HasValue,
pub fn value(self, text: impl IntoFragment<'a>) -> Selfwhere
R: HasValue,
The value as text.
Sourcepub fn range(self, now: f64, range: RangeInclusive<f64>) -> Selfwhere
R: RangeValue,
pub fn range(self, now: f64, range: RangeInclusive<f64>) -> Selfwhere
R: RangeValue,
A numeric value within a range.
Sourcepub fn step(self, step: f64) -> Selfwhere
R: RangeValue,
pub fn step(self, step: f64) -> Selfwhere
R: RangeValue,
The distance between neighbouring values of the range, such as 1 for a slider over
whole steps. With it, set_value moves a focusable slider with the keyboard and lands
exactly on the value however its steps are placed along the track.
Sourcepub fn placeholder(self, text: impl IntoFragment<'a>) -> Selfwhere
R: Editable,
pub fn placeholder(self, text: impl IntoFragment<'a>) -> Selfwhere
R: Editable,
The placeholder shown while the value is empty.