]> Shamusworld >> Repos - architektonas/blob - src/drawingview.h
Added ability to manipulate Lines by click & drag.
[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 SetGridSize(uint32_t);
19                 void UpdateGridBackground(void);
20                 Point SnapPointToGrid(Point);
21                 void RenderObjects(Painter *, Container *);
22                 void DeleteSelectedItems(void);
23                 void ClearSelection(void);
24                 void AddHoveredToSelection(void);
25                 void GetSelection(std::vector<void *> &);
26                 void GetHovered(std::vector<void *> &);
27                 void ToolMouse(int, Point);
28                 void ToolDraw(Painter *);
29                 void LineHandler(int, Point);
30                 void CheckObjectBounds(void);
31                 bool HitTestObjects(Point);
32
33         public slots:
34                 void AddNewObjectToDocument(Object *);
35                 void HandleActionUpdate(void);
36                 void SetCurrentLayer(int);
37
38         protected:
39                 void paintEvent(QPaintEvent * event);
40                 void resizeEvent(QResizeEvent * event);
41                 void mousePressEvent(QMouseEvent * event);
42                 void mouseMoveEvent(QMouseEvent * event);
43                 void mouseReleaseEvent(QMouseEvent * event);
44                 void wheelEvent(QWheelEvent * event);
45                 void keyPressEvent(QKeyEvent * event);
46                 void keyReleaseEvent(QKeyEvent * event);
47
48         private:
49                 QPoint GetAdjustedMousePosition(QMouseEvent * event);
50                 QPoint GetAdjustedClientPosition(int x, int y);
51
52         public:
53                 bool useAntialiasing;
54                 uint32_t numSelected;
55                 uint32_t numHovered;
56                 bool shiftDown;
57                 bool ctrlDown;
58
59         private:
60                 QPixmap gridBackground;
61                 double scale;                                                   // Window scaling factor
62                 int32_t offsetX, offsetY;                               // Window offsets
63         public:
64                 Container document;
65                 uint32_t gridPixels;                                    // Grid size in pixels
66         private:
67                 bool collided;
68                 bool scrollDrag;
69                 Vector oldPoint;
70
71         public:
72                 std::vector<void *> select;
73                 std::vector<void *> hover;
74                 Point toolPoint[32];
75
76 //      public:
77 //              static Container document;
78 };
79
80 #endif  // __DRAWINGVIEW_H__
81