guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
content_helpers.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <memory>
26#include <string>
27
28#include <utility/graphic/color.hpp>
29
30#include "guillaume/ecs/component_registry.hpp"
31#include "guillaume/ecs/entity.hpp"
32#include "guillaume/ecs/entity_registry.hpp"
33
34#include "guillaume/components/glyph.hpp"
35
36#include "guillaume/entities/icon.hpp"
37#include "guillaume/entities/text.hpp"
38
39namespace guillaume::entities
40{
41
60 inline std::shared_ptr<Icon> buildIcon(
61 ecs::ComponentRegistry &registry, ecs::EntityRegistry &entityRegistry,
62 std::shared_ptr<ecs::Entity> parent, const std::string &glyphName,
63 float fontSize, const utility::graphic::Color32Bit &color,
64 components::Glyph::Style style = components::Glyph::Style::Outlined)
65 {
66 if (glyphName.empty() || parent == nullptr) {
67 return nullptr;
68 }
69
70 Icon::Builder builder(registry, entityRegistry);
71
72 return builder.makeIcon(parent, glyphName, fontSize, color, style);
73 }
74
89 inline std::shared_ptr<Text> buildText(
90 ecs::ComponentRegistry &registry, ecs::EntityRegistry &entityRegistry,
91 std::shared_ptr<ecs::Entity> parent, const std::string &content,
92 float fontSize, const utility::graphic::Color32Bit &color)
93 {
94 if (content.empty() || parent == nullptr) {
95 return nullptr;
96 }
97
98 Text::Builder builder(registry, entityRegistry);
99
100 return builder.makeText(parent, content, fontSize, color);
101 }
102
118 inline std::shared_ptr<Text> buildText(
119 ecs::ComponentRegistry &registry, ecs::EntityRegistry &entityRegistry,
120 std::shared_ptr<ecs::Entity> parent, const std::string &content,
121 theme::TypeRole role, const utility::graphic::Color32Bit &color)
122 {
123 if (content.empty() || parent == nullptr) {
124 return nullptr;
125 }
126
127 Text::Builder builder(registry, entityRegistry);
128
129 return builder.makeText(parent, content, role, color);
130 }
131
132} // namespace guillaume::entities
Style
Family of the Material Symbols font the icon belongs to.
Definition glyph.hpp:66
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
Owns entities and gives the systems the list of entities to visit.
Configures Icon widgets and registers them in the scene's entity registry.
Definition icon.hpp:87
std::shared_ptr< Icon > makeIcon(std::shared_ptr< Entity > parent, const std::string &iconName, const float &fontSize, const utility::graphic::Color32Bit &color, const components::Glyph::Style &style)
Build an icon, register it under parent and reset the builder.
Definition icon.cpp:80
Configures Text widgets and registers them in the scene's entity registry.
Definition text.hpp:98
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.
Definition text.cpp:81
Widgets: the classes used to create entities with the right components and children.
Definition app_bar.hpp:46
std::shared_ptr< Text > buildText(ecs::ComponentRegistry &registry, ecs::EntityRegistry &entityRegistry, std::shared_ptr< ecs::Entity > parent, const std::string &content, float fontSize, const utility::graphic::Color32Bit &color)
Create a Text of a given font size as a child of a widget, or nothing when there is no content.
std::shared_ptr< Icon > buildIcon(ecs::ComponentRegistry &registry, ecs::EntityRegistry &entityRegistry, std::shared_ptr< ecs::Entity > parent, const std::string &glyphName, float fontSize, const utility::graphic::Color32Bit &color, components::Glyph::Style style=components::Glyph::Style::Outlined)
Create an Icon as a child of a widget, or nothing when there is no glyph to show.
TypeRole
The named text styles of Material Design 3: what a piece of text is, not how big it is.
Definition typescale.hpp:47