Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Leander Schulten
Lichtsteuerung
Commits
3f0a8684
Commit
3f0a8684
authored
Nov 17, 2018
by
Leander Schulten
Browse files
Missing change for the rgb_t property
parent
055c9ca1
Changes
1
Hide whitespace changes
Inline
Side-by-side
programms/types.h
View file @
3f0a8684
...
...
@@ -34,6 +34,13 @@ namespace Modules {
};
brightness_t
rgb
[
3
];
};
rgb_t
(
brightness_t
r
,
brightness_t
g
,
brightness_t
b
)
:
r
(
r
),
g
(
g
),
b
(
b
){}
rgb_t
&
operator
*
(
brightness_t
b
){
this
->
r
*=
b
/
255.
f
;
this
->
g
*=
b
/
255.
f
;
this
->
b
*=
b
/
255.
f
;
return
*
this
;
}
};
static_assert
(
sizeof
(
rgb_t
)
==
3
,
"size of rgb_t is not 3"
);
...
...
@@ -196,5 +203,44 @@ namespace Modules {
virtual
~
Named
()
=
default
;
};
/**
* Must be here, in the Property.hpp we have no rgb_t type
* @brief The RGBProperty class is a Property wrapper araoud the rgb_t type
*/
class
RGBProperty
:
public
Property
{
private:
rgb_t
value
;
RGBProperty
()
:
Property
(
Property
::
RGB
),
value
(
0
,
0
,
0
){}
void
save
(
SaveObject
&
o
)
const
override
{
auto
red
=
name
+
"_red"
;
auto
green
=
name
+
"_green"
;
auto
blue
=
name
+
"_blue"
;
o
.
saveInt
(
red
.
c_str
(),
value
.
red
);
o
.
saveInt
(
green
.
c_str
(),
value
.
green
);
o
.
saveInt
(
blue
.
c_str
(),
value
.
blue
);
}
void
load
(
const
LoadObject
&
l
)
override
{
auto
red
=
name
+
"_red"
;
auto
green
=
name
+
"_green"
;
auto
blue
=
name
+
"_blue"
;
value
.
red
=
l
.
loadInt
(
red
.
c_str
());
value
.
green
=
l
.
loadInt
(
green
.
c_str
());
value
.
blue
=
l
.
loadInt
(
blue
.
c_str
());
}
const
rgb_t
&
operator
*
()
const
{
return
value
;
}
rgb_t
&
operator
*
(){
return
value
;
}
void
setRGB
(
const
rgb_t
&
v
){
value
=
v
;
}
rgb_t
getRGB
()
const
{
return
value
;
}
};
}
#endif // TYPES_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment