1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-25 18:05:20 +02: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;
Surface bg(gmenu2x->bg);
drawTitleIcon("icons/explorer.png", true, &bg);
writeTitle(title, &bg);
writeSubTitle(subtitle, &bg);
drawTitleIcon(&bg, "icons/explorer.png", true);
writeTitle(&bg, title);
writeSubTitle(&bg, subtitle);
buttonBox.paint(&bg, 5);
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;
if (!icon.empty()) {
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);
}
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);
}
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);
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);
protected:
void drawTitleIcon(const std::string &icon, bool skinRes = false, Surface *s = NULL);
void writeTitle(const std::string &title, Surface *s = NULL);
void writeSubTitle(const std::string &subtitle, Surface *s = NULL);
void drawTitleIcon(Surface *s, const std::string &icon, bool skinRes = false);
void writeTitle(Surface *s, const std::string &title);
void writeSubTitle(Surface *s, const std::string &subtitle);
GMenu2X *gmenu2x;
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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