mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-25 21:17:20 +02:00
Pass a Surface to ButtonBox' and IconButton's paint function
This commit is contained in:
parent
ca3df65daa
commit
cfb96dd697
@ -232,7 +232,7 @@ void BrowseDialog::paint()
|
||||
writeTitle(title);
|
||||
writeSubTitle(subtitle);
|
||||
|
||||
buttonBox.paint(5);
|
||||
buttonBox.paint(gmenu2x->s, 5);
|
||||
|
||||
// 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.
|
||||
|
@ -22,10 +22,10 @@ void ButtonBox::clear()
|
||||
buttons.clear();
|
||||
}
|
||||
|
||||
void ButtonBox::paint(unsigned int posX)
|
||||
void ButtonBox::paint(Surface *s, unsigned int posX)
|
||||
{
|
||||
for (auto button : buttons)
|
||||
posX = gmenu2x->drawButton(button, posX);
|
||||
posX = gmenu2x->drawButton(s, button, posX);
|
||||
}
|
||||
|
||||
void ButtonBox::handleTS()
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
class GMenu2X;
|
||||
class IconButton;
|
||||
class Surface;
|
||||
|
||||
class ButtonBox
|
||||
{
|
||||
@ -15,7 +16,7 @@ public:
|
||||
void add(IconButton *button);
|
||||
void clear();
|
||||
|
||||
void paint(unsigned int posX);
|
||||
void paint(Surface *s, unsigned int posX);
|
||||
void handleTS();
|
||||
|
||||
private:
|
||||
|
@ -1177,10 +1177,10 @@ string GMenu2X::getDiskFree(const char *path) {
|
||||
return df;
|
||||
}
|
||||
|
||||
int GMenu2X::drawButton(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();
|
||||
btn->paint(s);
|
||||
return x+btn->getRect().w+6;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ public:
|
||||
void renameSection();
|
||||
void deleteSection();
|
||||
|
||||
int drawButton(IconButton *btn, 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);
|
||||
|
@ -65,12 +65,12 @@ bool IconButton::handleTS() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void IconButton::paint() {
|
||||
void IconButton::paint(Surface *s) {
|
||||
if (iconSurface) {
|
||||
iconSurface->blit(gmenu2x->s, iconRect);
|
||||
iconSurface->blit(s, iconRect);
|
||||
}
|
||||
if (!label.empty()) {
|
||||
gmenu2x->s->write(gmenu2x->font, label, labelRect.x, labelRect.y,
|
||||
s->write(gmenu2x->font, label, labelRect.x, labelRect.y,
|
||||
Font::HAlignLeft, Font::VAlignMiddle);
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
#define ICONBUTTON_H
|
||||
|
||||
#include "delegate.h"
|
||||
#include "gmenu2x.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <string>
|
||||
|
||||
class GMenu2X;
|
||||
class Surface;
|
||||
class Touchscreen;
|
||||
|
||||
@ -23,7 +23,8 @@ public:
|
||||
|
||||
bool handleTS();
|
||||
|
||||
void paint();
|
||||
void paint(Surface *s);
|
||||
void paint() { paint(gmenu2x->s); }
|
||||
|
||||
private:
|
||||
void recalcRects();
|
||||
|
@ -159,7 +159,7 @@ bool InputDialog::exec() {
|
||||
writeSubTitle(text);
|
||||
drawTitleIcon(icon);
|
||||
|
||||
buttonbox->paint(5);
|
||||
buttonbox->paint(gmenu2x->s, 5);
|
||||
|
||||
box.w = gmenu2x->font->getTextWidth(input) + 18;
|
||||
box.x = 160 - box.w / 2;
|
||||
|
@ -51,5 +51,5 @@ void MenuSetting::handleTS()
|
||||
|
||||
void MenuSetting::drawSelected(int /*y*/)
|
||||
{
|
||||
buttonBox.paint(5);
|
||||
buttonBox.paint(gmenu2x->s, 5);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ bool WallpaperDialog::exec()
|
||||
writeTitle("Wallpaper selection");
|
||||
writeSubTitle("Select an image from the list, to use as a wallpaper");
|
||||
|
||||
buttonbox.paint(5);
|
||||
buttonbox.paint(gmenu2x->s, 5);
|
||||
|
||||
//Selection
|
||||
iY = selected-firstElement;
|
||||
|
Loading…
Reference in New Issue
Block a user