guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
divider.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 <utility>
26#include <memory>
27
28#include <utility/graphic/color.hpp>
29#include <utility/graphic/pose.hpp>
30
31#include "guillaume/ecs/component_registry.hpp"
32#include "guillaume/entities/builder_base.hpp"
33#include "guillaume/ecs/entity_builder.hpp"
34#include "guillaume/ecs/entity_filler.hpp"
35
36#include "guillaume/components/bound.hpp"
37#include "guillaume/components/color.hpp"
38#include "guillaume/components/divider.hpp"
39#include "guillaume/components/line.hpp"
40#include "guillaume/components/transform.hpp"
41
42namespace guillaume::entities
43{
44
84 class Divider:
85 public ecs::EntityFiller<components::Transform, components::Bound,
86 components::Color, components::Line,
87 components::Divider>
88 {
89 public:
95
100 static constexpr float HairlineThickness =
102
106 static constexpr float BoldThickness =
108
113 class Builder: public EntityBuilderBase<Divider>
114 {
115 private:
116 utility::graphic::PoseF
117 _pose {};
118 utility::graphic::Color32Bit _color {};
119 float _length { 100.0f };
121 float _thickness { HairlineThickness };
122 float _inset { 16.0f };
123 Variant _variant { Variant::FullWidth };
125
126 public:
134 Builder(ecs::ComponentRegistry &componentRegistry,
135 ecs::EntityRegistry &entityRegistry);
136
142 std::shared_ptr<Divider> buildEntity(void) override;
143
150 void reset(void) override;
151
158 Builder &withPose(const utility::graphic::PoseF &pose);
159
166 Builder &withColor(const utility::graphic::Color32Bit &color);
167
174 Builder &withLength(float length);
175
182 Builder &withThickness(float thickness);
183
190 Builder &withInset(float inset);
191
197 Builder &withVariant(Variant variant);
198
211 std::shared_ptr<Divider> makeDivider(std::shared_ptr<Entity> parent,
212 float length, Variant variant);
213 };
214
215 public:
227 template<typename... Arguments>
228 static std::shared_ptr<Divider> create(Arguments &&...arguments)
229 {
230 std::shared_ptr<Divider> entity(
231 new Divider(std::forward<Arguments>(arguments)...));
232 return entity;
233 }
234
238 ~Divider(void) override;
239
246 Divider &setVariant(Variant variant);
247
255 Divider &setLength(float length);
256
262 Divider &setThickness(float thickness);
263
271 Divider &setBold(bool bold);
272
278 bool isBold(void) const;
279
287 Divider &setInset(float inset);
288
294 Divider &setColor(const utility::graphic::Color32Bit &color);
295
300 Variant getVariant(void) const;
301
302 private:
307 components::Divider &config(void);
308
313 const components::Divider &config(void) const;
314
320 void apply(void);
321
322 private:
334 const utility::graphic::PoseF &pose,
335 const utility::graphic::Color32Bit &color, float length,
336 float thickness, float inset, Variant variant);
337 };
338
339} // namespace guillaume::entities
State of a divider: a thin horizontal line separating content.
Definition divider.hpp:59
Variant
Which ends of the divider are inset.
Definition divider.hpp:67
static constexpr float BoldThickness
Thickness of a bold stroke, in dp.
Definition divider.hpp:73
static constexpr float HairlineThickness
Default stroke thickness, in dp.
Definition divider.hpp:70
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
The base class of a widget without children: an Entity that creates its components when it is constru...
Owns entities and gives the systems the list of entities to visit.
Builder & withLength(float length)
Set the total length.
Definition divider.cpp:72
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Construct a builder holding the defaults of reset().
Definition divider.cpp:33
Builder & withInset(float inset)
Set how much an inset end is shortened.
Definition divider.cpp:84
Builder & withVariant(Variant variant)
Choose which ends of the line are inset.
Definition divider.cpp:90
std::shared_ptr< Divider > buildEntity(void) override
Build a divider from the current configuration, without registering it or giving it a parent.
Definition divider.cpp:40
std::shared_ptr< Divider > makeDivider(std::shared_ptr< Entity > parent, float length, Variant variant)
Build a divider, register it under parent and reset the builder.
Definition divider.cpp:97
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the line starts.
Definition divider.cpp:59
Builder & withColor(const utility::graphic::Color32Bit &color)
Set the stroke color.
Definition divider.cpp:66
void reset(void) override
Restore the defaults: default pose, the OutlineVariant color of the active theme, length 100 dp,...
Definition divider.cpp:48
Builder & withThickness(float thickness)
Set the stroke thickness.
Definition divider.cpp:78
A thin horizontal line separating two pieces of content.
Definition divider.hpp:88
static std::shared_ptr< Divider > create(Arguments &&...arguments)
Build a divider without registering it in an entity registry.
Definition divider.hpp:228
static constexpr float BoldThickness
Stroke thickness of a bold divider, in dp (Paper bold).
Definition divider.hpp:106
Divider & setLength(float length)
Set the total length. Resizes the line at once.
Definition divider.cpp:155
~Divider(void) override
Destructor.
Definition divider.cpp:127
Divider & setVariant(Variant variant)
Choose which ends of the line are inset. Moves and resizes the line at once.
Definition divider.cpp:148
components::Divider::Variant Variant
Which ends of the line are shortened by the inset: FullWidth (none), Inset (leading end) or Middle (b...
Definition divider.hpp:94
bool isBold(void) const
Check whether the divider uses the bold stroke.
Definition divider.cpp:174
static constexpr float HairlineThickness
Default stroke thickness, in dp: a hairline (Paper StyleSheet.hairlineWidth on a 2x display).
Definition divider.hpp:100
Variant getVariant(void) const
Tell which ends of the line are inset.
Definition divider.cpp:193
Divider & setThickness(float thickness)
Set the stroke thickness. Restyles at once.
Definition divider.cpp:162
Divider & setBold(bool bold)
Switch between the hairline and the bold stroke (Paper bold). Restyles at once.
Definition divider.cpp:169
Divider & setColor(const utility::graphic::Color32Bit &color)
Set the stroke color. Restyles at once.
Definition divider.cpp:186
Divider & setInset(float inset)
Set how much an inset end is shortened. Moves and resizes the line at once.
Definition divider.cpp:179
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Widgets: the classes used to create entities with the right components and children.
Definition app_bar.hpp:46