]> Shamusworld >> Repos - architektonas/blob - src/drawingview.h
c4a7234fe733314ffc34bbebfcf98b3232a314e0
[architektonas] / src / drawingview.h
1 #ifndef __DRAWINGVIEW_H__
2 #define __DRAWINGVIEW_H__
3
4 #include <QtWidgets>
5 #include <stdint.h>
6 #include "structs.h"
7
8 class Painter;
9
10 class DrawingView: public QWidget
11 {
12         Q_OBJECT
13
14         public:
15                 DrawingView(QWidget * parent = NULL);
16
17         public:
18 //              void SetToolActive(Action * action);
19                 void SetGridSize(uint32_t);
20                 void UpdateGridBackground(void);
21                 Point SnapPointToGrid(Point);
22                 void RenderObjects(Painter *, Container *);
23                 void DeleteSelectedItems(void);
24                 void ClearSelection(void);
25                 void AddHoveredToSelection(void);
26                 void GetSelection(std::vector<void *> &);
27                 void GetHovered(std::vector<void *> &);
28
29         public slots:
30                 void AddNewObjectToDocument(Object *);
31                 void HandleActionUpdate(void);
32                 void SetCurrentLayer(int);
33
34         protected:
35                 void paintEvent(QPaintEvent * event);
36                 void resizeEvent(QResizeEvent * event);
37                 void mousePressEvent(QMouseEvent * event);
38                 void mouseMoveEvent(QMouseEvent * event);
39                 void mouseReleaseEvent(QMouseEvent * event);
40                 void wheelEvent(QWheelEvent * event);
41                 void keyPressEvent(QKeyEvent * event);
42                 void keyReleaseEvent(QKeyEvent * event);
43
44         private:
45                 QPoint GetAdjustedMousePosition(QMouseEvent * event);
46                 QPoint GetAdjustedClientPosition(int x, int y);
47
48         public:
49                 bool useAntialiasing;
50                 uint32_t numSelected;
51                 uint32_t numHovered;
52                 bool shiftDown;
53                 bool ctrlDown;
54
55         private:
56                 QPixmap gridBackground;
57                 double scale;                                                   // Window scaling factor
58                 int32_t offsetX, offsetY;                               // Window offsets
59         public:
60                 Container document;
61                 uint32_t gridPixels;                                    // Grid size in pixels
62         private:
63                 bool collided;
64                 bool scrollDrag;
65                 Vector oldPoint;
66
67         public:
68                 std::vector<void *> select;
69                 std::vector<void *> hover;
70 //              Action * toolAction;
71
72 //      public:
73 //              static Container document;
74 };
75
76 #endif  // __DRAWINGVIEW_H__
77