1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-27 11:49:54 +02:00

Rewrite of how the events are handled by the menusetting* objects.

This commit is contained in:
Ayla 2011-09-15 20:20:35 +02:00
parent fdee206d93
commit 7f2c7db8e2
12 changed files with 60 additions and 77 deletions

View File

@ -47,7 +47,7 @@ public:
virtual void draw(int y);
virtual void handleTS();
virtual void manageInput(bevent_t *event) = 0;
virtual bool manageInput(bevent_t *event) = 0;
virtual void adjustInput();
virtual void drawSelected(int y);
virtual bool edited() = 0;

View File

@ -64,10 +64,13 @@ void MenuSettingBool::draw(int y)
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop );
}
void MenuSettingBool::manageInput(bevent_t *event)
bool MenuSettingBool::manageInput(bevent_t *event)
{
if (event->button == ACCEPT && event->state == PRESSED)
toggle();
if (event->button == ACCEPT && event->state == PRESSED) {
toggle();
return true;
}
return false;
}
void MenuSettingBool::toggle()

View File

@ -45,7 +45,7 @@ public:
virtual ~MenuSettingBool() {}
virtual void draw(int y);
virtual void manageInput(bevent_t *event);
virtual bool manageInput(bevent_t *event);
virtual bool edited();
void setValue(int value);

View File

@ -65,7 +65,7 @@ void MenuSettingInt::draw(int y)
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop );
}
void MenuSettingInt::manageInput(bevent_t *event)
bool MenuSettingInt::manageInput(bevent_t *event)
{
switch (event->button) {
case LEFT:
@ -81,8 +81,9 @@ void MenuSettingInt::manageInput(bevent_t *event)
setValue(value() + 10);
break;
default:
break;
return false;
}
return true;
}
void MenuSettingInt::inc()

View File

@ -39,7 +39,7 @@ public:
const std::string &description, int *value, int min, int max);
virtual ~MenuSettingInt() {}
virtual void manageInput(bevent_t *event);
virtual bool manageInput(bevent_t *event);
virtual void adjustInput();
virtual void draw(int);
virtual bool edited();

View File

@ -49,7 +49,7 @@ MenuSettingMultiString::MenuSettingMultiString(
buttonBox.add(btn);
}
void MenuSettingMultiString::manageInput(bevent_t *event)
bool MenuSettingMultiString::manageInput(bevent_t *event)
{
switch(event->button) {
case LEFT:
@ -59,8 +59,9 @@ void MenuSettingMultiString::manageInput(bevent_t *event)
incSel();
break;
default:
break;
return false;
}
return true;
}
void MenuSettingMultiString::incSel()

View File

@ -45,7 +45,7 @@ public:
const std::vector<std::string> *choices);
virtual ~MenuSettingMultiString() {};
virtual void manageInput(bevent_t *event);
virtual bool manageInput(bevent_t *event);
};
#endif

View File

@ -82,29 +82,30 @@ void MenuSettingRGBA::handleTS() {
MenuSetting::handleTS();
}
void MenuSettingRGBA::manageInput(bevent_t *event) {
switch(event->button) {
case MANUAL:
inc();
break;
case CLEAR:
dec();
break;
bool MenuSettingRGBA::manageInput(bevent_t *event) {
switch(event->button) {
case MANUAL:
inc();
break;
case CLEAR:
dec();
break;
case ALTLEFT:
update_value(-10);
break;
case ALTRIGHT:
update_value(10);
break;
case LEFT:
leftComponent();
break;
case RIGHT:
rightComponent();
break;
default:
break;
}
case LEFT:
leftComponent();
break;
case RIGHT:
rightComponent();
break;
default:
return false;
}
return true;
}
void MenuSettingRGBA::update_value(int value)

View File

@ -48,7 +48,7 @@ public:
virtual void draw(int y);
virtual void handleTS();
virtual void manageInput(bevent_t *event);
virtual bool manageInput(bevent_t *event);
virtual void adjustInput();
virtual void drawSelected(int y);
virtual bool edited();

View File

@ -42,7 +42,7 @@ void MenuSettingStringBase::draw(int y)
ASFont::HAlignLeft, ASFont::VAlignTop);
}
void MenuSettingStringBase::manageInput(bevent_t *event)
bool MenuSettingStringBase::manageInput(bevent_t *event)
{
switch (event->button) {
case CLEAR:
@ -52,8 +52,10 @@ void MenuSettingStringBase::manageInput(bevent_t *event)
edit();
break;
default:
return false;
break;
}
return true;
}
void MenuSettingStringBase::clear()

View File

@ -38,7 +38,7 @@ public:
virtual ~MenuSettingStringBase();
virtual void draw(int y);
virtual void manageInput(bevent_t *event);
virtual bool manageInput(bevent_t *event);
virtual bool edited();
void setValue(const std::string &value) { *_value = value; }

View File

@ -110,53 +110,28 @@ bool SettingsDialog::exec() {
inputMgr.waitForEvent(&event);
} while (event.state != PRESSED);
switch (event.button) {
case SETTINGS:
close = true;
break;
case UP:
if (sel==0)
sel = voices.size()-1;
else
sel -= 1;
gmenu2x->setInputSpeed();
voices[sel]->adjustInput();
break;
case DOWN:
sel += 1;
if (sel>=voices.size()) sel = 0;
gmenu2x->setInputSpeed();
voices[sel]->adjustInput();
break;
default:
voices[sel]->manageInput(&event);
break;
}
/*
inputMgr.update();
if ( inputMgr[ACTION_START] ) action = SD_ACTION_CLOSE;
if ( inputMgr[ACTION_UP ] ) action = SD_ACTION_UP;
if ( inputMgr[ACTION_DOWN ] ) action = SD_ACTION_DOWN;
switch (action) {
case SD_ACTION_CLOSE: close = true; break;
case SD_ACTION_UP: {
if (sel==0)
sel = voices.size()-1;
else
sel -= 1;
gmenu2x->setInputSpeed();
voices[sel]->adjustInput();
} break;
case SD_ACTION_DOWN: {
sel += 1;
if (sel>=voices.size()) sel = 0;
gmenu2x->setInputSpeed();
voices[sel]->adjustInput();
} break;
if (voices[sel]->manageInput(&event) == false) {
switch (event.button) {
case SETTINGS:
close = true;
break;
case UP:
if (sel==0)
sel = voices.size()-1;
else
sel -= 1;
gmenu2x->setInputSpeed();
voices[sel]->adjustInput();
break;
case DOWN:
sel += 1;
if (sel>=voices.size()) sel = 0;
gmenu2x->setInputSpeed();
voices[sel]->adjustInput();
default:
break;
}
}
*/
}
gmenu2x->setInputSpeed();