]> git.mxchange.org Git - flightgear.git/blob - src/GUI/FGColor.cxx
Merge branch 'merge-requests/1555' into next
[flightgear.git] / src / GUI / FGColor.cxx
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include "FGColor.hxx"
6
7 #include <iostream>
8
9 #include <simgear/props/props.hxx>
10 #include <simgear/math/SGMath.hxx>
11
12 ////////////////////////////////////////////////////////////////////////
13 // FGColor class.
14 ////////////////////////////////////////////////////////////////////////
15
16 void
17 FGColor::print() const {
18     std::cerr << "red=" << _red << ", green=" << _green
19               << ", blue=" << _blue << ", alpha=" << _alpha << std::endl;
20 }
21
22 bool
23 FGColor::merge(const SGPropertyNode *node)
24 {
25     if (!node)
26         return false;
27
28     bool dirty = false;
29     const SGPropertyNode * n;
30     if ((n = node->getNode("red")))
31         _red = n->getFloatValue(), dirty = true;
32     if ((n = node->getNode("green")))
33         _green = n->getFloatValue(), dirty = true;
34     if ((n = node->getNode("blue")))
35         _blue = n->getFloatValue(), dirty = true;
36     if ((n = node->getNode("alpha")))
37         _alpha = n->getFloatValue(), dirty = true;
38     return dirty;
39 }
40
41 bool
42 FGColor::merge(const FGColor *color)
43 {
44     bool dirty = false;
45     if (color && color->_red >= 0.0)
46         _red = color->_red, dirty = true;
47     if (color && color->_green >= 0.0)
48         _green = color->_green, dirty = true;
49     if (color && color->_blue >= 0.0)
50         _blue = color->_blue, dirty = true;
51     if (color && color->_alpha >= 0.0)
52         _alpha = color->_alpha, dirty = true;
53     return dirty;
54 }
55