23#include "guillaume/components/borders.hpp"
30 : _topLeftRadius(0.0f)
31 , _topRightRadius(0.0f)
32 , _bottomRightRadius(0.0f)
33 , _bottomLeftRadius(0.0f)
41 return _topLeftRadius;
46 if (_topLeftRadius == radius) {
49 _topLeftRadius = radius;
56 return _topRightRadius;
61 if (_topRightRadius == radius) {
64 _topRightRadius = radius;
71 return _bottomRightRadius;
76 if (_bottomRightRadius == radius) {
79 _bottomRightRadius = radius;
86 return _bottomLeftRadius;
91 if (_bottomLeftRadius == radius) {
94 _bottomLeftRadius = radius;
109 if (_color == color) {
125 throw std::invalid_argument(
"Border width must be non-negative");
127 if (_width == width) {
142 return _width > 0.0f && _color.getAlpha() > 0;
147 if (_topLeftRadius != other._topLeftRadius) {
150 if (_topRightRadius != other._topRightRadius) {
153 if (_bottomRightRadius != other._bottomRightRadius) {
156 if (_bottomLeftRadius != other._bottomLeftRadius) {
159 if (_color != other._color) {
162 if (_width != other._width) {
170 return !(*
this == other);
175 if (_topLeftRadius != other._topLeftRadius) {
176 return _topLeftRadius < other._topLeftRadius;
178 if (_topRightRadius != other._topRightRadius) {
179 return _topRightRadius < other._topRightRadius;
181 if (_bottomRightRadius != other._bottomRightRadius) {
182 return _bottomRightRadius < other._bottomRightRadius;
184 if (_bottomLeftRadius != other._bottomLeftRadius) {
185 return _bottomLeftRadius < other._bottomLeftRadius;
187 if (_color != other._color) {
188 return _color < other._color;
Corner radii and outline stroke of a rectangular entity.
Borders & setWidth(float width)
Set the width of the stroke painted by systems::RectangleRender.
Borders & setTopLeftRadius(BorderRadius radius)
Set the radius of the top-left corner.
BorderRadius getBottomLeftRadius(void) const
Get the radius of the bottom-left corner.
float BorderRadius
A corner radius, in dp.
bool operator!=(const Borders &other) const
Opposite of operator==.
Borders & setBottomLeftRadius(BorderRadius radius)
Set the radius of the bottom-left corner.
float getWidth(void) const
Get the width of the stroke.
Borders & setBorderRadius(BorderRadius radius)
Set the same radius on the four corners.
Borders & setTopRightRadius(BorderRadius radius)
Set the radius of the top-right corner.
bool operator==(const Borders &other) const
Compare the four radii, the stroke color and the stroke width. The changed flag is not compared.
BorderRadius getBottomRightRadius(void) const
Get the radius of the bottom-right corner.
Borders & setColor(const utility::graphic::Color32Bit &color)
Set the color of the stroke.
BorderRadius getTopLeftRadius(void) const
Get the radius of the top-left corner.
Borders & setBottomRightRadius(BorderRadius radius)
Set the radius of the bottom-right corner.
Borders(void)
Construct square corners with no stroke: every radius 0, a transparent color and a width of 0.
utility::graphic::Color32Bit getColor(void) const
Get the color of the stroke.
bool operator<(const Borders &other) const
Order borders so they can be used as a key in an ordered container.
bool hasStroke(void) const
Check whether a visible stroke must be painted.
BorderRadius getTopRightRadius(void) const
Get the radius of the top-right corner.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
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.