mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-05 08:35:19 +02:00
Removed Surface::write method
All it did was redirect to Font::write, so it's better to call that method directly.
This commit is contained in:
parent
3a57912dca
commit
902145b698
@ -18,7 +18,7 @@ void Background::paint(Surface &s) {
|
||||
|
||||
sc["bgmain"]->blit(&s, 0, 0);
|
||||
|
||||
s.write(&font, clock.getTime(),
|
||||
font.write(&s, clock.getTime(),
|
||||
s.width() / 2, gmenu2x.bottomBarTextY,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
|
||||
|
@ -272,7 +272,7 @@ void BrowseDialog::paint()
|
||||
icon = iconFile;
|
||||
}
|
||||
icon->blit(gmenu2x->s, 5, offsetY);
|
||||
gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + rowHeight / 2,
|
||||
gmenu2x->font->write(gmenu2x->s, (*fl)[i], 24, offsetY + rowHeight / 2,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
|
||||
if (ts.available() && ts.pressed()
|
||||
|
@ -25,7 +25,7 @@ ContextMenu::ContextMenu(GMenu2X &gmenu2x, Menu &menu)
|
||||
, selected(0)
|
||||
{
|
||||
Translator &tr = gmenu2x.tr;
|
||||
Font *font = gmenu2x.font;
|
||||
Font& font = *gmenu2x.font;
|
||||
LinkApp* app = menu.selLinkApp();
|
||||
|
||||
// Init menu options:
|
||||
@ -78,10 +78,10 @@ ContextMenu::ContextMenu(GMenu2X &gmenu2x, Menu &menu)
|
||||
// Compute bounding box.
|
||||
int w = 0;
|
||||
for (auto option : options) {
|
||||
w = std::max(w, font->getTextWidth(option->text));
|
||||
w = std::max(w, font.getTextWidth(option->text));
|
||||
}
|
||||
w += 23;
|
||||
const int h = (font->getLineSpacing() + 2) * options.size() + 8;
|
||||
const int h = (font.getLineSpacing() + 2) * options.size() + 8;
|
||||
box = {
|
||||
static_cast<Sint16>((gmenu2x.resX - w) / 2),
|
||||
static_cast<Sint16>((gmenu2x.resY - h) / 2),
|
||||
@ -105,7 +105,7 @@ bool ContextMenu::runAnimations()
|
||||
|
||||
void ContextMenu::paint(Surface &s)
|
||||
{
|
||||
Font *font = gmenu2x.font;
|
||||
Font& font = *gmenu2x.font;
|
||||
|
||||
// Darken background.
|
||||
s.box(0, 0, gmenu2x.resX, gmenu2x.resY, 0, 0, 0, fadeAlpha);
|
||||
@ -116,7 +116,7 @@ void ContextMenu::paint(Surface &s)
|
||||
gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
|
||||
|
||||
// Draw selection background.
|
||||
const int h = font->getLineSpacing();
|
||||
const int h = font.getLineSpacing();
|
||||
SDL_Rect selbox = {
|
||||
static_cast<Sint16>(box.x + 4),
|
||||
static_cast<Sint16>(box.y + 4 + (h + 2) * selected),
|
||||
@ -127,7 +127,7 @@ void ContextMenu::paint(Surface &s)
|
||||
|
||||
// List options.
|
||||
for (uint i = 0; i < options.size(); i++) {
|
||||
s.write(font, options[i]->text, box.x + 12, box.y + 5 + (h + 2) * i,
|
||||
font.write(&s, options[i]->text, box.x + 12, box.y + 5 + (h + 2) * i,
|
||||
Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void Dialog::writeTitle(const std::string &title, Surface *s)
|
||||
{
|
||||
if (s==NULL)
|
||||
s = gmenu2x->s;
|
||||
s->write(gmenu2x->font, title, 40, 0, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x->font->write(s, title, 40, 0, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
void Dialog::writeSubTitle(const std::string &subtitle, Surface *s)
|
||||
@ -39,7 +39,5 @@ void Dialog::writeSubTitle(const std::string &subtitle, Surface *s)
|
||||
if (s==NULL)
|
||||
s = gmenu2x->s;
|
||||
std::string wrapped = gmenu2x->font->wordWrap(subtitle, gmenu2x->resX - 48);
|
||||
s->write(gmenu2x->font, wrapped, 40, gmenu2x->skinConfInt["topBarHeight"] - gmenu2x->font->getTextHeight(wrapped), Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x->font->write(s, wrapped, 40, gmenu2x->skinConfInt["topBarHeight"] - gmenu2x->font->getTextHeight(wrapped), Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
|
||||
|
@ -313,7 +313,7 @@ void GMenu2X::initBG() {
|
||||
if (sd) sd->blit(bgmain, 3, bottomBarIconY);
|
||||
|
||||
string df = getDiskFree(getHome().c_str());
|
||||
bgmain->write(font, df, 22, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle);
|
||||
font->write(bgmain, df, 22, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle);
|
||||
delete sd;
|
||||
|
||||
cpuX = font->getTextWidth(df)+32;
|
||||
@ -1058,7 +1058,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"]->width() + 3;
|
||||
s->write(font, text, x+re.w, y, Font::HAlignLeft, Font::VAlignMiddle);
|
||||
font->write(s, text, x+re.w, y, Font::HAlignLeft, Font::VAlignMiddle);
|
||||
re.w += font->getTextWidth(text);
|
||||
}
|
||||
return x+re.w+6;
|
||||
@ -1070,7 +1070,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, Font::HAlignRight, Font::VAlignMiddle);
|
||||
font->write(s, text, x, y, Font::HAlignRight, Font::VAlignMiddle);
|
||||
return x-6-font->getTextWidth(text);
|
||||
}
|
||||
return x-6;
|
||||
|
@ -12,7 +12,7 @@ HelpPopup::HelpPopup(GMenu2X &gmenu2x)
|
||||
}
|
||||
|
||||
void HelpPopup::paint(Surface &s) {
|
||||
Font *font = gmenu2x.font;
|
||||
Font& font = *gmenu2x.font;
|
||||
Translator &tr = gmenu2x.tr;
|
||||
int helpBoxHeight = 154;
|
||||
|
||||
@ -20,13 +20,13 @@ void HelpPopup::paint(Surface &s) {
|
||||
gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BG]);
|
||||
s.rectangle(12, 52, 296, helpBoxHeight,
|
||||
gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
|
||||
s.write(font, tr["CONTROLS"], 20, 60);
|
||||
font.write(&s, tr["CONTROLS"], 20, 60);
|
||||
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
|
||||
s.write(font, tr["A: Launch link / Confirm action"], 20, 80);
|
||||
s.write(font, tr["B: Show this help menu"], 20, 95);
|
||||
s.write(font, tr["L, R: Change section"], 20, 110);
|
||||
s.write(font, tr["SELECT: Show contextual menu"], 20, 155);
|
||||
s.write(font, tr["START: Show options menu"], 20, 170);
|
||||
font.write(&s, tr["A: Launch link / Confirm action"], 20, 80);
|
||||
font.write(&s, tr["B: Show this help menu"], 20, 95);
|
||||
font.write(&s, tr["L, R: Change section"], 20, 110);
|
||||
font.write(&s, tr["SELECT: Show contextual menu"], 20, 155);
|
||||
font.write(&s, tr["START: Show options menu"], 20, 170);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ void IconButton::paint(Surface *s) {
|
||||
iconSurface->blit(s, iconRect);
|
||||
}
|
||||
if (!label.empty()) {
|
||||
s->write(gmenu2x->font, label, labelRect.x, labelRect.y,
|
||||
gmenu2x->font->write(s, label, labelRect.x, labelRect.y,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ bool InputDialog::exec() {
|
||||
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,
|
||||
gmenu2x->font->write(gmenu2x->s, input, box.x + 5, box.y + box.h - 2,
|
||||
Font::HAlignLeft, Font::VAlignBottom);
|
||||
|
||||
curTick = SDL_GetTicks();
|
||||
@ -312,7 +312,7 @@ void InputDialog::drawVirtualKeyboard() {
|
||||
|
||||
gmenu2x->s->rectangle(re,
|
||||
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
gmenu2x->s->write(gmenu2x->font, charX,
|
||||
gmenu2x->font->write(gmenu2x->s, charX,
|
||||
kbLeft + xc * KEY_WIDTH + KEY_WIDTH / 2 - 1,
|
||||
KB_TOP + l * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
@ -332,7 +332,7 @@ void InputDialog::drawVirtualKeyboard() {
|
||||
selCol = 0;
|
||||
selRow = kb->size();
|
||||
}
|
||||
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"],
|
||||
gmenu2x->font->write(gmenu2x->s, gmenu2x->tr["Cancel"],
|
||||
(int)(160 - kbLength * KEY_WIDTH / 4),
|
||||
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
@ -343,7 +343,7 @@ void InputDialog::drawVirtualKeyboard() {
|
||||
selCol = 1;
|
||||
selRow = kb->size();
|
||||
}
|
||||
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"],
|
||||
gmenu2x->font->write(gmenu2x->s, gmenu2x->tr["OK"],
|
||||
(int)(160 + kbLength * KEY_WIDTH / 4),
|
||||
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
|
||||
Font::HAlignCenter, Font::VAlignMiddle);
|
||||
|
@ -70,7 +70,7 @@ void Link::paint() {
|
||||
if (iconSurface) {
|
||||
iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
|
||||
}
|
||||
gmenu2x->s->write(gmenu2x->font, getTitle(), iconX+16, rect.y + gmenu2x->skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom);
|
||||
gmenu2x->font->write(gmenu2x->s, getTitle(), iconX+16, rect.y + gmenu2x->skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom);
|
||||
}
|
||||
|
||||
void Link::paintHover() {
|
||||
|
@ -357,7 +357,7 @@ void LinkApp::drawRun() {
|
||||
else
|
||||
gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/
|
||||
iconSurface->blit(gmenu2x->s,x,gmenu2x->halfY-16);
|
||||
gmenu2x->s->write( gmenu2x->font, text, x+42, gmenu2x->halfY+1, Font::HAlignLeft, Font::VAlignMiddle );
|
||||
gmenu2x->font->write(gmenu2x->s, text, x+42, gmenu2x->halfY+1, Font::HAlignLeft, Font::VAlignMiddle );
|
||||
gmenu2x->s->flip();
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ void LinkApp::showManual() {
|
||||
ss << page+1;
|
||||
ss >> pageStatus;
|
||||
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
gmenu2x->font->write(gmenu2x->s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
|
||||
gmenu2x->s->flip();
|
||||
repaint = false;
|
||||
|
@ -222,7 +222,7 @@ void Menu::paint(Surface &s) {
|
||||
x += (((t * t) / linkWidth) * t) / linkWidth;
|
||||
}
|
||||
icon->blit(&s, x - 16, sectionLinkPadding, 32, 32);
|
||||
s.write(&font, sections[j], x, topBarHeight - sectionLinkPadding,
|
||||
font.write(&s, sections[j], x, topBarHeight - sectionLinkPadding,
|
||||
Font::HAlignCenter, Font::VAlignBottom);
|
||||
}
|
||||
sc.skinRes("imgs/section-l.png")->blit(&s, 0, 0);
|
||||
@ -254,7 +254,7 @@ void Menu::paint(Surface &s) {
|
||||
}
|
||||
|
||||
if (selLink()) {
|
||||
s.write(&font, selLink()->getDescription(),
|
||||
font.write(&s, selLink()->getDescription(),
|
||||
width / 2, height - bottomBarHeight + 2,
|
||||
Font::HAlignCenter, Font::VAlignBottom);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ MenuSetting::~MenuSetting()
|
||||
|
||||
void MenuSetting::draw(int /*valueX*/, int y, int /*h*/)
|
||||
{
|
||||
gmenu2x->s->write( gmenu2x->font, name, 5, y, Font::HAlignLeft, Font::VAlignTop );
|
||||
gmenu2x->font->write(gmenu2x->s, name, 5, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
void MenuSetting::handleTS(int /*valueX*/, int /*y*/, int /*h*/)
|
||||
|
@ -68,7 +68,7 @@ void MenuSettingBool::initButton()
|
||||
void MenuSettingBool::draw(int valueX, int y, int h)
|
||||
{
|
||||
MenuSetting::draw(valueX, y, h);
|
||||
gmenu2x->s->write( gmenu2x->font, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop );
|
||||
gmenu2x->font->write(gmenu2x->s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
bool MenuSettingBool::handleButtonPress(InputManager::Button button)
|
||||
|
@ -70,7 +70,7 @@ MenuSettingInt::MenuSettingInt(
|
||||
void MenuSettingInt::draw(int valueX, int y, int h)
|
||||
{
|
||||
MenuSetting::draw(valueX, y, h);
|
||||
gmenu2x->s->write(gmenu2x->font, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x->font->write(gmenu2x->s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
bool MenuSettingInt::handleButtonPress(InputManager::Button button)
|
||||
|
@ -56,10 +56,10 @@ void MenuSettingRGBA::draw(int valueX, int y, int 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 );
|
||||
gmenu2x->font->write(gmenu2x->s, "R: "+strR, valueX + h + 3, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x->font->write(gmenu2x->s, "G: "+strG, valueX + h + 3 + COMPONENT_WIDTH, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x->font->write(gmenu2x->s, "B: "+strB, valueX + h + 3 + COMPONENT_WIDTH * 2, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
gmenu2x->font->write(gmenu2x->s, "A: "+strA, valueX + h + 3 + COMPONENT_WIDTH * 3, y, Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
void MenuSettingRGBA::handleTS(int valueX, int y, int h) {
|
||||
|
@ -40,7 +40,7 @@ MenuSettingStringBase::~MenuSettingStringBase()
|
||||
void MenuSettingStringBase::draw(int valueX, int y, int h)
|
||||
{
|
||||
MenuSetting::draw(valueX, y, h);
|
||||
gmenu2x->s->write(gmenu2x->font, value(), valueX, y,
|
||||
gmenu2x->font->write(gmenu2x->s, value(), valueX, y,
|
||||
Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ int MessageBox::exec() {
|
||||
if (gmenu2x->sc[icon]) {
|
||||
gmenu2x->sc[icon]->blitCenter( &bg, box.x + ICON_PADDING + ICON_DIMENSION / 2, box.y + ICON_PADDING + ICON_DIMENSION / 2 );
|
||||
}
|
||||
bg.write( gmenu2x->font, text, box.x + TEXT_PADDING + (gmenu2x->sc[icon] ? ICON_PADDING + ICON_DIMENSION : 0), box.y + (box.h - textHeight) / 2, Font::HAlignLeft, Font::VAlignTop );
|
||||
gmenu2x->font->write(&bg, text, box.x + TEXT_PADDING + (gmenu2x->sc[icon] ? ICON_PADDING + ICON_DIMENSION : 0), box.y + (box.h - textHeight) / 2, Font::HAlignLeft, Font::VAlignTop);
|
||||
|
||||
int btnX = gmenu2x->halfX+box.w/2-6;
|
||||
for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) {
|
||||
|
@ -124,11 +124,11 @@ int Selector::exec(int startSelection) {
|
||||
iY = i-firstElement;
|
||||
if (fl.isDirectory(i)) {
|
||||
gmenu2x->sc["imgs/folder.png"]->blit(gmenu2x->s, 4, top + (iY * fontheight));
|
||||
gmenu2x->s->write(gmenu2x->font, fl[i], 21,
|
||||
gmenu2x->font->write(gmenu2x->s, fl[i], 21,
|
||||
top + (iY * fontheight) + (fontheight / 2),
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
} else
|
||||
gmenu2x->s->write(gmenu2x->font, titles[i - fl.dirCount()], 4,
|
||||
gmenu2x->font->write(gmenu2x->s, titles[i - fl.dirCount()], 4,
|
||||
top + (iY * fontheight) + (fontheight / 2),
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
}
|
||||
|
@ -75,12 +75,6 @@ public:
|
||||
void blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
void blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
|
||||
void write(Font *font, const std::string &text, int x, int y,
|
||||
Font::HAlign halign = Font::HAlignLeft,
|
||||
Font::VAlign valign = Font::VAlignTop) {
|
||||
font->write(this, text, x, y, halign, valign);
|
||||
}
|
||||
|
||||
void box(SDL_Rect re, RGBAColor c);
|
||||
void box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) {
|
||||
box((SDL_Rect){ x, y, w, h }, c);
|
||||
|
@ -105,7 +105,7 @@ void TextManualDialog::exec() {
|
||||
ss << page+1;
|
||||
ss >> pageStatus;
|
||||
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
|
||||
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
gmenu2x->font->write(gmenu2x->s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
|
||||
|
||||
gmenu2x->s->flip();
|
||||
|
||||
|
@ -115,7 +115,7 @@ bool WallpaperDialog::exec()
|
||||
for (i = firstElement; i < wallpapers.size()
|
||||
&& i < firstElement + nb_elements; i++) {
|
||||
iY = i-firstElement;
|
||||
gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5,
|
||||
gmenu2x->font->write(gmenu2x->s, wallpapers[i], 5,
|
||||
top + (iY * fontheight),
|
||||
Font::HAlignLeft, Font::VAlignTop);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user