Segmented
segmented · Elements · interactive
A row of two to five choices, all of them on screen at once.
Import
cpp
#include "gbui/widgets/segmented.hpp"Example
cpp
std::optional<std::size_t> segmented(Ui& ui, const Interaction& input, std::string_view id, const std::vector<Segment>& segments, std::size_t selected, const SegmentedOptions& options = {});A row of segments, one of them chosen. Returns the index pressed this frame, or nothing. The value is the caller's, like every other control here. The keyboard is ARIA's radio group, which is one Tab stop and not one per segment: Tab reaches the row, the arrows move and choose — because a radio group with a highlight separate from its value is a control where the reader has to press twice — and Home and End go to the ends.
API
SegmentedOptions
| Option | Type | Default | What it does |
|---|---|---|---|
name | std::string_view | What the whole row is for — "Diff layout", "Range". A group of choices with no name is a set of buttons a reader has to guess the subject of. | |
disabled | bool | false | |
stretch | bool | false | Each segment takes an equal share of the width. Off sizes each to its own label, which is what a strip inside a toolbar wants. |
height | float | 0.0f | Zero takes the active design's control height, less two pixels for the track it sits in — so a strip lines up with the controls beside it. |
size | float | 12.0f |