From 21ff02a69331fbcd53dc93a1af9a93618225b4bf Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Wed, 18 Feb 2015 14:35:00 -0600 Subject: 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 --- gui/slidervalue.cpp | 53 ++++++++++++----------------------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) (limited to 'gui/slidervalue.cpp') diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp index 5be58dcf3..3974c37d0 100644 --- a/gui/slidervalue.cpp +++ b/gui/slidervalue.cpp @@ -70,7 +70,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) mAction = new GUIAction(node); - child = node->first_node("font"); + child = FindNode(node, "font"); if (child) { mFont = LoadAttrFont(child, "resource"); @@ -78,21 +78,16 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) } // 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 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) mHandleHoverImage = LoadAttrImage(child, "handlehover"); } - child = node->first_node("data"); + child = FindNode(node, "data"); if (child) { attr = child->first_attribute("variable"); @@ -150,37 +145,13 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) 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(); -- cgit v1.2.3