porymap/include/ui/movablerect.h

33 lines
921 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
2021-02-18 00:20:14 +00:00
class MovableRect : public QGraphicsItem {
2019-01-09 00:04:48 +00:00
public:
2021-02-18 00:20:14 +00:00
MovableRect(bool* enabled, int width, int height, QRgb color);
QRectF boundingRect() const override {
2019-01-09 00:04:48 +00:00
qreal penWidth = 4;
2021-02-18 00:20:14 +00:00
return QRectF(-penWidth, -penWidth, 30 * 8 + penWidth * 2, 20 * 8 + penWidth * 2);
2019-01-09 00:04:48 +00:00
}
2021-02-18 00:20:14 +00:00
void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) override {
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);
2021-02-18 00:20:14 +00:00
bool* enabled;
private:
int width;
int height;
QRgb color;
2019-01-09 00:04:48 +00:00
};
#endif // MOVABLERECT_H