-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsquareitem.h
30 lines (27 loc) · 1.12 KB
/
squareitem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef SQUAREITEM_H
#define SQUAREITEM_H
#include "fortunestreetdata.h"
#include <QEvent>
#include <QGraphicsItem>
class SquareItem : public QGraphicsItem {
public:
SquareItem(const SquareData &dataValue, QGraphicsItem *parent = nullptr);
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
SquareData &getData();
const SquareData &getData() const;
QPointF getSnapLocation(const QPointF &loc);
/**
* This should be called after the ID is changed
*/
void updateZValueFromData();
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
private:
SquareData data;
QPointF oldPoint;
static void drawBackgroundedTextCentered(QPainter *painter, int x, int y, const QString &text, const QBrush &bgBrush);
static void drawBackgroundedTextRightAligned(QPainter *painter, int x, int y, const QString &text, const QBrush &bgBrush);
static void drawBackgroundedText(QPainter *painter, int x, int y, const QString &text, const QBrush &bgBrush);
};
#endif // SQUAREITEM_H