mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-28 18:32:25 +02:00
Handle menu-related buttons inside Menu class
This commit is contained in:
parent
d588b97b34
commit
074668336e
@ -686,40 +686,22 @@ void GMenu2X::main() {
|
|||||||
menu->handleTS();
|
menu->handleTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (input.waitForPressedButton()) {
|
InputManager::Button button = input.waitForPressedButton();
|
||||||
case InputManager::ACCEPT:
|
if (!menu->handleButtonPress(button)) {
|
||||||
if (menu->selLink() != NULL) menu->selLink()->run();
|
switch (button) {
|
||||||
break;
|
case InputManager::CANCEL:
|
||||||
case InputManager::CANCEL:
|
helpDisplayed=true;
|
||||||
helpDisplayed=true;
|
break;
|
||||||
break;
|
case InputManager::SETTINGS:
|
||||||
case InputManager::SETTINGS:
|
options();
|
||||||
options();
|
break;
|
||||||
break;
|
case InputManager::MENU:
|
||||||
case InputManager::MENU:
|
contextMenu();
|
||||||
contextMenu();
|
break;
|
||||||
break;
|
default:
|
||||||
case InputManager::UP:
|
break;
|
||||||
menu->linkUp();
|
}
|
||||||
break;
|
}
|
||||||
case InputManager::DOWN:
|
|
||||||
menu->linkDown();
|
|
||||||
break;
|
|
||||||
case InputManager::LEFT:
|
|
||||||
menu->linkLeft();
|
|
||||||
break;
|
|
||||||
case InputManager::RIGHT:
|
|
||||||
menu->linkRight();
|
|
||||||
break;
|
|
||||||
case InputManager::ALTLEFT:
|
|
||||||
menu->decSectionIndex();
|
|
||||||
break;
|
|
||||||
case InputManager::ALTRIGHT:
|
|
||||||
menu->incSectionIndex();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
src/menu.cpp
28
src/menu.cpp
@ -207,6 +207,34 @@ void Menu::paint(Surface &s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Menu::handleButtonPress(InputManager::Button button) {
|
||||||
|
switch (button) {
|
||||||
|
case InputManager::ACCEPT:
|
||||||
|
if (selLink() != NULL) selLink()->run();
|
||||||
|
return true;
|
||||||
|
case InputManager::UP:
|
||||||
|
linkUp();
|
||||||
|
return true;
|
||||||
|
case InputManager::DOWN:
|
||||||
|
linkDown();
|
||||||
|
return true;
|
||||||
|
case InputManager::LEFT:
|
||||||
|
linkLeft();
|
||||||
|
return true;
|
||||||
|
case InputManager::RIGHT:
|
||||||
|
linkRight();
|
||||||
|
return true;
|
||||||
|
case InputManager::ALTLEFT:
|
||||||
|
decSectionIndex();
|
||||||
|
return true;
|
||||||
|
case InputManager::ALTRIGHT:
|
||||||
|
incSectionIndex();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::handleTS() {
|
void Menu::handleTS() {
|
||||||
ConfIntHash &skinConfInt = gmenu2x->skinConfInt;
|
ConfIntHash &skinConfInt = gmenu2x->skinConfInt;
|
||||||
const int topBarHeight = skinConfInt["topBarHeight"];
|
const int topBarHeight = skinConfInt["topBarHeight"];
|
||||||
|
23
src/menu.h
23
src/menu.h
@ -21,8 +21,9 @@
|
|||||||
#ifndef MENU_H
|
#ifndef MENU_H
|
||||||
#define MENU_H
|
#define MENU_H
|
||||||
|
|
||||||
#include "link.h"
|
|
||||||
#include "delegate.h"
|
#include "delegate.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
#include "link.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -74,6 +75,13 @@ private:
|
|||||||
// Load all the links on the given section directory.
|
// Load all the links on the given section directory.
|
||||||
void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles);
|
void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles);
|
||||||
|
|
||||||
|
void decSectionIndex();
|
||||||
|
void incSectionIndex();
|
||||||
|
void linkLeft();
|
||||||
|
void linkRight();
|
||||||
|
void linkUp();
|
||||||
|
void linkDown();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Menu(GMenu2X *gmenu2x, Touchscreen &ts);
|
Menu(GMenu2X *gmenu2x, Touchscreen &ts);
|
||||||
~Menu();
|
~Menu();
|
||||||
@ -88,8 +96,6 @@ public:
|
|||||||
|
|
||||||
int selSectionIndex();
|
int selSectionIndex();
|
||||||
const std::string &selSection();
|
const std::string &selSection();
|
||||||
void decSectionIndex();
|
|
||||||
void incSectionIndex();
|
|
||||||
void setSectionIndex(int i);
|
void setSectionIndex(int i);
|
||||||
|
|
||||||
bool addActionLink(uint section, const std::string &title,
|
bool addActionLink(uint section, const std::string &title,
|
||||||
@ -102,16 +108,19 @@ public:
|
|||||||
|
|
||||||
void skinUpdated();
|
void skinUpdated();
|
||||||
void paint(Surface &s);
|
void paint(Surface &s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the pressing of the give button.
|
||||||
|
* Returns true iff the event was consumed.
|
||||||
|
*/
|
||||||
|
bool handleButtonPress(InputManager::Button button);
|
||||||
|
|
||||||
void handleTS();
|
void handleTS();
|
||||||
bool linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex);
|
bool linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex);
|
||||||
|
|
||||||
int selLinkIndex();
|
int selLinkIndex();
|
||||||
Link *selLink();
|
Link *selLink();
|
||||||
LinkApp *selLinkApp();
|
LinkApp *selLinkApp();
|
||||||
void linkLeft();
|
|
||||||
void linkRight();
|
|
||||||
void linkUp();
|
|
||||||
void linkDown();
|
|
||||||
void setLinkIndex(int i);
|
void setLinkIndex(int i);
|
||||||
|
|
||||||
const std::vector<std::string> &getSections() { return sections; }
|
const std::vector<std::string> &getSections() { return sections; }
|
||||||
|
Loading…
Reference in New Issue
Block a user