Skip to main content

Module state_style

Module state_style 

Source
Expand description

State-driven text-color / opacity / box-shadow / background swaps.

The CSS parser routes :hover / :focus / :active / :disabled declarations for text-color, opacity, and box-shadow (plus bg for :disabled) into a StateVisuals component (one StatePatch per state); this module’s apply_state_visuals system swaps the live TextStyle / Opacity / Visuals::shadows / Visuals::fill values as the interaction markers come and go, holding them in StyleOverrides and letting go onto the element’s own styles when every state ends. Swaps snap (no tween), matching CSS state rules without a transition - exactly like the border swap in crate::hover::apply_state_borders.

:disabled reacts to the Disabled marker at runtime (Wave 3: bind-disabled can add / remove it live). Statically disabled markup without a binding takes its :disabled styles as its own computed style (lumen_scene::computed); the patch here drives every dynamic case. eject_interaction_on_disable strips Hovered / Pressed / focus the moment an entity becomes disabled (moving keyboard focus to the next focusable) so no interaction state lingers on a greyed-out widget.

Structs§

StatePatch
One state’s property patch. Only authored fields swap; the rest keep the idle value.
StatePatched
Marks an element whose state patch apply_state_visuals holds, and names its layer in StyleOverrides.
StateStylePlugin
Plugin: registers eject_interaction_on_disable then apply_state_visuals.
StateVisuals
Author-set per-state style patches. Pressed wins over focused wins over hovered on a per-field basis (mirrors the cascade order skins author these rules in); disabled stamps over everything.

Functions§

apply_state_visuals
Swap text color / opacity / shadows / background per interaction state, and let them go when every state ends.
eject_interaction_on_disable
The moment an entity gains Disabled (spec section 0: runtime enable/disable via bind-disabled), strip every live interaction state from it: