mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-28 19:54:35 +02:00
Rewrite of how the events are handled by the menusetting* objects.
This commit is contained in:
parent
fdee206d93
commit
7f2c7db8e2
@ -47,7 +47,7 @@ public:
|
|||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void handleTS();
|
virtual void handleTS();
|
||||||
|
|
||||||
virtual void manageInput(bevent_t *event) = 0;
|
virtual bool manageInput(bevent_t *event) = 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,10 +64,13 @@ 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingBool::manageInput(bevent_t *event)
|
bool MenuSettingBool::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
if (event->button == ACCEPT && event->state == PRESSED)
|
if (event->button == ACCEPT && event->state == PRESSED) {
|
||||||
toggle();
|
toggle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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 void manageInput(bevent_t *event);
|
virtual bool manageInput(bevent_t *event);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
|
@ -65,7 +65,7 @@ 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingInt::manageInput(bevent_t *event)
|
bool MenuSettingInt::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
switch (event->button) {
|
switch (event->button) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
@ -81,8 +81,9 @@ void MenuSettingInt::manageInput(bevent_t *event)
|
|||||||
setValue(value() + 10);
|
setValue(value() + 10);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingInt::inc()
|
void MenuSettingInt::inc()
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
const std::string &description, int *value, int min, int max);
|
const std::string &description, int *value, int min, int max);
|
||||||
virtual ~MenuSettingInt() {}
|
virtual ~MenuSettingInt() {}
|
||||||
|
|
||||||
virtual void manageInput(bevent_t *event);
|
virtual bool manageInput(bevent_t *event);
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void draw(int);
|
virtual void draw(int);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
@ -49,7 +49,7 @@ MenuSettingMultiString::MenuSettingMultiString(
|
|||||||
buttonBox.add(btn);
|
buttonBox.add(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingMultiString::manageInput(bevent_t *event)
|
bool MenuSettingMultiString::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
switch(event->button) {
|
switch(event->button) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
@ -59,8 +59,9 @@ void MenuSettingMultiString::manageInput(bevent_t *event)
|
|||||||
incSel();
|
incSel();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingMultiString::incSel()
|
void MenuSettingMultiString::incSel()
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
const std::vector<std::string> *choices);
|
const std::vector<std::string> *choices);
|
||||||
virtual ~MenuSettingMultiString() {};
|
virtual ~MenuSettingMultiString() {};
|
||||||
|
|
||||||
virtual void manageInput(bevent_t *event);
|
virtual bool manageInput(bevent_t *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,7 +82,7 @@ void MenuSettingRGBA::handleTS() {
|
|||||||
MenuSetting::handleTS();
|
MenuSetting::handleTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingRGBA::manageInput(bevent_t *event) {
|
bool MenuSettingRGBA::manageInput(bevent_t *event) {
|
||||||
switch(event->button) {
|
switch(event->button) {
|
||||||
case MANUAL:
|
case MANUAL:
|
||||||
inc();
|
inc();
|
||||||
@ -103,8 +103,9 @@ void MenuSettingRGBA::manageInput(bevent_t *event) {
|
|||||||
rightComponent();
|
rightComponent();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingRGBA::update_value(int value)
|
void MenuSettingRGBA::update_value(int value)
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void handleTS();
|
virtual void handleTS();
|
||||||
virtual void manageInput(bevent_t *event);
|
virtual bool manageInput(bevent_t *event);
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void drawSelected(int y);
|
virtual void drawSelected(int y);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
@ -42,7 +42,7 @@ void MenuSettingStringBase::draw(int y)
|
|||||||
ASFont::HAlignLeft, ASFont::VAlignTop);
|
ASFont::HAlignLeft, ASFont::VAlignTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingStringBase::manageInput(bevent_t *event)
|
bool MenuSettingStringBase::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
switch (event->button) {
|
switch (event->button) {
|
||||||
case CLEAR:
|
case CLEAR:
|
||||||
@ -52,8 +52,10 @@ void MenuSettingStringBase::manageInput(bevent_t *event)
|
|||||||
edit();
|
edit();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingStringBase::clear()
|
void MenuSettingStringBase::clear()
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
virtual ~MenuSettingStringBase();
|
virtual ~MenuSettingStringBase();
|
||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void manageInput(bevent_t *event);
|
virtual bool manageInput(bevent_t *event);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
|
||||||
void setValue(const std::string &value) { *_value = value; }
|
void setValue(const std::string &value) { *_value = value; }
|
||||||
|
@ -110,6 +110,7 @@ bool SettingsDialog::exec() {
|
|||||||
inputMgr.waitForEvent(&event);
|
inputMgr.waitForEvent(&event);
|
||||||
} while (event.state != PRESSED);
|
} while (event.state != PRESSED);
|
||||||
|
|
||||||
|
if (voices[sel]->manageInput(&event) == false) {
|
||||||
switch (event.button) {
|
switch (event.button) {
|
||||||
case SETTINGS:
|
case SETTINGS:
|
||||||
close = true;
|
close = true;
|
||||||
@ -127,36 +128,10 @@ bool SettingsDialog::exec() {
|
|||||||
if (sel>=voices.size()) sel = 0;
|
if (sel>=voices.size()) sel = 0;
|
||||||
gmenu2x->setInputSpeed();
|
gmenu2x->setInputSpeed();
|
||||||
voices[sel]->adjustInput();
|
voices[sel]->adjustInput();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
voices[sel]->manageInput(&event);
|
|
||||||
break;
|
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;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gmenu2x->setInputSpeed();
|
gmenu2x->setInputSpeed();
|
||||||
|
Loading…
Reference in New Issue
Block a user