-
Notifications
You must be signed in to change notification settings - Fork 4
/
canvas.h
74 lines (59 loc) · 1.41 KB
/
canvas.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef _CANVAS_H_
#define _CANVAS_H_
#include <QGraphicsView>
#include "cell.h"
class QMouseEvent;
class QWheelEvent;
class SelectionGroup;
class SparseMap;
class Canvas : public QGraphicsView
{
Q_OBJECT;
public:
Canvas(QWidget *parent = NULL);
~Canvas();
bool mapToGrid(const QPoint &pos, QPoint &out);
bool mapToGrid(const QPoint &pos, QPoint &out, Subarea &subareaOut);
signals:
void madeSelection(const QRect &rect);
void clearedSelection();
public slots:
void setDocument(Document *doc);
void zoomIn();
void zoomOut();
void zoomReset();
void toggleGrid(bool enabled);
void cut();
void copy();
void paste();
void paste(const QByteArray &data, bool action = false);
void deleteSelected();
void clearSelection();
void clearFloatingSelection();
void moveFloatingSelection(const QPoint &pos);
void commitPaste();
private:
void setCenter(const QPointF ¢erPoint);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
private:
SelectionGroup *floatingSelection_;
SparseMap *drawmap_;
/* states */
bool selecting_;
bool moving_;
bool dragging_;
bool drawing_;
bool erasing_;
bool rectangle_;
/* coords */
QPoint lastPos_;
QPoint startPos_;
QRect lastRect_;
QPoint cursor_;
Subarea subcursor_;
QPointF center_;
};
#endif