|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
The rules of a switch: turning it on and off, coloring its track and placing its thumb, thumb icon and label. More...
#include <headers/guillaume/systems/switch.hpp>


Public Member Functions | |
| Switch (void) | |
| Create the system for the Layout phase, matching entities that have a components::Switch. | |
| ~Switch (void) override=default | |
| Default destructor. | |
| void | update (const ecs::Entity::Identifier &entityIdentifier) override |
| Frame entry point: call apply on one switch. | |
| Public Member Functions inherited from guillaume::ecs::SystemFiller< components::Switch > | |
| 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 switch. | |
| static void | apply (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Draw one switch from its components: thumb position, colors and accessibility. | |
| static bool | isDisabled (const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Whether the switch ignores input and is drawn disabled. | |
| static bool | isChecked (const ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Whether the switch is on. | |
| static void | setChecked (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, bool checked) |
| Turn the switch on or off from code. | |
| static void | toggle (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier) |
| Flip the switch 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 switch: turning it on and off, coloring its track and placing its thumb, thumb icon and label.
The switch entity is the track itself. The thumb that slides in it, the optional icon on the thumb and the optional label are child entities, recorded by identifier in components::Switch. Whether the switch is on is not in that component: it is the components::Value of the entity, 0 for off and 1 for on.
The Disabled variant wins over systems::interaction::setEnabled: apply rewrites the enabled flag from the variant each frame.
Definition at line 65 of file switch.hpp.
| guillaume::systems::Switch::Switch | ( | void | ) |
Create the system for the Layout phase, matching entities that have a components::Switch.
Definition at line 61 of file switch.cpp.


|
static |
Draw one switch from its components: thumb position, colors and accessibility.
The frame calls it through update. Call it yourself after writing components::Switch when the result must be visible before the next Layout phase; the setters of entities::Switch do.
| componentRegistry | The registry holding the components. |
| entityIdentifier | The switch entity. It must have components::Switch, components::Value, components::Color, components::Borders and components::Accessibility. The thumb, its icon and the label are optional. |
Definition at line 135 of file switch.cpp.


|
static |
Make an entity behave as a switch.
Does two things:
Call it once when the entity is built; entities::Switch 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 switch entity. It must already have components::Switch and components::Value. |
Definition at line 66 of file switch.cpp.

|
static |
Whether the switch is on.
| componentRegistry | The registry holding the components. |
| entityIdentifier | The switch entity. It must have a components::Value. |
Definition at line 100 of file switch.cpp.


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


|
static |
Turn the switch on or off from code.
Writes 1 or 0 into components::Value. The value-change callback of components::Switch is not called, and the call works on a disabled switch. The switch is redrawn at once by the change handler install set on the value; on an entity that did not go through install, it is redrawn at the next Layout phase.
| componentRegistry | The registry holding the components. |
| entityIdentifier | The switch entity. |
| checked | True to turn the switch on, false to turn it off. |
Definition at line 109 of file switch.cpp.


|
static |
Flip the switch as a click does.
Turns it on when off and off when on (through setChecked), then calls the value-change callback of the component with the new state. Nothing happens, and nothing is called, when the switch 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 switch entity. |
Definition at line 117 of file switch.cpp.


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