guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
line.cpp
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#include "guillaume/components/line.hpp"
24
26{
28 : _thickness(2.0f)
29 , _dashed(false)
30 , _dashLength(8.0f)
31 , _gapLength(8.0f)
32 {
33 }
34
35 float Line::getThickness(void) const
36 {
37 return _thickness;
38 }
39
40 Line &Line::setThickness(float thickness)
41 {
42 if (_thickness == thickness) {
43 return *this;
44 }
45 _thickness = thickness;
46 setHasChanged(true);
47 return *this;
48 }
49
50 bool Line::isDashed(void) const
51 {
52 return _dashed;
53 }
54
55 Line &Line::setDashed(bool dashed)
56 {
57 if (_dashed == dashed) {
58 return *this;
59 }
60 _dashed = dashed;
61 setHasChanged(true);
62 return *this;
63 }
64
65 float Line::getDashLength(void) const
66 {
67 return _dashLength;
68 }
69
70 Line &Line::setDashLength(float dashLength)
71 {
72 if (_dashLength == dashLength) {
73 return *this;
74 }
75 _dashLength = dashLength;
76 setHasChanged(true);
77 return *this;
78 }
79
80 float Line::getGapLength(void) const
81 {
82 return _gapLength;
83 }
84
85 Line &Line::setGapLength(float gapLength)
86 {
87 if (_gapLength == gapLength) {
88 return *this;
89 }
90 _gapLength = gapLength;
91 setHasChanged(true);
92 return *this;
93 }
95 {
96 return _placement;
97 }
98
100 {
101 if (_placement == placement) {
102 return *this;
103 }
104 _placement = placement;
105 setHasChanged(true);
106 return *this;
107 }
108
109 Line &Line::setColor(const utility::graphic::Color32Bit &color)
110 {
111 if (_hasColor && _color == color) {
112 return *this;
113 }
114 _hasColor = true;
115 _color = color;
116 setHasChanged(true);
117 return *this;
118 }
119
121 {
122 if (!_hasColor) {
123 return *this;
124 }
125 _hasColor = false;
126 setHasChanged(true);
127 return *this;
128 }
129
130 bool Line::hasColor(void) const
131 {
132 return _hasColor;
133 }
134
135 const utility::graphic::Color32Bit &Line::getColor(void) const
136 {
137 return _color;
138 }
139
140} // namespace guillaume::components
const utility::graphic::Color32Bit & getColor(void) const
Get the color given to setColor().
Definition line.cpp:135
Line & setThickness(float thickness)
Set the thickness of the stroke.
Definition line.cpp:40
Line(void)
Construct a solid, centered stroke 2 dp thick, with 8 dp dashes and gaps ready for setDashed(),...
Definition line.cpp:27
float getDashLength(void) const
Get the length of one dash.
Definition line.cpp:65
Line & setDashed(bool dashed)
Choose between a solid and a dashed stroke.
Definition line.cpp:55
bool isDashed(void) const
Check whether the stroke is dashed.
Definition line.cpp:50
float getGapLength(void) const
Get the gap between two dashes.
Definition line.cpp:80
Line & setPlacement(Placement placement)
Set where the stroke sits across the height of the bound.
Definition line.cpp:99
Line & setDashLength(float dashLength)
Set the length of one dash. Used only when the stroke is dashed.
Definition line.cpp:70
Line & setGapLength(float gapLength)
Set the gap between two dashes. Used only when the stroke is dashed.
Definition line.cpp:85
Placement getPlacement(void) const
Get where the stroke sits across the height of the bound.
Definition line.cpp:94
Placement
Where the stroke sits across the bound height.
Definition line.hpp:67
Line & clearColor(void)
Draw the stroke in the entity's components::Color again.
Definition line.cpp:120
Line & setColor(const utility::graphic::Color32Bit &color)
Give the stroke a color of its own, used in place of the entity's components::Color.
Definition line.cpp:109
float getThickness(void) const
Get the thickness of the stroke.
Definition line.cpp:35
bool hasColor(void) const
Check whether the stroke has a color of its own.
Definition line.cpp:130
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
Definition component.cpp:32
State. Every class here is plain data attached to an entity.