mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 19:03:44 +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);
|
writeTitle(title);
|
||||||
writeSubTitle(subtitle);
|
writeSubTitle(subtitle);
|
||||||
|
|
||||||
buttonBox.paint(5);
|
buttonBox.paint(gmenu2x->s, 5);
|
||||||
|
|
||||||
// TODO(MtH): I have no idea what the right value of firstElement would be,
|
// 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.
|
// but originally it was undefined and that is never a good idea.
|
||||||
|
@ -22,10 +22,10 @@ void ButtonBox::clear()
|
|||||||
buttons.clear();
|
buttons.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonBox::paint(unsigned int posX)
|
void ButtonBox::paint(Surface *s, unsigned int posX)
|
||||||
{
|
{
|
||||||
for (auto button : buttons)
|
for (auto button : buttons)
|
||||||
posX = gmenu2x->drawButton(button, posX);
|
posX = gmenu2x->drawButton(s, button, posX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonBox::handleTS()
|
void ButtonBox::handleTS()
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
class GMenu2X;
|
class GMenu2X;
|
||||||
class IconButton;
|
class IconButton;
|
||||||
|
class Surface;
|
||||||
|
|
||||||
class ButtonBox
|
class ButtonBox
|
||||||
{
|
{
|
||||||
@ -15,7 +16,7 @@ public:
|
|||||||
void add(IconButton *button);
|
void add(IconButton *button);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void paint(unsigned int posX);
|
void paint(Surface *s, unsigned int posX);
|
||||||
void handleTS();
|
void handleTS();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1177,10 +1177,10 @@ string GMenu2X::getDiskFree(const char *path) {
|
|||||||
return df;
|
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;
|
if (y<0) y = resY+y;
|
||||||
btn->setPosition(x, y-7);
|
btn->setPosition(x, y-7);
|
||||||
btn->paint();
|
btn->paint(s);
|
||||||
return x+btn->getRect().w+6;
|
return x+btn->getRect().w+6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ public:
|
|||||||
void renameSection();
|
void renameSection();
|
||||||
void deleteSection();
|
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 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 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 drawScrollBar(uint pageSize, uint totalSize, uint pagePos);
|
||||||
|
@ -65,12 +65,12 @@ bool IconButton::handleTS() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconButton::paint() {
|
void IconButton::paint(Surface *s) {
|
||||||
if (iconSurface) {
|
if (iconSurface) {
|
||||||
iconSurface->blit(gmenu2x->s, iconRect);
|
iconSurface->blit(s, iconRect);
|
||||||
}
|
}
|
||||||
if (!label.empty()) {
|
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);
|
Font::HAlignLeft, Font::VAlignMiddle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
#define ICONBUTTON_H
|
#define ICONBUTTON_H
|
||||||
|
|
||||||
#include "delegate.h"
|
#include "delegate.h"
|
||||||
|
#include "gmenu2x.h"
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class GMenu2X;
|
|
||||||
class Surface;
|
class Surface;
|
||||||
class Touchscreen;
|
class Touchscreen;
|
||||||
|
|
||||||
@ -23,7 +23,8 @@ public:
|
|||||||
|
|
||||||
bool handleTS();
|
bool handleTS();
|
||||||
|
|
||||||
void paint();
|
void paint(Surface *s);
|
||||||
|
void paint() { paint(gmenu2x->s); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recalcRects();
|
void recalcRects();
|
||||||
|
@ -159,7 +159,7 @@ bool InputDialog::exec() {
|
|||||||
writeSubTitle(text);
|
writeSubTitle(text);
|
||||||
drawTitleIcon(icon);
|
drawTitleIcon(icon);
|
||||||
|
|
||||||
buttonbox->paint(5);
|
buttonbox->paint(gmenu2x->s, 5);
|
||||||
|
|
||||||
box.w = gmenu2x->font->getTextWidth(input) + 18;
|
box.w = gmenu2x->font->getTextWidth(input) + 18;
|
||||||
box.x = 160 - box.w / 2;
|
box.x = 160 - box.w / 2;
|
||||||
|
@ -51,5 +51,5 @@ void MenuSetting::handleTS()
|
|||||||
|
|
||||||
void MenuSetting::drawSelected(int /*y*/)
|
void MenuSetting::drawSelected(int /*y*/)
|
||||||
{
|
{
|
||||||
buttonBox.paint(5);
|
buttonBox.paint(gmenu2x->s, 5);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ bool WallpaperDialog::exec()
|
|||||||
writeTitle("Wallpaper selection");
|
writeTitle("Wallpaper selection");
|
||||||
writeSubTitle("Select an image from the list, to use as a wallpaper");
|
writeSubTitle("Select an image from the list, to use as a wallpaper");
|
||||||
|
|
||||||
buttonbox.paint(5);
|
buttonbox.paint(gmenu2x->s, 5);
|
||||||
|
|
||||||
//Selection
|
//Selection
|
||||||
iY = selected-firstElement;
|
iY = selected-firstElement;
|
||||||
|
Loading…
Reference in New Issue
Block a user