1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-04 21:05:27 +03:00

Rewrite of the MenuSettingRGBA class so that it won't use the CLEAR/MENU buttons.

This commit is contained in:
Ayla 2011-09-18 01:33:11 +02:00
parent 7f2c7db8e2
commit d82e262662
2 changed files with 47 additions and 25 deletions

View File

@ -31,7 +31,7 @@ MenuSettingRGBA::MenuSettingRGBA(
const string &description, RGBAColor *value) const string &description, RGBAColor *value)
: MenuSetting(gmenu2x,name,description) : MenuSetting(gmenu2x,name,description)
{ {
IconButton *btn; edit = false;
selPart = 0; selPart = 0;
_value = value; _value = value;
@ -41,21 +41,7 @@ MenuSettingRGBA::MenuSettingRGBA(
this->setB(this->value().b); this->setB(this->value().b);
this->setA(this->value().a); this->setA(this->value().a);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Decrease"]); updateButtonBox();
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::dec));
buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/y.png", gmenu2x->tr["Increase"]);
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::inc));
buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::leftComponent));
buttonBox.add(btn);
btn = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"]);
btn->setAction(MakeDelegate(this, &MenuSettingRGBA::rightComponent));
buttonBox.add(btn);
} }
void MenuSettingRGBA::draw(int y) { void MenuSettingRGBA::draw(int y) {
@ -83,28 +69,45 @@ void MenuSettingRGBA::handleTS() {
} }
bool MenuSettingRGBA::manageInput(bevent_t *event) { bool MenuSettingRGBA::manageInput(bevent_t *event) {
if (edit) {
switch(event->button) { switch(event->button) {
case MANUAL: case LEFT:
inc();
break;
case CLEAR:
dec(); dec();
break; break;
case RIGHT:
inc();
break;
case ALTLEFT: case ALTLEFT:
update_value(-10); update_value(-10);
break; break;
case ALTRIGHT: case ALTRIGHT:
update_value(10); update_value(10);
break; break;
case LEFT: case ACCEPT:
leftComponent(); case UP:
break; case DOWN:
case RIGHT: edit = false;
rightComponent(); updateButtonBox();
break; break;
default: default:
return false; return false;
} }
} else {
switch(event->button) {
case LEFT:
leftComponent();
break;
case RIGHT:
rightComponent();
break;
case ACCEPT:
edit = true;
updateButtonBox();
break;
default:
return false;
}
}
return true; return true;
} }
@ -213,3 +216,19 @@ bool MenuSettingRGBA::edited()
{ {
return originalValue.r != value().r || originalValue.g != value().g || originalValue.b != value().b || originalValue.a != value().a; return originalValue.r != value().r || originalValue.g != value().g || originalValue.b != value().b || originalValue.a != value().a;
} }
void MenuSettingRGBA::updateButtonBox()
{
buttonBox.clear();
if (edit) {
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/l.png"));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"]));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/r.png"));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"]));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Confirm"]));
} else {
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/left.png"));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"]));
buttonBox.add(new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Edit"]));
}
}

View File

@ -40,6 +40,9 @@ private:
void leftComponent(); void leftComponent();
void rightComponent(); void rightComponent();
bool edit;
void updateButtonBox();
public: public:
MenuSettingRGBA( MenuSettingRGBA(
GMenu2X *gmenu2x, const std::string &name, GMenu2X *gmenu2x, const std::string &name,