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

The interaction state of an entity in one place: enabled or disabled, and whether it is hovered, pressed, focused or dragged. More...

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

Inheritance diagram for guillaume::components::StyleState:
Collaboration diagram for guillaume::components::StyleState:

Public Member Functions

 StyleState (void)=default
 Construct an enabled, idle state.
 ~StyleState (void)=default
 Default destructor.
bool isEnabled (void) const
 Check whether the entity accepts interaction.
StyleState & setEnabled (bool enabled)
 Enable or disable the entity.
bool isHovered (void) const
 Check whether the mouse pointer or a hand ray is over the entity.
StyleState & setHovered (bool hovered)
 Record whether the entity is hovered.
bool isPressed (void) const
 Check whether the entity is pressed: the left mouse button or hand button A is held on it, or a hand pinches or pokes it.
StyleState & setPressed (bool pressed)
 Record whether the entity is pressed.
bool isFocused (void) const
 Check whether the entity owns the input focus.
StyleState & setFocused (bool focused)
 Record whether the entity owns the input focus.
bool isDragged (void) const
 Check whether a drag gesture is in progress on the entity.
StyleState & setDragged (bool dragged)
 Record whether the entity is being dragged.
std::optional< theme::StateLayer > getActiveLayer (void) const
 Get the Material 3 state layer to paint over the entity.
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

The interaction state of an entity in one place: enabled or disabled, and whether it is hovered, pressed, focused or dragged.

The enabled flag is set by user code or a widget (systems::interaction::setEnabled). The four other flags are derived: systems::StyleState rewrites hovered, pressed and dragged every frame in the Event phase from the hover, button, pinch, poke and drag interaction components of the entity, and systems::Focus writes focused. Widget systems read getActiveLayer() to tint the entity, systems::FocusRingRender draws a ring around a focused entity, and the input systems ignore a disabled entity.

const auto &state =
registry.getComponent<components::StyleState>(identifier);
if (state.getActiveLayer() == theme::StateLayer::Pressed) { ... }
The interaction state of an entity in one place: enabled or disabled, and whether it is hovered,...
@ Pressed
0.12 overlay of the content color.
Definition tokens.hpp:226

A value written with setHovered(), setPressed() or setDragged() is overwritten on the next frame. An entity without StyleState is treated as enabled.

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

Definition at line 59 of file style_state.hpp.

Member Function Documentation

◆ getActiveLayer()

std::optional< theme::StateLayer > guillaume::components::StyleState::getActiveLayer ( void ) const

Get the Material 3 state layer to paint over the entity.

When several flags are set the strongest one wins: dragged, then pressed, then focused, then hovered.

Returns
The layer of the strongest active state, or std::nullopt when the entity is idle or disabled.

Definition at line 97 of file style_state.cpp.

◆ isDragged()

bool guillaume::components::StyleState::isDragged ( void ) const

Check whether a drag gesture is in progress on the entity.

Returns
True when dragged; always false when disabled.

Definition at line 86 of file style_state.cpp.

◆ isEnabled()

bool guillaume::components::StyleState::isEnabled ( void ) const

Check whether the entity accepts interaction.

Returns
True when enabled, which is the default.

Definition at line 36 of file style_state.cpp.

Here is the caller graph for this function:

◆ isFocused()

bool guillaume::components::StyleState::isFocused ( void ) const

Check whether the entity owns the input focus.

Returns
True when focused; always false when disabled.

Definition at line 75 of file style_state.cpp.

◆ isHovered()

bool guillaume::components::StyleState::isHovered ( void ) const

Check whether the mouse pointer or a hand ray is over the entity.

Returns
True when hovered; always false when disabled.

Definition at line 53 of file style_state.cpp.

◆ isPressed()

bool guillaume::components::StyleState::isPressed ( void ) const

Check whether the entity is pressed: the left mouse button or hand button A is held on it, or a hand pinches or pokes it.

Returns
True when pressed; always false when disabled.

Definition at line 64 of file style_state.cpp.

◆ setDragged()

StyleState & guillaume::components::StyleState::setDragged ( bool dragged)

Record whether the entity is being dragged.

Called every frame by systems::StyleState from DragInteraction::isDragging. Stores false when the entity is disabled; marks the component changed only when the flag differs.

Parameters
draggedTrue when a drag is in progress on the entity.
Returns
This component, to chain calls.

Definition at line 91 of file style_state.cpp.

Here is the call graph for this function:

◆ setEnabled()

StyleState & guillaume::components::StyleState::setEnabled ( bool enabled)

Enable or disable the entity.

Disabling also clears the hovered, pressed, focused and dragged flags, and they stay false while the entity is disabled. Marks the component changed only when a flag differs.

Parameters
enabledFalse to make the input systems ignore the entity.
Returns
This component, to chain calls.

Definition at line 41 of file style_state.cpp.

Here is the call graph for this function:

◆ setFocused()

StyleState & guillaume::components::StyleState::setFocused ( bool focused)

Record whether the entity owns the input focus.

Called by systems::Focus when the focus moves. Stores false when the entity is disabled; marks the component changed only when the flag differs.

Parameters
focusedTrue when the entity owns the focus.
Returns
This component, to chain calls.

Definition at line 80 of file style_state.cpp.

Here is the call graph for this function:

◆ setHovered()

StyleState & guillaume::components::StyleState::setHovered ( bool hovered)

Record whether the entity is hovered.

Called every frame by systems::StyleState. Stores false when the entity is disabled; marks the component changed only when the flag differs.

Parameters
hoveredTrue when a pointer or a hand ray is over the entity.
Returns
This component, to chain calls.

Definition at line 58 of file style_state.cpp.

Here is the call graph for this function:

◆ setPressed()

StyleState & guillaume::components::StyleState::setPressed ( bool pressed)

Record whether the entity is pressed.

Called every frame by systems::StyleState. Stores false when the entity is disabled; marks the component changed only when the flag differs.

Parameters
pressedTrue when the entity is pressed.
Returns
This component, to chain calls.

Definition at line 69 of file style_state.cpp.

Here is the call graph for this function:

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