mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 09:59:41 +02:00
ASFont: removed precalculation of half heights.
There is no point in precalculating something so cheap to recalculate. Also, the majority of uses was to compensate for passing the wrong alignment argument.
This commit is contained in:
parent
492a36b9df
commit
e4b71138b9
@ -177,8 +177,6 @@ unsigned SFontPlus::getLineHeight() {
|
||||
ASFont::ASFont(const std::string &fontImagePath)
|
||||
: font(fontImagePath, SFONTPLUS_CHARSET)
|
||||
{
|
||||
halfHeight = getHeight()/2;
|
||||
halfLineHeight = getLineHeight()/2;
|
||||
}
|
||||
|
||||
ASFont::~ASFont() {
|
||||
@ -208,7 +206,7 @@ void ASFont::write(SDL_Surface* surface, const std::string& text, int x, int y,
|
||||
case VAlignTop:
|
||||
break;
|
||||
case VAlignMiddle:
|
||||
y -= getHalfHeight();
|
||||
y -= getHeight() / 2;
|
||||
break;
|
||||
case VAlignBottom:
|
||||
y -= getHeight();
|
||||
@ -222,7 +220,7 @@ void ASFont::write(SDL_Surface* surface, std::vector<std::string> *text, int x,
|
||||
case VAlignTop:
|
||||
break;
|
||||
case VAlignMiddle:
|
||||
y -= getHalfHeight()*text->size();
|
||||
y -= (getHeight() / 2) * text->size();
|
||||
break;
|
||||
case VAlignBottom:
|
||||
y -= getHeight()*text->size();
|
||||
@ -258,16 +256,9 @@ void ASFont::write(Surface* surface, const std::string& text, int x, int y, HAli
|
||||
int ASFont::getHeight() {
|
||||
return font.getHeight();
|
||||
}
|
||||
int ASFont::getHalfHeight() {
|
||||
return halfHeight;
|
||||
}
|
||||
|
||||
int ASFont::getLineHeight() {
|
||||
return font.getLineHeight();
|
||||
}
|
||||
int ASFont::getHalfLineHeight() {
|
||||
return halfLineHeight;
|
||||
}
|
||||
|
||||
int ASFont::getTextWidth(const char* text) {
|
||||
return font.getTextWidth(text);
|
||||
|
@ -45,9 +45,7 @@ public:
|
||||
bool utf8Code(unsigned char c);
|
||||
|
||||
int getHeight();
|
||||
int getHalfHeight();
|
||||
int getLineHeight();
|
||||
int getHalfLineHeight();
|
||||
int getTextWidth(const char* text);
|
||||
int getTextWidth(const std::string& text);
|
||||
int getTextWidth(std::vector<std::string> *text);
|
||||
@ -58,7 +56,6 @@ public:
|
||||
|
||||
private:
|
||||
SFontPlus font;
|
||||
int halfHeight, halfLineHeight;
|
||||
};
|
||||
|
||||
#endif /* ASFONT_H */
|
||||
|
@ -1333,7 +1333,6 @@ void GMenu2X::contextMenu() {
|
||||
uint i, sel=0, fadeAlpha=0;
|
||||
|
||||
int h = font->getHeight();
|
||||
int h2 = font->getHalfHeight();
|
||||
SDL_Rect box;
|
||||
box.h = (h+2)*voices.size()+8;
|
||||
box.w = 0;
|
||||
@ -1370,7 +1369,7 @@ void GMenu2X::contextMenu() {
|
||||
//draw selection rect
|
||||
s->box( selbox.x, selbox.y, selbox.w, selbox.h, skinConfColors[COLOR_MESSAGE_BOX_SELECTION] );
|
||||
for (i=0; i<voices.size(); i++)
|
||||
s->write( font, voices[i].text, box.x+12, box.y+h2+5+(h+2)*i, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
s->write( font, voices[i].text, box.x+12, box.y+5+(h+2)*i, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
s->flip();
|
||||
|
||||
//touchscreen
|
||||
|
@ -36,7 +36,7 @@ MenuSetting::~MenuSetting()
|
||||
|
||||
void MenuSetting::draw(int y)
|
||||
{
|
||||
gmenu2x->s->write( gmenu2x->font, name, 5, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, name, 5, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
}
|
||||
|
||||
void MenuSetting::handleTS()
|
||||
|
@ -61,7 +61,7 @@ void MenuSettingBool::initButton()
|
||||
void MenuSettingBool::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
}
|
||||
|
||||
void MenuSettingBool::manageInput(bevent_t *event)
|
||||
|
@ -62,7 +62,7 @@ MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const strin
|
||||
void MenuSettingInt::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
}
|
||||
|
||||
void MenuSettingInt::manageInput(bevent_t *event)
|
||||
|
@ -63,10 +63,10 @@ void MenuSettingRGBA::draw(int 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+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, "R: "+strR, 169, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y, ASFont::HAlignLeft, ASFont::VAlignTop );
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::handleTS() {
|
||||
|
@ -38,10 +38,8 @@ MenuSettingStringBase::~MenuSettingStringBase()
|
||||
void MenuSettingStringBase::draw(int y)
|
||||
{
|
||||
MenuSetting::draw(y);
|
||||
gmenu2x->s->write(
|
||||
gmenu2x->font, value(),
|
||||
155, y + gmenu2x->font->getHalfHeight(),
|
||||
ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, value(), 155, y,
|
||||
ASFont::HAlignLeft, ASFont::VAlignTop);
|
||||
}
|
||||
|
||||
void MenuSettingStringBase::manageInput(bevent_t *event)
|
||||
|
Loading…
Reference in New Issue
Block a user