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