|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
A circle the user selects to pick one option, with an optional label next to it. More...
#include <headers/guillaume/entities/radio_button.hpp>


Classes | |
| class | Builder |
| Configures, creates and registers RadioButton widgets. More... | |
Public Types | |
| using | Variant = components::RadioButton::Variant |
| Public Types inherited from guillaume::entities::SurfaceBase< components::Selectable, components::Ring, components::RadioButton > | |
| using | Children |
| Public Types inherited from guillaume::ecs::Entity | |
| using | Identifier = std::size_t |
| The key under which an entity's components are stored. Systems and components refer to entities by this value. | |
| using | Signature = std::bitset<128> |
| A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits). | |
Public Member Functions | |
| ~RadioButton (void) override=default | |
| Default destructor. | |
| RadioButton & | setVariant (Variant variant) |
| Set the visual variant. Restyles at once. | |
| Variant | getVariant (void) const |
| Get the visual variant. | |
| RadioButton & | setLabel (const std::string &label) |
| Set the label text and the accessibility label. Restyles at once. | |
| bool | isSelected (void) const |
| Check whether the radio button is selected. | |
| RadioButton & | select (bool selected) |
| Select or deselect the radio button, even when it is disabled. Restyles at once. | |
| bool | isDisabled (void) const |
| Check whether the radio button ignores input. | |
| RadioButton & | setOnPress (std::function< void(void)> onPress) |
| Set the handler called when the user presses the radio button (Paper onPress). | |
| Public Member Functions inherited from guillaume::entities::SurfaceBase< components::Selectable, components::Ring, components::RadioButton > | |
| ~SurfaceBase (void) override=default | |
| Default destructor. | |
| SurfaceBase & | setPose (const utility::graphic::PoseF &pose) |
| Move the surface. | |
| SurfaceBase & | setColor (const utility::graphic::Color32Bit &color) |
| Set the fill color (Color component). | |
| SurfaceBase & | setBorderRadius (float radius) |
| Set the radius of the four corners (Borders component). | |
| SurfaceBase & | setSurfaceConfig (const SurfaceConfig &config) |
| Apply every field of a configuration at once. | |
| SurfaceConfig | getSurfaceConfig (void) const |
| Read the current configuration back from the components. | |
| SurfaceBase & | setChildren (const Children &children) |
| Choose the children this surface arranges, in order. | |
| std::vector< ecs::Entity::Identifier > | getChildren (void) const |
| Get the children this surface arranges. | |
| Public Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Layout, components::Transform, components::Bound, components::Color, components::Borders, ExtraComponents... > | |
| ParentEntityFiller (ComponentRegistry &componentRegistry) | |
| Create the entity, its listed components and its components::Hierarchy. It owns no child yet. | |
| virtual | ~ParentEntityFiller (void)=default |
| Destroy the entity object and release the children it owns; components stay in the registry (see EntityRegistry::removeEntity). | |
| Public Member Functions inherited from guillaume::ecs::Entity | |
| Entity (void) | |
| Create an entity with a fresh identifier, an empty signature, no parent and no component. | |
| virtual | ~Entity (void)=default |
| Destroy the entity object. | |
| Entity::Identifier | getIdentifier (void) const noexcept |
| Get the identifier of the entity. | |
| Entity::Signature | getSignature (void) const noexcept |
| Get the set of component types the entity declares. | |
| void | setSignature (const Signature &signature) |
| Replace the signature of the entity. | |
| std::int32_t | getLayer (void) const noexcept |
| Get the depth of the entity in the tree. | |
| Entity & | setParent (std::shared_ptr< Entity > parent) |
| Attach the entity under another one, or detach it. | |
| std::vector< Identifier > | releaseComponents (void) |
| Drop the entity's place in the tree and all its components. | |
| std::shared_ptr< Entity > | getParent (void) const noexcept |
| Get the parent entity. | |
| Public Member Functions inherited from guillaume::ecs::EntityRegistry | |
| EntityRegistry (void)=default | |
| Create a registry. | |
| virtual | ~EntityRegistry (void)=default |
| Virtual destructor. | |
| void | addEntity (std::shared_ptr< Entity > entity) |
| Make this registry own an entity, so that it stays alive and systems visit it. | |
| bool | removeEntity (Entity::Identifier identifier) |
| Remove an entity, with its children and all their components. | |
| void | clearEntities (void) |
| Remove every entity owned by this registry, with everything they own and all their components. | |
| const std::vector< std::shared_ptr< Entity > > & | getEntities (void) const |
| Get the entities this registry owns directly. | |
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) |
| List every entity of this registry and of the registries nested in it, level by level. | |
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) const |
| List every entity of this registry and of the registries nested in it, level by level (const overload). | |
| template<InheritFromEntity EntityType> | |
| std::shared_ptr< EntityType > | getEntity (Entity::Identifier identifier) |
| Find an entity owned directly by this registry, by identifier. | |
| template<InheritFromEntity EntityType> | |
| std::shared_ptr< const EntityType > | getEntity (Entity::Identifier identifier) const |
| Find an entity owned directly by this registry, by identifier (const overload). | |
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature) const |
| List the entities that have every component type of a signature, from the root down. | |
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature, const EntityTreeTraveler &traveler) const |
| List the entities that have every component type of a signature, in the order chosen by a traveler. | |
Static Public Member Functions | |
| template<typename... Arguments> | |
| static std::shared_ptr< RadioButton > | create (Arguments &&...arguments) |
| Create a radio button and its dot and label children, without registering it in an entity registry. | |
| Static Public Member Functions inherited from guillaume::ecs::Entity | |
| template<InheritFromComponent... ComponentTypes> | |
| static Signature | getSignatureFromTypes (void) |
| Build the signature that has exactly the bits of the given component types. | |
Static Public Attributes | |
| static constexpr float | DotSize = components::RadioButton::DotSize |
| Diameter of the dot shown while selected, in dp (M3: 10 dp). | |
| static constexpr float | TouchTarget |
| Side of the square that answers input, centered on the ring, in dp. | |
| static constexpr float | LabelGap = components::RadioButton::LabelGap |
| Gap between the touch target and the label, in dp. | |
| Static Public Attributes inherited from guillaume::ecs::Entity | |
| static constexpr Identifier | InvalidIdentifier |
| "No entity": never the identifier of a real entity | |
Additional Inherited Members | |
| Protected Member Functions inherited from guillaume::entities::SurfaceBase< components::Selectable, components::Ring, components::RadioButton > | |
| SurfaceBase (ecs::ComponentRegistry ®istry, const SurfaceConfig &config) | |
| Create the entity with its components and apply a configuration. | |
| void | applyGeometry (void) |
| Arrange the layout children now with systems::Layout::apply. | |
| Protected Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Layout, components::Transform, components::Bound, components::Color, components::Borders, ExtraComponents... > | |
| ComponentRegistry & | getComponentRegistry (void) |
| Get the registry that stores this entity's components. | |
| Protected Member Functions inherited from guillaume::ecs::ParentEntity | |
| std::vector< std::shared_ptr< Entity > > & | accessDirectEntities (void) override |
| Give access to the list of entities this entity owns directly. | |
| const std::vector< std::shared_ptr< Entity > > & | accessDirectEntities (void) const override |
| Give read access to the list of entities this entity owns directly. | |
| Protected Member Functions inherited from guillaume::ecs::Entity | |
| void | attachHierarchy (ComponentRegistry &componentRegistry) |
| Give the entity a components::Hierarchy in a registry and add that component to its signature. | |
| template<InheritFromComponent... ComponentTypes> | |
| void | setSignature (void) |
| Replace the signature by the one made of the given component types. | |
A circle the user selects to pick one option, with an optional label next to it.
Its state lives in components::RadioButton (variant, label, callback, child identifiers) and its selection in components::Selectable; systems::RadioButton colors the ring (a components::Ring), shows the inner dot while selected and places the label each frame, in the Layout phase. The class itself holds no field: its setters write the components and restyle at once.
RadioButton::create(registry, config, variant, label) builds the same widget without registering it in an entity registry; config is the SurfaceConfig of the ring (pose, size).
A radio button alone does not deselect the others: a press only selects it. Use RadioGroup to keep one option selected among several. The radio button owns its dot and label children: it is the entity registry they are registered in. The label child is built only when the label given at creation is not empty. The ring is 20 dp wide and answers input on a TouchTarget square centered on it. Its Color and enabled state are written each frame from the selection and the variant, so values set by hand on them are overwritten. select() does not call the press handler; only a user press does.
Definition at line 84 of file radio_button.hpp.
Visual variant: Enabled, Disabled (ignores input) or Error (error colors).
Definition at line 91 of file radio_button.hpp.
|
inlinestatic |
Create a radio button and its dot and label children, without registering it in an entity registry.
The constructor is private because the children need a radio button already held by a std::shared_ptr as parent: create() constructs the radio button then calls build(), which creates them.
| Arguments | The types of the constructor arguments. |
| arguments | The arguments forwarded to the constructor: (registry, config, variant, label). |
Definition at line 192 of file radio_button.hpp.

| RadioButton::Variant guillaume::entities::RadioButton::getVariant | ( | void | ) | const |
Get the visual variant.
Definition at line 181 of file radio_button.cpp.


| bool guillaume::entities::RadioButton::isDisabled | ( | void | ) | const |
Check whether the radio button ignores input.
Definition at line 158 of file radio_button.cpp.

| bool guillaume::entities::RadioButton::isSelected | ( | void | ) | const |
Check whether the radio button is selected.
Definition at line 203 of file radio_button.cpp.


| RadioButton & guillaume::entities::RadioButton::select | ( | bool | selected | ) |
Select or deselect the radio button, even when it is disabled. Restyles at once.
The press handler is not called and no other radio button is changed.
| selected | True to select, false to deselect. |
Definition at line 210 of file radio_button.cpp.

| RadioButton & guillaume::entities::RadioButton::setLabel | ( | const std::string & | label | ) |
Set the label text and the accessibility label. Restyles at once.
The text on screen changes only when the radio button was created with a label: no label child is built here.
| label | The new label text. |
Definition at line 188 of file radio_button.cpp.

| RadioButton & guillaume::entities::RadioButton::setOnPress | ( | std::function< void(void)> | onPress | ) |
Set the handler called when the user presses the radio button (Paper onPress).
The press selects the radio button first, then calls the handler, also when the radio button was already selected. A disabled radio button calls nothing.
| onPress | The function to call. Pass an empty function to remove the handler. |
Definition at line 164 of file radio_button.cpp.


| RadioButton & guillaume::entities::RadioButton::setVariant | ( | Variant | variant | ) |
Set the visual variant. Restyles at once.
| variant | Enabled, Disabled (ignores input) or Error (error colors). |
Definition at line 172 of file radio_button.cpp.


|
staticconstexpr |
Diameter of the dot shown while selected, in dp (M3: 10 dp).
Definition at line 271 of file radio_button.hpp.
|
staticconstexpr |
Gap between the touch target and the label, in dp.
Definition at line 283 of file radio_button.hpp.
|
staticconstexpr |
Side of the square that answers input, centered on the ring, in dp.
Definition at line 277 of file radio_button.hpp.