Expand description
SegmentedControl — a macOS-style segmented picker: one joined track,
several labelled segments, exactly one selected.
The SwiftUI Picker(...).pickerStyle(.segmented) / AppKit
NSSegmentedControl look: a single rounded track whose OUTER corners
are rounded, segments butted together with no gap and 1-px hairline
dividers between them, and the selected segment filled with the
theme’s accent surface. Compared with composing Buttons in a
FlexRow (the with_subtle + with_active_fn recipe), this widget
owns the whole strip, so the corners, dividers and keyboard model
(Left/Right move the selection) are right by construction.
Selection is bound to an Rc<Cell<usize>> the caller owns — the same
bidirectional-cell pattern as RadioGroup::with_selected_cell and
ToggleSwitch::with_state_cell: the cell is read every layout / paint
and written whenever the user picks a segment, so external writes show
up on the next frame without rebuilding the widget.
Each segment label is a real Label child (like RadioGroup) so
glyph rasterization is cached and the inspector tree mirrors the
visible structure; this widget’s paint() only draws the chrome and
retints the labels.
Unit tests live in segmented_tests.rs (pulled in as a child module)
to keep this file under the 800-line cap.
Structs§
- Segmented
Control - A macOS-style segmented control. See the module docs.