GUI: Support styles in xml to reduce xml file size
Also allow sliders to have their own text label instead of
requiring a whole separate text object for the label in the xml.
Change-Id: I6e314efb4bb454d496555ff7e003d743063a1308
diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp
index 5be58dc..3974c37 100644
--- a/gui/slidervalue.cpp
+++ b/gui/slidervalue.cpp
@@ -70,7 +70,7 @@
mAction = new GUIAction(node);
- child = node->first_node("font");
+ child = FindNode(node, "font");
if (child)
{
mFont = LoadAttrFont(child, "resource");
@@ -78,21 +78,16 @@
}
// Load the placement
- LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW);
+ LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW);
- child = node->first_node("colors");
+ child = FindNode(node, "colors");
if (child)
{
- attr = child->first_attribute("line");
- if (attr)
- ConvertStrToColor(attr->value(), &mLineColor);
-
- attr = child->first_attribute("slider");
- if (attr)
- ConvertStrToColor(attr->value(), &mSliderColor);
+ mLineColor = LoadAttrColor(child, "line");
+ mSliderColor = LoadAttrColor(child, "slider");
}
- child = node->first_node("resource");
+ child = FindNode(node, "resource");
if (child)
{
mBackgroundImage = LoadAttrImage(child, "background");
@@ -100,7 +95,7 @@
mHandleHoverImage = LoadAttrImage(child, "handlehover");
}
- child = node->first_node("data");
+ child = FindNode(node, "data");
if (child)
{
attr = child->first_attribute("variable");
@@ -150,37 +145,13 @@
mChangeOnDrag = atoi(attr->value());
}
- child = node->first_node("dimensions");
+ child = FindNode(node, "dimensions");
if (child)
{
- attr = child->first_attribute("lineh");
- if (attr)
- {
- string parsevalue = gui_parse_text(attr->value());
- mLineH = scale_theme_y(atoi(parsevalue.c_str()));
- }
-
- attr = child->first_attribute("linepadding");
- if (attr)
- {
- string parsevalue = gui_parse_text(attr->value());
- mPadding = scale_theme_x(atoi(parsevalue.c_str()));
- mLinePadding = mPadding;
- }
-
- attr = child->first_attribute("sliderw");
- if (attr)
- {
- string parsevalue = gui_parse_text(attr->value());
- mSliderW = scale_theme_x(atoi(parsevalue.c_str()));
- }
-
- attr = child->first_attribute("sliderh");
- if (attr)
- {
- string parsevalue = gui_parse_text(attr->value());
- mSliderH = scale_theme_y(atoi(parsevalue.c_str()));
- }
+ mLineH = LoadAttrIntScaleY(child, "lineh", mLineH);
+ mLinePadding = LoadAttrIntScaleX(child, "linepadding", mLinePadding);
+ mSliderW = LoadAttrIntScaleX(child, "sliderw", mSliderW);
+ mSliderH = LoadAttrIntScaleY(child, "sliderh", mSliderH);
}
mFontHeight = mFont->GetHeight();