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/scrolllist.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'gui/scrolllist.cpp') diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp index 8d9ab42f2..4b772d45d 100644 --- a/gui/scrolllist.cpp +++ b/gui/scrolllist.cpp @@ -65,18 +65,9 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) mLastHeaderValue = gui_parse_text(mHeaderText); mHeaderIsStatic = (mLastHeaderValue == mHeaderText); - memset(&mHighlightColor, 0, sizeof(COLOR)); - child = node->first_node("highlight"); - if (child) { - attr = child->first_attribute("color"); - if (attr) { - hasHighlightColor = true; - std::string color = attr->value(); - ConvertStrToColor(color, &mHighlightColor); - } - } + mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlightColor); - child = node->first_node("background"); + child = FindNode(node, "background"); if (child) { mBackground = LoadAttrImage(child, "resource"); @@ -84,11 +75,11 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) } // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); // Load the font, and possibly override the color - child = node->first_node("font"); + child = FindNode(node, "font"); if (child) { mFont = LoadAttrFont(child, "resource"); @@ -98,7 +89,7 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) } // Load the separator if it exists - child = node->first_node("separator"); + child = FindNode(node, "separator"); if (child) { mSeparatorColor = LoadAttrColor(child, "color"); @@ -106,7 +97,7 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) } // Fast scroll - child = node->first_node("fastscroll"); + child = FindNode(node, "fastscroll"); if (child) { mFastScrollLineColor = LoadAttrColor(child, "linecolor"); @@ -123,7 +114,7 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) actualItemHeight = mFontHeight + mItemSpacing + mSeparatorH; // Load the header if it exists - child = node->first_node("header"); + child = FindNode(node, "header"); if (child) { mHeaderH = mFontHeight; -- cgit v1.2.3