- don't clamp when setting, but on request (allows to set an invalid color)
- adapt constness - remove leftover debugging line
This commit is contained in:
parent
387888862c
commit
275a9a5cc0
2 changed files with 11 additions and 11 deletions
|
@ -666,7 +666,6 @@ FGDialog::setupGroup (puGroup * group, SGPropertyNode * props,
|
||||||
void
|
void
|
||||||
FGDialog::setColor(puObject * object, SGPropertyNode * props, int which)
|
FGDialog::setColor(puObject * object, SGPropertyNode * props, int which)
|
||||||
{
|
{
|
||||||
string label = props->getStringValue("label", "--");
|
|
||||||
string type = props->getName();
|
string type = props->getName();
|
||||||
string watch = "button";
|
string watch = "button";
|
||||||
FGColor c(_gui->getColor("background"));
|
FGColor c(_gui->getColor("background"));
|
||||||
|
@ -694,6 +693,7 @@ FGDialog::setColor(puObject * object, SGPropertyNode * props, int which)
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
c.clear();
|
c.clear();
|
||||||
c.setAlpha(1.0);
|
c.setAlpha(1.0);
|
||||||
|
|
||||||
dirty |= c.merge(_gui->getColor(type + '-' + pucol[i].name));
|
dirty |= c.merge(_gui->getColor(type + '-' + pucol[i].name));
|
||||||
if (which & pucol[i].mask)
|
if (which & pucol[i].mask)
|
||||||
dirty |= c.merge(props->getNode("color"));
|
dirty |= c.merge(props->getNode("color"));
|
||||||
|
|
|
@ -216,7 +216,7 @@ public:
|
||||||
bool set(const SGPropertyNode *prop) { clear(); return merge(prop); };
|
bool set(const SGPropertyNode *prop) { clear(); return merge(prop); };
|
||||||
bool set(const FGColor& color) { clear(); return merge(color); }
|
bool set(const FGColor& color) { clear(); return merge(color); }
|
||||||
bool set(float r, float g, float b, float a = 1.0f) {
|
bool set(float r, float g, float b, float a = 1.0f) {
|
||||||
_red = clamp(r), _green = clamp(g), _blue = clamp(b), _alpha = clamp(a);
|
_red = r, _green = g, _blue = b, _alpha = a;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool isValid() const {
|
bool isValid() const {
|
||||||
|
@ -228,21 +228,21 @@ public:
|
||||||
<< ", blue=" << _blue << ", alpha=" << _alpha << std::endl;
|
<< ", blue=" << _blue << ", alpha=" << _alpha << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setRed(float red) { _red = clamp(red); }
|
inline void setRed(float red) { _red = red; }
|
||||||
inline void setGreen(float green) { _green = clamp(green); }
|
inline void setGreen(float green) { _green = green; }
|
||||||
inline void setBlue(float blue) { _blue = clamp(blue); }
|
inline void setBlue(float blue) { _blue = blue; }
|
||||||
inline void setAlpha(float alpha) { _alpha = clamp(alpha); }
|
inline void setAlpha(float alpha) { _alpha = alpha; }
|
||||||
|
|
||||||
inline float red() const { return _red; }
|
inline float red() const { return clamp(_red); }
|
||||||
inline float green() const { return _green; }
|
inline float green() const { return clamp(_green); }
|
||||||
inline float blue() const { return _blue; }
|
inline float blue() const { return clamp(_blue); }
|
||||||
inline float alpha() const { return _alpha; }
|
inline float alpha() const { return clamp(_alpha); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float _red, _green, _blue, _alpha;
|
float _red, _green, _blue, _alpha;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float clamp(float f) { return f < 0.0 ? 0.0 : f > 1.0 ? 1.0 : f; }
|
float clamp(float f) const { return f < 0.0 ? 0.0 : f > 1.0 ? 1.0 : f; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue