Add support for actions triggered by key combination

Change-Id: I9dfa7de40229f00412d63fc9c1eb3a809a6eb2e6
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
This commit is contained in:
Vojtech Bocek
2014-04-16 17:51:17 +02:00
committed by Gerrit Code Review
parent 9c102b536d
commit 0b7fe504dc
9 changed files with 145 additions and 48 deletions
+21 -12
View File
@@ -55,6 +55,7 @@ std::map<std::string, PageSet*> PageManager::mPageSets;
PageSet* PageManager::mCurrentSet;
PageSet* PageManager::mBaseSet = NULL;
MouseCursor *PageManager::mMouseCursor = NULL;
HardwareKeyboard *PageManager::mHardwareKeyboard = NULL;
// Helper routine to convert a string to a color declaration
int ConvertStrToColor(std::string str, COLOR* color)
@@ -447,7 +448,7 @@ int Page::NotifyTouch(TOUCH_STATE state, int x, int y)
return ret;
}
int Page::NotifyKey(int key)
int Page::NotifyKey(int key, bool down)
{
std::vector<ActionObject*>::reverse_iterator iter;
@@ -455,16 +456,17 @@ int Page::NotifyKey(int key)
if (mActions.size() == 0)
return 1;
int ret = 1;
// We work backwards, from top-most element to bottom-most element
for (iter = mActions.rbegin(); iter != mActions.rend(); iter++)
{
int ret = (*iter)->NotifyKey(key);
if (ret == 0)
return 0;
else if (ret < 0)
LOGERR("An action handler has returned an error");
ret = (*iter)->NotifyKey(key, down);
if (ret < 0) {
LOGERR("An action handler has returned an error\n");
ret = 1;
}
}
return 1;
return ret;
}
int Page::NotifyKeyboard(int key)
@@ -719,12 +721,12 @@ int PageSet::NotifyTouch(TOUCH_STATE state, int x, int y)
return (mCurrentPage ? mCurrentPage->NotifyTouch(state, x, y) : -1);
}
int PageSet::NotifyKey(int key)
int PageSet::NotifyKey(int key, bool down)
{
if (mOverlayPage)
return (mOverlayPage->NotifyKey(key));
return (mOverlayPage->NotifyKey(key, down));
return (mCurrentPage ? mCurrentPage->NotifyKey(key) : -1);
return (mCurrentPage ? mCurrentPage->NotifyKey(key, down) : -1);
}
int PageSet::NotifyKeyboard(int key)
@@ -964,6 +966,13 @@ int PageManager::Render(void)
return res;
}
HardwareKeyboard *PageManager::GetHardwareKeyboard()
{
if(!mHardwareKeyboard)
mHardwareKeyboard = new HardwareKeyboard();
return mHardwareKeyboard;
}
MouseCursor *PageManager::GetMouseCursor()
{
if(!mMouseCursor)
@@ -1002,9 +1011,9 @@ int PageManager::NotifyTouch(TOUCH_STATE state, int x, int y)
return (mCurrentSet ? mCurrentSet->NotifyTouch(state, x, y) : -1);
}
int PageManager::NotifyKey(int key)
int PageManager::NotifyKey(int key, bool down)
{
return (mCurrentSet ? mCurrentSet->NotifyKey(key) : -1);
return (mCurrentSet ? mCurrentSet->NotifyKey(key, down) : -1);
}
int PageManager::NotifyKeyboard(int key)