diff options
author | Vojtech Bocek <vbocek@gmail.com> | 2014-02-08 02:05:33 +0100 |
---|---|---|
committer | Vojtech Bocek <vbocek@gmail.com> | 2014-02-12 19:19:32 +0100 |
commit | 072205626caec16f3028a9b698e792e525848581 (patch) | |
tree | d262f85a3f58a7a86181dcadc24d6c352928f3f2 | |
parent | Properly delete all GUIObjects and pages on theme reload (diff) | |
download | android_bootable_recovery-072205626caec16f3028a9b698e792e525848581.tar android_bootable_recovery-072205626caec16f3028a9b698e792e525848581.tar.gz android_bootable_recovery-072205626caec16f3028a9b698e792e525848581.tar.bz2 android_bootable_recovery-072205626caec16f3028a9b698e792e525848581.tar.lz android_bootable_recovery-072205626caec16f3028a9b698e792e525848581.tar.xz android_bootable_recovery-072205626caec16f3028a9b698e792e525848581.tar.zst android_bootable_recovery-072205626caec16f3028a9b698e792e525848581.zip |
-rw-r--r-- | gui/action.cpp | 11 | ||||
-rw-r--r-- | gui/fileselector.cpp | 4 | ||||
-rw-r--r-- | gui/input.cpp | 4 | ||||
-rw-r--r-- | gui/listbox.cpp | 4 | ||||
-rw-r--r-- | gui/object.cpp | 26 | ||||
-rw-r--r-- | gui/objects.hpp | 32 | ||||
-rw-r--r-- | gui/pages.cpp | 12 | ||||
-rw-r--r-- | gui/partitionlist.cpp | 4 | ||||
-rw-r--r-- | gui/progressbar.cpp | 4 | ||||
-rw-r--r-- | gui/slidervalue.cpp | 4 | ||||
-rw-r--r-- | gui/text.cpp | 4 |
11 files changed, 65 insertions, 44 deletions
diff --git a/gui/action.cpp b/gui/action.cpp index 951feb114..66ee5d6f0 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -144,16 +144,13 @@ int GUIAction::NotifyKey(int key) return 0; } -int GUIAction::NotifyVarChange(std::string varName, std::string value) +int GUIAction::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + if (varName.empty() && !isConditionValid() && !mKey && !mActionW) doActions(); - - // This handles notifying the condition system of page start - if (varName.empty() && isConditionValid()) - NotifyPageSet(); - - if ((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue()) + else if((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue()) doActions(); return 0; diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp index 484bcff11..e1570edd0 100644 --- a/gui/fileselector.cpp +++ b/gui/fileselector.cpp @@ -865,8 +865,10 @@ int GUIFileSelector::NotifyTouch(TOUCH_STATE state, int x, int y) return 0; } -int GUIFileSelector::NotifyVarChange(std::string varName, std::string value) +int GUIFileSelector::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + if(!isConditionTrue()) return 0; diff --git a/gui/input.cpp b/gui/input.cpp index b0065609e..61b0cff1f 100644 --- a/gui/input.cpp +++ b/gui/input.cpp @@ -591,8 +591,10 @@ int GUIInput::NotifyTouch(TOUCH_STATE state, int x, int y) return 0; } -int GUIInput::NotifyVarChange(std::string varName, std::string value) +int GUIInput::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + if (varName == mVariable && !isLocalChange) { HandleTextLocation(-1003); return 0; diff --git a/gui/listbox.cpp b/gui/listbox.cpp index 99e2dedf1..bbfc9344a 100644 --- a/gui/listbox.cpp +++ b/gui/listbox.cpp @@ -760,8 +760,10 @@ int GUIListBox::NotifyTouch(TOUCH_STATE state, int x, int y) return 0; } -int GUIListBox::NotifyVarChange(std::string varName, std::string value) +int GUIListBox::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + if(!isConditionTrue()) return 0; diff --git a/gui/object.cpp b/gui/object.cpp index b6010d778..41cc822bb 100644 --- a/gui/object.cpp +++ b/gui/object.cpp @@ -29,6 +29,8 @@ extern "C" { GUIObject::GUIObject(xml_node<>* node) { + mConditionsResult = true; + // Break out early, it's too hard to check if valid every step if (!node) return; @@ -78,13 +80,7 @@ bool GUIObject::IsConditionVariable(std::string var) bool GUIObject::isConditionTrue() { - std::vector<Condition>::iterator iter; - for (iter = mConditions.begin(); iter != mConditions.end(); iter++) - { - if (!isConditionTrue(&(*iter))) - return false; - } - return true; + return mConditionsResult; } bool GUIObject::isConditionTrue(Condition* condition) @@ -159,12 +155,15 @@ bool GUIObject::isConditionValid() return !mConditions.empty(); } -void GUIObject::NotifyPageSet() +int GUIObject::NotifyVarChange(const std::string& varName, const std::string& value) { + mConditionsResult = true; + + const bool varNameEmpty = varName.empty(); std::vector<Condition>::iterator iter; - for (iter = mConditions.begin(); iter != mConditions.end(); iter++) + for (iter = mConditions.begin(); iter != mConditions.end(); ++iter) { - if (iter->mCompareOp == "modified") + if(varNameEmpty && iter->mCompareOp == "modified") { string val; @@ -176,7 +175,14 @@ void GUIObject::NotifyPageSet() } iter->mLastVal = val; } + + if(varNameEmpty || iter->mVar1 == varName || iter->mVar2 == varName) + iter->mLastResult = isConditionTrue(&(*iter)); + + if(!iter->mLastResult) + mConditionsResult = false; } + return 0; } bool GUIObject::isMounted(string vol) diff --git a/gui/objects.hpp b/gui/objects.hpp index 42dfb1f09..472d23b42 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -114,10 +114,6 @@ public: // Return 0 if this object handles the request, 1 if not virtual int IsInRegion(int x, int y) { return ((x < mActionX || x > mActionX + mActionW || y < mActionY || y > mActionY + mActionH) ? 0 : 1); } - // NotifyVarChange - Notify of a variable change - // Returns 0 on success, <0 on error - virtual int NotifyVarChange(std::string varName, std::string value) { return 0; } - protected: int mActionX, mActionY, mActionW, mActionH; }; @@ -132,16 +128,24 @@ public: bool IsConditionVariable(std::string var); bool isConditionTrue(); bool isConditionValid(); - void NotifyPageSet(); + + // NotifyVarChange - Notify of a variable change + // Returns 0 on success, <0 on error + virtual int NotifyVarChange(const std::string& varName, const std::string& value); protected: class Condition { public: + Condition() { + mLastResult = true; + } + std::string mVar1; std::string mVar2; std::string mCompareOp; std::string mLastVal; + bool mLastResult; }; std::vector<Condition> mConditions; @@ -149,6 +153,8 @@ protected: protected: bool isMounted(std::string vol); bool isConditionTrue(Condition* condition); + + bool mConditionsResult; }; class InputObject @@ -189,7 +195,7 @@ public: virtual int GetCurrentBounds(int& w, int& h); // Notify of a variable change - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); // Set maximum width in pixels virtual int SetMaxWidth(unsigned width); @@ -264,7 +270,7 @@ public: public: virtual int NotifyTouch(TOUCH_STATE state, int x, int y); virtual int NotifyKey(int key); - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); virtual int doActions(); protected: @@ -441,7 +447,7 @@ public: virtual int NotifyTouch(TOUCH_STATE state, int x, int y); // NotifyVarChange - Notify of a variable change - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); // SetPos - Update the position of the render object // Return 0 on success, <0 on error @@ -545,7 +551,7 @@ public: virtual int NotifyTouch(TOUCH_STATE state, int x, int y); // NotifyVarChange - Notify of a variable change - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); // SetPos - Update the position of the render object // Return 0 on success, <0 on error @@ -633,7 +639,7 @@ public: virtual int NotifyTouch(TOUCH_STATE state, int x, int y); // NotifyVarChange - Notify of a variable change - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); // SetPos - Update the position of the render object // Return 0 on success, <0 on error @@ -737,7 +743,7 @@ public: // NotifyVarChange - Notify of a variable change // Returns 0 on success, <0 on error - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); protected: Resource* mEmptyBar; @@ -854,7 +860,7 @@ public: virtual int Update(void); // Notify of a variable change - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); // NotifyTouch - Notify of a touch event // Return 0 on success, >0 to ignore remainder of touch, and <0 on error @@ -937,7 +943,7 @@ public: virtual int NotifyTouch(TOUCH_STATE state, int x, int y); // Notify of a variable change - virtual int NotifyVarChange(std::string varName, std::string value); + virtual int NotifyVarChange(const std::string& varName, const std::string& value); // SetPageFocus - Notify when a page gains or loses focus virtual void SetPageFocus(int inFocus); diff --git a/gui/pages.cpp b/gui/pages.cpp index 73aab0352..2953eddb8 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -519,13 +519,8 @@ void Page::SetPageFocus(int inFocus) int Page::NotifyVarChange(std::string varName, std::string value) { - std::vector<ActionObject*>::iterator iter; - - // Don't try to handle a lack of handlers - if (mActions.size() == 0) - return 1; - - for (iter = mActions.begin(); iter != mActions.end(); ++iter) + std::vector<GUIObject*>::iterator iter; + for (iter = mObjects.begin(); iter != mObjects.end(); ++iter) { if ((*iter)->NotifyVarChange(varName, value)) LOGERR("An action handler errored on NotifyVarChange.\n"); @@ -865,7 +860,10 @@ PageSet* PageManager::SelectPackage(std::string name) tmp = FindPackage(name); if (tmp) + { mCurrentSet = tmp; + mCurrentSet->NotifyVarChange("", ""); + } else LOGERR("Unable to find package.\n"); diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp index cb9011f30..064b9df01 100644 --- a/gui/partitionlist.cpp +++ b/gui/partitionlist.cpp @@ -827,8 +827,10 @@ int GUIPartitionList::NotifyTouch(TOUCH_STATE state, int x, int y) return 0; } -int GUIPartitionList::NotifyVarChange(std::string varName, std::string value) +int GUIPartitionList::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + if(!isConditionTrue()) return 0; diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp index 9c80eb40a..83de4d13b 100644 --- a/gui/progressbar.cpp +++ b/gui/progressbar.cpp @@ -172,8 +172,10 @@ int GUIProgressBar::Update(void) return 2; } -int GUIProgressBar::NotifyVarChange(std::string varName, std::string value) +int GUIProgressBar::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + if(!isConditionTrue()) return 0; diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp index c83456b9e..972d1f728 100644 --- a/gui/slidervalue.cpp +++ b/gui/slidervalue.cpp @@ -396,8 +396,10 @@ int GUISliderValue::NotifyTouch(TOUCH_STATE state, int x, int y) return 0; } -int GUISliderValue::NotifyVarChange(std::string varName, std::string value) +int GUISliderValue::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + if (mLabel) mLabel->NotifyVarChange(varName, value); if (varName == mVariable) { diff --git a/gui/text.cpp b/gui/text.cpp index 715880b62..c594f4824 100644 --- a/gui/text.cpp +++ b/gui/text.cpp @@ -222,8 +222,10 @@ std::string GUIText::parseText(void) } } -int GUIText::NotifyVarChange(std::string varName, std::string value) +int GUIText::NotifyVarChange(const std::string& varName, const std::string& value) { + GUIObject::NotifyVarChange(varName, value); + mVarChanged = 1; return 0; } |