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

Cap the width of setting names in SettingDialog to the width of the longest

Setting values are now displayed 10 pixels to the right of setting names, as
passed to MenuSetting::draw.

This commit also contains the following cleanups:

* The height of a row is passed to MenuSetting's draw and touchscreen methods.
* MenuSettingRGBA's magic constant (36) to separate the text for a color's
  four components is now a named constant.
* MenuSettingRGBA's color preview squares are now rowHeight - 2 pixels tall,
  and have a white border surrounded by a black border to help view the color
  it contains in both light and dark themes.
* The rectangle behind the selected setting's name is now drawn by that
  setting's drawSelected method.
This commit is contained in:
Nebuleon Fumika
2014-07-24 06:08:54 +00:00
committed by Maarten ter Huurne
parent 15472a073e
commit bac622fc39
11 changed files with 53 additions and 52 deletions

View File

@@ -30,6 +30,8 @@
using std::string;
using std::stringstream;
constexpr unsigned int COMPONENT_WIDTH = 36;
MenuSettingRGBA::MenuSettingRGBA(
GMenu2X *gmenu2x, Touchscreen &ts_,
const string &name, const string &description, RGBAColor *value)
@@ -49,28 +51,28 @@ MenuSettingRGBA::MenuSettingRGBA(
updateButtonBox();
}
void MenuSettingRGBA::draw(int y) {
this->y = y;
MenuSetting::draw(y);
gmenu2x->s->rectangle( 153, y+1, 11, 11, 0,0,0,255 );
gmenu2x->s->box( 154, y+2, 9, 9, value() );
gmenu2x->s->write( gmenu2x->font, "R: "+strR, 169, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y, Font::HAlignLeft, Font::VAlignTop );
void MenuSettingRGBA::draw(int valueX, int y, int h) {
MenuSetting::draw(valueX, y, h);
gmenu2x->s->rectangle( valueX, y + 1, h - 2, h - 2, 0,0,0,255 );
gmenu2x->s->rectangle( valueX + 1, y + 2, h - 4, h - 4, 255,255,255,255 );
gmenu2x->s->box( valueX + 2, y + 3, h - 6, h - 6, value() );
gmenu2x->s->write( gmenu2x->font, "R: "+strR, valueX + h + 3, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "G: "+strG, valueX + h + 3 + COMPONENT_WIDTH, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "B: "+strB, valueX + h + 3 + COMPONENT_WIDTH * 2, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "A: "+strA, valueX + h + 3 + COMPONENT_WIDTH * 3, y, Font::HAlignLeft, Font::VAlignTop );
}
void MenuSettingRGBA::handleTS() {
void MenuSettingRGBA::handleTS(int valueX, int y, int h) {
if (ts.pressed()) {
for (int i=0; i<4; i++) {
if (i!=selPart && ts.inRect(166+i*36,y,36,14)) {
if (i!=selPart && ts.inRect(valueX + h + i * COMPONENT_WIDTH,y,COMPONENT_WIDTH,h)) {
selPart = i;
i = 4;
break;
}
}
}
MenuSetting::handleTS();
MenuSetting::handleTS(valueX, y, h);
}
bool MenuSettingRGBA::handleButtonPress(InputManager::Button button)
@@ -199,12 +201,12 @@ unsigned short MenuSettingRGBA::getSelPart()
}
}
void MenuSettingRGBA::drawSelected(int y)
void MenuSettingRGBA::drawSelected(int valueX, int y, int h)
{
int x = 166+selPart*36;
gmenu2x->s->box( x, y, 36, 14, gmenu2x->skinConfColors[COLOR_SELECTION_BG] );
int x = valueX + selPart * COMPONENT_WIDTH;
gmenu2x->s->box( x + h, y, COMPONENT_WIDTH, h, gmenu2x->skinConfColors[COLOR_SELECTION_BG] );
MenuSetting::drawSelected(y);
MenuSetting::drawSelected(valueX, y, h);
}
bool MenuSettingRGBA::edited()