diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2015-02-18 21:35:00 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2015-02-21 15:14:24 +0100 |
commit | 21ff02a69331fbcd53dc93a1af9a93618225b4bf (patch) | |
tree | 623fe5a07a506362b91a16b34d62a875b3d45c32 /gui/button.cpp | |
parent | gui: make kinetic scrolling deceleration more awesome (diff) | |
download | android_bootable_recovery-21ff02a69331fbcd53dc93a1af9a93618225b4bf.tar android_bootable_recovery-21ff02a69331fbcd53dc93a1af9a93618225b4bf.tar.gz android_bootable_recovery-21ff02a69331fbcd53dc93a1af9a93618225b4bf.tar.bz2 android_bootable_recovery-21ff02a69331fbcd53dc93a1af9a93618225b4bf.tar.lz android_bootable_recovery-21ff02a69331fbcd53dc93a1af9a93618225b4bf.tar.xz android_bootable_recovery-21ff02a69331fbcd53dc93a1af9a93618225b4bf.tar.zst android_bootable_recovery-21ff02a69331fbcd53dc93a1af9a93618225b4bf.zip |
Diffstat (limited to '')
-rw-r--r-- | gui/button.cpp | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/gui/button.cpp b/gui/button.cpp index 6ea0beec9..18b5560c4 100644 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -63,15 +63,11 @@ GUIButton::GUIButton(xml_node<>* node) mButtonLabel = new GUIText(node); mAction = new GUIAction(node); - child = node->first_node("image"); - if (child) + mButtonImg = new GUIImage(node); + if (mButtonImg->Render() < 0) { - mButtonImg = new GUIImage(node); - if (mButtonImg->Render() < 0) - { - delete mButtonImg; - mButtonImg = NULL; - } + delete mButtonImg; + mButtonImg = NULL; } if (mButtonLabel->Render() < 0) { @@ -79,45 +75,22 @@ GUIButton::GUIButton(xml_node<>* node) mButtonLabel = NULL; } // Load fill if it exists - memset(&mFillColor, 0, sizeof(COLOR)); - child = node->first_node("fill"); - if (child) - { - attr = child->first_attribute("color"); - if (attr) { - hasFill = true; - std::string color = attr->value(); - ConvertStrToColor(color, &mFillColor); - } - } + mFillColor = LoadAttrColor(FindNode(node, "fill"), "color", &hasFill); if (!hasFill && mButtonImg == NULL) { LOGERR("No image resource or fill specified for button.\n"); } // The icon is a special case - child = node->first_node("icon"); - if (child) - { - mButtonIcon = LoadAttrImage(child, "resource"); - } + mButtonIcon = LoadAttrImage(FindNode(node, "icon"), "resource"); - 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); int x, y, w, h; TextPlacement = TOP_LEFT; if (mButtonImg) { mButtonImg->GetRenderPos(x, y, w, h); } else if (hasFill) { - LoadPlacement(node->first_node("placement"), &x, &y, &w, &h, &TextPlacement); + LoadPlacement(FindNode(node, "placement"), &x, &y, &w, &h, &TextPlacement); } SetRenderPos(x, y, w, h); } |