]> Shamusworld >> Repos - architektonas/blob - src/drawingview.h
Tool for adding Lines works now.
[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 ToolMouseDown(Point);
28                 void ToolMouseMove(Point);
29                 void ToolMouseUp(Point);
30                 void ToolDraw(Painter *);
31
32         public slots:
33                 void AddNewObjectToDocument(Object *);
34                 void HandleActionUpdate(void);
35                 void SetCurrentLayer(int);
36
37         protected:
38                 void paintEvent(QPaintEvent * event);
39                 void resizeEvent(QResizeEvent * event);
40                 void mousePressEvent(QMouseEvent * event);
41                 void mouseMoveEvent(QMouseEvent * event);
42                 void mouseReleaseEvent(QMouseEvent * event);
43                 void wheelEvent(QWheelEvent * event);
44                 void keyPressEvent(QKeyEvent * event);
45                 void keyReleaseEvent(QKeyEvent * event);
46
47         private:
48                 QPoint GetAdjustedMousePosition(QMouseEvent * event);
49                 QPoint GetAdjustedClientPosition(int x, int y);
50
51         public:
52                 bool useAntialiasing;
53                 uint32_t numSelected;
54                 uint32_t numHovered;
55                 bool shiftDown;
56                 bool ctrlDown;
57
58         private:
59                 QPixmap gridBackground;
60                 double scale;                                                   // Window scaling factor
61                 int32_t offsetX, offsetY;                               // Window offsets
62         public:
63                 Container document;
64                 uint32_t gridPixels;                                    // Grid size in pixels
65         private:
66                 bool collided;
67                 bool scrollDrag;
68                 Vector oldPoint;
69
70         public:
71                 std::vector<void *> select;
72                 std::vector<void *> hover;
73 //              int toolState;
74                 Point toolPoint[32];
75 //              Object * toolObject;
76
77         // Tool methods (static)
78         public:
79 //              static void foo();
80 //      public:
81 //              static Container document;
82 };
83
84 #endif  // __DRAWINGVIEW_H__
85