|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
The rules of a radio button: selecting it, coloring its ring and placing its dot and label. More...
#include <headers/guillaume/systems/radio_button.hpp>


Public Member Functions | |
| RadioButton (void) | |
| Create the system for the Layout phase, matching entities that have a components::RadioButton. | |
| ~RadioButton (void) override=default | |
| Default destructor. | |
| void | update (const ecs::Entity::Identifier &entityIdentifier) override |
| Frame entry point: call apply on one radio button. | |
| Public Member Functions inherited from guillaume::ecs::SystemFiller< components::RadioButton > | |
| SystemFiller (Phase phase) | |
| Create the system and set its signature from ComponentTypes. | |
| virtual | ~SystemFiller (void)=default |
| Virtual destructor. | |
| Public Member Functions inherited from guillaume::ecs::System | |
| System (Phase phase) | |
| Create a system that runs in a given phase, with an empty signature. | |
| virtual | ~System (void)=default |
| Virtual destructor. | |
| Phase | getPhase (void) const noexcept |
| Get the phase of the frame in which the system runs. | |
| Entity::Signature | getSignature (void) const noexcept |
| Get the component types an entity must declare to be visited by this system. | |
| void | routine (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry, const ecs::EntityTreeTraveler &traveler) |
| Run the system once over a scene: prepare(), update() on each matching entity, cleanup(). | |
| void | bindComponentRegistry (ecs::ComponentRegistry &componentRegistry) |
| Bind a component registry so update() can be called directly, without routine(). | |
| void | unbindComponentRegistry (void) |
| Drop the binding made by bindComponentRegistry(). | |
| virtual void | prepare (void) |
| Called once per pass, before the first update(). | |
| virtual void | cleanup (void) |
| Called once per pass, after the last update(). | |
Static Public Member Functions | |
| static void | install (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Make an entity behave as a radio button. | |
| static void | apply (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Draw one radio button from its components: colors, accessibility, dot and label position. | |
| static bool | isDisabled (const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Whether the radio button ignores input and is drawn disabled. | |
| static void | select (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, bool selected) |
| Select or deselect a radio button from code and show it at once. | |
| static void | press (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Select the radio button as a click does. | |
Additional Inherited Members | |
| Protected Member Functions inherited from guillaume::ecs::System | |
| template<InheritFromComponent... ComponentTypes> | |
| void | setSignature (void) |
| Replace the signature by the one made of the given component types. | |
| ecs::EntityRegistry & | getEntityRegistry (void) |
| Get the entity registry of the scene being processed. | |
| const ecs::EntityRegistry & | getEntityRegistry (void) const |
| Get the entity registry of the scene being processed, read-only. | |
| ecs::ComponentRegistry & | getComponentRegistry (void) |
| Get the component registry of the scene being processed. | |
| const ecs::ComponentRegistry & | getComponentRegistry (void) const |
| Get the component registry of the scene being processed, read-only. | |
| template<InheritFromComponent ComponentType> | |
| bool | hasComponent (const ecs::Entity::Identifier &entityIdentifier) const |
| Tell whether an entity has a component, in the bound registry. | |
| template<InheritFromComponent ComponentType> | |
| ComponentType & | getComponent (const ecs::Entity::Identifier &entityIdentifier) |
| Get a component of an entity from the bound registry, to read or modify it. | |
| template<InheritFromComponent ComponentType> | |
| const ComponentType & | getComponent (const ecs::Entity::Identifier &entityIdentifier) const |
| Get a component of an entity from the bound registry, read-only. | |
| template<InheritFromComponent ComponentType> | |
| bool | requireComponent (const ecs::Entity::Identifier &entityIdentifier) |
| Tell whether an entity has a component, and log a warning naming the entity and the component when it does not. | |
The rules of a radio button: selecting it, coloring its ring and placing its dot and label.
The radio button entity is the 20 dp ring itself. The dot shown when it is selected and its optional label are child entities, recorded by identifier in components::RadioButton. Whether it is selected is not in that component: it is the flag of components::Selectable.
A radio button alone can be selected but never deselects itself or its neighbours on a press. Exclusive choice comes from the parent: systems::RadioGroup, or a components::SelectionGroup handled by systems::Selection.
The Disabled variant wins over systems::interaction::setEnabled: apply rewrites the enabled flag from the variant each frame.
Definition at line 63 of file radio_button.hpp.
| guillaume::systems::RadioButton::RadioButton | ( | void | ) |
Create the system for the Layout phase, matching entities that have a components::RadioButton.
Definition at line 48 of file radio_button.cpp.


|
static |
Draw one radio button from its components: colors, accessibility, dot and label position.
The ring is Primary when selected and OnSurfaceVariant otherwise; Error replaces both in the Error variant, and the disabled content color when disabled. The dot takes the same color when selected, is centered in the ring, and is transparent otherwise. The label is placed to the right of the touch target, after components::RadioButton::LabelGap, vertically centered on the ring.
The frame calls it through update. Call it yourself after writing components::RadioButton when the result must be visible before the next Layout phase; the setters of entities::RadioButton do.
| componentRegistry | The registry holding the components. |
| entityIdentifier | The radio button entity. It must have components::RadioButton, components::Selectable, components::Ring, components::Color and components::Accessibility. The dot and the label are optional. |
Definition at line 125 of file radio_button.cpp.


|
static |
Make an entity behave as a radio button.
Does three things:
Call it once when the entity is built; entities::RadioButton does it for you. It does not style anything: call apply after it.
| componentRegistry | The registry holding the components. The handlers keep its address, so it must outlive the entity. |
| entityIdentifier | The radio button entity. It must already have components::RadioButton, components::Selectable and a components::Layout whose fixed width is the width of the ring. |
Definition at line 53 of file radio_button.cpp.

|
static |
Whether the radio button ignores input and is drawn disabled.
| componentRegistry | The registry holding the components. |
| entityIdentifier | The radio button entity. |
Definition at line 88 of file radio_button.cpp.


|
static |
Select the radio button as a click does.
Selects it (it stays selected when it already was), draws it, then calls the press callback of the component, on every press, whether or not the selection changed. Nothing happens, and nothing is called, when the radio button is disabled.
The handlers set by install call it; call it directly to simulate a click, for example in a test on a bare identifier.
| componentRegistry | The registry holding the components. |
| entityIdentifier | The radio button entity. |
Definition at line 107 of file radio_button.cpp.


|
static |
Select or deselect a radio button from code and show it at once.
Writes the selected flag of components::Selectable, then calls apply. The press callback is not called, the call works on a disabled radio button, and the other radio buttons of a group are not touched. systems::RadioGroup uses it to apply its value.
| componentRegistry | The registry holding the components. |
| entityIdentifier | The radio button entity. |
| selected | True to select it, false to deselect it. |
Definition at line 98 of file radio_button.cpp.


|
overridevirtual |
Frame entry point: call apply on one radio button.
| entityIdentifier | The radio button entity. An entity without a components::RadioButton is logged and skipped. |
Implements guillaume::ecs::System.
Definition at line 208 of file radio_button.cpp.
