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

Configures Text widgets and registers them in the scene's entity registry. More...

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

Inheritance diagram for guillaume::entities::Text::Builder:
Collaboration diagram for guillaume::entities::Text::Builder:

Public Member Functions

 Builder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder holding the defaults of reset().
std::shared_ptr< Text > buildEntity (void) override
 Build a text from the current configuration, without registering it or giving it a parent.
void reset (void) override
 Restore the defaults: empty content, role BodyMedium, no explicit font size, and the OnSurface color of the active theme.
Builder & withContent (const std::string &content)
 Set the characters to draw.
Builder & withFontSize (const float &fontSize)
 Override the role font size with an explicit size.
Builder & withTypeRole (theme::TypeRole role)
 Set the typescale role and drop any explicit font size.
Builder & withColor (const utility::graphic::Color32Bit &color)
 Set the text color.
std::shared_ptr< Text > makeText (std::shared_ptr< Entity > parent, const std::string &content, const float &fontSize, const utility::graphic::Color32Bit &color)
 Build a text with an explicit font size, register it under parent and reset the builder.
std::shared_ptr< Text > makeText (std::shared_ptr< Entity > parent, const std::string &content, theme::TypeRole role, const utility::graphic::Color32Bit &color)
 Build a text styled by a typescale role, register it under parent and reset the builder.
Public Member Functions inherited from guillaume::entities::EntityBuilderBase< Text >
 EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder bound to two registries.
 ~EntityBuilderBase (void) override=default
 Default destructor.
std::shared_ptr< Text > registerEntity (std::shared_ptr< ecs::Entity > parent)
 Build the widget, attach it to its parent, hand it to the entity registry, then reset the builder to its defaults.
Public Member Functions inherited from guillaume::ecs::EntityBuilder
 EntityBuilder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Create a builder working on a pair of registries, normally those of one scene.
virtual ~EntityBuilder (void)=default
 Virtual destructor.

Additional Inherited Members

Protected Member Functions inherited from guillaume::ecs::EntityBuilder
ComponentRegistry & getComponentRegistry (void)
 Get the registry in which the builder creates components.
EntityRegistry & getEntityRegistry (void)
 Get the registry in which the builder registers the entities it creates.

Detailed Description

Configures Text widgets and registers them in the scene's entity registry.

Definition at line 97 of file text.hpp.

Constructor & Destructor Documentation

◆ Builder()

guillaume::entities::Text::Builder::Builder ( ecs::ComponentRegistry & componentRegistry,
ecs::EntityRegistry & entityRegistry )

Construct a builder holding the defaults of reset().

Parameters
componentRegistryThe registry the components of the built texts are stored in.
entityRegistryThe registry that owns the texts built by makeText.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ buildEntity()

std::shared_ptr< Text > guillaume::entities::Text::Builder::buildEntity ( void )
overridevirtual

Build a text from the current configuration, without registering it or giving it a parent.

Returns
The new text.

Implements guillaume::entities::EntityBuilderBase< Text >.

Definition at line 40 of file text.cpp.

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

◆ makeText() [1/2]

std::shared_ptr< Text > guillaume::entities::Text::Builder::makeText ( std::shared_ptr< Entity > parent,
const std::string & content,
const float & fontSize,
const utility::graphic::Color32Bit & color )

Build a text with an explicit font size, register it under parent and reset the builder.

The role is the one configured on the builder (BodyMedium unless withTypeRole() was called): it gives the weight, line height and letter spacing.

Parameters
parentThe entity the text is attached to, or nullptr for a root entity.
contentThe characters to draw.
fontSizeThe font size, in dp.
colorThe text color (RGBA).
Returns
The registered text.

Definition at line 81 of file text.cpp.

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

◆ makeText() [2/2]

std::shared_ptr< Text > guillaume::entities::Text::Builder::makeText ( std::shared_ptr< Entity > parent,
const std::string & content,
theme::TypeRole role,
const utility::graphic::Color32Bit & color )

Build a text styled by a typescale role, register it under parent and reset the builder.

Parameters
parentThe entity the text is attached to, or nullptr for a root entity.
contentThe characters to draw.
roleThe typescale role giving the font size, weight, line height and letter spacing.
colorThe text color (RGBA).
Returns
The registered text.

Definition at line 91 of file text.cpp.

Here is the call graph for this function:

◆ reset()

void guillaume::entities::Text::Builder::reset ( void )
overridevirtual

Restore the defaults: empty content, role BodyMedium, no explicit font size, and the OnSurface color of the active theme.

Implements guillaume::ecs::EntityBuilder.

Definition at line 47 of file text.cpp.

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

◆ withColor()

Text::Builder & guillaume::entities::Text::Builder::withColor ( const utility::graphic::Color32Bit & color)

Set the text color.

Parameters
colorThe color (RGBA). By default the OnSurface color the active theme had when the builder was last reset.
Returns
Reference to this builder for chaining.

Definition at line 75 of file text.cpp.

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

◆ withContent()

Text::Builder & guillaume::entities::Text::Builder::withContent ( const std::string & content)

Set the characters to draw.

Parameters
contentThe text content. Empty by default.
Returns
Reference to this builder for chaining.

Definition at line 55 of file text.cpp.

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

◆ withFontSize()

Text::Builder & guillaume::entities::Text::Builder::withFontSize ( const float & fontSize)

Override the role font size with an explicit size.

The other metrics still come from the role. A later call to withTypeRole() drops this size.

Parameters
fontSizeThe font size, in dp. By default the role size is used.
Returns
Reference to this builder for chaining.

Definition at line 61 of file text.cpp.

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

◆ withTypeRole()

Text::Builder & guillaume::entities::Text::Builder::withTypeRole ( theme::TypeRole role)

Set the typescale role and drop any explicit font size.

Parameters
roleThe typescale role, resolved against the active theme each frame. BodyMedium by default.
Returns
Reference to this builder for chaining.

Definition at line 67 of file text.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: