Skip to main content

Status

Struct Status 

Source
pub struct Status {
Show 18 fields pub interaction: Interaction, pub focused: bool, pub cursor: Option<usize>, pub selection: Option<(usize, usize)>, pub composing: Option<(usize, usize)>, pub handles: bool, pub caret_hidden: bool, pub drag_over: bool, pub hover_progress: f32, pub focus_progress: f32, pub press_progress: f32, pub opacity: f32, pub value: f32, pub time: f32, pub anim_color: Option<Color>, pub anim_radius: Option<BorderRadius>, pub scroll_y: f32, pub hover_cursor: Option<Point>,
}
Expand description

A widget’s complete status for one frame: pointer interaction, focus, caret and selection (for fields), animation progress and opacity.

Fields§

§interaction: Interaction

Whether the pointer is over the widget or pressing it.

§focused: bool

Whether the widget holds the keyboard focus.

§cursor: Option<usize>

The caret’s (character) index, if this widget is a focused field.

§selection: Option<(usize, usize)>

The selected (start, end) range, in character indices.

§composing: Option<(usize, usize)>

The (start, end) range being composed by the IME (provisional, underlined text); None outside composition. In character indices.

§handles: bool

Does the selection carry handles? A selection made with a finger does — a long press on a word — and one made with a mouse or the keyboard does not. Set by the shell, and only for the focused field.

§caret_hidden: bool

Is the caret in the hidden half of its blink? Set by the shell, and only for the focused field; a field paints no caret while it is.

§drag_over: bool

Is a drag currently over this widget, and would it be accepted? Only ever true for a crate::DragTarget; it is what lets one paint the “drop it here” state itself rather than have the shell paint it from outside.

§hover_progress: f32

The hover transition’s progress (0.0..=1.0).

§focus_progress: f32

The focus transition’s progress (0.0..=1.0).

§press_progress: f32

The press transition’s progress (0.0..=1.0): the animated form of Interaction::Pressed, as hover_progress is the animated form of Interaction::Hovered.

A press used to be a flag and nothing else, so every state layer and every held radius in the crate reached full the instant a finger landed and vanished the instant it left. The reference fades its press highlight over 200 ms against the 50 ms it gives hover and focus (ink_well.dart:995) — the press is the slower of the two, which is the opposite of what a flag does.

interaction stays for the decisions that really are discrete — is this the widget being held? — and this is what the paint reads.

§opacity: f32

The opacity to apply (a fade-in); 1.0 = opaque.

§value: f32

The widget’s own animated value (a switch’s 0 → 1, for instance), driven by Widget::anim_target.

§time: f32

The time elapsed (in seconds) since start-up — for continuous, time-driven animations (a CircularProgressIndicator, for instance).

§anim_color: Option<Color>

The interpolated color of an animated background (Container::animated_color) while in transition; None = no animated color, and the widget uses its own.

§anim_radius: Option<BorderRadius>

The interpolated corner radius (Container::animated_radius) while in transition; None = a fixed radius, and the widget uses its own.

§scroll_y: f32

This widget’s retained vertical scroll (in px), for widgets that scroll their own content (a multi-line field); 0 otherwise.

§hover_cursor: Option<Point>

The pointer’s absolute position when it hovers an interactive sub-region of this widget (milestone 208); None otherwise. The widget brings it back to local coordinates through its bounds to highlight the targeted zone (a suffix icon…). Set by the shell from cursor_icon.

Implementations§

Source§

impl Status

Source

pub fn states(&self) -> WidgetStates

The states this widget is in, as a WidgetStateProperty resolves against (widget_state.dart:168).

Three of the eight, because three are all a status honestly knows: hovered, focused and pressed. Selected, Disabled, Error, Dragged and ScrolledUnder are the widget’s own to add with WidgetStates::set — nothing outside a checkbox knows whether it is ticked, and a status that guessed would be wrong for every widget that never selects anything.

It reads the flags, not the fades: a property is a step between values, and where the change should be gradual the widget animates between two resolved values rather than resolving a fraction. See the module note.

Trait Implementations§

Source§

impl Clone for Status

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 Copy for Status

Source§

impl Debug for Status

Source§

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

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

impl Default for Status

Source§

fn default() -> Self

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

impl PartialEq for Status

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 Status

Auto Trait Implementations§

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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
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.