Skip to main content

Status

Struct Status 

Source
pub struct Status {
Show 24 fields pub interaction: Interaction, pub focused: bool, pub cursor: Option<usize>, pub selection: Option<(usize, usize)>, pub composing: Option<(usize, usize)>, pub toolbar: Option<bool>, pub handles: bool, pub region: Option<(usize, usize)>, pub region_bar: bool, pub region_grips: (Option<usize>, Option<usize>), 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>, pub value_placed: bool, pub thumb: Option<usize>,
}
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.

§toolbar: Option<bool>

Is the field’s bar (Cut, Copy, Paste, Select all) showing over its selection? Some(can_paste) when it is — with whether the clipboard held text when it opened — and None otherwise. Set by the shell, and only for the focused field.

§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.

§region: Option<(usize, usize)>

The (start, end) range of this text that a SelectionArea’s selection covers, in characters. Kept by the shell, for any text in the area whether or not it has the focus — which is the difference from selection, a field’s own.

§region_bar: bool

Does the selection a selection area holds show its bar? Set for every text the selection covers; the first of them in reading order carries the bar.

§region_grips: (Option<usize>, Option<usize>)

The handles of a selection area’s touch selection that hang from this text: the character where the selection starts, if it starts here, and the boundary where it ends, if it ends here.

§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.

§value_placed: bool

Was value placed by a finger — held by a drag, or settling from where one let go (milestone 638)? A widget that curves its value paints it straight while it is: the thumb under a finger is where the finger is.

§thumb: Option<usize>

Which of this widget’s thumbs the last drag on it took (milestone 651), on a track with two: 0 the start, 1 the end. It stays after the drag ends, as the reference’s last selection does, so that the thumb last moved stays on top and its press fades out on it rather than on its neighbour. Set by the shell.

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) -> Status

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<(), Error>

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

impl Default for Status

Source§

fn default() -> Status

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

impl PartialEq for Status

Source§

fn eq(&self, other: &Status) -> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSend for T
where T: Send,

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more