Skip to main content

sync_switch_visuals

Function sync_switch_visuals 

Source
pub fn sync_switch_visuals(
    commands: Commands<'_, '_>,
    parents: Query<'_, '_, (&Toggleable, &Transform, Option<&KnobGeometry>, Option<&TransitionSpecs>)>,
    thumbs: Query<'_, '_, (Entity, &ChildOf, &mut SwitchThumb, &mut Style, &mut Visuals, Option<&SwitchThumbSlide>), (With<SwitchThumb>, Without<Toggleable>)>,
)
Expand description

Place the SwitchThumb child: size + corner radius from the laid-out track height, and the horizontal inset toward the checked/unchecked end. The first placement snaps; a subsequent checked flip starts a SwitchThumbSlide from the thumb’s current position so it glides.

The track fill belongs to crate::controls::sync_track_fill, which serves <toggle> and <switch> alike.