porymap/include/ui/movablerect.h

38 lines
996 B
C
Raw Normal View History

#ifndef MOVABLERECT_H
#define MOVABLERECT_H
2019-01-09 00:04:48 +00:00
#include <QGraphicsItem>
#include <QPainter>
#include <QRgb>
2019-01-09 00:04:48 +00:00
class MovableRect : public QGraphicsItem
2019-01-09 00:04:48 +00:00
{
public:
MovableRect(bool *enabled, int width, int height, QRgb color);
2019-01-09 00:04:48 +00:00
QRectF boundingRect() const override
{
qreal penWidth = 4;
return QRectF(-penWidth,
-penWidth,
30 * 8 + penWidth * 2,
20 * 8 + penWidth * 2);
}
2019-08-07 04:35:02 +01:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
2019-01-09 00:04:48 +00:00
{
painter->setPen(this->color);
painter->drawRect(-2, -2, this->width + 3, this->height + 3);
2019-01-09 00:04:48 +00:00
painter->setPen(QColor(0, 0, 0));
painter->drawRect(-3, -3, this->width + 5, this->height + 5);
painter->drawRect(-1, -1, this->width + 1, this->height + 1);
2019-01-09 00:04:48 +00:00
}
void updateLocation(int x, int y);
bool *enabled;
private:
int width;
int height;
QRgb color;
2019-01-09 00:04:48 +00:00
};
#endif // MOVABLERECT_H