Skip to main content

Module toggle_group

Module toggle_group 

Expand description

ToggleGroup — the segmented control. A strip of segments of which one is chosen (or, before the person has chosen, none). Clicking a segment chooses it and fires the on_change callback with the new index.

State lives on the widget unless it is bound: ToggleGroup::bind_selection keeps a crate::LocalState and the strip in step both ways, and on_change / on_action report the person’s choices.

The chosen segment is a lift (HIG §9.3): a thumb one surface step off the track, set concentrically inside it, with primary ink and no hue.

ToggleGroup::multiple is the multi-select form (the weekdays an alarm repeats on): every segment is its own toggle, each as wide as its label, wrapping onto further rows when the strip runs out of room.

Page tabs (SegmentedStyle::Tabs) start flush: the first label and its underline sit on the strip’s leading edge, each tab as wide as its label, and a strip longer than its room scrolls sideways instead of eliding.

ToggleGroup::from_state binds the choice to typed view state instead of a callback. ToggleGroup::vertical stacks icon segments into a tool rail: each segment shows its icon, and its label (with the Segment::with_hint shortcut) is its tooltip; the label is its accessible name.

Structs§

Segment
One choice of a ToggleGroup or a SegmentedFace.
SegmentedFace
An immediate-mode segmented strip over caller-owned segment rects (the rects must be contiguous, except a multi-select strip’s). The caller owns the hit-test; this paints the themed look over them. Size the strip with SegmentedFace::height and SegmentedFace::intrinsic_width, and split it with SegmentedFace::partition_segments.
SegmentedTouch
The retained control and painted strips share one touch recognizer. Only a completed single-finger gesture chooses; cancellation, a second finger, a removed strip or an externally changed selection refuses it.
SegmentedTouchGroup
One painted segmented strip, identified independently of its position. Keep id stable while the strip remains mounted.
ToggleGroup

Enums§

SegmentedStyle
What a segmented strip is. The style never chooses a colour: the chosen segment is always a lift with primary ink.
SegmentedTouchResult
The input owner applies a selection through its existing admitted action.

Constants§

NONE_CHOSEN
No segment chosen: what ToggleGroup::selected and SegmentedFace::new use for “none” (ToggleGroup::selection says it as None).

Functions§

segment_colors
(fill, label) of one segment; fill == None means nothing is painted under it. On a SegmentedStyle::Segmented track the fill is the thumb.