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 on_change 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 its own toggle, as wide as its label, wrapping onto further rows. Page tabs (SegmentedStyle::Tabs) start flush — each tab as wide as its label and padding, the chosen one a selector lift (crate::chrome::paint_selector) like a window’s tabs — and a strip longer than its room scrolls 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 label (with its Segment::with_hint shortcut) its tooltip and its accessible name.

Structs§

Segment
One choice of a ToggleGroup or a SegmentedFace.
SegmentProps
One choice of a ToggleGroup or a ViewTabs: what it says, and how it shows.
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
ToggleGroupProps
A small set of choices, one of which is made: an alignment, a density, a unit. The chosen one is a thumb lifted off the track. What switches what a window shows is ViewTabs.
ViewTabsProps
Tabs that switch what a window’s content shows: a request’s Params, Headers and Body, a container’s Logs and Stats. Assistive technology meets them as a tab list whose chosen tab is selected, not checked.

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.