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

What an entity means to a user who does not see it: its name, its role, its state and its place in the keyboard traversal. More...

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

Inheritance diagram for guillaume::components::Accessibility:
Collaboration diagram for guillaume::components::Accessibility:

Public Member Functions

 Accessibility (void)=default
 Construct a description with no label, no role, no state, a focus order of 0 and the focusable flag set.
 ~Accessibility (void)=default
 Default destructor.
const std::string & getLabel (void) const
 Get the name announced for the entity.
Accessibility & setLabel (const std::string &label)
 Set the name announced for the entity, such as "Close".
const std::string & getHint (void) const
 Get the sentence describing what activating the entity does.
Accessibility & setHint (const std::string &hint)
 Set the sentence describing what activating the entity does, such as "Closes the dialog".
AccessibilityRole getRole (void) const
 Get what kind of control the entity is.
Accessibility & setRole (AccessibilityRole role)
 Set what kind of control the entity is.
bool isSelected (void) const
 Check whether the entity is the selected one of its group (the active navigation destination, a selected chip).
Accessibility & setSelected (bool selected)
 Set whether the entity is the selected one of its group.
std::optional< CheckedState > getChecked (void) const
 Get whether the entity is ticked.
Accessibility & setChecked (std::optional< CheckedState > checked)
 Set whether the entity is ticked.
std::optional< bool > getExpanded (void) const
 Get whether the entity shows the content it controls (an open menu, an unfolded section).
Accessibility & setExpanded (std::optional< bool > expanded)
 Set whether the entity shows the content it controls.
const std::optional< AccessibilityValue > & getValue (void) const
 Get the position of the entity within its range.
Accessibility & setValue (std::optional< AccessibilityValue > value)
 Set the position of the entity within its range.
LiveRegion getLiveRegion (void) const
 Get how urgently a change of the entity is announced.
Accessibility & setLiveRegion (LiveRegion liveRegion)
 Set how urgently a change of the entity is announced.
int getFocusOrder (void) const
 Get the rank of the entity in the Tab traversal.
Accessibility & setFocusOrder (int focusOrder)
 Set the rank of the entity in the Tab traversal.
bool isFocusable (void) const
 Check whether the Tab traversal stops on the entity.
Accessibility & setFocusable (bool focusable)
 Include the entity in the Tab traversal or leave it out.
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

What an entity means to a user who does not see it: its name, its role, its state and its place in the keyboard traversal.

Widget systems write it when they install a widget (role) and each time the widget changes (label, checked, selected, expanded); user code may set a label, a hint or a focus order. systems::Focus reads the focus order and the focusable flag to build the Tab traversal. The other fields describe the entity to an assistive technology.

registry.getComponent<components::Accessibility>(identifier)
.setLabel("Delete the selected file")
What an entity means to a user who does not see it: its name, its role, its state and its place in th...
Accessibility & setFocusOrder(int focusOrder)
Set the rank of the entity in the Tab traversal.
Accessibility & setLabel(const std::string &label)
Set the name announced for the entity, such as "Close".

The disabled state is not stored here: read it from StyleState.

See also
systems::Focus, systems::interaction::makeInteractive, StyleState

Definition at line 109 of file accessibility.hpp.

Member Function Documentation

◆ getChecked()

std::optional< CheckedState > guillaume::components::Accessibility::getChecked ( void ) const

Get whether the entity is ticked.

Returns
The checked state, or std::nullopt when the entity is not a control that can be ticked.

Definition at line 85 of file accessibility.cpp.

◆ getExpanded()

std::optional< bool > guillaume::components::Accessibility::getExpanded ( void ) const

Get whether the entity shows the content it controls (an open menu, an unfolded section).

Returns
True when expanded, false when collapsed, or std::nullopt when the entity does not expand.

Definition at line 100 of file accessibility.cpp.

◆ getFocusOrder()

int guillaume::components::Accessibility::getFocusOrder ( void ) const

Get the rank of the entity in the Tab traversal.

systems::Focus visits the entities with a positive order first, by ascending order, then the entities with order 0, in the order the system updates them.

Returns
The focus order; 0, the default, means no explicit rank.

Definition at line 147 of file accessibility.cpp.

◆ getHint()

const std::string & guillaume::components::Accessibility::getHint ( void ) const

Get the sentence describing what activating the entity does.

Returns
The hint; empty when none was set.

Definition at line 43 of file accessibility.cpp.

◆ getLabel()

const std::string & guillaume::components::Accessibility::getLabel ( void ) const

Get the name announced for the entity.

Returns
The label; empty when none was set.

Definition at line 29 of file accessibility.cpp.

◆ getLiveRegion()

LiveRegion guillaume::components::Accessibility::getLiveRegion ( void ) const

Get how urgently a change of the entity is announced.

Returns
The live region; LiveRegion::None by default.

Definition at line 133 of file accessibility.cpp.

◆ getRole()

AccessibilityRole guillaume::components::Accessibility::getRole ( void ) const

Get what kind of control the entity is.

Returns
The role; AccessibilityRole::None by default.

Definition at line 57 of file accessibility.cpp.

◆ getValue()

const std::optional< AccessibilityValue > & guillaume::components::Accessibility::getValue ( void ) const

Get the position of the entity within its range.

Returns
The range value, or std::nullopt when the entity has no range.

Definition at line 114 of file accessibility.cpp.

◆ isFocusable()

bool guillaume::components::Accessibility::isFocusable ( void ) const

Check whether the Tab traversal stops on the entity.

Returns
True, the default, when Tab can focus the entity.

Definition at line 164 of file accessibility.cpp.

◆ isSelected()

bool guillaume::components::Accessibility::isSelected ( void ) const

Check whether the entity is the selected one of its group (the active navigation destination, a selected chip).

Returns
True when selected.

Definition at line 71 of file accessibility.cpp.

◆ setChecked()

Accessibility & guillaume::components::Accessibility::setChecked ( std::optional< CheckedState > checked)

Set whether the entity is ticked.

Marks the component changed only when the state differs.

Parameters
checkedThe checked state, or std::nullopt for an entity that cannot be ticked.
Returns
This component, to chain calls.

Definition at line 91 of file accessibility.cpp.

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

◆ setExpanded()

Accessibility & guillaume::components::Accessibility::setExpanded ( std::optional< bool > expanded)

Set whether the entity shows the content it controls.

Marks the component changed only when the state differs.

Parameters
expandedTrue when expanded, false when collapsed, or std::nullopt for an entity that does not expand.
Returns
This component, to chain calls.

Definition at line 105 of file accessibility.cpp.

Here is the call graph for this function:

◆ setFocusable()

Accessibility & guillaume::components::Accessibility::setFocusable ( bool focusable)

Include the entity in the Tab traversal or leave it out.

An entity left out can still take the focus when it is clicked. Marks the component changed only when the flag differs.

Parameters
focusableFalse to make Tab skip the entity.
Returns
This component, to chain calls.

Definition at line 169 of file accessibility.cpp.

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

◆ setFocusOrder()

Accessibility & guillaume::components::Accessibility::setFocusOrder ( int focusOrder)

Set the rank of the entity in the Tab traversal.

Marks the component changed only when the order differs.

Parameters
focusOrderThe rank: 1 is reached first; 0 removes the explicit rank.
Returns
This component, to chain calls.
Exceptions
std::invalid_argumentIf focusOrder is negative.

Definition at line 152 of file accessibility.cpp.

Here is the call graph for this function:

◆ setHint()

Accessibility & guillaume::components::Accessibility::setHint ( const std::string & hint)

Set the sentence describing what activating the entity does, such as "Closes the dialog".

Marks the component changed only when the hint differs.

Parameters
hintThe sentence to announce after the label; empty for none.
Returns
This component, to chain calls.

Definition at line 48 of file accessibility.cpp.

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

◆ setLabel()

Accessibility & guillaume::components::Accessibility::setLabel ( const std::string & label)

Set the name announced for the entity, such as "Close".

Marks the component changed only when the label differs.

Parameters
labelThe name to announce; empty for none.
Returns
This component, to chain calls.

Definition at line 34 of file accessibility.cpp.

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

◆ setLiveRegion()

Accessibility & guillaume::components::Accessibility::setLiveRegion ( LiveRegion liveRegion)

Set how urgently a change of the entity is announced.

Marks the component changed only when the value differs.

Parameters
liveRegionThe politeness of the announcements.
Returns
This component, to chain calls.

Definition at line 138 of file accessibility.cpp.

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

◆ setRole()

Accessibility & guillaume::components::Accessibility::setRole ( AccessibilityRole role)

Set what kind of control the entity is.

Marks the component changed only when the role differs.

Parameters
roleThe role to announce.
Returns
This component, to chain calls.

Definition at line 62 of file accessibility.cpp.

Here is the call graph for this function:

◆ setSelected()

Accessibility & guillaume::components::Accessibility::setSelected ( bool selected)

Set whether the entity is the selected one of its group.

Marks the component changed only when the state differs.

Parameters
selectedTrue when the entity is selected.
Returns
This component, to chain calls.

Definition at line 76 of file accessibility.cpp.

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

◆ setValue()

Accessibility & guillaume::components::Accessibility::setValue ( std::optional< AccessibilityValue > value)

Set the position of the entity within its range.

Always marks the component changed.

Parameters
valueThe range value, or std::nullopt to remove it.
Returns
This component, to chain calls.
Exceptions
std::invalid_argumentIf min > max or now is outside [min, max]. The stored value is then left as it was.

Definition at line 120 of file accessibility.cpp.

Here is the call graph for this function:

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