1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-23 00:43:09 +02:00

BrowseDialog: simplify code using InputManager::waitForPressedButton().

This commit is contained in:
Maarten ter Huurne 2011-10-23 09:11:06 +02:00
parent 315bf0a180
commit ccf55e5d61
2 changed files with 26 additions and 43 deletions

View File

@ -73,58 +73,41 @@ bool BrowseDialog::exec()
return result;
}
BrowseDialog::Action BrowseDialog::getAction(InputManager::ButtonEvent *event)
BrowseDialog::Action BrowseDialog::getAction(InputManager::Button button)
{
BrowseDialog::Action action;
switch(event->button) {
switch (button) {
case InputManager::MENU:
action = BrowseDialog::ACT_CLOSE;
break;
return BrowseDialog::ACT_CLOSE;
case InputManager::UP:
action = BrowseDialog::ACT_UP;
break;
return BrowseDialog::ACT_UP;
case InputManager::DOWN:
action = BrowseDialog::ACT_DOWN;
break;
return BrowseDialog::ACT_DOWN;
case InputManager::ALTLEFT:
action = BrowseDialog::ACT_SCROLLUP;
break;
return BrowseDialog::ACT_SCROLLUP;
case InputManager::ALTRIGHT:
action = BrowseDialog::ACT_SCROLLDOWN;
break;
return BrowseDialog::ACT_SCROLLDOWN;
case InputManager::LEFT:
case InputManager::CANCEL:
action = BrowseDialog::ACT_GOUP;
break;
return BrowseDialog::ACT_GOUP;
case InputManager::ACCEPT:
action = BrowseDialog::ACT_SELECT;
break;
return BrowseDialog::ACT_SELECT;
case InputManager::SETTINGS:
action = BrowseDialog::ACT_CONFIRM;
break;
return BrowseDialog::ACT_CONFIRM;
default:
action = BrowseDialog::ACT_NONE;
break;
return BrowseDialog::ACT_NONE;
}
return action;
}
void BrowseDialog::handleInput()
{
InputManager::Button button = gmenu2x->input.waitForPressedButton();
BrowseDialog::Action action;
InputManager::ButtonEvent event;
do {
gmenu2x->input.waitForEvent(&event);
} while (event.state != InputManager::PRESSED);
if (ts_pressed && !gmenu2x->ts.pressed()) {
action = BrowseDialog::ACT_SELECT;
ts_pressed = false;
} else {
action = getAction(&event);
action = getAction(button);
}
if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;

View File

@ -76,7 +76,7 @@ private:
ButtonBox buttonBox;
Action getAction(InputManager::ButtonEvent *event);
Action getAction(InputManager::Button button);
void handleInput();
void paint();