porymap/include/ui/overlay.h

91 lines
2 KiB
C
Raw Normal View History

#ifndef OVERLAY_H
#define OVERLAY_H
#include <QList>
#include <QString>
#include <QColor>
#include <QPainter>
class OverlayItem {
public:
OverlayItem() {}
virtual ~OverlayItem() {};
2020-08-27 01:42:42 +01:00
virtual void render(QPainter *) {};
};
class OverlayText : public OverlayItem {
public:
OverlayText(QString text, int x, int y, QColor color, int fontSize) {
this->text = text;
this->x = x;
this->y = y;
this->color = color;
this->fontSize = fontSize;
}
~OverlayText() {}
virtual void render(QPainter *painter);
private:
QString text;
int x;
int y;
QColor color;
int fontSize;
};
class OverlayRect : public OverlayItem {
public:
OverlayRect(int x, int y, int width, int height, QColor color, bool filled) {
this->x = x;
this->y = y;
this->width = width;
this->height = height;
this->color = color;
this->filled = filled;
}
~OverlayRect() {}
virtual void render(QPainter *painter);
private:
int x;
int y;
int width;
int height;
QColor color;
bool filled;
};
class OverlayImage : public OverlayItem {
public:
OverlayImage(int x, int y, QImage image) {
this->x = x;
this->y = y;
this->image = image;
}
~OverlayImage() {}
virtual void render(QPainter *painter);
private:
int x;
int y;
QImage image;
};
class Overlay
{
public:
Overlay() {}
~Overlay() {
this->clearItems();
}
2021-11-30 18:38:06 +00:00
void setHidden(bool hidden);
2021-11-30 17:58:39 +00:00
void renderItems(QPainter *painter);
QList<OverlayItem*> getItems();
void clearItems();
void addText(QString text, int x, int y, QString color = "#000000", int fontSize = 12);
void addRect(int x, int y, int width, int height, QString color = "#000000", bool filled = false);
bool addImage(int x, int y, QString filepath, int width = -1, int height = -1, unsigned offset = 0, bool hflip = false, bool vflip = false, bool setTransparency = false);
private:
QList<OverlayItem*> items;
2021-11-30 18:38:06 +00:00
bool hidden;
};
#endif // OVERLAY_H