pub struct StateStyle<T> {
pub normal: T,
pub hovered: Option<T>,
pub pressed: Option<T>,
pub focused: Option<T>,
pub disabled: Option<T>,
}Expand description
Style map keyed by interaction state (hover, press, focus, disabled).
§Examples
use ailloli_ui_core::style::{InteractionState, StateStyle};
let styles = StateStyle { normal: 0, hovered: Some(1), pressed: None, focused: None, disabled: None };
assert_eq!(styles.resolve(InteractionState { hovered: true, ..InteractionState::default() }), 1);Fields§
§normal: TRequired fallback style when no applicable override exists.
hovered: Option<T>Optional hover override.
pressed: Option<T>Optional active-press override.
focused: Option<T>Optional keyboard-focus override.
disabled: Option<T>Optional disabled override.
Implementations§
Source§impl<T: Clone> StateStyle<T>
impl<T: Clone> StateStyle<T>
Sourcepub fn resolve(&self, state: InteractionState) -> T
pub fn resolve(&self, state: InteractionState) -> T
Clones the highest-priority available override for state.
Precedence is disabled, pressed, hovered, focused, then normal. A true
flag with a None override falls through to the next true flag rather
than immediately selecting normal.
§Examples
use ailloli_ui_core::style::{InteractionState, StateStyle};
let styles = StateStyle { normal: "normal", hovered: Some("hover"), pressed: Some("press"), focused: None, disabled: None };
let state = InteractionState { hovered: true, pressed: true, ..InteractionState::default() };
assert_eq!(styles.resolve(state), "press");Trait Implementations§
Source§impl<T: Clone> Clone for StateStyle<T>
impl<T: Clone> Clone for StateStyle<T>
Source§fn clone(&self) -> StateStyle<T>
fn clone(&self) -> StateStyle<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for StateStyle<T>
impl<T: Debug> Debug for StateStyle<T>
Source§impl<T: PartialEq> PartialEq for StateStyle<T>
impl<T: PartialEq> PartialEq for StateStyle<T>
impl<T> StructuralPartialEq for StateStyle<T>
Auto Trait Implementations§
impl<T> Freeze for StateStyle<T>where
T: Freeze,
impl<T> RefUnwindSafe for StateStyle<T>where
T: RefUnwindSafe,
impl<T> Send for StateStyle<T>where
T: Send,
impl<T> Sync for StateStyle<T>where
T: Sync,
impl<T> Unpin for StateStyle<T>where
T: Unpin,
impl<T> UnwindSafe for StateStyle<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more