#[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);