1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-09-28 21:09:47 +03:00

Don't pass around naked Surface pointers when drawing

Use references instead.
This commit is contained in:
Maarten ter Huurne 2014-08-10 04:26:59 +02:00
parent 20c5ec4eb6
commit aff5f53f7d
34 changed files with 255 additions and 220 deletions

View File

@ -16,13 +16,13 @@ void Background::paint(Surface &s) {
Font &font = *gmenu2x.font;
SurfaceCollection &sc = gmenu2x.sc;
sc["bgmain"]->blit(&s, 0, 0);
sc["bgmain"]->blit(s, 0, 0);
font.write(&s, clock.getTime(),
font.write(s, clock.getTime(),
s.width() / 2, gmenu2x.bottomBarTextY,
Font::HAlignCenter, Font::VAlignMiddle);
battery.getIcon().blit(&s, s.width() - 19, gmenu2x.bottomBarIconY);
battery.getIcon().blit(s, s.width() - 19, gmenu2x.bottomBarIconY);
}
bool Background::handleButtonPress(InputManager::Button button) {
@ -38,6 +38,6 @@ bool Background::handleButtonPress(InputManager::Button button) {
}
}
bool Background::handleTouchscreen(Touchscreen &/*ts*/) {
bool Background::handleTouchscreen(Touchscreen&) {
return false;
}

View File

@ -224,18 +224,20 @@ void BrowseDialog::quit()
void BrowseDialog::paint()
{
Surface& s = *gmenu2x->s;
unsigned int i, iY;
unsigned int firstElement, lastElement;
unsigned int offsetY;
Surface bg(gmenu2x->bg);
drawTitleIcon(&bg, "icons/explorer.png", true);
writeTitle(&bg, title);
writeSubTitle(&bg, subtitle);
buttonBox.paint(&bg, 5);
drawTitleIcon(bg, "icons/explorer.png", true);
writeTitle(bg, title);
writeSubTitle(bg, subtitle);
buttonBox.paint(bg, 5);
bg.convertToDisplayFormat();
bg.blit(gmenu2x->s,0,0);
bg.blit(s, 0, 0);
// TODO(MtH): I have no idea what the right value of firstElement would be,
// but originally it was undefined and that is never a good idea.
@ -249,7 +251,7 @@ void BrowseDialog::paint()
//Selection
const int topBarHeight = gmenu2x->skinConfInt["topBarHeight"];
iY = topBarHeight + 1 + (selected - firstElement) * rowHeight;
gmenu2x->s->box(2, iY, gmenu2x->resX - 12, rowHeight - 1,
s.box(2, iY, gmenu2x->resX - 12, rowHeight - 1,
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
lastElement = firstElement + numRows;
@ -259,7 +261,7 @@ void BrowseDialog::paint()
offsetY = topBarHeight + 1;
//Files & Directories
gmenu2x->s->setClipRect(clipRect);
s.setClipRect(clipRect);
for (i = firstElement; i < lastElement; i++) {
Surface *icon;
if (fl->isDirectory(i)) {
@ -271,8 +273,8 @@ void BrowseDialog::paint()
} else {
icon = iconFile;
}
icon->blit(gmenu2x->s, 5, offsetY);
gmenu2x->font->write(gmenu2x->s, (*fl)[i], 24, offsetY + rowHeight / 2,
icon->blit(s, 5, offsetY);
gmenu2x->font->write(s, (*fl)[i], 24, offsetY + rowHeight / 2,
Font::HAlignLeft, Font::VAlignMiddle);
if (ts.available() && ts.pressed()
@ -283,8 +285,8 @@ void BrowseDialog::paint()
offsetY += rowHeight;
}
gmenu2x->s->clearClipRect();
s.clearClipRect();
gmenu2x->drawScrollBar(numRows,fl->size(), firstElement);
gmenu2x->s->flip();
s.flip();
}

View File

@ -22,14 +22,16 @@ void ButtonBox::clear()
buttons.clear();
}
void ButtonBox::paint(Surface *s, unsigned int posX)
void ButtonBox::paint(Surface& s, unsigned int posX)
{
for (auto button : buttons)
for (auto button : buttons) {
posX = gmenu2x->drawButton(s, button, posX);
}
}
void ButtonBox::handleTS()
{
for (auto button : buttons)
for (auto button : buttons) {
button->handleTS();
}
}

View File

@ -16,7 +16,7 @@ public:
void add(IconButton *button);
void clear();
void paint(Surface *s, unsigned int posX);
void paint(Surface& s, unsigned int posX);
void handleTS();
private:

View File

@ -127,7 +127,7 @@ void ContextMenu::paint(Surface &s)
// List options.
for (uint i = 0; i < options.size(); i++) {
font.write(&s, 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);
}
}

View File

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

@ -197,7 +197,7 @@ int Font::getTextHeight(const string &text)
return nLines * getLineSpacing();
}
void Font::write(Surface *surface, const string &text,
void Font::write(Surface& surface, const string &text,
int x, int y, HAlign halign, VAlign valign)
{
if (!font) {
@ -220,7 +220,7 @@ void Font::write(Surface *surface, const string &text,
}
}
void Font::writeLine(Surface *surface, std::string const& text,
void Font::writeLine(Surface& surface, std::string const& text,
int x, int y, HAlign halign, VAlign valign)
{
if (!font) {
@ -261,21 +261,21 @@ void Font::writeLine(Surface *surface, std::string const& text,
}
SDL_Rect rect = { (Sint16) x, (Sint16) (y - 1), 0, 0 };
SDL_BlitSurface(s, NULL, surface->raw, &rect);
SDL_BlitSurface(s, NULL, surface.raw, &rect);
/* Note: rect.x / rect.y are reset everytime because SDL_BlitSurface
* will modify them if negative */
rect.x = x;
rect.y = y + 1;
SDL_BlitSurface(s, NULL, surface->raw, &rect);
SDL_BlitSurface(s, NULL, surface.raw, &rect);
rect.x = x - 1;
rect.y = y;
SDL_BlitSurface(s, NULL, surface->raw, &rect);
SDL_BlitSurface(s, NULL, surface.raw, &rect);
rect.x = x + 1;
rect.y = y;
SDL_BlitSurface(s, NULL, surface->raw, &rect);
SDL_BlitSurface(s, NULL, surface.raw, &rect);
SDL_FreeSurface(s);
rect.x = x;
@ -289,6 +289,6 @@ void Font::writeLine(Surface *surface, std::string const& text,
ERROR("Font rendering failed for text \"%s\"\n", text.c_str());
return;
}
SDL_BlitSurface(s, NULL, surface->raw, &rect);
SDL_BlitSurface(s, NULL, surface.raw, &rect);
SDL_FreeSurface(s);
}

View File

@ -38,7 +38,7 @@ public:
return lineSpacing;
}
void write(Surface *surface,
void write(Surface& surface,
const std::string &text, int x, int y,
HAlign halign = HAlignLeft, VAlign valign = VAlignTop);
@ -48,7 +48,7 @@ private:
std::string wordWrapSingleLine(const std::string &text,
size_t start, size_t end, int width);
void writeLine(Surface *surface, std::string const& text,
void writeLine(Surface& surface, std::string const& text,
int x, int y, HAlign halign, VAlign valign);
TTF_Font *font;

View File

@ -322,17 +322,17 @@ void GMenu2X::initBG() {
bg = Surface::emptySurface(resX, resY);
}
drawTopBar(bg);
drawBottomBar(bg);
drawTopBar(*bg);
drawBottomBar(*bg);
Surface *bgmain = new Surface(bg);
sc.add(bgmain,"bgmain");
Surface *sd = Surface::loadImage("imgs/sd.png", confStr["skin"]);
if (sd) sd->blit(bgmain, 3, bottomBarIconY);
if (sd) sd->blit(*bgmain, 3, bottomBarIconY);
string df = getDiskFree(getHome().c_str());
font->write(bgmain, df, 22, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle);
font->write(*bgmain, df, 22, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle);
delete sd;
cpuX = font->getTextWidth(df)+32;
@ -351,20 +351,20 @@ void GMenu2X::initBG() {
if (web) {
Surface *webserver = Surface::loadImage(
"imgs/webserver.png", confStr["skin"]);
if (webserver) webserver->blit(bgmain, serviceX, bottomBarIconY);
if (webserver) webserver->blit(*bgmain, serviceX, bottomBarIconY);
serviceX -= 19;
delete webserver;
}
if (samba) {
Surface *sambaS = Surface::loadImage(
"imgs/samba.png", confStr["skin"]);
if (sambaS) sambaS->blit(bgmain, serviceX, bottomBarIconY);
if (sambaS) sambaS->blit(*bgmain, serviceX, bottomBarIconY);
serviceX -= 19;
delete sambaS;
}
if (inet) {
Surface *inetS = Surface::loadImage("imgs/inet.png", confStr["skin"]);
if (inetS) inetS->blit(bgmain, serviceX, bottomBarIconY);
if (inetS) inetS->blit(*bgmain, serviceX, bottomBarIconY);
serviceX -= 19;
delete inetS;
}
@ -1044,14 +1044,14 @@ string GMenu2X::getDiskFree(const char *path) {
return df;
}
int GMenu2X::drawButton(Surface *s, IconButton *btn, int x, int y) {
int GMenu2X::drawButton(Surface& s, IconButton *btn, int x, int y) {
if (y<0) y = resY+y;
btn->setPosition(x, y-7);
btn->paint(s);
return x+btn->getRect().w+6;
}
int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x, int y) {
int GMenu2X::drawButton(Surface& s, const string &btn, const string &text, int x, int y) {
if (y<0) y = resY+y;
SDL_Rect re = { static_cast<Sint16>(x), static_cast<Sint16>(y - 7), 0, 16 };
if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
@ -1063,7 +1063,7 @@ int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x
return x+re.w+6;
}
int GMenu2X::drawButtonRight(Surface *s, const string &btn, const string &text, int x, int y) {
int GMenu2X::drawButtonRight(Surface& s, const string &btn, const string &text, int x, int y) {
if (y<0) y = resY+y;
if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
x -= 16;
@ -1097,22 +1097,22 @@ void GMenu2X::drawScrollBar(uint pageSize, uint totalSize, uint pagePos) {
skinConfColors[COLOR_SELECTION_BG]);
}
void GMenu2X::drawTopBar(Surface *s) {
void GMenu2X::drawTopBar(Surface& s) {
Surface *bar = sc.skinRes("imgs/topbar.png", false);
if (bar) {
bar->blit(s, 0, 0);
} else {
const int h = skinConfInt["topBarHeight"];
s->box(0, 0, resX, h, skinConfColors[COLOR_TOP_BAR_BG]);
s.box(0, 0, resX, h, skinConfColors[COLOR_TOP_BAR_BG]);
}
}
void GMenu2X::drawBottomBar(Surface *s) {
void GMenu2X::drawBottomBar(Surface& s) {
Surface *bar = sc.skinRes("imgs/bottombar.png", false);
if (bar) {
bar->blit(s, 0, resY-bar->height());
} else {
const int h = skinConfInt["bottomBarHeight"];
s->box(0, resY - h, resX, h, skinConfColors[COLOR_BOTTOM_BAR_BG]);
s.box(0, resY - h, resX, h, skinConfColors[COLOR_BOTTOM_BAR_BG]);
}
}

View File

@ -199,13 +199,13 @@ public:
void renameSection();
void deleteSection();
int drawButton(Surface *s, IconButton *btn, int x=5, int y=-10);
int drawButton(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
int drawButtonRight(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
int drawButton(Surface& s, IconButton *btn, int x=5, int y=-10);
int drawButton(Surface& s, const std::string &btn, const std::string &text, int x=5, int y=-10);
int drawButtonRight(Surface& s, const std::string &btn, const std::string &text, int x=5, int y=-10);
void drawScrollBar(uint pageSize, uint totalSize, uint pagePos);
void drawTopBar(Surface *s);
void drawBottomBar(Surface *s);
void drawTopBar(Surface& s);
void drawBottomBar(Surface& s);
Touchscreen &getTouchscreen() { return ts; }
};

View File

@ -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]);
font.write(&s, tr["CONTROLS"], 20, 60);
font.write(s, tr["CONTROLS"], 20, 60);
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
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);
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
}

View File

@ -65,7 +65,7 @@ bool IconButton::handleTS() {
return false;
}
void IconButton::paint(Surface *s) {
void IconButton::paint(Surface& s) {
if (iconSurface) {
iconSurface->blit(s, iconRect);
}

View File

@ -23,8 +23,7 @@ public:
bool handleTS();
void paint(Surface *s);
void paint() { paint(gmenu2x->s); }
void paint(Surface& s);
private:
void recalcRects();

View File

@ -55,7 +55,7 @@ ImageDialog::~ImageDialog() {
void ImageDialog::beforeFileList() {
if (fl->isFile(selected) && fileExists(getPath()+"/"+(*fl)[selected]))
previews[getPath()+"/"+(*fl)[selected]]->blitRight(gmenu2x->s, 310, 43);
previews[getPath()+"/"+(*fl)[selected]]->blitRight(*gmenu2x->s, 310, 43);
}
void ImageDialog::onChangeDir() {

View File

@ -150,25 +150,27 @@ bool InputDialog::exec() {
bool caretOn = true;
Surface bg(gmenu2x->bg);
drawTitleIcon(&bg, icon, false);
writeTitle(&bg, title);
writeSubTitle(&bg, text);
buttonbox->paint(&bg, 5);
drawTitleIcon(bg, icon, false);
writeTitle(bg, title);
writeSubTitle(bg, text);
buttonbox->paint(bg, 5);
bg.convertToDisplayFormat();
close = false;
ok = true;
while (!close) {
bg.blit(gmenu2x->s,0,0);
Surface& s = *gmenu2x->s;
bg.blit(s, 0, 0);
box.w = gmenu2x->font->getTextWidth(input) + 18;
box.x = 160 - box.w / 2;
gmenu2x->s->box(box.x, box.y, box.w, box.h,
s.box(box.x, box.y, box.w, box.h,
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
gmenu2x->s->rectangle(box.x, box.y, box.w, box.h,
s.rectangle(box.x, box.y, box.w, box.h,
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
gmenu2x->font->write(gmenu2x->s, input, box.x + 5, box.y + box.h - 2,
gmenu2x->font->write(s, input, box.x + 5, box.y + box.h - 2,
Font::HAlignLeft, Font::VAlignBottom);
curTick = SDL_GetTicks();
@ -178,13 +180,13 @@ bool InputDialog::exec() {
}
if (caretOn) {
gmenu2x->s->box(box.x + box.w - 12, box.y + 3, 8, box.h - 6,
s.box(box.x + box.w - 12, box.y + 3, 8, box.h - 6,
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
}
if (ts.available()) ts.poll();
drawVirtualKeyboard();
gmenu2x->s->flip();
s.flip();
switch (inputMgr.waitForPressedButton()) {
case InputManager::SETTINGS:
@ -264,8 +266,10 @@ void InputDialog::changeKeys() {
}
void InputDialog::drawVirtualKeyboard() {
Surface& s = *gmenu2x->s;
//keyboard border
gmenu2x->s->rectangle(kbRect, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
s.rectangle(kbRect, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
if (selCol<0) selCol = selRow==(int)kb->size() ? 1 : kbLength-1;
if (selCol>=(int)kbLength) selCol = 0;
@ -274,13 +278,13 @@ void InputDialog::drawVirtualKeyboard() {
//selection
if (selRow<(int)kb->size())
gmenu2x->s->box(kbLeft + selCol * KEY_WIDTH - 1,
s.box(kbLeft + selCol * KEY_WIDTH - 1,
KB_TOP + selRow * KEY_HEIGHT, KEY_WIDTH - 1, KEY_HEIGHT - 2,
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
else {
if (selCol > 1) selCol = 0;
if (selCol < 0) selCol = 1;
gmenu2x->s->box(kbLeft + selCol * kbLength * KEY_WIDTH / 2 - 1,
s.box(kbLeft + selCol * kbLength * KEY_WIDTH / 2 - 1,
KB_TOP + kb->size() * KEY_HEIGHT, kbLength * KEY_WIDTH / 2 - 1,
KEY_HEIGHT - 1, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
}
@ -310,9 +314,9 @@ void InputDialog::drawVirtualKeyboard() {
selRow = l;
}
gmenu2x->s->rectangle(re,
s.rectangle(re,
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
gmenu2x->font->write(gmenu2x->s, charX,
gmenu2x->font->write(s, charX,
kbLeft + xc * KEY_WIDTH + KEY_WIDTH / 2 - 1,
KB_TOP + l * KEY_HEIGHT + KEY_HEIGHT / 2,
Font::HAlignCenter, Font::VAlignMiddle);
@ -327,23 +331,23 @@ void InputDialog::drawVirtualKeyboard() {
static_cast<Uint16>(kbLength * KEY_WIDTH / 2 - 1),
KEY_HEIGHT - 1
};
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
s.rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
if (ts.available() && ts.pressed() && ts.inRect(re)) {
selCol = 0;
selRow = kb->size();
}
gmenu2x->font->write(gmenu2x->s, gmenu2x->tr["Cancel"],
gmenu2x->font->write(s, gmenu2x->tr["Cancel"],
(int)(160 - kbLength * KEY_WIDTH / 4),
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
Font::HAlignCenter, Font::VAlignMiddle);
re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1;
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
s.rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
if (ts.available() && ts.pressed() && ts.inRect(re)) {
selCol = 1;
selRow = kb->size();
}
gmenu2x->font->write(gmenu2x->s, gmenu2x->tr["OK"],
gmenu2x->font->write(s, gmenu2x->tr["OK"],
(int)(160 + kbLength * KEY_WIDTH / 4),
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
Font::HAlignCenter, Font::VAlignMiddle);

View File

@ -67,17 +67,21 @@ bool Link::handleTS() {
}
void Link::paint() {
Surface& s = *gmenu2x->s;
if (iconSurface) {
iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
iconSurface->blit(s, iconX, rect.y+padding, 32,32);
}
gmenu2x->font->write(gmenu2x->s, getTitle(), iconX+16, rect.y + gmenu2x->skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom);
gmenu2x->font->write(s, getTitle(), iconX+16, rect.y + gmenu2x->skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom);
}
void Link::paintHover() {
Surface& s = *gmenu2x->s;
if (gmenu2x->useSelectionPng)
gmenu2x->sc["imgs/selection.png"]->blit(gmenu2x->s, rect, Font::HAlignCenter, Font::VAlignMiddle);
gmenu2x->sc["imgs/selection.png"]->blit(s, rect, Font::HAlignCenter, Font::VAlignMiddle);
else
gmenu2x->s->box(rect.x, rect.y, rect.w, rect.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
s.box(rect.x, rect.y, rect.w, rect.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
}
void Link::updateSurfaces()

View File

@ -371,8 +371,8 @@ void LinkApp::drawLaunch(Surface& s) {
gmenu2x->sc[getIcon()]->blit(gmenu2x->s,x,104);
else
gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/
iconSurface->blit(&s, x, gmenu2x->halfY - 16);
gmenu2x->font->write(&s, text, x + 42, gmenu2x->halfY + 1, Font::HAlignLeft, Font::VAlignMiddle);
iconSurface->blit(s, x, gmenu2x->halfY - 16);
gmenu2x->font->write(s, text, x + 42, gmenu2x->halfY + 1, Font::HAlignLeft, Font::VAlignMiddle);
}
void LinkApp::start() {
@ -459,23 +459,25 @@ void LinkApp::showManual() {
#endif
while (!close) {
if (repaint) {
bg->blit(gmenu2x->s, 0, 0);
pngman->blit(gmenu2x->s, -page*320, 0);
Surface& s = *gmenu2x->s;
gmenu2x->drawBottomBar(gmenu2x->s);
gmenu2x->drawButton(gmenu2x->s, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(gmenu2x->s, "cancel", "",
gmenu2x->drawButton(gmenu2x->s, "right", gmenu2x->tr["Change page"],
gmenu2x->drawButton(gmenu2x->s, "left", "", 5)-10))-10);
if (repaint) {
bg->blit(s, 0, 0);
pngman->blit(s, -page*320, 0);
gmenu2x->drawBottomBar(s);
gmenu2x->drawButton(s, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(s, "cancel", "",
gmenu2x->drawButton(s, "right", gmenu2x->tr["Change page"],
gmenu2x->drawButton(s, "left", "", 5)-10))-10);
ss.clear();
ss << page+1;
ss >> pageStatus;
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
gmenu2x->font->write(gmenu2x->s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
gmenu2x->font->write(s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
gmenu2x->s->flip();
s.flip();
repaint = false;
}

View File

@ -221,12 +221,12 @@ void Menu::paint(Surface &s) {
int t = sectionDelta < 0 ? sectionDelta + linkWidth : sectionDelta;
x += (((t * t) / linkWidth) * t) / linkWidth;
}
icon->blit(&s, x - 16, sectionLinkPadding, 32, 32);
font.write(&s, sections[j], x, topBarHeight - sectionLinkPadding,
icon->blit(s, x - 16, sectionLinkPadding, 32, 32);
font.write(s, sections[j], x, topBarHeight - sectionLinkPadding,
Font::HAlignCenter, Font::VAlignBottom);
}
sc.skinRes("imgs/section-l.png")->blit(&s, 0, 0);
sc.skinRes("imgs/section-r.png")->blit(&s, width - 10, 0);
sc.skinRes("imgs/section-l.png")->blit(s, 0, 0);
sc.skinRes("imgs/section-r.png")->blit(s, width - 10, 0);
vector<Link*> &sectionLinks = links[iSection];
const uint numLinks = sectionLinks.size();
@ -254,7 +254,7 @@ void Menu::paint(Surface &s) {
}
if (selLink()) {
font.write(&s, selLink()->getDescription(),
font.write(s, selLink()->getDescription(),
width / 2, height - bottomBarHeight + 2,
Font::HAlignCenter, Font::VAlignBottom);
}
@ -269,11 +269,11 @@ void Menu::paint(Surface &s) {
//Manual indicator
if (!linkApp->getManual().empty())
sc.skinRes("imgs/manual.png")->blit(
&s, gmenu2x->manualX, gmenu2x->bottomBarIconY);
s, gmenu2x->manualX, gmenu2x->bottomBarIconY);
}
if (ts.available()) {
btnContextMenu->paint();
btnContextMenu->paint(s);
}
}

View File

@ -41,7 +41,8 @@ MenuSetting::~MenuSetting()
void MenuSetting::draw(int /*valueX*/, int y, int /*h*/)
{
gmenu2x->font->write(gmenu2x->s, name, 5, y, Font::HAlignLeft, Font::VAlignTop);
Surface& s = *gmenu2x->s;
gmenu2x->font->write(s, name, 5, y, Font::HAlignLeft, Font::VAlignTop);
}
void MenuSetting::handleTS(int /*valueX*/, int /*y*/, int /*h*/)
@ -51,9 +52,11 @@ void MenuSetting::handleTS(int /*valueX*/, int /*y*/, int /*h*/)
void MenuSetting::drawSelected(int valueX, int y, int h)
{
Surface& s = *gmenu2x->s;
// The selection rectangle
gmenu2x->s->box(0, y, valueX - 5, h,
s.box(0, y, valueX - 5, h,
gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
buttonBox.paint(gmenu2x->s, 5);
buttonBox.paint(s, 5);
}

View File

@ -67,8 +67,9 @@ void MenuSettingBool::initButton()
void MenuSettingBool::draw(int valueX, int y, int h)
{
Surface& s = *gmenu2x->s;
MenuSetting::draw(valueX, y, h);
gmenu2x->font->write(gmenu2x->s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
gmenu2x->font->write(s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
}
bool MenuSettingBool::handleButtonPress(InputManager::Button button)

View File

@ -69,8 +69,9 @@ MenuSettingInt::MenuSettingInt(
void MenuSettingInt::draw(int valueX, int y, int h)
{
Surface& s = *gmenu2x->s;
MenuSetting::draw(valueX, y, h);
gmenu2x->font->write(gmenu2x->s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
gmenu2x->font->write(s, strvalue, valueX, y, Font::HAlignLeft, Font::VAlignTop);
}
bool MenuSettingInt::handleButtonPress(InputManager::Button button)

View File

@ -52,14 +52,16 @@ MenuSettingRGBA::MenuSettingRGBA(
}
void MenuSettingRGBA::draw(int valueX, int y, int h) {
Surface& s = *gmenu2x->s;
MenuSetting::draw(valueX, y, 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->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);
s.rectangle(valueX, y + 1, h - 2, h - 2, 0,0,0,255);
s.rectangle(valueX + 1, y + 2, h - 4, h - 4, 255,255,255,255);
s.box(valueX + 2, y + 3, h - 6, h - 6, value());
gmenu2x->font->write(s, "R: "+strR, valueX + h + 3, y, Font::HAlignLeft, Font::VAlignTop);
gmenu2x->font->write(s, "G: "+strG, valueX + h + 3 + COMPONENT_WIDTH, y, Font::HAlignLeft, Font::VAlignTop);
gmenu2x->font->write(s, "B: "+strB, valueX + h + 3 + COMPONENT_WIDTH * 2, y, Font::HAlignLeft, Font::VAlignTop);
gmenu2x->font->write(s, "A: "+strA, valueX + h + 3 + COMPONENT_WIDTH * 3, y, Font::HAlignLeft, Font::VAlignTop);
}
void MenuSettingRGBA::handleTS(int valueX, int y, int h) {

View File

@ -39,8 +39,9 @@ MenuSettingStringBase::~MenuSettingStringBase()
void MenuSettingStringBase::draw(int valueX, int y, int h)
{
Surface& s = *gmenu2x->s;
MenuSetting::draw(valueX, y, h);
gmenu2x->font->write(gmenu2x->s, value(), valueX, y,
gmenu2x->font->write(s, value(), valueX, y,
Font::HAlignLeft, Font::VAlignTop);
}

View File

@ -62,7 +62,8 @@ void MessageBox::setButton(InputManager::Button button, const string &label) {
}
int MessageBox::exec() {
Surface bg(gmenu2x->s);
Surface& s = *gmenu2x->s;
Surface bg(s);
//Darken background
bg.box(0, 0, gmenu2x->resX, gmenu2x->resY, 0,0,0,200);
@ -83,9 +84,9 @@ int MessageBox::exec() {
bg.rectangle(box, gmenu2x->skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
//icon+text
if (gmenu2x->sc[icon]) {
gmenu2x->sc[icon]->blitCenter( &bg, box.x + ICON_PADDING + ICON_DIMENSION / 2, box.y + ICON_PADDING + ICON_DIMENSION / 2 );
gmenu2x->sc[icon]->blitCenter(bg, box.x + ICON_PADDING + ICON_DIMENSION / 2, box.y + ICON_PADDING + ICON_DIMENSION / 2);
}
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);
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++) {
@ -93,7 +94,7 @@ int MessageBox::exec() {
buttonPositions[i].y = box.y+box.h+8;
buttonPositions[i].w = btnX;
btnX = gmenu2x->drawButtonRight(&bg, buttonLabels[i], buttons[i], btnX, buttonPositions[i].y);
btnX = gmenu2x->drawButtonRight(bg, buttonLabels[i], buttons[i], btnX, buttonPositions[i].y);
buttonPositions[i].x = btnX;
buttonPositions[i].w = buttonPositions[i].x-btnX-6;
@ -101,8 +102,8 @@ int MessageBox::exec() {
}
bg.convertToDisplayFormat();
bg.blit(gmenu2x->s,0,0);
gmenu2x->s->flip();
bg.blit(s, 0, 0);
s.flip();
int result = -1;
while (result < 0) {

View File

@ -60,19 +60,19 @@ int Selector::exec(int startSelection) {
fl.browse();
Surface bg(gmenu2x->bg);
drawTitleIcon(&bg, link->getIconPath(), true);
writeTitle(&bg, link->getTitle());
writeSubTitle(&bg, link->getDescription());
drawTitleIcon(bg, link->getIconPath(), true);
writeTitle(bg, link->getTitle());
writeSubTitle(bg, link->getDescription());
if (link->getSelectorBrowser()) {
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(&bg, "accept", gmenu2x->tr["Select"],
gmenu2x->drawButton(&bg, "cancel", gmenu2x->tr["Up one folder"],
gmenu2x->drawButton(&bg, "left", "", 5)-10)));
gmenu2x->drawButton(bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(bg, "accept", gmenu2x->tr["Select"],
gmenu2x->drawButton(bg, "cancel", gmenu2x->tr["Up one folder"],
gmenu2x->drawButton(bg, "left", "", 5)-10)));
} else {
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(&bg, "cancel", "",
gmenu2x->drawButton(&bg, "accept", gmenu2x->tr["Select"], 5)) - 10);
gmenu2x->drawButton(bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(bg, "cancel", "",
gmenu2x->drawButton(bg, "accept", gmenu2x->tr["Select"], 5)) - 10);
}
unsigned int top, height;
@ -95,7 +95,9 @@ int Selector::exec(int startSelection) {
gmenu2x->sc.addSkinRes("imgs/folder.png");
gmenu2x->sc.defaultAlpha = false;
while (!close) {
bg.blit(gmenu2x->s,0,0);
Surface& s = *gmenu2x->s;
bg.blit(s, 0, 0);
if (selected >= firstElement + nb_elements)
firstElement = selected - nb_elements + 1;
@ -106,36 +108,35 @@ int Selector::exec(int startSelection) {
if (selected-fl.dirCount()<screens.size()
&& !screens[selected-fl.dirCount()].empty()) {
Surface *screenshot = gmenu2x->sc[screens[selected-fl.dirCount()]];
if (screenshot)
screenshot->blitRight(
gmenu2x->s, 320, 0, 320, 240,
128u);
if (screenshot) {
screenshot->blitRight(s, 320, 0, 320, 240, 128u);
}
}
//Selection
iY = top + (selected - firstElement) * fontheight;
if (selected<fl.size())
gmenu2x->s->box(1, iY, 309, fontheight, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
s.box(1, iY, 309, fontheight, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
//Files & Dirs
gmenu2x->s->setClipRect(0, top, 311, height);
s.setClipRect(0, top, 311, height);
for (i = firstElement; i < fl.size()
&& i < firstElement + nb_elements; i++) {
iY = i-firstElement;
if (fl.isDirectory(i)) {
gmenu2x->sc["imgs/folder.png"]->blit(gmenu2x->s, 4, top + (iY * fontheight));
gmenu2x->font->write(gmenu2x->s, fl[i], 21,
gmenu2x->sc["imgs/folder.png"]->blit(s, 4, top + (iY * fontheight));
gmenu2x->font->write(s, fl[i], 21,
top + (iY * fontheight) + (fontheight / 2),
Font::HAlignLeft, Font::VAlignMiddle);
} else
gmenu2x->font->write(gmenu2x->s, titles[i - fl.dirCount()], 4,
gmenu2x->font->write(s, titles[i - fl.dirCount()], 4,
top + (iY * fontheight) + (fontheight / 2),
Font::HAlignLeft, Font::VAlignMiddle);
}
gmenu2x->s->clearClipRect();
s.clearClipRect();
gmenu2x->drawScrollBar(nb_elements, fl.size(), firstElement);
gmenu2x->s->flip();
s.flip();
switch (gmenu2x->input.waitForPressedButton()) {
case InputManager::SETTINGS:

View File

@ -78,16 +78,18 @@ bool SettingsDialog::exec() {
}
while (!close) {
Surface& s = *gmenu2x->s;
if (ts.available()) ts.poll();
bg.blit(gmenu2x->s,0,0);
bg.blit(s, 0, 0);
gmenu2x->drawTopBar(gmenu2x->s);
gmenu2x->drawTopBar(s);
//link icon
drawTitleIcon(gmenu2x->s, icon);
writeTitle(gmenu2x->s, text);
drawTitleIcon(s, icon);
writeTitle(s, text);
gmenu2x->drawBottomBar(gmenu2x->s);
gmenu2x->drawBottomBar(s);
if (sel>firstElement+numRows-1) firstElement=sel-numRows+1;
if (sel<firstElement) firstElement=sel;
@ -119,9 +121,9 @@ bool SettingsDialog::exec() {
gmenu2x->drawScrollBar(numRows, voices.size(), firstElement);
//description
writeSubTitle(gmenu2x->s, voices[sel]->getDescription());
writeSubTitle(s, voices[sel]->getDescription());
gmenu2x->s->flip();
s.flip();
voices[sel]->handleTS(maxNameWidth + 15, iY, rowHeight);
InputManager::Button button = inputMgr.waitForPressedButton();

View File

@ -159,8 +159,8 @@ void Surface::blit(SDL_Surface *destination, int x, int y, int w, int h, int a)
SDL_SetAlpha(raw, SDL_SRCALPHA|SDL_RLEACCEL, a);
SDL_BlitSurface(raw, (w==0 || h==0) ? NULL : &src, destination, &dest);
}
void Surface::blit(Surface *destination, int x, int y, int w, int h, int a) const {
blit(destination->raw,x,y,w,h,a);
void Surface::blit(Surface& destination, int x, int y, int w, int h, int a) const {
blit(destination.raw, x, y, w, h, a);
}
void Surface::blitCenter(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
@ -168,17 +168,17 @@ void Surface::blitCenter(SDL_Surface *destination, int x, int y, int w, int h, i
int oh = raw->h / 2; if (h != 0) oh = min(oh, h / 2);
blit(destination, x - ow, y - oh, w, h, a);
}
void Surface::blitCenter(Surface *destination, int x, int y, int w, int h, int a) const {
blitCenter(destination->raw,x,y,w,h,a);
void Surface::blitCenter(Surface& destination, int x, int y, int w, int h, int a) const {
blitCenter(destination.raw, x, y, w, h, a);
}
void Surface::blitRight(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
if (!w) w = raw->w;
blit(destination, x - min(raw->w, w), y, w, h, a);
}
void Surface::blitRight(Surface *destination, int x, int y, int w, int h, int a) const {
void Surface::blitRight(Surface& destination, int x, int y, int w, int h, int a) const {
if (!w) w = raw->w;
blitRight(destination->raw,x,y,w,h,a);
blitRight(destination.raw, x, y, w, h, a);
}
void Surface::box(SDL_Rect re, RGBAColor c) {
@ -252,7 +252,7 @@ void Surface::applyClipRect(SDL_Rect& rect) {
}
}
void Surface::blit(Surface *destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) const {
void Surface::blit(Surface& destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) const {
switch (halign) {
case Font::HAlignLeft:
break;

View File

@ -76,10 +76,10 @@ public:
void setClipRect(int x, int y, int w, int h);
void setClipRect(SDL_Rect rect);
void blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
void blit(Surface *destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop) const;
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 blit(Surface& destination, int x, int y, int w=0, int h=0, int a=-1) const;
void blit(Surface& destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop) const;
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 box(SDL_Rect re, RGBAColor c);
void box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) {

View File

@ -37,6 +37,7 @@ TextDialog::TextDialog(GMenu2X *gmenu2x, const string &title, const string &desc
void TextDialog::drawText(const vector<string> &text, unsigned int y,
unsigned int firstRow, unsigned int rowsPerPage)
{
Surface& s = *gmenu2x->s;
const int fontHeight = gmenu2x->font->getLineSpacing();
for (unsigned i = firstRow; i < firstRow + rowsPerPage && i < text.size(); i++) {
@ -44,10 +45,10 @@ void TextDialog::drawText(const vector<string> &text, unsigned int y,
int rowY = y + (i - firstRow) * fontHeight;
if (line == "----") { // horizontal ruler
rowY += fontHeight / 2;
gmenu2x->s->box(5, rowY, gmenu2x->resX - 16, 1, 255, 255, 255, 130);
gmenu2x->s->box(5, rowY+1, gmenu2x->resX - 16, 1, 0, 0, 0, 130);
s.box(5, rowY, gmenu2x->resX - 16, 1, 255, 255, 255, 130);
s.box(5, rowY+1, gmenu2x->resX - 16, 1, 0, 0, 0, 130);
} else {
gmenu2x->font->write(gmenu2x->s, line, 5, rowY);
gmenu2x->font->write(s, line, 5, rowY);
}
}
@ -61,16 +62,16 @@ void TextDialog::exec() {
//link icon
if (!fileExists(icon))
drawTitleIcon(&bg, "icons/ebook.png", true);
drawTitleIcon(bg, "icons/ebook.png", true);
else
drawTitleIcon(&bg, icon, false);
writeTitle(&bg, title);
writeSubTitle(&bg, description);
drawTitleIcon(bg, icon, false);
writeTitle(bg, title);
writeSubTitle(bg, description);
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(&bg, "cancel", "",
gmenu2x->drawButton(&bg, "down", gmenu2x->tr["Scroll"],
gmenu2x->drawButton(&bg, "up", "", 5)-10))-10);
gmenu2x->drawButton(bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(bg, "cancel", "",
gmenu2x->drawButton(bg, "down", gmenu2x->tr["Scroll"],
gmenu2x->drawButton(bg, "up", "", 5)-10))-10);
bg.convertToDisplayFormat();
@ -82,9 +83,11 @@ void TextDialog::exec() {
unsigned firstRow = 0;
while (!close) {
bg.blit(gmenu2x->s, 0, 0);
Surface& s = *gmenu2x->s;
bg.blit(s, 0, 0);
drawText(text, contentY, firstRow, rowsPerPage);
gmenu2x->s->flip();
s.flip();
switch(gmenu2x->input.waitForPressedButton()) {
case InputManager::UP:

View File

@ -75,17 +75,17 @@ void TextManualDialog::exec() {
//link icon
if (!fileExists(icon))
drawTitleIcon(&bg, "icons/ebook.png", true);
drawTitleIcon(bg, "icons/ebook.png", true);
else
drawTitleIcon(&bg, icon, false);
writeTitle(&bg, title+(description.empty() ? "" : ": "+description));
drawTitleIcon(bg, icon, false);
writeTitle(bg, title+(description.empty() ? "" : ": "+description));
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(&bg, "cancel", "",
gmenu2x->drawButton(&bg, "right", gmenu2x->tr["Change page"],
gmenu2x->drawButton(&bg, "left", "",
gmenu2x->drawButton(&bg, "down", gmenu2x->tr["Scroll"],
gmenu2x->drawButton(&bg, "up", "", 5)-10))-10))-10);
gmenu2x->drawButton(bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(bg, "cancel", "",
gmenu2x->drawButton(bg, "right", gmenu2x->tr["Change page"],
gmenu2x->drawButton(bg, "left", "",
gmenu2x->drawButton(bg, "down", gmenu2x->tr["Scroll"],
gmenu2x->drawButton(bg, "up", "", 5)-10))-10))-10);
bg.convertToDisplayFormat();
@ -97,17 +97,19 @@ void TextManualDialog::exec() {
string pageStatus;
while (!close) {
bg.blit(gmenu2x->s,0,0);
writeSubTitle(gmenu2x->s, pages[page].title);
Surface& s = *gmenu2x->s;
bg.blit(s,0,0);
writeSubTitle(s, pages[page].title);
drawText(pages[page].text, 42 /* TODO */, firstRow, rowsPerPage);
ss.clear();
ss << page+1;
ss >> pageStatus;
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
gmenu2x->font->write(gmenu2x->s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
gmenu2x->font->write(s, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
gmenu2x->s->flip();
s.flip();
switch(gmenu2x->input.waitForPressedButton()) {
case InputManager::UP:

View File

@ -88,41 +88,43 @@ bool WallpaperDialog::exec()
unsigned int nb_elements = height / fontheight;
while (!close) {
Surface& s = *gmenu2x->s;
if (selected > firstElement + nb_elements - 1)
firstElement = selected - nb_elements + 1;
if (selected < firstElement)
firstElement = selected;
//Wallpaper
gmenu2x->sc[((string)"skin:wallpapers/" + wallpapers[selected]).c_str()]->blit(gmenu2x->s, 0, 0);
gmenu2x->sc[((string)"skin:wallpapers/" + wallpapers[selected]).c_str()]->blit(s, 0, 0);
gmenu2x->drawTopBar(gmenu2x->s);
gmenu2x->drawBottomBar(gmenu2x->s);
gmenu2x->drawTopBar(s);
gmenu2x->drawBottomBar(s);
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"]);
drawTitleIcon(s, "icons/wallpaper.png", true);
writeTitle(s, gmenu2x->tr["Wallpaper selection"]);
writeSubTitle(s, gmenu2x->tr["Select a wallpaper from the list"]);
buttonbox.paint(gmenu2x->s, 5);
buttonbox.paint(s, 5);
//Selection
iY = selected - firstElement;
iY = top + (iY * fontheight);
gmenu2x->s->box(2, iY, 308, fontheight, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
s.box(2, iY, 308, fontheight, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
//Files & Directories
gmenu2x->s->setClipRect(0, top, 311, height);
s.setClipRect(0, top, 311, height);
for (i = firstElement; i < wallpapers.size()
&& i < firstElement + nb_elements; i++) {
iY = i-firstElement;
gmenu2x->font->write(gmenu2x->s, wallpapers[i], 5,
gmenu2x->font->write(s, wallpapers[i], 5,
top + (iY * fontheight),
Font::HAlignLeft, Font::VAlignTop);
}
gmenu2x->s->clearClipRect();
s.clearClipRect();
gmenu2x->drawScrollBar(nb_elements, wallpapers.size(), firstElement);
gmenu2x->s->flip();
s.flip();
switch(gmenu2x->input.waitForPressedButton()) {
case InputManager::CANCEL: