|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Configuration of a radio button: its variant, its label and the identifiers of its dot and label children. More...
#include <headers/guillaume/components/radio_button.hpp>


Public Types | |
| enum class | Variant { Enabled , Disabled , Error } |
| Visual variant. More... | |
| using | PressHandler = std::function<void(void)> |
| Called when the user selects the radio. | |
Public Member Functions | |
| RadioButton (void)=default | |
| Create the configuration of an enabled radio with no label. | |
| ~RadioButton (void)=default | |
| Default destructor. | |
| Variant | getVariant (void) const noexcept |
| Get the visual variant. | |
| RadioButton & | setVariant (Variant variant) |
| Choose the visual variant. | |
| const std::string & | getLabel (void) const noexcept |
| Get the label text. | |
| RadioButton & | setLabel (const std::string &label) |
| Set the label text. | |
| ecs::Entity::Identifier | getDot (void) const noexcept |
| Get the child entity drawn as the inner dot. | |
| RadioButton & | setDot (ecs::Entity::Identifier identifier) |
| Record which child entity is the inner dot. | |
| ecs::Entity::Identifier | getLabelEntity (void) const noexcept |
| Get the child entity that draws the label. | |
| RadioButton & | setLabelEntity (ecs::Entity::Identifier identifier) |
| Record which child entity draws the label. | |
| const PressHandler & | getOnPress (void) const noexcept |
| Get the callback run when the user selects the radio. | |
| RadioButton & | setOnPress (PressHandler handler) |
| Set the callback run when the user selects the radio. | |
| 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 | DotSize = 10.0f |
| Diameter of the selected dot, in dp. | |
| static constexpr float | TouchTarget = 40.0f |
| Edge of the square touch target centered on the ring, in dp. | |
| static constexpr float | LabelGap = 4.0f |
| Gap between the touch target and the label, in dp. | |
Configuration of a radio button: its variant, its label and the identifiers of its dot and label children.
Whether the radio is selected is not stored here but in the components::Selectable of the same entity.
Role in the frame:
To select a radio from code call systems::RadioButton::select(); a user press goes through systems::RadioButton::press(), which also runs the press callback.
Definition at line 55 of file radio_button.hpp.
| using guillaume::components::RadioButton::PressHandler = std::function<void(void)> |
Called when the user selects the radio.
Definition at line 68 of file radio_button.hpp.
|
strong |
Visual variant.
Enabled is the regular look. Disabled greys the radio and makes it ignore presses. Error draws the ring, the dot and the label in the error color.
Definition at line 65 of file radio_button.hpp.
|
noexcept |
Get the child entity drawn as the inner dot.
Definition at line 57 of file radio_button.cpp.
|
noexcept |
Get the label text.
Definition at line 43 of file radio_button.cpp.
|
noexcept |
Get the child entity that draws the label.
Definition at line 71 of file radio_button.cpp.
|
noexcept |
Get the callback run when the user selects the radio.
Definition at line 86 of file radio_button.cpp.
|
noexcept |
Get the visual variant.
Definition at line 29 of file radio_button.cpp.

| RadioButton & guillaume::components::RadioButton::setDot | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity is the inner dot.
Marks the component changed when the identifier differs. The system centers the dot in the ring and makes it transparent while the radio is not selected.
| identifier | The dot child. |
Definition at line 62 of file radio_button.cpp.

| RadioButton & guillaume::components::RadioButton::setLabel | ( | const std::string & | label | ) |
Set the label text.
Marks the component changed when the text differs. The system copies it to the radio's Accessibility label; the text drawn on screen is the one of the label child.
| label | The label text. |
Definition at line 48 of file radio_button.cpp.


| RadioButton & guillaume::components::RadioButton::setLabelEntity | ( | ecs::Entity::Identifier | identifier | ) |
Record which child entity draws the label.
Marks the component changed when the identifier differs.
| identifier | The label child. |
Definition at line 76 of file radio_button.cpp.

| RadioButton & guillaume::components::RadioButton::setOnPress | ( | PressHandler | handler | ) |
Set the callback run when the user selects the radio.
It runs on every press of an enabled radio, after the selection was set, and not for a selection made from code. A radio inside a radio group has this callback replaced by the group's. Does not mark the component changed.
| handler | The callback, or an empty one to remove it. |
Definition at line 91 of file radio_button.cpp.

| RadioButton & guillaume::components::RadioButton::setVariant | ( | Variant | variant | ) |
Choose the visual variant.
Marks the component changed when the variant differs. The system enables or disables the entity's interaction to match.
| variant | Enabled, Disabled or Error. |
Definition at line 34 of file radio_button.cpp.

|
staticconstexpr |
Diameter of the selected dot, in dp.
Definition at line 71 of file radio_button.hpp.
|
staticconstexpr |
Gap between the touch target and the label, in dp.
Definition at line 77 of file radio_button.hpp.
|
staticconstexpr |
Edge of the square touch target centered on the ring, in dp.
Definition at line 74 of file radio_button.hpp.