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

A Material Symbols icon, chosen by name and drawn as one glyph of the icon font. More...

#include <headers/guillaume/entities/icon.hpp>

Inheritance diagram for guillaume::entities::Icon:
Collaboration diagram for guillaume::entities::Icon:

Classes

class  Builder
 Configures Icon widgets and registers them in the scene's entity registry. More...

Public Member Functions

 ~Icon (void)
 Destructor.
Icon & setGlyphName (const std::string &glyphName)
 Change the icon to draw.
Icon & setFontSize (const float &fontSize)
 Set the size of the icon.
Icon & setColor (const utility::graphic::Color32Bit &color)
 Set the icon color.
Icon & setStyle (const components::Glyph::Style &style)
 Set the Material Symbols style of the glyph.
Icon & setAccessibilityLabel (const std::string &label)
 Give the icon a meaning for assistive technologies.
Public Member Functions inherited from guillaume::ecs::EntityFiller< components::Transform, components::Bound, components::Glyph, components::Color >
 EntityFiller (ComponentRegistry &componentRegistry)
 Create the entity, its listed components and its components::Hierarchy.
virtual ~EntityFiller (void)=default
 Destroy the entity object; its components stay in the registry (see EntityRegistry::removeEntity).
Public Member Functions inherited from guillaume::ecs::Entity
 Entity (void)
 Create an entity with a fresh identifier, an empty signature, no parent and no component.
virtual ~Entity (void)=default
 Destroy the entity object.
Entity::Identifier getIdentifier (void) const noexcept
 Get the identifier of the entity.
Entity::Signature getSignature (void) const noexcept
 Get the set of component types the entity declares.
void setSignature (const Signature &signature)
 Replace the signature of the entity.
std::int32_t getLayer (void) const noexcept
 Get the depth of the entity in the tree.
Entity & setParent (std::shared_ptr< Entity > parent)
 Attach the entity under another one, or detach it.
std::vector< Identifier > releaseComponents (void)
 Drop the entity's place in the tree and all its components.
std::shared_ptr< Entity > getParent (void) const noexcept
 Get the parent entity.

Static Public Member Functions

template<typename... Arguments>
static std::shared_ptr< Icon > create (Arguments &&...arguments)
 Build an icon without registering it in an entity registry.
Static Public Member Functions inherited from guillaume::ecs::Entity
template<InheritFromComponent... ComponentTypes>
static Signature getSignatureFromTypes (void)
 Build the signature that has exactly the bits of the given component types.

Additional Inherited Members

Public Types inherited from guillaume::ecs::Entity
using Identifier = std::size_t
 The key under which an entity's components are stored. Systems and components refer to entities by this value.
using Signature = std::bitset<128>
 A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits).
Static Public Attributes inherited from guillaume::ecs::Entity
static constexpr Identifier InvalidIdentifier
 "No entity": never the identifier of a real entity
Protected Member Functions inherited from guillaume::ecs::EntityFiller< components::Transform, components::Bound, components::Glyph, components::Color >
ComponentRegistry & getComponentRegistry (void)
 Get the registry that stores this entity's components.
Protected Member Functions inherited from guillaume::ecs::Entity
void attachHierarchy (ComponentRegistry &componentRegistry)
 Give the entity a components::Hierarchy in a registry and add that component to its signature.
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.

Detailed Description

A Material Symbols icon, chosen by name and drawn as one glyph of the icon font.

Icon is a leaf widget: it has no children. Its state lives in components::Glyph (name, font size, style), components::Color and components::Transform. Each frame systems::MeasureGlyph writes the measured glyph size into components::Bound, in the Measure phase, and systems::GlyphRender draws the glyph, in the Render phase. The class itself holds no field.

Icon::Builder builder(getComponentRegistry(), getEntityRegistry());
auto icon = builder.makeIcon(parent, "favorite", 24.0f,
getActiveColor(SchemeColorRole::Primary),
components::Glyph::Style::Outlined);
icon->setAccessibilityLabel("Add to favorites");
Configures Icon widgets and registers them in the scene's entity registry.
Definition icon.hpp:87
utility::graphic::Color32Bit getActiveColor(SchemeColorRole role)
Get the color the active scheme gives to a role.

Icon::create(registry, glyphName, fontSize, color, style) builds the same widget without registering it in an entity registry.

Watch out:

  • The Bound is overwritten every frame with the measured size; size an icon with its font size.
  • A name missing from the code point table of the font is drawn as ?.
  • The style is stored in components::Glyph, but both systems load the Material Symbols Outlined font whatever its value.
  • An icon is decorative for assistive technologies until setAccessibilityLabel() gives it a label.
See also
components::Glyph, systems::MeasureGlyph, systems::GlyphRender

Definition at line 77 of file icon.hpp.

Constructor & Destructor Documentation

◆ ~Icon()

guillaume::entities::Icon::~Icon ( void )

Destructor.

Definition at line 104 of file icon.cpp.

Member Function Documentation

◆ create()

template<typename... Arguments>
std::shared_ptr< Icon > guillaume::entities::Icon::create ( Arguments &&... arguments)
inlinestatic

Build an icon without registering it in an entity registry.

The arguments are forwarded to the private constructor: (registry, glyphName, fontSize, color, style). An icon has no children to build.

Template Parameters
ArgumentsThe constructor argument types.
Parameters
argumentsThe constructor arguments, as listed above.
Returns
The new icon. The caller owns it.

Definition at line 185 of file icon.hpp.

Here is the caller graph for this function:

◆ setAccessibilityLabel()

Icon & guillaume::entities::Icon::setAccessibilityLabel ( const std::string & label)

Give the icon a meaning for assistive technologies.

An icon has no components::Accessibility until this is called with a non-empty label, which adds the component with the Image role. A later empty label sets the role back to None and clears the label; the component stays.

Parameters
labelThe text announced for the icon, or an empty string to make the icon decorative.
Returns
Reference to this icon for chaining.

Definition at line 135 of file icon.cpp.

Here is the call graph for this function:

◆ setColor()

Icon & guillaume::entities::Icon::setColor ( const utility::graphic::Color32Bit & color)

Set the icon color.

Parameters
colorThe new color (RGBA), written to components::Color.
Returns
Reference to this icon for chaining.

Definition at line 126 of file icon.cpp.

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

◆ setFontSize()

Icon & guillaume::entities::Icon::setFontSize ( const float & fontSize)

Set the size of the icon.

The Bound follows at the next Measure phase.

Parameters
fontSizeThe new font size of the glyph, in dp.
Returns
Reference to this icon for chaining.

Definition at line 117 of file icon.cpp.

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

◆ setGlyphName()

Icon & guillaume::entities::Icon::setGlyphName ( const std::string & glyphName)

Change the icon to draw.

Parameters
glyphNameThe Material Symbols name of the new icon, written to components::Glyph.
Returns
Reference to this icon for chaining.
See also
components::Glyph::getName

Definition at line 108 of file icon.cpp.

Here is the call graph for this function:

◆ setStyle()

Icon & guillaume::entities::Icon::setStyle ( const components::Glyph::Style & style)

Set the Material Symbols style of the glyph.

Parameters
styleThe new style, written to components::Glyph.
Returns
Reference to this icon for chaining.

Definition at line 152 of file icon.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: