summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/gui.cpp1
-rw-r--r--gui/pages.cpp69
-rw-r--r--gui/pages.hpp2
3 files changed, 52 insertions, 20 deletions
diff --git a/gui/gui.cpp b/gui/gui.cpp
index c755a9848..ebd70534c 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -734,6 +734,7 @@ int gui_changePage(std::string newPage)
int gui_changeOverlay(std::string overlay)
{
+ LOGINFO("Set overlay: '%s'\n", overlay.c_str());
PageManager::ChangeOverlay(overlay);
gForceRender.set_value(1);
return 0;
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);
}
diff --git a/gui/pages.hpp b/gui/pages.hpp
index 50155d0e9..f0b2155c4 100644
--- a/gui/pages.hpp
+++ b/gui/pages.hpp
@@ -115,7 +115,7 @@ protected:
std::vector<Page*> mPages;
std::vector<xml_node<>*> templates;
Page* mCurrentPage;
- Page* mOverlayPage; // This is a special case, used for "locking" the screen
+ std::vector<Page*> mOverlays; // Special case for popup dialogs and the lock screen
std::vector<xml_document<>*> mIncludedDocs;
};