Expand description
Interaction-state paint primitives: hover, press, focus ring - all
folded into a single Interaction fat component.
Interaction.hover_tint blends the Visuals solid fill toward a
tint while the entity is Hovered or Focused. press_tint
overrides that blend when the entity is Pressed - pressed >
hovered/focused > idle. focus_outline paints a stroked ring around
the entity while it has Focused. Gradient fills are skipped by
the tween (no animation path); the gradient renders unchanged.
Tween state (HoverTween, PressTween) stays in separate transient
components - they’re auto-attached / cleared by the systems below, never
authored. The tinted fill and the swapped border are held in
StyleOverrides while they show, so a restyle meanwhile keeps them and
they let go onto whatever the element’s styles say by then.
Structs§
- Focus
Outline Spec - Stored on
Interaction::focus_outline. Was a free-standingFocusOutlinecomponent before the alpha2 collapse. - Hover
Tint Plugin - Plugin: registers
apply_hover_tintthenapply_press_tintinTickStage::Systems. Press runs second so it can stamp over whatever hover wrote on the same tick. - Hover
Tween - Per-entity timer driving the hover tween.
progressruns 0 -> 1 toward the hover tint while hovered/focused, and 1 -> 0 toward what is under the tint when both interaction markers are gone. Idempotent across frames so the system can simply stepprogressby delta-time. - Interaction
- Author-set interaction-state paint: hover tint + press tint + focus
outline, all on one component. Each field is
Option-shaped so markup can opt into any subset. Absent component = no hover / press / focus visual feedback. - Press
Tween - Per-entity press tween (mirror of
HoverTweenfor the press state). - State
Border Held - Marks an element whose
Visuals::borderapply_state_bordersholds, and names its layer inStyleOverrides.
Constants§
- HOVER_
TWEEN_ DURATION - How long it takes for the hover-tint to fully blend in or out, in seconds. Picked to feel responsive but not jittery - comparable to a macOS button highlight, faster than a Material ripple.
- PRESS_
TWEEN_ DURATION - Press tween duration - faster than hover, matches the snappy “click pulse” of native buttons.
Functions§
- apply_
hover_ tint - Drive
HoverTween’s progress towardtarget, then blend the solidVisuals::fillfrom what is under the tint towardInteraction::hover_tint. - apply_
press_ tint - Override the solid
Visuals::fillwithInteraction::press_tintwhile the entity is visually pressed. Tweens overPRESS_TWEEN_DURATIONusing ease-out. - apply_
state_ borders - Swap
Visuals::borderper interaction state: focused ->Interaction::focus_border, hovered ->Interaction::hover_border, idle -> whatever the element’s styles give it then. Focus wins over hover when both are active. Borders snap (no tween), matching CSS:hover/:focusborder rules without atransition. - extract_
focus_ outlines - Extract: for every focused entity whose
Interactiondeclares a focus outline, spawn anExtractedOutlinein the render world that draws on top of the matching rect.