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/slider.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 'gui/slider.cpp')
-rw-r--r-- | gui/slider.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/gui/slider.cpp b/gui/slider.cpp index c53dabc28..2fd114d88 100644 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -33,6 +33,7 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) xml_node<>* child; sAction = NULL; + sSliderLabel = NULL; sSlider = NULL; sSliderUsed = NULL; sTouch = NULL; @@ -44,7 +45,8 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) return; } - child = node->first_node("resource"); + // Load the resources + child = FindNode(node, "resource"); if (child) { sSlider = LoadAttrImage(child, "base"); @@ -52,11 +54,27 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) sTouch = LoadAttrImage(child, "touch"); } + // Load the text label + sSliderLabel = new GUIText(node); + if (sSliderLabel->Render() < 0) + { + delete sSliderLabel; + sSliderLabel = NULL; + } + // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY); + Placement TextPlacement = CENTER; + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &TextPlacement); mRenderW = sSlider->GetWidth(); mRenderH = sSlider->GetHeight(); + if (sSliderLabel) { + int sTextX = mRenderX + (mRenderW / 2); + int w, h; + sSliderLabel->GetCurrentBounds(w, h); + int sTextY = mRenderY + ((mRenderH - h) / 2); + sSliderLabel->SetRenderPos(sTextX, sTextY); + } if (sTouch && sTouch->GetResource()) { sTouchW = sTouch->GetWidth(); // Width of the "touch image" that follows the touch (arrow) @@ -78,6 +96,7 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) GUISlider::~GUISlider() { delete sAction; + delete sSliderLabel; } int GUISlider::Render(void) @@ -99,6 +118,11 @@ int GUISlider::Render(void) if (sTouch && sTouch->GetResource()) gr_blit(sTouch->GetResource(), 0, 0, sTouchW, sTouchH, sCurTouchX, (mRenderY + ((mRenderH - sTouchH) / 2))); + if (sSliderLabel) { + int ret = sSliderLabel->Render(); + if (ret < 0) return ret; + } + sUpdate = 0; return 0; } |