|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Selected/unselected flag of an entity, with a callback run when it changes. More...
#include <headers/guillaume/components/selection.hpp>


Public Types | |
| using | Handler = std::function<void(bool)> |
| Callback receiving the new state: true when just selected. | |
Public Member Functions | |
| Selectable (void)=default | |
| Create an unselected flag with no handler. | |
| ~Selectable (void)=default | |
| Default destructor for the Selectable component. | |
| bool | isSelected (void) const |
| Check whether the entity is selected. | |
| Selectable & | setSelected (bool selected) |
| Select or deselect the entity. | |
| Selectable & | setOnSelectionChangedHandler (const Handler &handler) |
| Set the callback run when the selection changes. | |
| Handler | getOnSelectionChangedHandler (void) const |
| Get the callback run when the selection changes. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
Selected/unselected flag of an entity, with a callback run when it changes.
Widget systems write it and read it as the selection of their widget: radio buttons, checkboxes, chips and navigation destinations all have one. When the parent entity has a components::SelectionGroup, systems::Selection (Event phase) keeps at most one Selectable child selected.
The handler runs inside setSelected(), synchronously. The widget systems install their own handler here to restyle the widget, so replacing it on a widget's entity removes that behaviour.
Definition at line 56 of file selection.hpp.
| using guillaume::components::Selectable::Handler = std::function<void(bool)> |
Callback receiving the new state: true when just selected.
Definition at line 60 of file selection.hpp.
| Selectable::Handler guillaume::components::Selectable::getOnSelectionChangedHandler | ( | void | ) | const |
Get the callback run when the selection changes.
Definition at line 51 of file selection.cpp.
| bool guillaume::components::Selectable::isSelected | ( | void | ) | const |
Check whether the entity is selected.
Definition at line 27 of file selection.cpp.
| Selectable & guillaume::components::Selectable::setOnSelectionChangedHandler | ( | const Handler & | handler | ) |
Set the callback run when the selection changes.
Replaces the previous handler. Does not mark the component changed.
| handler | The callback, or an empty one to remove it. |
Definition at line 45 of file selection.cpp.

| Selectable & guillaume::components::Selectable::setSelected | ( | bool | selected | ) |
Select or deselect the entity.
When the state differs from the stored one, stores it, marks the component changed and calls the handler with the new state. Does nothing otherwise.
| selected | True to select the entity. |
Definition at line 32 of file selection.cpp.
