Skip to main content

Annotation

Struct Annotation 

Source
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 Annotation<'_, AnyRole>

Source

pub fn new() -> Self

An annotation with nothing set.

Source§

impl<'a, R: RoleKind> Annotation<'a, R>

Source

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.

Source

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.

Source

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.

Source

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>

Source

pub fn name(self, name: impl IntoFragment<'a>) -> Self

The accessible name.

Source

pub fn description(self, text: impl IntoFragment<'a>) -> Self

A longer description.

Source

pub fn tooltip(self, text: impl IntoFragment<'a>) -> Self

The tooltip text, which names an otherwise unnamed node.

Source

pub fn test_id(self, id: impl IntoTestId<'a>) -> Self

A test id, typed through TestId or a string built at run time.

Source

pub fn kind(self, kind: &'static str) -> Self

What reported the node, for of_type and the inspector. "app" when unset.

Source

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.

Source

pub fn prop(self, key: &'static str, value: impl IntoFragment<'a>) -> Self

A free-form property, such as a tab’s unsaved.

Source

pub fn text_size(self, size: impl Into<Pixels>) -> Self

The text size in logical pixels.

Source

pub fn click_clock(self, clock: ClickClock) -> Self

Which clock counts multiple clicks.

Source

pub fn caret_clock(self, clock: CaretClock) -> Self

Which clock blinks the caret.

Source

pub fn disabled(self, on: bool) -> Self

The node takes no input.

Source

pub fn current(self, on: bool) -> Self

The current item in a set, such as the open page in a sidebar.

Source

pub fn busy(self, on: bool) -> Self

The node is loading or updating.

Source

pub fn hidden(self, on: bool) -> Self

The node is not shown, such as a hover-only control while the pointer is elsewhere.

Source

pub fn modal(self, on: bool) -> Self

Everything outside the node is inert while it is shown.

Source

pub fn required(self, on: bool) -> Self

A form control must be filled in.

Source

pub fn invalid(self, on: bool) -> Self

A form control’s value is rejected.

Source

pub fn readonly(self, on: bool) -> Self

The node shows a value that cannot be changed.

Source

pub fn position(self, index: u32, of: u32) -> Self

The position in its set, counted from 1, and the size of the set.

Source

pub fn key(self, key: impl Into<Key>) -> Self

The key other annotations use to name this one.

Source

pub fn labelled_by(self, key: impl Into<Key>) -> Self

The node whose name labels this one.

Source

pub fn label_for(self, key: impl Into<Key>) -> Self

The node this one labels.

Source

pub fn described_by(self, key: impl Into<Key>) -> Self

The node whose text describes this one.

Source

pub fn controls(self, key: impl Into<Key>) -> Self

The node this one controls, such as the panel a disclosure button opens.

Source

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.

Source

pub fn checked(self, state: impl Into<Checked>) -> Self
where R: Checkable,

Checked, unchecked or mixed.

Source

pub fn pressed(self, on: bool) -> Self
where R: Pressable,

Whether a toggle button is pressed.

Source

pub fn expanded(self, on: bool) -> Self
where R: Expandable,

Whether the node’s content or popup is shown.

Source

pub fn selected(self, on: bool) -> Self
where R: SelectableItem,

Whether the item is selected in its container.

Source

pub fn level(self, level: u16) -> Self
where R: Leveled,

The nesting level, from 1. A 0 is reported as a tree warning.

Source

pub fn value(self, text: impl IntoFragment<'a>) -> Self
where R: HasValue,

The value as text.

Source

pub fn range(self, now: f64, range: RangeInclusive<f64>) -> Self
where R: RangeValue,

A numeric value within a range.

Source

pub fn step(self, step: f64) -> Self
where 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.

Source

pub fn placeholder(self, text: impl IntoFragment<'a>) -> Self
where R: Editable,

The placeholder shown while the value is empty.

Source

pub fn multiline(self, on: bool) -> Self
where R: Editable,

Whether the text box takes more than one line.

Trait Implementations§

Source§

impl<R: RoleKind> Clone for Annotation<'_, R>

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<R: RoleKind> Debug for Annotation<'_, R>

Source§

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

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

impl Default for Annotation<'_, AnyRole>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, R> Forget for Annotation<'a, R>

§

impl<'a, R> Freeze for Annotation<'a, R>
where PhantomData<(fn() -> R, &'a ())>: Freeze,

§

impl<'a, R> Move for Annotation<'a, R>

§

impl<'a, R> RefUnwindSafe for Annotation<'a, R>

§

impl<'a, R> Send for Annotation<'a, R>
where &'a (): Send,

§

impl<'a, R> Sync for Annotation<'a, R>

§

impl<'a, R> Unpin for Annotation<'a, R>
where &'a (): Unpin,

§

impl<'a, R> UnsafeUnpin for Annotation<'a, R>
where PhantomData<(fn() -> R, &'a ())>: UnsafeUnpin,

§

impl<'a, R> UnwindSafe for Annotation<'a, R>
where &'a (): 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.