#[non_exhaustive]pub enum WidgetState {
Disabled,
Pressed,
Focused,
Hovered,
Idle,
}Expand description
The single resolved state of an interactive widget, derived from a Response’s
independent flags into one precedence order.
Precedence: Disabled, then Pressed, then
Focused, then Hovered, then Idle.
Theme’s *_for methods all derive this once via of rather than each
re-deriving their own precedence chain from Response’s flags, which is how bg_for/
fg_for and style_for used to disagree on whether disabled mattered at all.
#[non_exhaustive]: widget state may grow further variants (e.g. a Selected state) without
that being a breaking change for callers who already match with a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Disabled
Response::disabled is true, regardless of any other flag.
Pressed
Response::pressed is true and the widget isn’t disabled.
Focused
Response::focused is true and the widget is neither disabled nor pressed.
Hovered
Response::hovered is true and the widget is neither disabled, pressed, nor focused.
Idle
None of the above: the widget’s resting state.
Implementations§
Source§impl WidgetState
impl WidgetState
Sourcepub const fn of<Id>(response: &Response<Id>) -> Self
pub const fn of<Id>(response: &Response<Id>) -> Self
Derives the single resolved state from response’s independent flags.
§Examples
use retroglyph_ui::theme::WidgetState;
use retroglyph_ui::interact::Interaction;
use retroglyph_core::grid::Rect;
let mut interaction = Interaction::<u32>::default();
let response = interaction.interact(Rect::new(0, 0, 1, 1), 1, Default::default());
assert_eq!(WidgetState::of(&response), WidgetState::Idle);Trait Implementations§
Source§impl Clone for WidgetState
impl Clone for WidgetState
Source§fn clone(&self) -> WidgetState
fn clone(&self) -> WidgetState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WidgetState
Source§impl Debug for WidgetState
impl Debug for WidgetState
impl Eq for WidgetState
Source§impl PartialEq for WidgetState
impl PartialEq for WidgetState
Source§fn eq(&self, other: &WidgetState) -> bool
fn eq(&self, other: &WidgetState) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for WidgetState
Auto Trait Implementations§
impl Freeze for WidgetState
impl RefUnwindSafe for WidgetState
impl Send for WidgetState
impl Sync for WidgetState
impl Unpin for WidgetState
impl UnsafeUnpin for WidgetState
impl UnwindSafe for WidgetState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).