|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Colors, sizes and lays out an icon button: a round button that shows a single icon and no label. More...
#include <headers/guillaume/systems/icon_button.hpp>
Public Member Functions | |
| IconButton (void) | |
| Create the system for the Layout phase, matching entities that have both a components::IconButton and a components::Button. | |
| ~IconButton (void) override=default | |
| Default destructor. | |
| void | update (const ecs::Entity::Identifier &entityIdentifier) override |
| Frame entry point: call apply on one button. | |
| Public Member Functions inherited from guillaume::ecs::SystemFiller< components::IconButton, components::Button > | |
| 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 ®istry, const ecs::Entity::Identifier &identifier) |
| Make an entity behave as an icon button. | |
| static float | iconFontSize (const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier) |
| Get the font size of the icon for the configured size. | |
| static utility::graphic::Color32Bit | contentColor (const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier) |
| Get the color of the icon of the button when it is enabled. | |
| static void | styleState (ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier) |
| First half of apply: write the colors. | |
| static void | geometry (ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier) |
| Second half of apply: write the size and the corner radius of the button and center its icon. | |
| static void | apply (ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier) |
| Style and lay out one button at once: styleState, then geometry. | |
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. | |
Colors, sizes and lays out an icon button: a round button that shows a single icon and no label.
This is the variant half of a button; systems::Button owns the input half (press, toggle, callbacks) and calls back into apply through the restyle function of components::Button.
The size of the button is fixed by its size setting: any width or height written to its components::Bound elsewhere is overwritten each frame.
Definition at line 60 of file icon_button.hpp.
| guillaume::systems::IconButton::IconButton | ( | void | ) |
Create the system for the Layout phase, matching entities that have both a components::IconButton and a components::Button.
Definition at line 191 of file icon_button.cpp.
|
static |
Style and lay out one button at once: styleState, then geometry.
The frame calls it through update. Call it yourself after changing components::IconButton or components::Button when the result must be visible before the next Layout phase; systems::Button does on every hover, press and release.
| registry | The registry holding the components. |
| identifier | The button entity. It must have the components listed in the class description. |
| std::runtime_error | If the configured size or variant is not a valid enumerator. |
Definition at line 338 of file icon_button.cpp.
|
static |
Get the color of the icon of the button when it is enabled.
It depends on the variant and on whether the button counts as active: a selected button always does, and a Filled or Tonal button that is not a toggle does too.
| registry | The registry holding the components. |
| identifier | The button entity. |
| std::runtime_error | If the configured variant is not a valid enumerator. |
Definition at line 218 of file icon_button.cpp.
|
static |
Second half of apply: write the size and the corner radius of the button and center its icon.
The button becomes a square of the container size of its size setting with fully rounded corners, and its touch target is grown through systems::Button::applyTouchTarget. The icon, when there is one, gets its font size and is centered from its measured components::Bound, in front of the container.
| registry | The registry holding the components. |
| identifier | The button entity. |
Definition at line 292 of file icon_button.cpp.
|
static |
Get the font size of the icon for the configured size.
The widget class uses it to create the icon child at the right size.
| registry | The registry holding the components. |
| identifier | The button entity. |
| std::runtime_error | If the configured size is not a valid enumerator. |
Definition at line 209 of file icon_button.cpp.
|
static |
Make an entity behave as an icon button.
Adds a components::Elevation at level 0 when the entity has none, wires input through systems::Button::install, and stores apply in components::Button as the restyle function, so a hover, a press or a toggle redraws the button without waiting for the Layout phase. Call it once when the entity is built; entities::IconButton does it for you.
| registry | The registry holding the components. It must outlive the entity. |
| identifier | The button entity. It must already have its components::Button and the hand and mouse hover and button interaction components. |
Definition at line 197 of file icon_button.cpp.
|
static |
First half of apply: write the colors.
The outline width is always written as 1 dp; a button without an outline gets a transparent outline color.
| registry | The registry holding the components. |
| identifier | The button entity. |
Definition at line 231 of file icon_button.cpp.
|
overridevirtual |
Frame entry point: call apply on one button.
| entityIdentifier | The button entity. An entity missing components::IconButton or components::Button is logged and skipped. |
Implements guillaume::ecs::System.
Definition at line 345 of file icon_button.cpp.