Date:2014-01-16 01:03:15 (6 months 8 days ago)
Author:Paul Cercueil
Commit:cfb96dd697b1793189262a5fad221eef0e988595
Message:Pass a Surface to ButtonBox' and IconButton's paint function

Files: src/browsedialog.cpp (1 diff)
src/buttonbox.cpp (1 diff)
src/buttonbox.h (2 diffs)
src/gmenu2x.cpp (1 diff)
src/gmenu2x.h (1 diff)
src/iconbutton.cpp (1 diff)
src/iconbutton.h (2 diffs)
src/inputdialog.cpp (1 diff)
src/menusetting.cpp (1 diff)
src/wallpaperdialog.cpp (1 diff)

Change Details

src/browsedialog.cpp
232232    writeTitle(title);
233233    writeSubTitle(subtitle);
234234
235    buttonBox.paint(5);
235    buttonBox.paint(gmenu2x->s, 5);
236236
237237    // TODO(MtH): I have no idea what the right value of firstElement would be,
238238    // but originally it was undefined and that is never a good idea.
src/buttonbox.cpp
2222    buttons.clear();
2323}
2424
25void ButtonBox::paint(unsigned int posX)
25void ButtonBox::paint(Surface *s, unsigned int posX)
2626{
2727    for (auto button : buttons)
28        posX = gmenu2x->drawButton(button, posX);
28        posX = gmenu2x->drawButton(s, button, posX);
2929}
3030
3131void ButtonBox::handleTS()
src/buttonbox.h
55
66class GMenu2X;
77class IconButton;
8class Surface;
89
910class ButtonBox
1011{
...... 
1516    void add(IconButton *button);
1617    void clear();
1718
18    void paint(unsigned int posX);
19    void paint(Surface *s, unsigned int posX);
1920    void handleTS();
2021
2122private:
src/gmenu2x.cpp
11771177    return df;
11781178}
11791179
1180int GMenu2X::drawButton(IconButton *btn, int x, int y) {
1180int GMenu2X::drawButton(Surface *s, IconButton *btn, int x, int y) {
11811181    if (y<0) y = resY+y;
11821182    btn->setPosition(x, y-7);
1183    btn->paint();
1183    btn->paint(s);
11841184    return x+btn->getRect().w+6;
11851185}
11861186
src/gmenu2x.h
212212    void renameSection();
213213    void deleteSection();
214214
215    int drawButton(IconButton *btn, int x=5, int y=-10);
215    int drawButton(Surface *s, IconButton *btn, int x=5, int y=-10);
216216    int drawButton(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
217217    int drawButtonRight(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
218218    void drawScrollBar(uint pageSize, uint totalSize, uint pagePos);
src/iconbutton.cpp
6565    return false;
6666}
6767
68void IconButton::paint() {
68void IconButton::paint(Surface *s) {
6969    if (iconSurface) {
70        iconSurface->blit(gmenu2x->s, iconRect);
70        iconSurface->blit(s, iconRect);
7171    }
7272    if (!label.empty()) {
73        gmenu2x->s->write(gmenu2x->font, label, labelRect.x, labelRect.y,
73        s->write(gmenu2x->font, label, labelRect.x, labelRect.y,
7474                Font::HAlignLeft, Font::VAlignMiddle);
7575    }
7676}
src/iconbutton.h
22#define ICONBUTTON_H
33
44#include "delegate.h"
5#include "gmenu2x.h"
56
67#include <SDL.h>
78#include <string>
89
9class GMenu2X;
1010class Surface;
1111class Touchscreen;
1212
...... 
2323
2424    bool handleTS();
2525
26    void paint();
26    void paint(Surface *s);
27    void paint() { paint(gmenu2x->s); }
2728
2829private:
2930    void recalcRects();
src/inputdialog.cpp
159159        writeSubTitle(text);
160160        drawTitleIcon(icon);
161161
162        buttonbox->paint(5);
162        buttonbox->paint(gmenu2x->s, 5);
163163
164164        box.w = gmenu2x->font->getTextWidth(input) + 18;
165165        box.x = 160 - box.w / 2;
src/menusetting.cpp
5151
5252void MenuSetting::drawSelected(int /*y*/)
5353{
54    buttonBox.paint(5);
54    buttonBox.paint(gmenu2x->s, 5);
5555}
src/wallpaperdialog.cpp
9595        writeTitle("Wallpaper selection");
9696        writeSubTitle("Select an image from the list, to use as a wallpaper");
9797
98        buttonbox.paint(5);
98        buttonbox.paint(gmenu2x->s, 5);
9999
100100        //Selection
101101        iY = selected-firstElement;

Archive Download the corresponding diff file



interactive