Skip to main content

sync_tab_button_visuals

Function sync_tab_button_visuals 

Source
pub fn sync_tab_button_visuals(
    buttons: Query<'_, '_, (&TabButtonStyle, Option<&Selected>, &mut Visuals, &mut StyleOverrides), With<TabStripButton>>,
)
Expand description

Keep a tab-strip button’s visuals in step with whether it currently carries Selected: swap Visuals::fill between TabButtonStyle::selected_bg / TabButtonStyle::unselected_bg. The fill is held in StyleOverrides under the hover and press tints, so a tint releases onto the current state colour rather than a stale one - mirrors crate::controls::sync_track_fill.

Runs every tick rather than gating on a change filter: unlike Toggleable::checked (a bool that only ever changes via an explicit flip), Selected is a marker that’s inserted and removed as it moves between siblings, and there’s no single component whose Changed filter would fire on both transitions. The write-if-target- differs guard below keeps idle frames from dirtying Visuals (and therefore triggering a repaint) even though the query has no filter - same technique sync_slider_thumb and the crate::controls::sync_toggle_visuals knob pass use.