mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-26 04:30:38 +02:00
SettingsDialog: simplify code using InputManager::waitForPressedButton().
Replaced MenuSetting::manageInput() by handleButtonPress(), because we will only pass pressed buttons to it, not the entire input event.
This commit is contained in:
parent
40fd35d764
commit
a38c283e17
@ -47,7 +47,7 @@ public:
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
|
||||
virtual bool manageInput(InputManager::ButtonEvent *event) = 0;
|
||||
virtual bool handleButtonPress(InputManager::Button button) = 0;
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited() = 0;
|
||||
|
@ -64,15 +64,15 @@ void MenuSettingBool::draw(int y)
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
}
|
||||
|
||||
bool MenuSettingBool::manageInput(InputManager::ButtonEvent *event)
|
||||
bool MenuSettingBool::handleButtonPress(InputManager::Button button)
|
||||
{
|
||||
if (event->button == InputManager::ACCEPT
|
||||
&& event->state == InputManager::PRESSED) {
|
||||
if (button == InputManager::ACCEPT) {
|
||||
toggle();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuSettingBool::toggle()
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
virtual ~MenuSettingBool() {}
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
||||
virtual bool handleButtonPress(InputManager::Button button);
|
||||
virtual bool edited();
|
||||
|
||||
void setValue(int value);
|
||||
|
@ -66,9 +66,9 @@ void MenuSettingInt::draw(int y)
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
}
|
||||
|
||||
bool MenuSettingInt::manageInput(InputManager::ButtonEvent *event)
|
||||
bool MenuSettingInt::handleButtonPress(InputManager::Button button)
|
||||
{
|
||||
switch (event->button) {
|
||||
switch (button) {
|
||||
case InputManager::LEFT:
|
||||
dec();
|
||||
break;
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
int increment = 1);
|
||||
virtual ~MenuSettingInt() {}
|
||||
|
||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
||||
virtual bool handleButtonPress(InputManager::Button button);
|
||||
virtual void adjustInput();
|
||||
virtual void draw(int);
|
||||
virtual bool edited();
|
||||
|
@ -49,9 +49,9 @@ MenuSettingMultiString::MenuSettingMultiString(
|
||||
buttonBox.add(btn);
|
||||
}
|
||||
|
||||
bool MenuSettingMultiString::manageInput(InputManager::ButtonEvent *event)
|
||||
bool MenuSettingMultiString::handleButtonPress(InputManager::Button button)
|
||||
{
|
||||
switch(event->button) {
|
||||
switch (button) {
|
||||
case InputManager::LEFT:
|
||||
decSel();
|
||||
break;
|
||||
|
@ -28,7 +28,7 @@
|
||||
class MenuSettingMultiString : public MenuSettingStringBase {
|
||||
private:
|
||||
virtual void edit() {
|
||||
/* never called because manageInput() is overridden */
|
||||
/* never called because handleButtonPress() is overridden */
|
||||
}
|
||||
|
||||
const std::vector<std::string> *choices;
|
||||
@ -45,7 +45,7 @@ public:
|
||||
const std::vector<std::string> *choices);
|
||||
virtual ~MenuSettingMultiString() {};
|
||||
|
||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
||||
virtual bool handleButtonPress(InputManager::Button button);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -68,9 +68,10 @@ void MenuSettingRGBA::handleTS() {
|
||||
MenuSetting::handleTS();
|
||||
}
|
||||
|
||||
bool MenuSettingRGBA::manageInput(InputManager::ButtonEvent *event) {
|
||||
bool MenuSettingRGBA::handleButtonPress(InputManager::Button button)
|
||||
{
|
||||
if (edit) {
|
||||
switch(event->button) {
|
||||
switch (button) {
|
||||
case InputManager::LEFT:
|
||||
dec();
|
||||
break;
|
||||
@ -93,7 +94,7 @@ bool MenuSettingRGBA::manageInput(InputManager::ButtonEvent *event) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
switch(event->button) {
|
||||
switch (button) {
|
||||
case InputManager::LEFT:
|
||||
leftComponent();
|
||||
break;
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual void handleTS();
|
||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
||||
virtual bool handleButtonPress(InputManager::Button button);
|
||||
virtual void adjustInput();
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
@ -42,9 +42,9 @@ void MenuSettingStringBase::draw(int y)
|
||||
ASFont::HAlignLeft, ASFont::VAlignTop);
|
||||
}
|
||||
|
||||
bool MenuSettingStringBase::manageInput(InputManager::ButtonEvent *event)
|
||||
bool MenuSettingStringBase::handleButtonPress(InputManager::Button button)
|
||||
{
|
||||
switch (event->button) {
|
||||
switch (button) {
|
||||
case InputManager::CANCEL:
|
||||
clear();
|
||||
break;
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
virtual ~MenuSettingStringBase();
|
||||
|
||||
virtual void draw(int y);
|
||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
||||
virtual bool handleButtonPress(InputManager::Button button);
|
||||
virtual bool edited();
|
||||
|
||||
void setValue(const std::string &value) { *_value = value; }
|
||||
|
@ -105,13 +105,9 @@ bool SettingsDialog::exec() {
|
||||
gmenu2x->s->flip();
|
||||
voices[sel]->handleTS();
|
||||
|
||||
InputManager::ButtonEvent event;
|
||||
do {
|
||||
inputMgr.waitForEvent(&event);
|
||||
} while (event.state != InputManager::PRESSED);
|
||||
|
||||
if (voices[sel]->manageInput(&event) == false) {
|
||||
switch (event.button) {
|
||||
InputManager::Button button = inputMgr.waitForPressedButton();
|
||||
if (!voices[sel]->handleButtonPress(button)) {
|
||||
switch (button) {
|
||||
case InputManager::SETTINGS:
|
||||
close = true;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user