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

Marks an entity whose Selectable children are mutually exclusive, and remembers which one is selected. More...

#include <headers/guillaume/components/selection.hpp>

Inheritance diagram for guillaume::components::SelectionGroup:
Collaboration diagram for guillaume::components::SelectionGroup:

Public Member Functions

 SelectionGroup (void)=default
 Create a group with no selection that may stay empty.
 ~SelectionGroup (void)=default
 Default destructor for the SelectionGroup component.
bool hasSelection (void) const
 Check whether the group names a selected child.
ecs::Entity::Identifier getSelected (void) const
 Get the selected child.
SelectionGroup & setSelected (ecs::Entity::Identifier selected)
 Record which child is selected.
SelectionGroup & clearSelection (void)
 Record that no child is selected.
bool isEmptyAllowed (void) const
 Check whether the group may have no selection.
SelectionGroup & setAllowEmpty (bool allowEmpty)
 Choose whether the group may have no selection.
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.

Detailed Description

Marks an entity whose Selectable children are mutually exclusive, and remembers which one is selected.

systems::Selection (Event phase) reads the children from the entity's components::Hierarchy each frame: when several are selected it keeps the first one, and it writes the result here. The navigation bar and the navigation drawer use it for their destinations.

To change the selection, call systems::Selection::select() or select the child's Selectable; setSelected() here only records the result.

Watch out: when no child is selected but this component still names one, the system selects that child again. Deselecting the selected child alone is therefore undone on the next frame; call clearSelection() as well to empty the group.

See also
components::Selectable
systems::Selection

Definition at line 131 of file selection.hpp.

Member Function Documentation

◆ clearSelection()

SelectionGroup & guillaume::components::SelectionGroup::clearSelection ( void )

Record that no child is selected.

Same as setSelected(ecs::Entity::InvalidIdentifier).

Returns
This component, for chaining.

Definition at line 77 of file selection.cpp.

Here is the call graph for this function:

◆ getSelected()

ecs::Entity::Identifier guillaume::components::SelectionGroup::getSelected ( void ) const

Get the selected child.

Returns
Its identifier, or ecs::Entity::InvalidIdentifier when none is selected.

Definition at line 61 of file selection.cpp.

◆ hasSelection()

bool guillaume::components::SelectionGroup::hasSelection ( void ) const

Check whether the group names a selected child.

Returns
True when getSelected() is a valid identifier.

Definition at line 56 of file selection.cpp.

◆ isEmptyAllowed()

bool guillaume::components::SelectionGroup::isEmptyAllowed ( void ) const

Check whether the group may have no selection.

Returns
True when an empty selection is allowed (the default).

Definition at line 82 of file selection.cpp.

◆ setAllowEmpty()

SelectionGroup & guillaume::components::SelectionGroup::setAllowEmpty ( bool allowEmpty)

Choose whether the group may have no selection.

When it may not, systems::Selection selects the first Selectable child whenever the group is empty. Marks the component changed when the flag differs.

Parameters
allowEmptyFalse to always keep one child selected.
Returns
This component, for chaining.

Definition at line 87 of file selection.cpp.

Here is the call graph for this function:

◆ setSelected()

SelectionGroup & guillaume::components::SelectionGroup::setSelected ( ecs::Entity::Identifier selected)

Record which child is selected.

Marks the component changed when the identifier differs. It does not touch the Selectable of any child.

Parameters
selectedThe selected child, or ecs::Entity::InvalidIdentifier for none.
Returns
This component, for chaining.

Definition at line 67 of file selection.cpp.

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

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