25#include "guillaume/entities/text.hpp"
26#include "guillaume/systems/typography.hpp"
27#include "guillaume/entities/builder_base.hpp"
28#include "guillaume/theme.hpp"
33 Text::Text::Builder::Builder(ecs::ComponentRegistry &componentRegistry,
34 ecs::EntityRegistry &entityRegistry)
43 _typeRole, _color, _fontSize);
82 std::shared_ptr<Entity> parent,
const std::string &content,
83 const float &fontSize,
const utility::graphic::Color32Bit &color)
86 .withFontSize(fontSize)
88 .registerEntity(parent);
92 std::shared_ptr<Entity> parent,
const std::string &content,
98 .registerEntity(parent);
102 const float &fontSize,
const utility::graphic::Color32Bit &color)
103 : Text(registry, content,
theme::TypeRole::Default, color, fontSize)
109 std::optional<float> fontSize)
114 typography().setRole(role).setFontSize(fontSize);
136 void Text::applyTypography(
void)
158 typography().setRole(role).
setFontSize(std::nullopt);
165 return typography().getRole();
Main color of an entity: the fill of a shape, or the ink of a text or an icon.
A run of text: its content, its font metrics and the position of the editing cursor.
Which typescale role a text uses (BodyMedium, TitleLarge, ...) and an optional explicit size.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
ComponentType & getComponent(const Entity::Identifier &entityIdentifier)
Get a component of an entity, to read or modify it.
ComponentRegistry & getComponentRegistry(void)
Get the registry in which the builder creates components.
EntityFiller(ComponentRegistry &componentRegistry)
ComponentRegistry & getComponentRegistry(void)
Entity::Identifier getIdentifier(void) const noexcept
Get the identifier of the entity.
Base of every widget Builder: turns a configuration into a widget that is attached to a parent and ow...
Configures Text widgets and registers them in the scene's entity registry.
Builder & withFontSize(const float &fontSize)
Override the role font size with an explicit size.
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 ...
Builder & withTypeRole(theme::TypeRole role)
Set the typescale role and drop any explicit font size.
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.
Builder & withContent(const std::string &content)
Set the characters to draw.
Builder & withColor(const utility::graphic::Color32Bit &color)
Set the text color.
A single run of text drawn with a typescale role, a color and an optional explicit font size.
Text & setContent(const std::string &content)
Replace the characters to draw.
theme::TypeRole getTypeRole(void) const
Get the typescale role the text is styled with.
Text & setFontSize(const float &fontSize)
Override the role font size with an explicit size.
Text & setTypeRole(theme::TypeRole role)
Set the typescale role and drop any explicit font size.
static std::shared_ptr< Text > create(Arguments &&...arguments)
Build a text without registering it in an entity registry.
Text & setColor(const utility::graphic::Color32Bit &color)
Set the text color.
static void apply(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Resolve the metrics of one text and write them into its components::Text.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Widgets: the classes used to create entities with the right components and children.
Design tokens: colors, type scale, shapes, elevation, motion and spacing. Read them through guillaume...
TypeRole
The named text styles of Material Design 3: what a piece of text is, not how big it is.
@ BodyMedium
14 / 20, regular.
utility::graphic::Color32Bit getActiveColor(SchemeColorRole role)
Get the color the active scheme gives to a role.