-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathalignbox.h
More file actions
48 lines (35 loc) · 1.07 KB
/
alignbox.h
File metadata and controls
48 lines (35 loc) · 1.07 KB
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
39
40
41
42
43
44
45
46
47
48
#ifndef ALIGNBOX_H
#define ALIGNBOX_H
#include <QtGui>
#include <QGraphicsSceneMouseEvent>
#include <QStyleOptionGraphicsItem>
#include <QGraphicsItem>
#include <QGraphicsWidget>
#include <QDebug>
#include <QGraphicsScene>
class ResizeHandle : public QGraphicsRectItem
{
public:
explicit ResizeHandle(Qt::Alignment alignment, QGraphicsItem* parent = 0);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
private:
QPointF offset;
Qt::Alignment align;
};
class AlignWidget : public QGraphicsWidget
{
public:
AlignWidget(QGraphicsItem* parent = 0);
public:
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
void gridUpdate(QPainter* painter, int gridSize);
void mouseMoveEvent( QGraphicsSceneMouseEvent *event);
void setGeometry(const QRectF& rect);
private:
void createHandle(Qt::Alignment align);
void adjustHandle(Qt::Alignment align, ResizeHandle* handle);
QHash<Qt::Alignment, ResizeHandle*> resizeHandles;
};
#endif