1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 18:32:20 +03:00

Put Surface argument first in Dialog paint methods

This is the convention that most classes stick to. The likely reason
why Dialog didn't stick to the convention was to be able to provide
a default value for this argument, but that feature wasn't very useful
since every caller already had access to the default surface.
This commit is contained in:
Maarten ter Huurne 2014-08-10 04:02:10 +02:00
parent 5a281cf661
commit 20c5ec4eb6
9 changed files with 29 additions and 36 deletions

View File

@ -229,9 +229,9 @@ void BrowseDialog::paint()
unsigned int offsetY; unsigned int offsetY;
Surface bg(gmenu2x->bg); Surface bg(gmenu2x->bg);
drawTitleIcon("icons/explorer.png", true, &bg); drawTitleIcon(&bg, "icons/explorer.png", true);
writeTitle(title, &bg); writeTitle(&bg, title);
writeSubTitle(subtitle, &bg); writeSubTitle(&bg, subtitle);
buttonBox.paint(&bg, 5); buttonBox.paint(&bg, 5);
bg.convertToDisplayFormat(); bg.convertToDisplayFormat();

View File

@ -8,11 +8,8 @@ Dialog::Dialog(GMenu2X *gmenu2x) : gmenu2x(gmenu2x)
{ {
} }
void Dialog::drawTitleIcon(const std::string &icon, bool skinRes, Surface *s) void Dialog::drawTitleIcon(Surface *s, const std::string &icon, bool skinRes)
{ {
if (s==NULL)
s = gmenu2x->s;
Surface *i = NULL; Surface *i = NULL;
if (!icon.empty()) { if (!icon.empty()) {
if (skinRes) if (skinRes)
@ -27,17 +24,13 @@ void Dialog::drawTitleIcon(const std::string &icon, bool skinRes, Surface *s)
i->blit(s,4,(gmenu2x->skinConfInt["topBarHeight"]-32)/2); i->blit(s,4,(gmenu2x->skinConfInt["topBarHeight"]-32)/2);
} }
void Dialog::writeTitle(const std::string &title, Surface *s) void Dialog::writeTitle(Surface *s, const std::string &title)
{ {
if (s==NULL)
s = gmenu2x->s;
gmenu2x->font->write(s, 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) void Dialog::writeSubTitle(Surface *s, const std::string &subtitle)
{ {
if (s==NULL)
s = gmenu2x->s;
std::string wrapped = gmenu2x->font->wordWrap(subtitle, gmenu2x->resX - 48); std::string wrapped = gmenu2x->font->wordWrap(subtitle, gmenu2x->resX - 48);
gmenu2x->font->write(s, 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);
} }

View File

@ -12,9 +12,9 @@ public:
Dialog(GMenu2X *gmenu2x); Dialog(GMenu2X *gmenu2x);
protected: protected:
void drawTitleIcon(const std::string &icon, bool skinRes = false, Surface *s = NULL); void drawTitleIcon(Surface *s, const std::string &icon, bool skinRes = false);
void writeTitle(const std::string &title, Surface *s = NULL); void writeTitle(Surface *s, const std::string &title);
void writeSubTitle(const std::string &subtitle, Surface *s = NULL); void writeSubTitle(Surface *s, const std::string &subtitle);
GMenu2X *gmenu2x; GMenu2X *gmenu2x;
}; };

View File

@ -150,9 +150,9 @@ bool InputDialog::exec() {
bool caretOn = true; bool caretOn = true;
Surface bg(gmenu2x->bg); Surface bg(gmenu2x->bg);
drawTitleIcon(icon, false, &bg); drawTitleIcon(&bg, icon, false);
writeTitle(title, &bg); writeTitle(&bg, title);
writeSubTitle(text, &bg); writeSubTitle(&bg, text);
buttonbox->paint(&bg, 5); buttonbox->paint(&bg, 5);
bg.convertToDisplayFormat(); bg.convertToDisplayFormat();

View File

@ -60,9 +60,9 @@ int Selector::exec(int startSelection) {
fl.browse(); fl.browse();
Surface bg(gmenu2x->bg); Surface bg(gmenu2x->bg);
drawTitleIcon(link->getIconPath(), true, &bg); drawTitleIcon(&bg, link->getIconPath(), true);
writeTitle(link->getTitle(), &bg); writeTitle(&bg, link->getTitle());
writeSubTitle(link->getDescription(), &bg); writeSubTitle(&bg, link->getDescription());
if (link->getSelectorBrowser()) { if (link->getSelectorBrowser()) {
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"], gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],

View File

@ -84,8 +84,8 @@ bool SettingsDialog::exec() {
gmenu2x->drawTopBar(gmenu2x->s); gmenu2x->drawTopBar(gmenu2x->s);
//link icon //link icon
drawTitleIcon(icon); drawTitleIcon(gmenu2x->s, icon);
writeTitle(text); writeTitle(gmenu2x->s, text);
gmenu2x->drawBottomBar(gmenu2x->s); gmenu2x->drawBottomBar(gmenu2x->s);
@ -119,7 +119,7 @@ bool SettingsDialog::exec() {
gmenu2x->drawScrollBar(numRows, voices.size(), firstElement); gmenu2x->drawScrollBar(numRows, voices.size(), firstElement);
//description //description
writeSubTitle(voices[sel]->getDescription()); writeSubTitle(gmenu2x->s, voices[sel]->getDescription());
gmenu2x->s->flip(); gmenu2x->s->flip();
voices[sel]->handleTS(maxNameWidth + 15, iY, rowHeight); voices[sel]->handleTS(maxNameWidth + 15, iY, rowHeight);

View File

@ -61,11 +61,11 @@ void TextDialog::exec() {
//link icon //link icon
if (!fileExists(icon)) if (!fileExists(icon))
drawTitleIcon("icons/ebook.png",true,&bg); drawTitleIcon(&bg, "icons/ebook.png", true);
else else
drawTitleIcon(icon,false,&bg); drawTitleIcon(&bg, icon, false);
writeTitle(title,&bg); writeTitle(&bg, title);
writeSubTitle(description,&bg); writeSubTitle(&bg, description);
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"], gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(&bg, "cancel", "", gmenu2x->drawButton(&bg, "cancel", "",

View File

@ -75,10 +75,10 @@ void TextManualDialog::exec() {
//link icon //link icon
if (!fileExists(icon)) if (!fileExists(icon))
drawTitleIcon("icons/ebook.png",true,&bg); drawTitleIcon(&bg, "icons/ebook.png", true);
else else
drawTitleIcon(icon,false,&bg); drawTitleIcon(&bg, icon, false);
writeTitle(title+(description.empty() ? "" : ": "+description),&bg); writeTitle(&bg, title+(description.empty() ? "" : ": "+description));
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"], gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(&bg, "cancel", "", gmenu2x->drawButton(&bg, "cancel", "",
@ -98,7 +98,7 @@ void TextManualDialog::exec() {
while (!close) { while (!close) {
bg.blit(gmenu2x->s,0,0); bg.blit(gmenu2x->s,0,0);
writeSubTitle(pages[page].title); writeSubTitle(gmenu2x->s, pages[page].title);
drawText(pages[page].text, 42 /* TODO */, firstRow, rowsPerPage); drawText(pages[page].text, 42 /* TODO */, firstRow, rowsPerPage);
ss.clear(); ss.clear();

View File

@ -99,9 +99,9 @@ bool WallpaperDialog::exec()
gmenu2x->drawTopBar(gmenu2x->s); gmenu2x->drawTopBar(gmenu2x->s);
gmenu2x->drawBottomBar(gmenu2x->s); gmenu2x->drawBottomBar(gmenu2x->s);
drawTitleIcon("icons/wallpaper.png",true); drawTitleIcon(gmenu2x->s, "icons/wallpaper.png", true);
writeTitle(gmenu2x->tr["Wallpaper selection"]); writeTitle(gmenu2x->s, gmenu2x->tr["Wallpaper selection"]);
writeSubTitle(gmenu2x->tr["Select a wallpaper from the list"]); writeSubTitle(gmenu2x->s, gmenu2x->tr["Select a wallpaper from the list"]);
buttonbox.paint(gmenu2x->s, 5); buttonbox.paint(gmenu2x->s, 5);