diff options
author | Vojtech Bocek <vbocek@gmail.com> | 2013-07-25 22:53:02 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@198.50.184.117> | 2013-08-24 14:56:48 +0200 |
commit | fafb0c541bb4b24515c57251a44d87825eec90fb (patch) | |
tree | 9cddb55ceef8912c8fafe618c98147ff6df19ef6 /gui/slider.cpp | |
parent | Clean-up in partitions.hpp (diff) | |
download | android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.gz android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.bz2 android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.lz android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.xz android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.zst android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.zip |
Diffstat (limited to '')
-rw-r--r-- | gui/slider.cpp | 218 |
1 files changed, 109 insertions, 109 deletions
diff --git a/gui/slider.cpp b/gui/slider.cpp index 4542d60e1..b46d156f6 100644 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -28,143 +28,143 @@ extern "C" { GUISlider::GUISlider(xml_node<>* node) { - xml_attribute<>* attr; - xml_node<>* child; - - sAction = NULL; - sSlider = NULL; - sSliderUsed = NULL; - sTouch = NULL; - sTouchW = 20; - - if (!node) - { - LOGERR("GUISlider created without XML node\n"); - return; - } - - child = node->first_node("resource"); - if (child) - { - attr = child->first_attribute("base"); - if (attr) - sSlider = PageManager::FindResource(attr->value()); - - attr = child->first_attribute("used"); - if (attr) - sSliderUsed = PageManager::FindResource(attr->value()); - - attr = child->first_attribute("touch"); - if (attr) - sTouch = PageManager::FindResource(attr->value()); - } - - // Load the placement + xml_attribute<>* attr; + xml_node<>* child; + + sAction = NULL; + sSlider = NULL; + sSliderUsed = NULL; + sTouch = NULL; + sTouchW = 20; + + if (!node) + { + LOGERR("GUISlider created without XML node\n"); + return; + } + + child = node->first_node("resource"); + if (child) + { + attr = child->first_attribute("base"); + if (attr) + sSlider = PageManager::FindResource(attr->value()); + + attr = child->first_attribute("used"); + if (attr) + sSliderUsed = PageManager::FindResource(attr->value()); + + attr = child->first_attribute("touch"); + if (attr) + sTouch = PageManager::FindResource(attr->value()); + } + + // Load the placement LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY); - if (sSlider && sSlider->GetResource()) - { + if (sSlider && sSlider->GetResource()) + { mRenderW = gr_get_width(sSlider->GetResource()); - mRenderH = gr_get_height(sSlider->GetResource()); - } - if (sTouch && sTouch->GetResource()) - { - sTouchW = gr_get_width(sTouch->GetResource()); // Width of the "touch image" that follows the touch (arrow) - sTouchH = gr_get_height(sTouch->GetResource()); // Height of the "touch image" that follows the touch (arrow) - } - - //LOGINFO("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW); + mRenderH = gr_get_height(sSlider->GetResource()); + } + if (sTouch && sTouch->GetResource()) + { + sTouchW = gr_get_width(sTouch->GetResource()); // Width of the "touch image" that follows the touch (arrow) + sTouchH = gr_get_height(sTouch->GetResource()); // Height of the "touch image" that follows the touch (arrow) + } + + //LOGINFO("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW); mActionX = mRenderX; - mActionY = mRenderY; - mActionW = mRenderW; - mActionH = mRenderH; + mActionY = mRenderY; + mActionW = mRenderW; + mActionH = mRenderH; - sAction = new GUIAction(node); + sAction = new GUIAction(node); - sCurTouchX = mRenderX; - sUpdate = 1; - - return; + sCurTouchX = mRenderX; + sUpdate = 1; } GUISlider::~GUISlider() { - delete sAction; + delete sAction; } int GUISlider::Render(void) { - if (!sSlider || !sSlider->GetResource()) return -1; + if (!sSlider || !sSlider->GetResource()) + return -1; - // Draw the slider - gr_blit(sSlider->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY); + // Draw the slider + gr_blit(sSlider->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY); - // Draw the used - if (sSliderUsed && sSliderUsed->GetResource() && sCurTouchX > mRenderX) - { - gr_blit(sSliderUsed->GetResource(), 0, 0, sCurTouchX - mRenderX, mRenderH, mRenderX, mRenderY); - } + // Draw the used + if (sSliderUsed && sSliderUsed->GetResource() && sCurTouchX > mRenderX) + gr_blit(sSliderUsed->GetResource(), 0, 0, sCurTouchX - mRenderX, mRenderH, mRenderX, mRenderY); - // Draw the touch icon - if (sTouch && sTouch->GetResource()) - { - gr_blit(sTouch->GetResource(), 0, 0, sTouchW, sTouchH, sCurTouchX, (mRenderY + ((mRenderH - sTouchH) / 2))); - } + // Draw the touch icon + if (sTouch && sTouch->GetResource()) + gr_blit(sTouch->GetResource(), 0, 0, sTouchW, sTouchH, sCurTouchX, (mRenderY + ((mRenderH - sTouchH) / 2))); - sUpdate = 0; - return 0; + sUpdate = 0; + return 0; } int GUISlider::Update(void) { - if (sUpdate) return 2; - return 0; + if (sUpdate) + return 2; + return 0; } int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y) { - static bool dragging = false; + static bool dragging = false; switch (state) - { - case TOUCH_START: - if (x >= mRenderX && x <= mRenderX + sTouchW && - y >= mRenderY && y <= mRenderY + mRenderH) - { - sCurTouchX = x - (sTouchW / 2); - if (sCurTouchX < mRenderX) sCurTouchX = mRenderX; - dragging = true; - } - break; - - case TOUCH_DRAG: - if (!dragging) return 0; - if (y < mRenderY - sTouchH || y > mRenderY + (sTouchH * 2)) - { - sCurTouchX = mRenderX; - dragging = false; - sUpdate = 1; - break; - } - sCurTouchX = x - (sTouchW / 2); - if (sCurTouchX < mRenderX) sCurTouchX = mRenderX; - if (sCurTouchX > mRenderX + mRenderW - sTouchW) sCurTouchX = mRenderX + mRenderW - sTouchW; - sUpdate = 1; - break; - - case TOUCH_RELEASE: - if (!dragging) return 0; - if (sCurTouchX >= mRenderX + mRenderW - sTouchW) - { - sAction->doActions(); - } - sCurTouchX = mRenderX; - dragging = false; - sUpdate = 1; + { + case TOUCH_START: + if (x >= mRenderX && x <= mRenderX + sTouchW && + y >= mRenderY && y <= mRenderY + mRenderH) + { + sCurTouchX = x - (sTouchW / 2); + if (sCurTouchX < mRenderX) + sCurTouchX = mRenderX; + dragging = true; + } + break; + + case TOUCH_DRAG: + if (!dragging) + return 0; + if (y < mRenderY - sTouchH || y > mRenderY + (sTouchH * 2)) + { + sCurTouchX = mRenderX; + dragging = false; + sUpdate = 1; + break; + } + sCurTouchX = x - (sTouchW / 2); + if (sCurTouchX < mRenderX) + sCurTouchX = mRenderX; + if (sCurTouchX > mRenderX + mRenderW - sTouchW) + sCurTouchX = mRenderX + mRenderW - sTouchW; + sUpdate = 1; + break; + + case TOUCH_RELEASE: + if (!dragging) + return 0; + + if (sCurTouchX >= mRenderX + mRenderW - sTouchW) + sAction->doActions(); + + sCurTouchX = mRenderX; + dragging = false; + sUpdate = 1; case TOUCH_REPEAT: case TOUCH_HOLD: - break; - } - return 0; + break; + } + return 0; } - |