diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2015-03-16 18:18:56 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2015-03-19 18:32:39 +0100 |
commit | 1c273318c76ba5238cdc7081a6a1207d74e89ba6 (patch) | |
tree | 940fc792b4fe8b023a83a75e1d865e4b89fc3381 /gui/pages.cpp | |
parent | Ingore touch events for 0,0 (diff) | |
download | android_bootable_recovery-1c273318c76ba5238cdc7081a6a1207d74e89ba6.tar android_bootable_recovery-1c273318c76ba5238cdc7081a6a1207d74e89ba6.tar.gz android_bootable_recovery-1c273318c76ba5238cdc7081a6a1207d74e89ba6.tar.bz2 android_bootable_recovery-1c273318c76ba5238cdc7081a6a1207d74e89ba6.tar.lz android_bootable_recovery-1c273318c76ba5238cdc7081a6a1207d74e89ba6.tar.xz android_bootable_recovery-1c273318c76ba5238cdc7081a6a1207d74e89ba6.tar.zst android_bootable_recovery-1c273318c76ba5238cdc7081a6a1207d74e89ba6.zip |
Diffstat (limited to 'gui/pages.cpp')
-rw-r--r-- | gui/pages.cpp | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/gui/pages.cpp b/gui/pages.cpp index 23cfcd822..7107c924c 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -655,7 +655,6 @@ PageSet::PageSet(char* xmlFile) { mResources = new ResourceManager; mCurrentPage = NULL; - mOverlayPage = NULL; mXmlFile = xmlFile; if (xmlFile) @@ -666,6 +665,7 @@ PageSet::PageSet(char* xmlFile) PageSet::~PageSet() { + mOverlays.clear(); for (std::vector<Page*>::iterator itr = mPages.begin(); itr != mPages.end(); ++itr) delete *itr; @@ -931,12 +931,27 @@ int PageSet::SetPage(std::string page) int PageSet::SetOverlay(Page* page) { - if (mOverlayPage) mOverlayPage->SetPageFocus(0); - mOverlayPage = page; - if (mOverlayPage) - { - mOverlayPage->SetPageFocus(1); - mOverlayPage->NotifyVarChange("", ""); + if (page) { + if (mOverlays.size() >= 10) { + LOGERR("Too many overlays requested, max is 10.\n"); + return -1; + } + page->SetPageFocus(1); + page->NotifyVarChange("", ""); + + if (!mOverlays.empty()) + mOverlays.back()->SetPageFocus(0); + + mOverlays.push_back(page); + } else { + if (!mOverlays.empty()) { + mOverlays.back()->SetPageFocus(0); + mOverlays.pop_back(); + if (!mOverlays.empty()) + mOverlays.back()->SetPageFocus(1); + else if (mCurrentPage) + mCurrentPage->SetPageFocus(1); // Just in case somehow the regular page lost focus, we'll set it again + } } return 0; } @@ -1055,7 +1070,14 @@ int PageSet::Render(void) ret = (mCurrentPage ? mCurrentPage->Render() : -1); if (ret < 0) return ret; - ret = (mOverlayPage ? mOverlayPage->Render() : -1); + + std::vector<Page*>::iterator iter; + + for (iter = mOverlays.begin(); iter != mOverlays.end(); iter++) { + ret = ((*iter) ? (*iter)->Render() : -1); + if (ret < 0) + return ret; + } return ret; } @@ -1066,46 +1088,55 @@ int PageSet::Update(void) ret = (mCurrentPage ? mCurrentPage->Update() : -1); if (ret < 0 || ret > 1) return ret; - ret = (mOverlayPage ? mOverlayPage->Update() : -1); + + std::vector<Page*>::iterator iter; + + for (iter = mOverlays.begin(); iter != mOverlays.end(); iter++) { + ret = ((*iter) ? (*iter)->Update() : -1); + if (ret < 0) + return ret; + } return ret; } int PageSet::NotifyTouch(TOUCH_STATE state, int x, int y) { - if (mOverlayPage) - return (mOverlayPage->NotifyTouch(state, x, y)); + if (!mOverlays.empty()) + return mOverlays.back()->NotifyTouch(state, x, y); return (mCurrentPage ? mCurrentPage->NotifyTouch(state, x, y) : -1); } int PageSet::NotifyKey(int key, bool down) { - if (mOverlayPage) - return (mOverlayPage->NotifyKey(key, down)); + if (!mOverlays.empty()) + return mOverlays.back()->NotifyKey(key, down); return (mCurrentPage ? mCurrentPage->NotifyKey(key, down) : -1); } int PageSet::NotifyKeyboard(int key) { - if (mOverlayPage) - return (mOverlayPage->NotifyKeyboard(key)); + if (!mOverlays.empty()) + return mOverlays.back()->NotifyKeyboard(key); return (mCurrentPage ? mCurrentPage->NotifyKeyboard(key) : -1); } int PageSet::SetKeyBoardFocus(int inFocus) { - if (mOverlayPage) - return (mOverlayPage->SetKeyBoardFocus(inFocus)); + if (!mOverlays.empty()) + return mOverlays.back()->SetKeyBoardFocus(inFocus); return (mCurrentPage ? mCurrentPage->SetKeyBoardFocus(inFocus) : -1); } int PageSet::NotifyVarChange(std::string varName, std::string value) { - if (mOverlayPage) - mOverlayPage->NotifyVarChange(varName, value); + std::vector<Page*>::iterator iter; + + for (iter = mOverlays.begin(); iter != mOverlays.end(); iter++) + (*iter)->NotifyVarChange(varName, value); return (mCurrentPage ? mCurrentPage->NotifyVarChange(varName, value) : -1); } |