mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 19:03:44 +02:00
Introduced enums for text alignment in the ASFont class.
This commit is contained in:
parent
c54dec90f5
commit
a35a7e2c35
@ -32,33 +32,39 @@ void ASFont::write(SDL_Surface* surface, const char* text, int x, int y) {
|
||||
font.write(surface, text, x, y);
|
||||
}
|
||||
|
||||
void ASFont::write(SDL_Surface* surface, const std::string& text, int x, int y, const unsigned short halign, const unsigned short valign) {
|
||||
void ASFont::write(SDL_Surface* surface, const std::string& text, int x, int y, HAlign halign, VAlign valign) {
|
||||
switch (halign) {
|
||||
case SFontHAlignCenter:
|
||||
case HAlignLeft:
|
||||
break;
|
||||
case HAlignCenter:
|
||||
x -= getTextWidth(text)/2;
|
||||
break;
|
||||
case SFontHAlignRight:
|
||||
case HAlignRight:
|
||||
x -= getTextWidth(text);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valign) {
|
||||
case SFontVAlignMiddle:
|
||||
case VAlignTop:
|
||||
break;
|
||||
case VAlignMiddle:
|
||||
y -= getHalfHeight();
|
||||
break;
|
||||
case SFontVAlignBottom:
|
||||
case VAlignBottom:
|
||||
y -= getHeight();
|
||||
break;
|
||||
}
|
||||
|
||||
font.write(surface, text, x, y);
|
||||
}
|
||||
void ASFont::write(SDL_Surface* surface, std::vector<std::string> *text, int x, int y, const unsigned short halign, const unsigned short valign) {
|
||||
void ASFont::write(SDL_Surface* surface, std::vector<std::string> *text, int x, int y, HAlign halign, VAlign valign) {
|
||||
switch (valign) {
|
||||
case SFontVAlignMiddle:
|
||||
case VAlignTop:
|
||||
break;
|
||||
case VAlignMiddle:
|
||||
y -= getHalfHeight()*text->size();
|
||||
break;
|
||||
case SFontVAlignBottom:
|
||||
case VAlignBottom:
|
||||
y -= getHeight()*text->size();
|
||||
break;
|
||||
}
|
||||
@ -66,10 +72,12 @@ void ASFont::write(SDL_Surface* surface, std::vector<std::string> *text, int x,
|
||||
for (unsigned i=0; i<text->size(); i++) {
|
||||
int ix = x;
|
||||
switch (halign) {
|
||||
case SFontHAlignCenter:
|
||||
case HAlignLeft:
|
||||
break;
|
||||
case HAlignCenter:
|
||||
ix -= getTextWidth(text->at(i))/2;
|
||||
break;
|
||||
case SFontHAlignRight:
|
||||
case HAlignRight:
|
||||
ix -= getTextWidth(text->at(i));
|
||||
break;
|
||||
}
|
||||
@ -78,7 +86,7 @@ void ASFont::write(SDL_Surface* surface, std::vector<std::string> *text, int x,
|
||||
}
|
||||
}
|
||||
|
||||
void ASFont::write(Surface* surface, const std::string& text, int x, int y, const unsigned short halign, const unsigned short valign) {
|
||||
void ASFont::write(Surface* surface, const std::string& text, int x, int y, HAlign halign, VAlign valign) {
|
||||
if (text.find("\n", 0) != std::string::npos) {
|
||||
std::vector<std::string> textArr;
|
||||
split(textArr,text,"\n");
|
||||
|
15
src/asfont.h
15
src/asfont.h
@ -11,15 +11,12 @@
|
||||
struct SDL_Surface;
|
||||
class Surface;
|
||||
|
||||
const unsigned short SFontHAlignLeft = 0;
|
||||
const unsigned short SFontHAlignRight = 1;
|
||||
const unsigned short SFontHAlignCenter = 2;
|
||||
const unsigned short SFontVAlignTop = 0;
|
||||
const unsigned short SFontVAlignBottom = 1;
|
||||
const unsigned short SFontVAlignMiddle = 2;
|
||||
|
||||
class ASFont {
|
||||
public:
|
||||
enum HAlign { HAlignLeft, HAlignRight, HAlignCenter };
|
||||
enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle };
|
||||
|
||||
ASFont(SDL_Surface* font);
|
||||
ASFont(Surface* font);
|
||||
ASFont(const std::string &font);
|
||||
@ -35,9 +32,9 @@ public:
|
||||
int getTextWidth(const std::string& text);
|
||||
int getTextWidth(std::vector<std::string> *text);
|
||||
void write(SDL_Surface* surface, const char* text, int x, int y);
|
||||
void write(SDL_Surface* surface, const std::string& text, int x, int y, const unsigned short halign = 0, const unsigned short valign = 0);
|
||||
void write(SDL_Surface* surface, std::vector<std::string> *text, int x, int y, const unsigned short halign = 0, const unsigned short valign = 0);
|
||||
void write(Surface* surface, const std::string& text, int x, int y, const unsigned short halign = 0, const unsigned short valign = 0);
|
||||
void write(SDL_Surface* surface, const std::string& text, int x, int y, HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
|
||||
void write(SDL_Surface* surface, std::vector<std::string> *text, int x, int y, HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
|
||||
void write(Surface* surface, const std::string& text, int x, int y, HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
|
||||
|
||||
private:
|
||||
SFontPlus font;
|
||||
|
@ -260,7 +260,7 @@ void BrowseDialog::paint()
|
||||
icon = iconFile;
|
||||
}
|
||||
icon->blit(gmenu2x->s, 5, offsetY);
|
||||
gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, SFontHAlignLeft, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
|
||||
if (gmenu2x->f200 && gmenu2x->ts.pressed() && gmenu2x->ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) {
|
||||
ts_pressed = true;
|
||||
|
@ -31,14 +31,14 @@ void Dialog::writeTitle(const std::string &title, Surface *s)
|
||||
{
|
||||
if (s==NULL)
|
||||
s = gmenu2x->s;
|
||||
s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"]/4, SFontHAlignLeft, SFontVAlignMiddle);
|
||||
s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"]/4, ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
}
|
||||
|
||||
void Dialog::writeSubTitle(const std::string &subtitle, Surface *s)
|
||||
{
|
||||
if (s==NULL)
|
||||
s = gmenu2x->s;
|
||||
s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"]/4*3, SFontHAlignLeft, SFontVAlignMiddle);
|
||||
s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"]/4*3, ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
}
|
||||
|
||||
|
||||
|
@ -374,7 +374,7 @@ void GMenu2X::initBG() {
|
||||
string df = getDiskFree();
|
||||
|
||||
sd.blit( sc["bgmain"], 3, bottomBarIconY );
|
||||
sc["bgmain"]->write( font, df, 22, bottomBarTextY, SFontHAlignLeft, SFontVAlignMiddle );
|
||||
sc["bgmain"]->write( font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
volumeX = 27+font->getTextWidth(df);
|
||||
volume.blit( sc["bgmain"], volumeX, bottomBarIconY );
|
||||
volumeX += 19;
|
||||
@ -845,7 +845,7 @@ void GMenu2X::main() {
|
||||
sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32);
|
||||
else
|
||||
sc.skinRes("icons/section.png")->blit(s,x-16,sectionLinkPadding);
|
||||
s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, SFontHAlignCenter, SFontVAlignBottom );
|
||||
s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, ASFont::HAlignCenter, ASFont::VAlignBottom );
|
||||
}
|
||||
|
||||
//Links
|
||||
@ -874,10 +874,10 @@ void GMenu2X::main() {
|
||||
*/
|
||||
|
||||
if (menu->selLink()!=NULL) {
|
||||
s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, SFontHAlignCenter, SFontVAlignBottom );
|
||||
s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, ASFont::HAlignCenter, ASFont::VAlignBottom );
|
||||
if (menu->selLinkApp()!=NULL) {
|
||||
s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, SFontHAlignLeft, SFontVAlignMiddle );
|
||||
s->write ( font, menu->selLinkApp()->volumeStr(), volumeX, bottomBarTextY, SFontHAlignLeft, SFontVAlignMiddle );
|
||||
s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
s->write ( font, menu->selLinkApp()->volumeStr(), volumeX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
//Manual indicator
|
||||
if (!menu->selLinkApp()->getManual().empty())
|
||||
sc.skinRes("imgs/manual.png")->blit(s,manualX,bottomBarIconY);
|
||||
@ -931,7 +931,7 @@ void GMenu2X::main() {
|
||||
tickFPS = tickNow;
|
||||
drawn_frames = 0;
|
||||
}
|
||||
s->write( font, fps+" FPS", resX-1,1 ,SFontHAlignRight );
|
||||
s->write( font, fps+" FPS", resX-1,1 ,ASFont::HAlignRight );
|
||||
#endif
|
||||
|
||||
s->flip();
|
||||
@ -1371,7 +1371,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, SFontHAlignLeft, SFontVAlignMiddle );
|
||||
s->write( font, voices[i].text, box.x+12, box.y+h2+5+(h+2)*i, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
s->flip();
|
||||
|
||||
//touchscreen
|
||||
@ -1647,7 +1647,7 @@ void GMenu2X::scanner() {
|
||||
Surface scanbg(bg);
|
||||
drawButton(&scanbg, "x", tr["Exit"],
|
||||
drawButton(&scanbg, "b", "", 5)-10);
|
||||
scanbg.write(font,tr["Link Scanner"],halfX,7,SFontHAlignCenter,SFontVAlignMiddle);
|
||||
scanbg.write(font,tr["Link Scanner"],halfX,7,ASFont::HAlignCenter,ASFont::VAlignMiddle);
|
||||
|
||||
uint lineY = 42;
|
||||
|
||||
@ -1993,7 +1993,7 @@ int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x
|
||||
if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
|
||||
sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7);
|
||||
re.w = sc["imgs/buttons/"+btn+".png"]->raw->w+3;
|
||||
s->write(font, text, x+re.w, y, SFontHAlignLeft, SFontVAlignMiddle);
|
||||
s->write(font, text, x+re.w, y, ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
re.w += font->getTextWidth(text);
|
||||
}
|
||||
return x+re.w+6;
|
||||
@ -2005,7 +2005,7 @@ int GMenu2X::drawButtonRight(Surface *s, const string &btn, const string &text,
|
||||
x -= 16;
|
||||
sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7);
|
||||
x -= 3;
|
||||
s->write(font, text, x, y, SFontHAlignRight, SFontVAlignMiddle);
|
||||
s->write(font, text, x, y, ASFont::HAlignRight, ASFont::VAlignMiddle);
|
||||
return x-6-font->getTextWidth(text);
|
||||
}
|
||||
return x-6;
|
||||
|
@ -71,13 +71,13 @@ void IconButton::recalcSize() {
|
||||
if (labelPosition == IconButton::DISP_LEFT || labelPosition == IconButton::DISP_RIGHT) {
|
||||
w += margin + labelRect.w;
|
||||
//if (labelRect.h > h) h = labelRect.h;
|
||||
labelHAlign = SFontHAlignLeft;
|
||||
labelVAlign = SFontVAlignMiddle;
|
||||
labelHAlign = ASFont::HAlignLeft;
|
||||
labelVAlign = ASFont::VAlignMiddle;
|
||||
} else {
|
||||
h += margin + labelRect.h;
|
||||
//if (labelRect.w > w) w = labelRect.w;
|
||||
labelHAlign = SFontHAlignCenter;
|
||||
labelVAlign = SFontVAlignTop;
|
||||
labelHAlign = ASFont::HAlignCenter;
|
||||
labelVAlign = ASFont::VAlignTop;
|
||||
}
|
||||
|
||||
switch (labelPosition) {
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef ICONBUTTON_H
|
||||
#define ICONBUTTON_H
|
||||
|
||||
#include <string>
|
||||
#include "button.h"
|
||||
#include "asfont.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -14,7 +16,8 @@ protected:
|
||||
GMenu2X *gmenu2x;
|
||||
string icon, label;
|
||||
int labelPosition, labelMargin;
|
||||
unsigned short labelHAlign, labelVAlign;
|
||||
ASFont::HAlign labelHAlign;
|
||||
ASFont::VAlign labelVAlign;
|
||||
void recalcSize();
|
||||
SDL_Rect iconRect, labelRect;
|
||||
|
||||
|
@ -150,7 +150,7 @@ bool InputDialog::exec() {
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x->s->rectangle(box.x, box.y, box.w, box.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
gmenu2x->s->write(gmenu2x->font, input, box.x+5, box.y+box.h-2, SFontHAlignLeft, SFontVAlignBottom);
|
||||
gmenu2x->s->write(gmenu2x->font, input, box.x+5, box.y+box.h-2, ASFont::HAlignLeft, ASFont::VAlignBottom);
|
||||
|
||||
curTick = SDL_GetTicks();
|
||||
if (curTick-caretTick>=600) {
|
||||
@ -317,7 +317,7 @@ int InputDialog::drawVirtualKeyboard() {
|
||||
}
|
||||
|
||||
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x->s->write(gmenu2x->font, charX, kbLeft+xc*KEY_WIDTH+KEY_WIDTH/2-1, KB_TOP+l*KEY_HEIGHT+KEY_HEIGHT/2, SFontHAlignCenter, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, charX, kbLeft+xc*KEY_WIDTH+KEY_WIDTH/2-1, KB_TOP+l*KEY_HEIGHT+KEY_HEIGHT/2, ASFont::HAlignCenter, ASFont::VAlignMiddle);
|
||||
xc++;
|
||||
}
|
||||
}
|
||||
@ -329,7 +329,7 @@ int InputDialog::drawVirtualKeyboard() {
|
||||
selCol = 0;
|
||||
selRow = kb->size();
|
||||
}
|
||||
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"], (int)(160-kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, SFontHAlignCenter, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"], (int)(160-kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, ASFont::HAlignCenter, ASFont::VAlignMiddle);
|
||||
|
||||
re.x = kbLeft+kbLength*KEY_WIDTH/2-1;
|
||||
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
@ -337,7 +337,7 @@ int InputDialog::drawVirtualKeyboard() {
|
||||
selCol = 1;
|
||||
selRow = kb->size();
|
||||
}
|
||||
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], (int)(160+kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, SFontHAlignCenter, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], (int)(160+kbLength*KEY_WIDTH/4), KB_TOP+kb->size()*KEY_HEIGHT+KEY_HEIGHT/2, ASFont::HAlignCenter, ASFont::VAlignMiddle);
|
||||
|
||||
//if ts released
|
||||
if (gmenu2x->f200 && ts.released() && ts.inRect(kbRect)) {
|
||||
|
@ -43,12 +43,12 @@ void Link::run() {}
|
||||
|
||||
void Link::paint() {
|
||||
iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
|
||||
gmenu2x->s->write( gmenu2x->font, getTitle(), iconX+16, rect.y+gmenu2x->skinConfInt["linkHeight"]-padding, SFontHAlignCenter, SFontVAlignBottom );
|
||||
gmenu2x->s->write( gmenu2x->font, getTitle(), iconX+16, rect.y+gmenu2x->skinConfInt["linkHeight"]-padding, ASFont::HAlignCenter, ASFont::VAlignBottom );
|
||||
}
|
||||
|
||||
bool Link::paintHover() {
|
||||
if (gmenu2x->useSelectionPng)
|
||||
gmenu2x->sc["imgs/selection.png"]->blit(gmenu2x->s,rect,SFontHAlignCenter,SFontVAlignMiddle);
|
||||
gmenu2x->sc["imgs/selection.png"]->blit(gmenu2x->s,rect,ASFont::HAlignCenter,ASFont::VAlignMiddle);
|
||||
else
|
||||
gmenu2x->s->box(rect.x, rect.y, rect.w, rect.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
return true;
|
||||
|
@ -280,7 +280,7 @@ void LinkApp::drawRun() {
|
||||
else
|
||||
gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/
|
||||
gmenu2x->sc[getIconPath()]->blit(gmenu2x->s,x,gmenu2x->halfY-16);
|
||||
gmenu2x->s->write( gmenu2x->font, text, x+42, gmenu2x->halfY+1, SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, text, x+42, gmenu2x->halfY+1, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
gmenu2x->s->flip();
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ void LinkApp::showManual() {
|
||||
ss << page+1;
|
||||
ss >> pageStatus;
|
||||
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, SFontHAlignRight, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, ASFont::HAlignRight, ASFont::VAlignMiddle);
|
||||
|
||||
gmenu2x->s->flip();
|
||||
repaint = false;
|
||||
|
@ -36,7 +36,7 @@ MenuSetting::~MenuSetting()
|
||||
|
||||
void MenuSetting::draw(int y)
|
||||
{
|
||||
gmenu2x->s->write( gmenu2x->font, name, 5, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, name, 5, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
}
|
||||
|
||||
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(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
}
|
||||
|
||||
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(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
}
|
||||
|
||||
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(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||
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 );
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::handleTS() {
|
||||
|
@ -41,7 +41,7 @@ void MenuSettingStringBase::draw(int y)
|
||||
gmenu2x->s->write(
|
||||
gmenu2x->font, value(),
|
||||
155, y + gmenu2x->font->getHalfHeight(),
|
||||
SFontHAlignLeft, SFontVAlignMiddle);
|
||||
ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
}
|
||||
|
||||
void MenuSettingStringBase::manageInput(bevent_t *event)
|
||||
|
@ -84,7 +84,7 @@ int MessageBox::exec() {
|
||||
//icon+text
|
||||
if (gmenu2x->sc[icon] != NULL)
|
||||
gmenu2x->sc[icon]->blitCenter( &bg, box.x+25, box.y+gmenu2x->font->getHeight()+3 );
|
||||
bg.write( gmenu2x->font, text, box.x+(gmenu2x->sc[icon] != NULL ? 47 : 10), box.y+gmenu2x->font->getHeight()+3, SFontHAlignLeft, SFontVAlignMiddle );
|
||||
bg.write( gmenu2x->font, text, box.x+(gmenu2x->sc[icon] != NULL ? 47 : 10), box.y+gmenu2x->font->getHeight()+3, ASFont::HAlignLeft, ASFont::VAlignMiddle );
|
||||
|
||||
int btnX = gmenu2x->halfX+box.w/2-6;
|
||||
for (uint i=0; i<buttons.size(); i++) {
|
||||
|
@ -106,9 +106,9 @@ int Selector::exec(int startSelection) {
|
||||
iY = i-firstElement;
|
||||
if (fl.isDirectory(i)) {
|
||||
gmenu2x->sc["imgs/folder.png"]->blit(gmenu2x->s, 4, 42+(iY*16));
|
||||
gmenu2x->s->write(gmenu2x->font, fl[i], 21, 49+(iY*16), SFontHAlignLeft, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, fl[i], 21, 49+(iY*16), ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
} else
|
||||
gmenu2x->s->write(gmenu2x->font, titles[i-fl.dirCount()], 4, 49+(iY*16), SFontHAlignLeft, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, titles[i-fl.dirCount()], 4, 49+(iY*16), ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
}
|
||||
gmenu2x->s->clearClipRect();
|
||||
|
||||
|
@ -267,10 +267,6 @@ void Surface::blendAdd(Surface *target, int x, int y) {
|
||||
*/
|
||||
}
|
||||
|
||||
void Surface::write(ASFont *font, const string &text, int x, int y, const unsigned short halign, const unsigned short valign) {
|
||||
font->write(this,text,x,y,halign,valign);
|
||||
}
|
||||
|
||||
void Surface::operator = (SDL_Surface *s) {
|
||||
raw = SDL_DisplayFormat(s);
|
||||
halfW = raw->w/2;
|
||||
@ -340,21 +336,25 @@ void Surface::setClipRect(SDL_Rect rect) {
|
||||
SDL_SetClipRect(raw,&rect);
|
||||
}
|
||||
|
||||
bool Surface::blit(Surface *destination, SDL_Rect container, const unsigned short halign, const unsigned short valign) {
|
||||
bool Surface::blit(Surface *destination, SDL_Rect container, ASFont::HAlign halign, ASFont::VAlign valign) {
|
||||
switch (halign) {
|
||||
case SFontHAlignCenter:
|
||||
case ASFont::HAlignLeft:
|
||||
break;
|
||||
case ASFont::HAlignCenter:
|
||||
container.x += container.w/2-halfW;
|
||||
break;
|
||||
case SFontHAlignRight:
|
||||
case ASFont::HAlignRight:
|
||||
container.x += container.w-raw->w;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valign) {
|
||||
case SFontVAlignMiddle:
|
||||
case ASFont::VAlignTop:
|
||||
break;
|
||||
case ASFont::VAlignMiddle:
|
||||
container.y += container.h/2-halfH;
|
||||
break;
|
||||
case SFontVAlignBottom:
|
||||
case ASFont::VAlignBottom:
|
||||
container.y += container.h-raw->h;
|
||||
break;
|
||||
}
|
||||
|
@ -75,14 +75,16 @@ public:
|
||||
void setClipRect(SDL_Rect rect);
|
||||
|
||||
bool blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blit(Surface *destination, SDL_Rect container, const unsigned short halign=0, const unsigned short valign=0);
|
||||
bool blit(Surface *destination, SDL_Rect container, ASFont::HAlign halign = ASFont::HAlignLeft, ASFont::VAlign valign = ASFont::VAlignTop);
|
||||
bool blit(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blitCenter(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
|
||||
void write(ASFont *font, const string &text, int x, int y, const unsigned short halign=0, const unsigned short valign=0);
|
||||
void write(ASFont *font, const string &text, int x, int y, ASFont::HAlign halign = ASFont::HAlignLeft, ASFont::VAlign valign = ASFont::VAlignTop) {
|
||||
font->write(this, text, x, y, halign, valign);
|
||||
}
|
||||
|
||||
int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8);
|
||||
int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8);
|
||||
|
@ -96,7 +96,7 @@ void TextManualDialog::exec() {
|
||||
ss << page+1;
|
||||
ss >> pageStatus;
|
||||
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, SFontHAlignRight, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, ASFont::HAlignRight, ASFont::VAlignMiddle);
|
||||
|
||||
gmenu2x->s->flip();
|
||||
|
||||
|
@ -80,7 +80,7 @@ bool WallpaperDialog::exec()
|
||||
gmenu2x->s->setClipRect(0,41,311,179);
|
||||
for (i=firstElement; i<wallpapers.size() && i<firstElement+10; i++) {
|
||||
iY = i-firstElement;
|
||||
gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5, 52+(iY*17), SFontHAlignLeft, SFontVAlignMiddle);
|
||||
gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5, 52+(iY*17), ASFont::HAlignLeft, ASFont::VAlignMiddle);
|
||||
}
|
||||
gmenu2x->s->clearClipRect();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user