guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::components::Borders Class Reference

Corner radii and outline stroke of a rectangular entity. More...

#include <headers/guillaume/components/borders.hpp>

Inheritance diagram for guillaume::components::Borders:
Collaboration diagram for guillaume::components::Borders:

Public Types

using BorderRadius = float
 A corner radius, in dp.

Public Member Functions

 Borders (void)
 Construct square corners with no stroke: every radius 0, a transparent color and a width of 0.
 ~Borders (void)=default
 Default destructor for the Borders component.
BorderRadius getTopLeftRadius (void) const
 Get the radius of the top-left corner.
Borders & setTopLeftRadius (BorderRadius radius)
 Set the radius of the top-left corner.
BorderRadius getTopRightRadius (void) const
 Get the radius of the top-right corner.
Borders & setTopRightRadius (BorderRadius radius)
 Set the radius of the top-right corner.
BorderRadius getBottomRightRadius (void) const
 Get the radius of the bottom-right corner.
Borders & setBottomRightRadius (BorderRadius radius)
 Set the radius of the bottom-right corner.
BorderRadius getBottomLeftRadius (void) const
 Get the radius of the bottom-left corner.
Borders & setBottomLeftRadius (BorderRadius radius)
 Set the radius of the bottom-left corner.
Borders & setBorderRadius (BorderRadius radius)
 Set the same radius on the four corners.
Borders & setColor (const utility::graphic::Color32Bit &color)
 Set the color of the stroke.
utility::graphic::Color32Bit getColor (void) const
 Get the color of the stroke.
Borders & setWidth (float width)
 Set the width of the stroke painted by systems::RectangleRender.
float getWidth (void) const
 Get the width of the stroke.
bool hasStroke (void) const
 Check whether a visible stroke must be painted.
bool operator== (const Borders &other) const
 Compare the four radii, the stroke color and the stroke width. The changed flag is not compared.
bool operator!= (const Borders &other) const
 Opposite of operator==.
bool operator< (const Borders &other) const
 Order borders so they can be used as a key in an ordered container.
Public Member Functions inherited from guillaume::ecs::Component
bool hasChanged (void) const
 Tell whether a value of the component changed since the flags were last reset (the end of the previous frame).
void setHasChanged (bool hasChanged)
 Raise or lower the changed flag.
 Component (void)=default
 Create a component that is not marked as changed.
virtual ~Component (void)=default
 Virtual destructor, so components can be destroyed through the base class.

Detailed Description

Corner radii and outline stroke of a rectangular entity.

systems::RectangleRender (Render phase) reads it, with Transform, Bound and Color, to draw the entity: the bound filled with the entity's components::Color, its corners rounded, and, when hasStroke() is true, an outline of the stroke width and color drawn inside the bound. An entity needs this component, even left at its defaults, to be drawn as a rectangle. systems::FocusRingRender reads the radii too, so the focus ring follows the corners.

Written by the application for a plain surface and by the widget systems for their widgets, which usually take the radius from a theme shape token.

registry.getComponent<components::Borders>(id)
.setWidth(1.0f)
.setColor(utility::graphic::Color32Bit(121, 116, 126, 255));
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 & setBorderRadius(BorderRadius radius)
Set the same radius on the four corners.
Definition borders.cpp:99
Borders & setColor(const utility::graphic::Color32Bit &color)
Set the color of the stroke.
Definition borders.cpp:107
Note
The four radii are stored separately, but systems::RectangleRender draws every corner with their average, clamped to half the smaller side of the bound. Use setBorderRadius() unless another reader needs distinct values.
Defaults: square corners, transparent color, width 0, so no stroke.
See also
systems::RectangleRender, components::Color, components::Bound

Definition at line 66 of file borders.hpp.

Member Typedef Documentation

◆ BorderRadius

A corner radius, in dp.

Definition at line 69 of file borders.hpp.

Constructor & Destructor Documentation

◆ Borders()

guillaume::components::Borders::Borders ( void )
explicit

Construct square corners with no stroke: every radius 0, a transparent color and a width of 0.

Definition at line 29 of file borders.cpp.

Here is the caller graph for this function:

Member Function Documentation

◆ getBottomLeftRadius()

Borders::BorderRadius guillaume::components::Borders::getBottomLeftRadius ( void ) const

Get the radius of the bottom-left corner.

Returns
The radius, in dp (0 for a square corner).

Definition at line 84 of file borders.cpp.

Here is the caller graph for this function:

◆ getBottomRightRadius()

Borders::BorderRadius guillaume::components::Borders::getBottomRightRadius ( void ) const

Get the radius of the bottom-right corner.

Returns
The radius, in dp (0 for a square corner).

Definition at line 69 of file borders.cpp.

Here is the caller graph for this function:

◆ getColor()

utility::graphic::Color32Bit guillaume::components::Borders::getColor ( void ) const

Get the color of the stroke.

Returns
A copy of the stroke color (RGBA).

Definition at line 117 of file borders.cpp.

◆ getTopLeftRadius()

Borders::BorderRadius guillaume::components::Borders::getTopLeftRadius ( void ) const

Get the radius of the top-left corner.

Returns
The radius, in dp (0 for a square corner).

Definition at line 39 of file borders.cpp.

Here is the caller graph for this function:

◆ getTopRightRadius()

Borders::BorderRadius guillaume::components::Borders::getTopRightRadius ( void ) const

Get the radius of the top-right corner.

Returns
The radius, in dp (0 for a square corner).

Definition at line 54 of file borders.cpp.

Here is the caller graph for this function:

◆ getWidth()

float guillaume::components::Borders::getWidth ( void ) const

Get the width of the stroke.

Returns
The stroke width, in dp (0 when no stroke is painted).

Definition at line 135 of file borders.cpp.

◆ hasStroke()

bool guillaume::components::Borders::hasStroke ( void ) const

Check whether a visible stroke must be painted.

Returns
True when the width is above 0 and the color alpha is not 0.

Definition at line 140 of file borders.cpp.

◆ operator!=()

bool guillaume::components::Borders::operator!= ( const Borders & other) const

Opposite of operator==.

Parameters
otherThe borders to compare with.
Returns
True when a radius, the stroke color or the stroke width differs.

Definition at line 168 of file borders.cpp.

Here is the call graph for this function:

◆ operator<()

bool guillaume::components::Borders::operator< ( const Borders & other) const

Order borders so they can be used as a key in an ordered container.

Compares, in this order, the top-left, top-right, bottom-right and bottom-left radii, then the stroke color. The stroke width is not compared: two borders that differ only by their width are unequal for operator== but neither is less than the other.

Parameters
otherThe borders to compare with.
Returns
True when this one sorts before other.

Definition at line 173 of file borders.cpp.

Here is the call graph for this function:

◆ operator==()

bool guillaume::components::Borders::operator== ( const Borders & other) const

Compare the four radii, the stroke color and the stroke width. The changed flag is not compared.

Parameters
otherThe borders to compare with.
Returns
True when every value is equal.

Definition at line 145 of file borders.cpp.

Here is the call graph for this function:

◆ setBorderRadius()

Borders & guillaume::components::Borders::setBorderRadius ( BorderRadius radius)

Set the same radius on the four corners.

Marks the component changed when at least one corner differs. A radius of half the smaller side of the bound, or more, gives a pill or a circle.

Parameters
radiusThe radius, in dp (0 for square corners).
Returns
This component, for chaining.

Definition at line 99 of file borders.cpp.

Here is the call graph for this function:

◆ setBottomLeftRadius()

Borders & guillaume::components::Borders::setBottomLeftRadius ( BorderRadius radius)

Set the radius of the bottom-left corner.

Marks the component changed only when the radius differs.

Parameters
radiusThe radius, in dp (0 for a square corner).
Returns
This component, for chaining.

Definition at line 89 of file borders.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBottomRightRadius()

Borders & guillaume::components::Borders::setBottomRightRadius ( BorderRadius radius)

Set the radius of the bottom-right corner.

Marks the component changed only when the radius differs.

Parameters
radiusThe radius, in dp (0 for a square corner).
Returns
This component, for chaining.

Definition at line 74 of file borders.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColor()

Borders & guillaume::components::Borders::setColor ( const utility::graphic::Color32Bit & color)

Set the color of the stroke.

Marks the component changed only when the color differs. The stroke is visible only when the width is also above 0.

Parameters
colorThe stroke color (RGBA); an alpha of 0 hides the stroke.
Returns
This component, for chaining.

Definition at line 107 of file borders.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTopLeftRadius()

Borders & guillaume::components::Borders::setTopLeftRadius ( BorderRadius radius)

Set the radius of the top-left corner.

Marks the component changed only when the radius differs.

Parameters
radiusThe radius, in dp (0 for a square corner).
Returns
This component, for chaining.

Definition at line 44 of file borders.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTopRightRadius()

Borders & guillaume::components::Borders::setTopRightRadius ( BorderRadius radius)

Set the radius of the top-right corner.

Marks the component changed only when the radius differs.

Parameters
radiusThe radius, in dp (0 for a square corner).
Returns
This component, for chaining.

Definition at line 59 of file borders.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWidth()

Borders & guillaume::components::Borders::setWidth ( float width)

Set the width of the stroke painted by systems::RectangleRender.

The stroke is drawn inside the bound, following the corner radius. A width of 0 (the default) disables the stroke. Marks the component changed only when the width differs.

Parameters
widthThe stroke width, in dp; must not be negative.
Returns
This component, for chaining.
Exceptions
std::invalid_argumentIf width is negative.

Definition at line 122 of file borders.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: