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

Computes the size of every icon and writes it into its Bound, so the layout knows how much room the icon takes. More...

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

Inheritance diagram for guillaume::systems::MeasureGlyph:
Collaboration diagram for guillaume::systems::MeasureGlyph:

Public Member Functions

 MeasureGlyph (std::shared_ptr< utility::RessourceProvider > ressourceProvider, utility::Engine &engine)
 Create the system in the Measure phase and load the icon font and its code point table.
 ~MeasureGlyph (void)
 Destroy the system and its cache.
void prepare (void) override
 Does nothing: the system needs no per-frame setup.
void cleanup (void) override
 Does nothing: the cache is kept from one frame to the next.
virtual void update (const ecs::Entity::Identifier &entityIdentifier) override
 Write the size of one icon into its components::Bound, measuring it with the engine when it is not in the cache yet.
Public Member Functions inherited from guillaume::ecs::SystemFiller< components::Glyph, components::Bound, components::Transform, components::Color >
 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

Computes the size of every icon and writes it into its Bound, so the layout knows how much room the icon takes.

An icon is a components::Glyph: a name looked up in the Material Symbols icon font. This system runs in the Measure phase on entities with Glyph, Bound, Transform and Color.

The measurement is asked to the engine (utility::Engine::measureText) once per distinct MeasureGlyphCacheKey and kept for the life of the system; later frames only copy the cached size.

Things to know:

  • The Bound of an icon entity is overwritten every frame.
  • A name that is not in the code point table, or a missing table, is measured as the character ?, which is also what systems::GlyphRender draws.
  • When the icon font cannot be loaded the system does nothing and the Bound keeps its value.
  • Every style is measured with the same font file (the outlined one).
See also
components::Glyph, systems::GlyphRender
MeasureGlyphCacheKey

Definition at line 147 of file measure_glyph.hpp.

Constructor & Destructor Documentation

◆ MeasureGlyph()

guillaume::systems::MeasureGlyph::MeasureGlyph ( std::shared_ptr< utility::RessourceProvider > ressourceProvider,
utility::Engine & engine )

Create the system in the Measure phase and load the icon font and its code point table.

A missing font or table is logged and does not throw.

Parameters
ressourceProviderProvider used to load the font and the table. Must not be null.
engineThe engine asked to measure the icons. It must outlive the system.

Definition at line 31 of file measure_glyph.cpp.

Here is the call graph for this function:

◆ ~MeasureGlyph()

guillaume::systems::MeasureGlyph::~MeasureGlyph ( void )

Destroy the system and its cache.

Definition at line 62 of file measure_glyph.cpp.

Member Function Documentation

◆ cleanup()

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

Does nothing: the cache is kept from one frame to the next.

Reimplemented from guillaume::ecs::System.

Definition at line 70 of file measure_glyph.cpp.

◆ prepare()

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

Does nothing: the system needs no per-frame setup.

Reimplemented from guillaume::ecs::System.

Definition at line 66 of file measure_glyph.cpp.

◆ update()

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

Write the size of one icon into its components::Bound, measuring it with the engine when it is not in the cache yet.

Parameters
entityIdentifierThe icon entity. It is skipped when the icon font is missing, and skipped with a log message when one of the four components is missing.

Implements guillaume::ecs::System.

Definition at line 74 of file measure_glyph.cpp.

Here is the call graph for this function:

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