guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
borders.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 <cmath>
26#include <ostream>
27
28#include <utility/graphic/color.hpp>
29
30#include "guillaume/ecs/component.hpp"
31
33{
34
66 class Borders: public ecs::Component
67 {
68 public:
69 using BorderRadius = float;
70
71 private:
72 BorderRadius _topLeftRadius;
73 BorderRadius _topRightRadius;
74 BorderRadius _bottomRightRadius;
76 BorderRadius _bottomLeftRadius;
77 utility::graphic::Color32Bit _color;
78 float _width;
79
80 public:
85 explicit Borders(void);
86
90 ~Borders(void) = default;
91
97
107
113
123
129
139
145
155
167
178 Borders &setColor(const utility::graphic::Color32Bit &color);
179
184 utility::graphic::Color32Bit getColor(void) const;
185
198 Borders &setWidth(float width);
199
204 float getWidth(void) const;
205
211 bool hasStroke(void) const;
212
219 bool operator==(const Borders &other) const;
220
227 bool operator!=(const Borders &other) const;
228
241 bool operator<(const Borders &other) const;
242 };
243
254 std::ostream &operator<<(std::ostream &stream, const Borders &borders);
255
256} // namespace guillaume::components
Corner radii and outline stroke of a rectangular entity.
Definition borders.hpp:67
Borders & setWidth(float width)
Set the width of the stroke painted by systems::RectangleRender.
Definition borders.cpp:122
Borders & setTopLeftRadius(BorderRadius radius)
Set the radius of the top-left corner.
Definition borders.cpp:44
BorderRadius getBottomLeftRadius(void) const
Get the radius of the bottom-left corner.
Definition borders.cpp:84
float BorderRadius
A corner radius, in dp.
Definition borders.hpp:69
bool operator!=(const Borders &other) const
Opposite of operator==.
Definition borders.cpp:168
Borders & setBottomLeftRadius(BorderRadius radius)
Set the radius of the bottom-left corner.
Definition borders.cpp:89
float getWidth(void) const
Get the width of the stroke.
Definition borders.cpp:135
Borders & setBorderRadius(BorderRadius radius)
Set the same radius on the four corners.
Definition borders.cpp:99
Borders & setTopRightRadius(BorderRadius radius)
Set the radius of the top-right corner.
Definition borders.cpp:59
bool operator==(const Borders &other) const
Compare the four radii, the stroke color and the stroke width. The changed flag is not compared.
Definition borders.cpp:145
BorderRadius getBottomRightRadius(void) const
Get the radius of the bottom-right corner.
Definition borders.cpp:69
Borders & setColor(const utility::graphic::Color32Bit &color)
Set the color of the stroke.
Definition borders.cpp:107
BorderRadius getTopLeftRadius(void) const
Get the radius of the top-left corner.
Definition borders.cpp:39
Borders & setBottomRightRadius(BorderRadius radius)
Set the radius of the bottom-right corner.
Definition borders.cpp:74
Borders(void)
Construct square corners with no stroke: every radius 0, a transparent color and a width of 0.
Definition borders.cpp:29
utility::graphic::Color32Bit getColor(void) const
Get the color of the stroke.
Definition borders.cpp:117
~Borders(void)=default
Default destructor for the Borders component.
bool operator<(const Borders &other) const
Order borders so they can be used as a key in an ordered container.
Definition borders.cpp:173
bool hasStroke(void) const
Check whether a visible stroke must be painted.
Definition borders.cpp:140
BorderRadius getTopRightRadius(void) const
Get the radius of the top-right corner.
Definition borders.cpp:54
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
State. Every class here is plain data attached to an entity.
std::ostream & operator<<(std::ostream &stream, const Borders &borders)
Print the four corner radii, for logs and test failures.
Definition borders.cpp:193