3
GUIAlphaElement::GUIAlphaElement(const std::string &callback) : GUIRectangle(callback)
5
setColor(225.0f, 225.0f, 225.0f);
11
bool GUIAlphaElement::loadXMLSettings(const TiXmlElement *element)
16
setAlphaFadeScale(XMLArbiter::fillComponents1f(element, "alphaFadeScale", alphaFadeScale));
17
setMinAlpha(XMLArbiter::fillComponents1f(element, "minAlpha", minAlpha));
19
for(const TiXmlElement *child = element->FirstChildElement();
21
child = child->NextSiblingElement() )
23
const char * value = child->Value();
27
if(!strcmp(value, "Color"))
28
XMLArbiter::fillComponents4f(child, color);
30
if(!strcmp(value, "Text"))
31
label.loadXMLSettings(child);
35
setColor(color.x, color.y, color.z);
36
return GUIRectangle::loadXMLSettings(element);
39
void GUIAlphaElement::setColor(const Tuple3f& color)
41
setColor(color.x, color.y, color.z);
44
void GUIAlphaElement::setColor(float r, float g, float b)
46
color.set(clamp(r, 0.0f, 255.0f),
47
clamp(g, 0.0f, 255.0f),
48
clamp(b, 0.0f, 255.0f),
49
clamp(color.w, 0.0f, 1.0f));
51
color.x /= (color.x > 1.0) ? 255.0f : 1.0f;
52
color.y /= (color.y > 1.0) ? 255.0f : 1.0f;
53
color.z /= (color.z > 1.0) ? 255.0f : 1.0f;
56
const Tuple4f &GUIAlphaElement::getColor()
61
void GUIAlphaElement::setLabelString(const std::string &labelArg)
66
GUIText * GUIAlphaElement::getLabel()
71
const std::string &GUIAlphaElement::getLabelString()
73
return label.getString();
76
void GUIAlphaElement::setAlpha(float alphaArg)
78
color.w = clamp(alphaArg, minAlpha, 1.0f);
81
float GUIAlphaElement::getAlpha()
86
void GUIAlphaElement::setAlphaFadeScale(float duration)
88
alphaFadeScale = clamp(duration, 0.0f, 10.0f);
91
float GUIAlphaElement::getAlphaFadeScale()
93
return alphaFadeScale;
96
void GUIAlphaElement::setMinAlpha(float minAlphaArg)
98
minAlpha = clamp(minAlphaArg, 0.2f, 1.0f);
101
float GUIAlphaElement::getMinAlpha()
106
void GUIAlphaElement::modifyCurrentAlpha(float clockTick)
108
if(!mouseOver && !pressed)
109
setAlpha(color.w - clockTick * alphaFadeScale);
111
setAlpha(color.w + clockTick * alphaFadeScale);