mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-23 09:03:08 +02:00
BrowseDialog: simplify code using InputManager::waitForPressedButton().
This commit is contained in:
parent
315bf0a180
commit
ccf55e5d61
@ -73,58 +73,41 @@ bool BrowseDialog::exec()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowseDialog::Action BrowseDialog::getAction(InputManager::ButtonEvent *event)
|
BrowseDialog::Action BrowseDialog::getAction(InputManager::Button button)
|
||||||
{
|
{
|
||||||
BrowseDialog::Action action;
|
switch (button) {
|
||||||
|
case InputManager::MENU:
|
||||||
switch(event->button) {
|
return BrowseDialog::ACT_CLOSE;
|
||||||
case InputManager::MENU:
|
case InputManager::UP:
|
||||||
action = BrowseDialog::ACT_CLOSE;
|
return BrowseDialog::ACT_UP;
|
||||||
break;
|
case InputManager::DOWN:
|
||||||
case InputManager::UP:
|
return BrowseDialog::ACT_DOWN;
|
||||||
action = BrowseDialog::ACT_UP;
|
case InputManager::ALTLEFT:
|
||||||
break;
|
return BrowseDialog::ACT_SCROLLUP;
|
||||||
case InputManager::DOWN:
|
case InputManager::ALTRIGHT:
|
||||||
action = BrowseDialog::ACT_DOWN;
|
return BrowseDialog::ACT_SCROLLDOWN;
|
||||||
break;
|
case InputManager::LEFT:
|
||||||
case InputManager::ALTLEFT:
|
case InputManager::CANCEL:
|
||||||
action = BrowseDialog::ACT_SCROLLUP;
|
return BrowseDialog::ACT_GOUP;
|
||||||
break;
|
case InputManager::ACCEPT:
|
||||||
case InputManager::ALTRIGHT:
|
return BrowseDialog::ACT_SELECT;
|
||||||
action = BrowseDialog::ACT_SCROLLDOWN;
|
case InputManager::SETTINGS:
|
||||||
break;
|
return BrowseDialog::ACT_CONFIRM;
|
||||||
case InputManager::LEFT:
|
default:
|
||||||
case InputManager::CANCEL:
|
return BrowseDialog::ACT_NONE;
|
||||||
action = BrowseDialog::ACT_GOUP;
|
}
|
||||||
break;
|
|
||||||
case InputManager::ACCEPT:
|
|
||||||
action = BrowseDialog::ACT_SELECT;
|
|
||||||
break;
|
|
||||||
case InputManager::SETTINGS:
|
|
||||||
action = BrowseDialog::ACT_CONFIRM;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
action = BrowseDialog::ACT_NONE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return action;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowseDialog::handleInput()
|
void BrowseDialog::handleInput()
|
||||||
{
|
{
|
||||||
|
InputManager::Button button = gmenu2x->input.waitForPressedButton();
|
||||||
|
|
||||||
BrowseDialog::Action action;
|
BrowseDialog::Action action;
|
||||||
InputManager::ButtonEvent event;
|
|
||||||
|
|
||||||
do {
|
|
||||||
gmenu2x->input.waitForEvent(&event);
|
|
||||||
} while (event.state != InputManager::PRESSED);
|
|
||||||
|
|
||||||
if (ts_pressed && !gmenu2x->ts.pressed()) {
|
if (ts_pressed && !gmenu2x->ts.pressed()) {
|
||||||
action = BrowseDialog::ACT_SELECT;
|
action = BrowseDialog::ACT_SELECT;
|
||||||
ts_pressed = false;
|
ts_pressed = false;
|
||||||
} else {
|
} else {
|
||||||
action = getAction(&event);
|
action = getAction(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;
|
if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;
|
||||||
|
@ -76,7 +76,7 @@ private:
|
|||||||
|
|
||||||
ButtonBox buttonBox;
|
ButtonBox buttonBox;
|
||||||
|
|
||||||
Action getAction(InputManager::ButtonEvent *event);
|
Action getAction(InputManager::Button button);
|
||||||
void handleInput();
|
void handleInput();
|
||||||
|
|
||||||
void paint();
|
void paint();
|
||||||
|
Loading…
Reference in New Issue
Block a user