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
ToggleGroupor aSegmentedFace. - Segmented
Face - 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::heightandSegmentedFace::intrinsic_width, and split it withSegmentedFace::partition_segments. - Segmented
Touch - 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.
- Segmented
Touch Group - One painted segmented strip, identified independently of its position.
Keep
idstable while the strip remains mounted. - Toggle
Group
Enums§
- Segmented
Style - What a segmented strip is. The style never chooses a colour: the chosen segment is always a lift with primary ink.
- Segmented
Touch Result - The input owner applies a selection through its existing admitted action.
Constants§
- NONE_
CHOSEN - No segment chosen: what
ToggleGroup::selectedandSegmentedFace::newuse for “none” (ToggleGroup::selectionsays it asNone).
Functions§
- segment_
colors (fill, label)of one segment;fill == Nonemeans nothing is painted under it. On aSegmentedStyle::Segmentedtrack the fill is the thumb.