From: mfranz Date: Tue, 12 Jul 2005 16:48:16 +0000 (+0000) Subject: - don't clamp when setting, but on request (allows to set an invalid color) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=275a9a5cc056300330fe33a6842deb73c1c677e7;p=flightgear.git - don't clamp when setting, but on request (allows to set an invalid color) - adapt constness - remove leftover debugging line --- diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index f49d990d5..8d8f14185 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -666,7 +666,6 @@ FGDialog::setupGroup (puGroup * group, SGPropertyNode * props, void FGDialog::setColor(puObject * object, SGPropertyNode * props, int which) { - string label = props->getStringValue("label", "--"); string type = props->getName(); string watch = "button"; FGColor c(_gui->getColor("background")); @@ -694,6 +693,7 @@ FGDialog::setColor(puObject * object, SGPropertyNode * props, int which) bool dirty = false; c.clear(); c.setAlpha(1.0); + dirty |= c.merge(_gui->getColor(type + '-' + pucol[i].name)); if (which & pucol[i].mask) dirty |= c.merge(props->getNode("color")); diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index 6bc5cd7f9..e0c46837f 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -216,7 +216,7 @@ public: bool set(const SGPropertyNode *prop) { clear(); return merge(prop); }; bool set(const FGColor& color) { clear(); return merge(color); } 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; } bool isValid() const { @@ -228,21 +228,21 @@ public: << ", blue=" << _blue << ", alpha=" << _alpha << std::endl; } - inline void setRed(float red) { _red = clamp(red); } - inline void setGreen(float green) { _green = clamp(green); } - inline void setBlue(float blue) { _blue = clamp(blue); } - inline void setAlpha(float alpha) { _alpha = clamp(alpha); } + inline void setRed(float red) { _red = red; } + inline void setGreen(float green) { _green = green; } + inline void setBlue(float blue) { _blue = blue; } + inline void setAlpha(float alpha) { _alpha = alpha; } - inline float red() const { return _red; } - inline float green() const { return _green; } - inline float blue() const { return _blue; } - inline float alpha() const { return _alpha; } + inline float red() const { return clamp(_red); } + inline float green() const { return clamp(_green); } + inline float blue() const { return clamp(_blue); } + inline float alpha() const { return clamp(_alpha); } protected: float _red, _green, _blue, _alpha; 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; } };