- clear alpha like r/g/b
- fix warning - replace tabs by 4 spaces, according to the style of the file
This commit is contained in:
parent
f65eb6e3d5
commit
f3e88fc05d
2 changed files with 38 additions and 38 deletions
|
@ -369,7 +369,7 @@ FGDialog::display (SGPropertyNode * props)
|
||||||
LayoutWidget wid(props);
|
LayoutWidget wid(props);
|
||||||
|
|
||||||
puFont *fnt = _gui->getDefaultFont();
|
puFont *fnt = _gui->getDefaultFont();
|
||||||
wid.setDefaultFont(fnt, fnt->getPointSize());
|
wid.setDefaultFont(fnt, int(fnt->getPointSize());
|
||||||
|
|
||||||
int pw=0, ph=0;
|
int pw=0, ph=0;
|
||||||
if(!userw || !userh)
|
if(!userw || !userh)
|
||||||
|
|
|
@ -196,52 +196,52 @@ private:
|
||||||
|
|
||||||
class FGColor {
|
class FGColor {
|
||||||
public:
|
public:
|
||||||
FGColor() { clear(); }
|
FGColor() { clear(); }
|
||||||
FGColor(float r, float g, float b, float a = 1.0f) { set(r, g, b, a); }
|
FGColor(float r, float g, float b, float a = 1.0f) { set(r, g, b, a); }
|
||||||
FGColor(const SGPropertyNode *prop) { set(prop); }
|
FGColor(const SGPropertyNode *prop) { set(prop); }
|
||||||
|
|
||||||
FGColor& operator=(const FGColor& c) {
|
FGColor& operator=(const FGColor& c) {
|
||||||
_red = c._red;
|
_red = c._red;
|
||||||
_green = c._green;
|
_green = c._green;
|
||||||
_blue = c._blue;
|
_blue = c._blue;
|
||||||
_alpha = c._alpha;
|
_alpha = c._alpha;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void clear() { _red = _green = _blue = -1.0f; _alpha = 1.0f; }
|
inline void clear() { _red = _green = _blue = _alpha = -1.0f; }
|
||||||
// merges in non-negative components from property with children <red> etc.
|
// merges in non-negative components from property with children <red> etc.
|
||||||
void merge(const SGPropertyNode *prop);
|
void merge(const SGPropertyNode *prop);
|
||||||
void merge(const FGColor& color);
|
void merge(const FGColor& color);
|
||||||
|
|
||||||
void set(const SGPropertyNode *prop) { clear(); merge(prop); };
|
void set(const SGPropertyNode *prop) { clear(); merge(prop); };
|
||||||
void set(const FGColor& color) { clear(); merge(color); }
|
void set(const FGColor& color) { clear(); merge(color); }
|
||||||
void set(float r, float g, float b, float a = 1.0f) {
|
void set(float r, float g, float b, float a = 1.0f) {
|
||||||
_red = clamp(r), _green = clamp(g), _blue = clamp(b), _alpha = clamp(a);
|
_red = clamp(r), _green = clamp(g), _blue = clamp(b), _alpha = clamp(a);
|
||||||
}
|
}
|
||||||
bool isValid() const {
|
bool isValid() const {
|
||||||
return _red >= 0.0 && _green >= 0.0 && _blue >= 0.0
|
return _red >= 0.0 && _green >= 0.0 && _blue >= 0.0
|
||||||
&& _alpha >= 0.0;
|
&& _alpha >= 0.0;
|
||||||
}
|
}
|
||||||
void print() const {
|
void print() const {
|
||||||
std::cerr << "red=" << _red << ", green=" << _green
|
std::cerr << "red=" << _red << ", green=" << _green
|
||||||
<< ", 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 = clamp(red); }
|
||||||
inline void setGreen(float green) { _green = clamp(green); }
|
inline void setGreen(float green) { _green = clamp(green); }
|
||||||
inline void setBlue(float blue) { _blue = clamp(blue); }
|
inline void setBlue(float blue) { _blue = clamp(blue); }
|
||||||
inline void setAlpha(float alpha) { _alpha = clamp(alpha); }
|
inline void setAlpha(float alpha) { _alpha = clamp(alpha); }
|
||||||
|
|
||||||
inline float red() const { return _red; }
|
inline float red() const { return _red; }
|
||||||
inline float green() const { return _green; }
|
inline float green() const { return _green; }
|
||||||
inline float blue() const { return _blue; }
|
inline float blue() const { return _blue; }
|
||||||
inline float alpha() const { return _alpha; }
|
inline float alpha() const { return _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) { return f < 0.0 ? 0.0 : f > 1.0 ? 1.0 : f; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue