|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
State of a radio group: a column of radio buttons of which at most one is selected. More...
#include <headers/guillaume/components/radio_group.hpp>


Public Types | |
| using | ValueChangeHandler = std::function<void(std::size_t)> |
Public Member Functions | |
| RadioGroup (void)=default | |
| Create the state of a group with no option and no selection. | |
| ~RadioGroup (void)=default | |
| Default destructor. | |
| const std::vector< std::string > & | getOptions (void) const noexcept |
| Get the label of each option. | |
| RadioGroup & | setOptions (const std::vector< std::string > &options) |
| Replace the label of each option. | |
| std::optional< std::size_t > | getValue (void) const noexcept |
| Get the selected option. | |
| RadioGroup & | setValue (std::optional< std::size_t > value) |
| Store the selected option. | |
| const std::vector< ecs::Entity::Identifier > & | getButtons (void) const noexcept |
| Get the radio button child of each option. | |
| RadioGroup & | setButtons (const std::vector< ecs::Entity::Identifier > &buttons) |
| Record the radio button child of each option. | |
| const ValueChangeHandler & | getOnValueChange (void) const noexcept |
| Get the callback run when the user changes the selection. | |
| RadioGroup & | setOnValueChange (ValueChangeHandler handler) |
| Set the callback run when the user changes the selection. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
Static Public Attributes | |
| static constexpr float | RowSpacing = 20.0f |
State of a radio group: a column of radio buttons of which at most one is selected.
It holds the label of each option, the index of the selected option, the selection callback and the identifier of the radio button child of each option.
Role in the frame:
setValue() only stores the index. To select an option from code and see it at once, call systems::RadioGroup::select(), which throws std::out_of_range for an index past the options.
Definition at line 58 of file radio_group.hpp.
| using guillaume::components::RadioGroup::ValueChangeHandler = std::function<void(std::size_t)> |
Called with the index of the newly selected option when the user selects another option than the current one.
Definition at line 63 of file radio_group.hpp.
|
noexcept |
Get the radio button child of each option.
Definition at line 58 of file radio_group.cpp.
|
noexcept |
Get the callback run when the user changes the selection.
Definition at line 74 of file radio_group.cpp.
|
noexcept |
Get the label of each option.
Definition at line 29 of file radio_group.cpp.
|
noexcept |
Get the selected option.
Definition at line 43 of file radio_group.cpp.

| RadioGroup & guillaume::components::RadioGroup::setButtons | ( | const std::vector< ecs::Entity::Identifier > & | buttons | ) |
Record the radio button child of each option.
Marks the component changed when the list differs.
| buttons | Their identifiers, in option order. |
Definition at line 63 of file radio_group.cpp.

| RadioGroup & guillaume::components::RadioGroup::setOnValueChange | ( | ValueChangeHandler | handler | ) |
Set the callback run when the user changes the selection.
It is not run when the user presses the option that is already selected, nor for a selection made from code. Does not mark the component changed.
| handler | The callback; it receives the index of the newly selected option. |
Definition at line 79 of file radio_group.cpp.

| RadioGroup & guillaume::components::RadioGroup::setOptions | ( | const std::vector< std::string > & | options | ) |
Replace the label of each option.
Marks the component changed when the list differs. The widget class creates one radio button child per label.
| options | The labels, top to bottom. |
Definition at line 34 of file radio_group.cpp.

| RadioGroup & guillaume::components::RadioGroup::setValue | ( | std::optional< std::size_t > | value | ) |
Store the selected option.
Marks the component changed when the value differs. The index is not checked here, and the selection callback is not run.
| value | The index of the option, or std::nullopt to select nothing. |
Definition at line 48 of file radio_group.cpp.


|
staticconstexpr |
Vertical space between 20 dp rings so their 40 dp targets do not overlap, in dp.
Definition at line 67 of file radio_group.hpp.