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/keyboard.cpp | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'gui/keyboard.cpp') diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 5528be936..d0262aac2 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -48,7 +48,8 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) { int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0; rowY = colX = -1; - highlightRenderCount = hasHighlight = hasCapsHighlight = 0; + highlightRenderCount = 0; + hasHighlight = hasCapsHighlight = false; char resource[10], layout[8], row[5], key[6], longpress[7]; xml_attribute<>* attr; xml_node<>* child; @@ -66,36 +67,17 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) if (!node) return; // Load the action - child = node->first_node("action"); + child = FindNode(node, "action"); if (child) { mAction = new GUIAction(node); } - memset(&mHighlightColor, 0, sizeof(COLOR)); - child = node->first_node("highlight"); - if (child) { - attr = child->first_attribute("color"); - if (attr) { - hasHighlight = 1; - std::string color = attr->value(); - ConvertStrToColor(color, &mHighlightColor); - } - } - - memset(&mCapsHighlightColor, 0, sizeof(COLOR)); - child = node->first_node("capshighlight"); - if (child) { - attr = child->first_attribute("color"); - if (attr) { - hasCapsHighlight = 1; - std::string color = attr->value(); - ConvertStrToColor(color, &mCapsHighlightColor); - } - } + mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlight); + mCapsHighlightColor = LoadAttrColor(FindNode(node, "capshighlight"), "color", &hasCapsHighlight); // Load the images for the different layouts - child = node->first_node("layout"); + child = FindNode(node, "layout"); if (child) { layoutindex = 1; @@ -120,7 +102,7 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) // Load all of the layout maps layoutindex = 1; strcpy(layout, "layout1"); - keylayout = node->first_node(layout); + keylayout = FindNode(node, layout); while (keylayout) { if (layoutindex > MAX_KEYBOARD_LAYOUTS) { @@ -212,12 +194,12 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) } layoutindex++; layout[6] = (char)(layoutindex + 48); - keylayout = node->first_node(layout); + keylayout = FindNode(node, layout); } int x, y, w, h; // Load the placement - LoadPlacement(node->first_node("placement"), &x, &y, &w, &h); + LoadPlacement(FindNode(node, "placement"), &x, &y, &w, &h); SetActionPos(x, y, KeyboardWidth, KeyboardHeight); SetRenderPos(x, y, w, h); return; -- cgit v1.2.3