guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::systems::RadioButton Class Reference

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>

Inheritance diagram for guillaume::systems::RadioButton:
Collaboration diagram for guillaume::systems::RadioButton:

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.

Detailed Description

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.

See also
guillaume::components::RadioButton, guillaume::systems::RadioGroup, guillaume::components::Selectable

Definition at line 63 of file radio_button.hpp.

Constructor & Destructor Documentation

◆ RadioButton()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ apply()

void guillaume::systems::RadioButton::apply ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier )
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.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ install()

void guillaume::systems::RadioButton::install ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier )
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.

Parameters
componentRegistryThe registry holding the components. The handlers keep its address, so it must outlive the entity.
entityIdentifierThe 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.

Here is the call graph for this function:

◆ isDisabled()

bool guillaume::systems::RadioButton::isDisabled ( const ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier )
static

Whether the radio button ignores input and is drawn disabled.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe radio button entity.
Returns
True when the variant of components::RadioButton is Disabled or when the components::StyleState of the entity is not enabled.

Definition at line 88 of file radio_button.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ press()

void guillaume::systems::RadioButton::press ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier )
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.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe radio button entity.

Definition at line 107 of file radio_button.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select()

void guillaume::systems::RadioButton::select ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier,
bool selected )
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.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe radio button entity.
selectedTrue to select it, false to deselect it.

Definition at line 98 of file radio_button.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void guillaume::systems::RadioButton::update ( const ecs::Entity::Identifier & entityIdentifier)
overridevirtual

Frame entry point: call apply on one radio button.

Parameters
entityIdentifierThe 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.

Here is the call graph for this function:

The documentation for this class was generated from the following files: