Skip to main content

apply_hover_tint

Function apply_hover_tint 

Source
pub fn apply_hover_tint(
    commands: Commands<'_, '_>,
    tick: Res<'_, Tick>,
    anim: Res<'_, AnimationsActive>,
    active: Query<'_, '_, (Entity, &Interaction, &mut Visuals, &mut StyleOverrides, Option<&mut HoverTween>, Option<&TransitionSpecs>), Or<(With<Hovered>, With<Focused>)>>,
    idle: Query<'_, '_, (Entity, &mut Visuals, &mut StyleOverrides, &Interaction, &mut HoverTween, Option<&TransitionSpecs>), (Without<Hovered>, Without<Focused>)>,
    orphaned: Query<'_, '_, (Entity, &mut Visuals, &mut StyleOverrides), (With<HoverTween>, Without<Interaction>)>,
)
Expand description

Drive HoverTween’s progress toward target, then blend the solid Visuals::fill from what is under the tint toward Interaction::hover_tint.

The blended fill is held in StyleOverrides at the hover layer, so a restyle meanwhile keeps it, and the colour it blends from is whatever is under that layer now: the resting fill, or a toggle’s checked track, as they stand this frame. A class that changes the resting bg while the pointer is over the element is what the tint fades back to.

Idle entities (no Hovered/Focused) target 0; active ones target 1. Once an idle entity finishes draining (progress = 0), the tween is removed and the fill let go, to keep archetype churn bounded.