2020-05-02 22:25:35 +01:00
|
|
|
#ifndef OVERLAY_H
|
|
|
|
#define OVERLAY_H
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QColor>
|
|
|
|
#include <QPainter>
|
2022-10-11 04:47:42 +01:00
|
|
|
#include <QStaticText>
|
2022-10-15 17:33:12 +01:00
|
|
|
#include <QPainterPath>
|
2020-05-02 22:25:35 +01:00
|
|
|
|
|
|
|
class OverlayItem {
|
|
|
|
public:
|
|
|
|
OverlayItem() {}
|
|
|
|
virtual ~OverlayItem() {};
|
2022-10-11 22:21:44 +01:00
|
|
|
virtual void render(QPainter *) {};
|
2020-05-02 22:25:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class OverlayText : public OverlayItem {
|
|
|
|
public:
|
2022-10-11 04:47:42 +01:00
|
|
|
OverlayText(const QString inputText, int x, int y, QColor color, int fontSize) :
|
|
|
|
text(QStaticText(inputText))
|
|
|
|
{
|
2020-05-02 22:25:35 +01:00
|
|
|
this->x = x;
|
|
|
|
this->y = y;
|
|
|
|
this->color = color;
|
|
|
|
this->fontSize = fontSize;
|
|
|
|
}
|
|
|
|
~OverlayText() {}
|
2022-10-11 22:21:44 +01:00
|
|
|
virtual void render(QPainter *painter);
|
2020-05-02 22:25:35 +01:00
|
|
|
private:
|
2022-10-11 04:47:42 +01:00
|
|
|
const QStaticText text;
|
2020-05-02 22:25:35 +01:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
QColor color;
|
|
|
|
int fontSize;
|
|
|
|
};
|
|
|
|
|
2022-10-11 19:52:52 +01:00
|
|
|
class OverlayPath : public OverlayItem {
|
2020-05-02 22:25:35 +01:00
|
|
|
public:
|
2022-10-11 19:52:52 +01:00
|
|
|
OverlayPath(QPainterPath path, QColor borderColor, QColor fillColor) {
|
|
|
|
this->path = path;
|
2022-10-11 18:30:27 +01:00
|
|
|
this->borderColor = borderColor;
|
|
|
|
this->fillColor = fillColor;
|
2020-05-02 22:25:35 +01:00
|
|
|
}
|
2022-10-11 19:52:52 +01:00
|
|
|
~OverlayPath() {}
|
2022-10-11 22:21:44 +01:00
|
|
|
virtual void render(QPainter *painter);
|
2020-05-02 22:25:35 +01:00
|
|
|
private:
|
2022-10-11 19:52:52 +01:00
|
|
|
QPainterPath path;
|
2022-10-11 18:30:27 +01:00
|
|
|
QColor borderColor;
|
|
|
|
QColor fillColor;
|
2020-05-02 22:25:35 +01:00
|
|
|
};
|
|
|
|
|
2024-10-28 15:42:44 +00:00
|
|
|
class OverlayPixmap : public OverlayItem {
|
2020-05-02 22:25:35 +01:00
|
|
|
public:
|
2024-10-28 15:42:44 +00:00
|
|
|
OverlayPixmap(int x, int y, QPixmap pixmap) {
|
2020-05-02 22:25:35 +01:00
|
|
|
this->x = x;
|
|
|
|
this->y = y;
|
2024-10-28 15:42:44 +00:00
|
|
|
this->pixmap = pixmap;
|
2020-05-02 22:25:35 +01:00
|
|
|
}
|
2024-10-28 15:42:44 +00:00
|
|
|
~OverlayPixmap() {}
|
2022-10-11 22:21:44 +01:00
|
|
|
virtual void render(QPainter *painter);
|
2020-05-02 22:25:35 +01:00
|
|
|
private:
|
|
|
|
int x;
|
|
|
|
int y;
|
2024-10-28 15:42:44 +00:00
|
|
|
QPixmap pixmap;
|
2020-05-02 22:25:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class Overlay
|
|
|
|
{
|
|
|
|
public:
|
2021-12-09 17:32:19 +00:00
|
|
|
Overlay() {
|
|
|
|
this->x = 0;
|
|
|
|
this->y = 0;
|
2022-10-13 20:14:53 +01:00
|
|
|
this->angle = 0;
|
2022-10-11 22:21:44 +01:00
|
|
|
this->hScale = 1.0;
|
|
|
|
this->vScale = 1.0;
|
2021-12-09 17:32:19 +00:00
|
|
|
this->hidden = false;
|
2021-12-31 21:12:04 +00:00
|
|
|
this->opacity = 1.0;
|
2022-10-10 17:22:38 +01:00
|
|
|
this->clippingRect = nullptr;
|
2021-12-09 17:32:19 +00:00
|
|
|
}
|
2020-05-02 22:25:35 +01:00
|
|
|
~Overlay() {
|
|
|
|
this->clearItems();
|
|
|
|
}
|
2021-12-09 17:32:19 +00:00
|
|
|
bool getHidden();
|
2021-11-30 18:38:06 +00:00
|
|
|
void setHidden(bool hidden);
|
2021-12-31 21:12:04 +00:00
|
|
|
int getOpacity();
|
|
|
|
void setOpacity(int opacity);
|
2021-12-09 17:32:19 +00:00
|
|
|
int getX();
|
|
|
|
int getY();
|
|
|
|
void setX(int x);
|
|
|
|
void setY(int y);
|
2022-10-14 02:58:59 +01:00
|
|
|
qreal getHScale();
|
|
|
|
qreal getVScale();
|
|
|
|
void setHScale(qreal scale);
|
|
|
|
void setVScale(qreal scale);
|
2022-11-03 17:19:57 +00:00
|
|
|
void setScale(qreal hScale, qreal vScale);
|
2022-10-15 18:12:40 +01:00
|
|
|
int getRotation();
|
|
|
|
void setRotation(int angle);
|
2022-10-11 22:21:44 +01:00
|
|
|
void rotate(int degrees);
|
2022-10-10 17:22:38 +01:00
|
|
|
void setClippingRect(QRectF rect);
|
|
|
|
void clearClippingRect();
|
2021-12-09 17:32:19 +00:00
|
|
|
void setPosition(int x, int y);
|
|
|
|
void move(int deltaX, int deltaY);
|
2021-11-30 17:58:39 +00:00
|
|
|
void renderItems(QPainter *painter);
|
2020-05-02 22:25:35 +01:00
|
|
|
QList<OverlayItem*> getItems();
|
|
|
|
void clearItems();
|
2022-10-11 19:52:52 +01:00
|
|
|
void addText(const QString text, int x, int y, QString colorStr, int fontSize);
|
|
|
|
bool addRect(int x, int y, int width, int height, QString borderColorStr, QString fillColorStr, int rounding);
|
2022-10-01 22:38:50 +01:00
|
|
|
bool addImage(int x, int y, QString filepath, bool useCache = true, int width = -1, int height = -1, int xOffset = 0, int yOffset = 0, qreal hScale = 1, qreal vScale = 1, QList<QRgb> palette = QList<QRgb>(), bool setTransparency = false);
|
2021-12-01 21:06:14 +00:00
|
|
|
bool addImage(int x, int y, QImage image);
|
2022-10-11 22:21:44 +01:00
|
|
|
bool addPath(QList<int> xCoords, QList<int> yCoords, QString borderColorStr, QString fillColorStr);
|
2020-05-02 22:25:35 +01:00
|
|
|
private:
|
2022-10-13 20:14:53 +01:00
|
|
|
void clampAngle();
|
2022-10-11 19:52:52 +01:00
|
|
|
QColor getColor(QString colorStr);
|
2020-05-02 22:25:35 +01:00
|
|
|
QList<OverlayItem*> items;
|
2021-12-09 17:32:19 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
2022-10-13 20:14:53 +01:00
|
|
|
int angle;
|
2022-10-11 22:21:44 +01:00
|
|
|
qreal hScale;
|
|
|
|
qreal vScale;
|
2021-11-30 18:38:06 +00:00
|
|
|
bool hidden;
|
2021-12-31 21:12:04 +00:00
|
|
|
qreal opacity;
|
2022-10-10 17:22:38 +01:00
|
|
|
QRectF *clippingRect;
|
2020-05-02 22:25:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OVERLAY_H
|