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

A straight stroke across the width of the entity: a divider, an indicator, the underline of a text field. More...

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

Inheritance diagram for guillaume::components::Line:
Collaboration diagram for guillaume::components::Line:

Public Types

enum class  Placement { Center , Top , Bottom }
 Where the stroke sits across the bound height. More...

Public Member Functions

 Line (void)
 Construct a solid, centered stroke 2 dp thick, with 8 dp dashes and gaps ready for setDashed(), and no color of its own.
 ~Line (void)=default
 Default destructor for the Line component.
float getThickness (void) const
 Get the thickness of the stroke.
Line & setThickness (float thickness)
 Set the thickness of the stroke.
bool isDashed (void) const
 Check whether the stroke is dashed.
Line & setDashed (bool dashed)
 Choose between a solid and a dashed stroke.
float getDashLength (void) const
 Get the length of one dash.
Line & setDashLength (float dashLength)
 Set the length of one dash. Used only when the stroke is dashed.
float getGapLength (void) const
 Get the gap between two dashes.
Line & setGapLength (float gapLength)
 Set the gap between two dashes. Used only when the stroke is dashed.
Placement getPlacement (void) const
 Get where the stroke sits across the height of the bound.
Line & setPlacement (Placement placement)
 Set where the stroke sits across the height of the bound.
Line & setColor (const utility::graphic::Color32Bit &color)
 Give the stroke a color of its own, used in place of the entity's components::Color.
Line & clearColor (void)
 Draw the stroke in the entity's components::Color again.
bool hasColor (void) const
 Check whether the stroke has a color of its own.
const utility::graphic::Color32Bit & getColor (void) const
 Get the color given to setColor().
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

A straight stroke across the width of the entity: a divider, an indicator, the underline of a text field.

The stroke runs from the left edge to the right edge of the entity's components::Bound. The placement says where it sits across the height (middle, top edge or bottom edge); it can be solid or dashed. The stroke follows the orientation of the entity, so a rotated entity gives a vertical line.

Written by the widget systems that own a stroke (systems::Divider, systems::TextField, ...) or by the application. Read by systems::LineRender in the Render phase, with the entity's Transform, Bound and Color.

registry.getComponent<components::Line>(id)
.setThickness(1.0f)
A straight stroke across the width of the entity: a divider, an indicator, the underline of a text fi...
Definition line.hpp:62
Line & setThickness(float thickness)
Set the thickness of the stroke.
Definition line.cpp:40
Line & setPlacement(Placement placement)
Set where the stroke sits across the height of the bound.
Definition line.cpp:99
Note
The stroke is drawn in the entity's components::Color unless setColor() gives it a color of its own. The entity needs a components::Color in both cases, or systems::LineRender skips it.
The length is the width of the Bound. The height of the Bound only matters for the placement: the thickness is not limited by it.
See also
systems::LineRender, components::Bound, components::Color

Definition at line 61 of file line.hpp.

Member Enumeration Documentation

◆ Placement

Where the stroke sits across the bound height.

Enumerator
Center 

Half-way down the bound (dividers, indicators).

Top 

Inside the bound, against its top edge.

Bottom 

Inside the bound, against its bottom edge (text field underline).

Definition at line 67 of file line.hpp.

Constructor & Destructor Documentation

◆ Line()

guillaume::components::Line::Line ( void )
explicit

Construct a solid, centered stroke 2 dp thick, with 8 dp dashes and gaps ready for setDashed(), and no color of its own.

Definition at line 27 of file line.cpp.

Here is the caller graph for this function:

Member Function Documentation

◆ clearColor()

Line & guillaume::components::Line::clearColor ( void )

Draw the stroke in the entity's components::Color again.

Marks the component changed only when a color was set.

Returns
This component, for chaining.

Definition at line 120 of file line.cpp.

Here is the call graph for this function:

◆ getColor()

const utility::graphic::Color32Bit & guillaume::components::Line::getColor ( void ) const

Get the color given to setColor().

Returns
The stroke color. Check hasColor() first: when it is false this value is not the color the stroke is drawn in.

Definition at line 135 of file line.cpp.

◆ getDashLength()

float guillaume::components::Line::getDashLength ( void ) const

Get the length of one dash.

Returns
The dash length, in dp (8 by default).

Definition at line 65 of file line.cpp.

◆ getGapLength()

float guillaume::components::Line::getGapLength ( void ) const

Get the gap between two dashes.

Returns
The gap length, in dp (8 by default).

Definition at line 80 of file line.cpp.

◆ getPlacement()

Line::Placement guillaume::components::Line::getPlacement ( void ) const

Get where the stroke sits across the height of the bound.

Returns
The placement (Center by default).

Definition at line 94 of file line.cpp.

◆ getThickness()

float guillaume::components::Line::getThickness ( void ) const

Get the thickness of the stroke.

Returns
The thickness, in dp (2 by default).

Definition at line 35 of file line.cpp.

◆ hasColor()

bool guillaume::components::Line::hasColor ( void ) const

Check whether the stroke has a color of its own.

Returns
True after setColor(), false after clearColor() and by default.

Definition at line 130 of file line.cpp.

◆ isDashed()

bool guillaume::components::Line::isDashed ( void ) const

Check whether the stroke is dashed.

Returns
True for dashes, false (the default) for a solid stroke.

Definition at line 50 of file line.cpp.

◆ setColor()

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

Give the stroke a color of its own, used in place of the entity's components::Color.

This lets one entity carry both a fill (components::Color) and a stroke of another color, such as a filled text field and its underline. Marks the component changed unless the same color was already set.

Parameters
colorThe stroke color (RGBA).
Returns
This component, for chaining.

Definition at line 109 of file line.cpp.

Here is the call graph for this function:

◆ setDashed()

Line & guillaume::components::Line::setDashed ( bool dashed)

Choose between a solid and a dashed stroke.

Marks the component changed only when the value differs.

Parameters
dashedTrue to draw dashes of getDashLength() separated by gaps of getGapLength().
Returns
This component, for chaining.

Definition at line 55 of file line.cpp.

Here is the call graph for this function:

◆ setDashLength()

Line & guillaume::components::Line::setDashLength ( float dashLength)

Set the length of one dash. Used only when the stroke is dashed.

Marks the component changed only when the value differs.

Parameters
dashLengthThe dash length, in dp; 0 or less draws a solid stroke.
Returns
This component, for chaining.

Definition at line 70 of file line.cpp.

Here is the call graph for this function:

◆ setGapLength()

Line & guillaume::components::Line::setGapLength ( float gapLength)

Set the gap between two dashes. Used only when the stroke is dashed.

Marks the component changed only when the value differs.

Parameters
gapLengthThe gap length, in dp; a negative value counts as 0.
Returns
This component, for chaining.

Definition at line 85 of file line.cpp.

Here is the call graph for this function:

◆ setPlacement()

Line & guillaume::components::Line::setPlacement ( Placement placement)

Set where the stroke sits across the height of the bound.

A Top or Bottom stroke is also drawn slightly in front of the entity, so it shows over a fill drawn by the same entity. Marks the component changed only when the value differs.

Parameters
placementThe placement of the stroke.
Returns
This component, for chaining.

Definition at line 99 of file line.cpp.

Here is the call graph for this function:

◆ setThickness()

Line & guillaume::components::Line::setThickness ( float thickness)

Set the thickness of the stroke.

Marks the component changed only when the value differs.

Parameters
thicknessThe thickness, in dp.
Returns
This component, for chaining.

Definition at line 40 of file line.cpp.

Here is the call graph for this function:

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