23#include "guillaume/components/selection.hpp"
34 if (_selected == selected) {
39 if (_onSelectionChanged) {
40 _onSelectionChanged(_selected);
47 _onSelectionChanged = handler;
53 return _onSelectionChanged;
69 if (_selected == selected) {
89 if (_allowEmpty == allowEmpty) {
92 _allowEmpty = allowEmpty;
bool isSelected(void) const
Check whether the entity is selected.
Selectable & setSelected(bool selected)
Select or deselect the entity.
std::function< void(bool)> Handler
Callback receiving the new state: true when just selected.
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.
Selectable(void)=default
Create an unselected flag with no handler.
Marks an entity whose Selectable children are mutually exclusive, and remembers which one is selected...
bool isEmptyAllowed(void) const
Check whether the group may have no selection.
bool hasSelection(void) const
Check whether the group names a selected child.
ecs::Entity::Identifier getSelected(void) const
Get the selected child.
SelectionGroup(void)=default
Create a group with no selection that may stay empty.
SelectionGroup & setAllowEmpty(bool allowEmpty)
Choose whether the group may have no selection.
SelectionGroup & setSelected(ecs::Entity::Identifier selected)
Record which child is selected.
SelectionGroup & clearSelection(void)
Record that no child is selected.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
State. Every class here is plain data attached to an entity.