mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 18:21:54 +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 draw(int y);
|
||||||
virtual void handleTS();
|
virtual void handleTS();
|
||||||
|
|
||||||
virtual bool manageInput(InputManager::ButtonEvent *event) = 0;
|
virtual bool handleButtonPress(InputManager::Button button) = 0;
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void drawSelected(int y);
|
virtual void drawSelected(int y);
|
||||||
virtual bool edited() = 0;
|
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 );
|
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
|
if (button == InputManager::ACCEPT) {
|
||||||
&& event->state == InputManager::PRESSED) {
|
|
||||||
toggle();
|
toggle();
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuSettingBool::toggle()
|
void MenuSettingBool::toggle()
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
virtual ~MenuSettingBool() {}
|
virtual ~MenuSettingBool() {}
|
||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
|
||||||
void setValue(int value);
|
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 );
|
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:
|
case InputManager::LEFT:
|
||||||
dec();
|
dec();
|
||||||
break;
|
break;
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
int increment = 1);
|
int increment = 1);
|
||||||
virtual ~MenuSettingInt() {}
|
virtual ~MenuSettingInt() {}
|
||||||
|
|
||||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void draw(int);
|
virtual void draw(int);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
@ -49,9 +49,9 @@ MenuSettingMultiString::MenuSettingMultiString(
|
|||||||
buttonBox.add(btn);
|
buttonBox.add(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuSettingMultiString::manageInput(InputManager::ButtonEvent *event)
|
bool MenuSettingMultiString::handleButtonPress(InputManager::Button button)
|
||||||
{
|
{
|
||||||
switch(event->button) {
|
switch (button) {
|
||||||
case InputManager::LEFT:
|
case InputManager::LEFT:
|
||||||
decSel();
|
decSel();
|
||||||
break;
|
break;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
class MenuSettingMultiString : public MenuSettingStringBase {
|
class MenuSettingMultiString : public MenuSettingStringBase {
|
||||||
private:
|
private:
|
||||||
virtual void edit() {
|
virtual void edit() {
|
||||||
/* never called because manageInput() is overridden */
|
/* never called because handleButtonPress() is overridden */
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> *choices;
|
const std::vector<std::string> *choices;
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
const std::vector<std::string> *choices);
|
const std::vector<std::string> *choices);
|
||||||
virtual ~MenuSettingMultiString() {};
|
virtual ~MenuSettingMultiString() {};
|
||||||
|
|
||||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,9 +68,10 @@ void MenuSettingRGBA::handleTS() {
|
|||||||
MenuSetting::handleTS();
|
MenuSetting::handleTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuSettingRGBA::manageInput(InputManager::ButtonEvent *event) {
|
bool MenuSettingRGBA::handleButtonPress(InputManager::Button button)
|
||||||
|
{
|
||||||
if (edit) {
|
if (edit) {
|
||||||
switch(event->button) {
|
switch (button) {
|
||||||
case InputManager::LEFT:
|
case InputManager::LEFT:
|
||||||
dec();
|
dec();
|
||||||
break;
|
break;
|
||||||
@ -93,7 +94,7 @@ bool MenuSettingRGBA::manageInput(InputManager::ButtonEvent *event) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch(event->button) {
|
switch (button) {
|
||||||
case InputManager::LEFT:
|
case InputManager::LEFT:
|
||||||
leftComponent();
|
leftComponent();
|
||||||
break;
|
break;
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void handleTS();
|
virtual void handleTS();
|
||||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void drawSelected(int y);
|
virtual void drawSelected(int y);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
@ -42,9 +42,9 @@ void MenuSettingStringBase::draw(int y)
|
|||||||
ASFont::HAlignLeft, ASFont::VAlignTop);
|
ASFont::HAlignLeft, ASFont::VAlignTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuSettingStringBase::manageInput(InputManager::ButtonEvent *event)
|
bool MenuSettingStringBase::handleButtonPress(InputManager::Button button)
|
||||||
{
|
{
|
||||||
switch (event->button) {
|
switch (button) {
|
||||||
case InputManager::CANCEL:
|
case InputManager::CANCEL:
|
||||||
clear();
|
clear();
|
||||||
break;
|
break;
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
virtual ~MenuSettingStringBase();
|
virtual ~MenuSettingStringBase();
|
||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual bool manageInput(InputManager::ButtonEvent *event);
|
virtual bool handleButtonPress(InputManager::Button button);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
|
||||||
void setValue(const std::string &value) { *_value = value; }
|
void setValue(const std::string &value) { *_value = value; }
|
||||||
|
@ -105,13 +105,9 @@ bool SettingsDialog::exec() {
|
|||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
voices[sel]->handleTS();
|
voices[sel]->handleTS();
|
||||||
|
|
||||||
InputManager::ButtonEvent event;
|
InputManager::Button button = inputMgr.waitForPressedButton();
|
||||||
do {
|
if (!voices[sel]->handleButtonPress(button)) {
|
||||||
inputMgr.waitForEvent(&event);
|
switch (button) {
|
||||||
} while (event.state != InputManager::PRESSED);
|
|
||||||
|
|
||||||
if (voices[sel]->manageInput(&event) == false) {
|
|
||||||
switch (event.button) {
|
|
||||||
case InputManager::SETTINGS:
|
case InputManager::SETTINGS:
|
||||||
close = true;
|
close = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user