-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra_items.h
38 lines (33 loc) · 1.25 KB
/
extra_items.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
31
32
33
34
35
36
37
38
#ifndef EXTRA_ITEMS_H
#define EXTRA_ITEMS_H
#include <QGraphicsProxyWidget>
#include <QLinkedList>
#include <QPainter>
//A rounded-rectangle shape item with corner-radius 'radius'.
class MRoundRectItem : public QGraphicsPathItem {
public:
MRoundRectItem(const QRectF& rect, qreal radius, QGraphicsItem* parent = 0, QGraphicsScene* scene = 0);
};
//A rhombus shape item.
class MRhombusItem : public QGraphicsPolygonItem {
public:
MRhombusItem(const QRectF& rect, QGraphicsItem* parent = 0, QGraphicsScene* scene = 0);
};
//A parallelogram shape item, top corners 'skew' px right of bottom ones.
class MPllgramItem : public QGraphicsPolygonItem {
public:
MPllgramItem(const QRectF& rect, qreal skew, QGraphicsItem* parent = 0, QGraphicsScene* scene = 0);
};
//QGraphicsProxyWidget that raises all ancestors' z-values on hover.
//This is necessary to prevent popup menus being hidden under other items.
class ElevProxyWidget : public QGraphicsProxyWidget {
Q_OBJECT
public:
using QGraphicsProxyWidget::QGraphicsProxyWidget;
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
private:
QLinkedList<QPair<QGraphicsItem*, qreal>> old_z;
};
#endif //EXTRA_ITEMS_H