Skip to content

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

Nothing is downloaded until you press it.

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

OptionTypeDefaultWhat it does
namestd::string_viewWhat 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.
disabledboolfalse
stretchboolfalseEach segment takes an equal share of the width. Off sizes each to its own label, which is what a strip inside a toolbar wants.
heightfloat0.0fZero 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.
sizefloat12.0f

Released under the LGPL-3.0-or-later licence.