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

Draws the focus indicator: an outline around the entity that has the keyboard focus. More...

#include <headers/guillaume/systems/focus_ring_render.hpp>

Inheritance diagram for guillaume::systems::FocusRingRender:
Collaboration diagram for guillaume::systems::FocusRingRender:

Public Member Functions

 FocusRingRender (utility::Engine &engine)
 Create the system in the Render phase.
 ~FocusRingRender (void) override=default
 Destroy the system. The engine objects it created are left in the engine.
void prepare (void) override
 Mark every ring as not drawn yet. Called once per frame before the entities are visited.
void cleanup (void) override
 Remove the rings that were not drawn this frame, which is how an entity that lost the focus loses its ring. Called once per frame after the entities.
void update (const ecs::Entity::Identifier &entityIdentifier) override
 Draw the ring of one entity if it is focused, creating the engine object on the first frame and updating it afterwards.
Public Member Functions inherited from guillaume::systems::RenderHandleMap
 RenderHandleMap (void)=default
 Create an empty map.
 ~RenderHandleMap (void)=default
 Destroy the map without removing the engine objects it refers to.
void markAllUnused (void)
 Clear the used flag of every handle. Call it from the system's prepare(), before any entity is drawn.
void removeUnused (utility::Engine &engine)
 Remove from the engine, then from the map, every handle whose used flag is still false. Call it from the system's cleanup().
RenderHandle * find (const ecs::Entity::Identifier &identifier)
 Look up the handle of an entity.
void insert (const ecs::Entity::Identifier &identifier, RenderHandle handle)
 Store the handle of an entity, replacing the one it had.
std::size_t size (void) const
 Count the entities that have an engine object in this map.
void clear (void)
 Forget every handle without calling utility::Engine::removeObject. Use it only when the engine objects are gone already or are destroyed with the engine.
Public Member Functions inherited from guillaume::ecs::SystemFiller< components::Transform, components::Bound, components::StyleState >
 SystemFiller (Phase phase)
 Create the system and set its signature from ComponentTypes.
virtual ~SystemFiller (void)=default
 Virtual destructor.
Public Member Functions inherited from guillaume::ecs::System
 System (Phase phase)
 Create a system that runs in a given phase, with an empty signature.
virtual ~System (void)=default
 Virtual destructor.
Phase getPhase (void) const noexcept
 Get the phase of the frame in which the system runs.
Entity::Signature getSignature (void) const noexcept
 Get the component types an entity must declare to be visited by this system.
void routine (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry, const ecs::EntityTreeTraveler &traveler)
 Run the system once over a scene: prepare(), update() on each matching entity, cleanup().
void bindComponentRegistry (ecs::ComponentRegistry &componentRegistry)
 Bind a component registry so update() can be called directly, without routine().
void unbindComponentRegistry (void)
 Drop the binding made by bindComponentRegistry().

Additional Inherited Members

Protected Member Functions inherited from guillaume::ecs::System
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.
ecs::EntityRegistry & getEntityRegistry (void)
 Get the entity registry of the scene being processed.
const ecs::EntityRegistry & getEntityRegistry (void) const
 Get the entity registry of the scene being processed, read-only.
ecs::ComponentRegistry & getComponentRegistry (void)
 Get the component registry of the scene being processed.
const ecs::ComponentRegistry & getComponentRegistry (void) const
 Get the component registry of the scene being processed, read-only.
template<InheritFromComponent ComponentType>
bool hasComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Tell whether an entity has a component, in the bound registry.
template<InheritFromComponent ComponentType>
ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier)
 Get a component of an entity from the bound registry, to read or modify it.
template<InheritFromComponent ComponentType>
const ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Get a component of an entity from the bound registry, read-only.
template<InheritFromComponent ComponentType>
bool requireComponent (const ecs::Entity::Identifier &entityIdentifier)
 Tell whether an entity has a component, and log a warning naming the entity and the component when it does not.

Detailed Description

Draws the focus indicator: an outline around the entity that has the keyboard focus.

Runs in the Render phase on entities with Transform, Bound and StyleState. It writes no component. An entity gets a ring only while components::StyleState::isFocused is true; the ring is removed on the first frame the flag is false.

The ring is theme::FocusRing::Width dp thick and starts theme::FocusRing::Offset dp outside the bound, in the Secondary color of the active scheme. When the entity has a components::Borders with a radius, the ring follows it (the four radii are averaged); otherwise its corners are square. It is lifted by RectangleRender::StrokeLift towards the viewer.

Registered after systems::Focus and systems::StyleState, which decide in the Event phase which entity is focused.

See also
components::StyleState, systems::Focus
RenderHandleMap, shape::buildRoundedStrokeMesh

Definition at line 61 of file focus_ring_render.hpp.

Constructor & Destructor Documentation

◆ FocusRingRender()

guillaume::systems::FocusRingRender::FocusRingRender ( utility::Engine & engine)

Create the system in the Render phase.

Parameters
engineThe engine the rings are uploaded to. It must outlive the system.

Definition at line 35 of file focus_ring_render.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ cleanup()

void guillaume::systems::FocusRingRender::cleanup ( void )
overridevirtual

Remove the rings that were not drawn this frame, which is how an entity that lost the focus loses its ring. Called once per frame after the entities.

Reimplemented from guillaume::ecs::System.

Definition at line 47 of file focus_ring_render.cpp.

Here is the call graph for this function:

◆ prepare()

void guillaume::systems::FocusRingRender::prepare ( void )
overridevirtual

Mark every ring as not drawn yet. Called once per frame before the entities are visited.

Reimplemented from guillaume::ecs::System.

Definition at line 42 of file focus_ring_render.cpp.

Here is the call graph for this function:

◆ update()

void guillaume::systems::FocusRingRender::update ( const ecs::Entity::Identifier & entityIdentifier)
overridevirtual

Draw the ring of one entity if it is focused, creating the engine object on the first frame and updating it afterwards.

Parameters
entityIdentifierThe entity to consider. It is skipped when it is not focused, and skipped with a log message when one of the three components is missing.

Implements guillaume::ecs::System.

Definition at line 53 of file focus_ring_render.cpp.

Here is the call graph for this function:

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