src/tools/basetool.h

Thu, 14 Apr 2022 11:08:20 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 14 Apr 2022 11:08:20 +0300
changeset 186
922662adb72a
parent 185
a38a0eb007b0
child 188
64ea7282611e
permissions
-rw-r--r--

work on circle tool

96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
100
43ce3672648a fix build
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
2 #include <QMouseEvent>
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 #include "../main.h"
104
cd4df75924b7 Add connections
Teemu Piippo <teemu@hecknology.net>
parents: 103
diff changeset
4 #include "../ui/canvas.h"
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5
111
1f42c03fafca Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents: 109
diff changeset
6 class Document;
1f42c03fafca Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents: 109
diff changeset
7
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 class BaseTool : public QObject
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 {
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 Q_OBJECT
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 public:
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 143
diff changeset
13 BaseTool(Document* document);
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 virtual QString name() const = 0;
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 virtual QString toolTip() const = 0;
185
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
17 virtual bool mouseClick(Canvas*, QMouseEvent*) { return false; }
121
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
18 virtual bool mouseDoubleClicked(QMouseEvent*, QMouseEvent*) { return false; }
000781318c36 added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents: 111
diff changeset
19 virtual bool mouseMove(Document*, Canvas*, QMouseEvent*) { return false; }
125
f127982d3412 Move tools under Document instead of MainWindow
Teemu Piippo <teemu@hecknology.net>
parents: 121
diff changeset
20 virtual bool keyReleased(Document*, Canvas*, QKeyEvent*) { return false; }
126
a7c720aff97c moved ObjectEditor under SelectTool
Teemu Piippo <teemu@hecknology.net>
parents: 125
diff changeset
21 virtual QWidget* toolWidget() { return nullptr; }
a7c720aff97c moved ObjectEditor under SelectTool
Teemu Piippo <teemu@hecknology.net>
parents: 125
diff changeset
22 virtual void selectionChanged(const QSet<ldraw::id_t>&) {}
106
128efb9d148b work on draw preview
Teemu Piippo <teemu@hecknology.net>
parents: 104
diff changeset
23 virtual void reset() {}
109
40a1cf2f38f5 replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents: 108
diff changeset
24 virtual void overpaint(Canvas*, QPainter*) const {}
163
36ea1a8aee33 Add icons for tools
Teemu Piippo <teemu@hecknology.net>
parents: 152
diff changeset
25 virtual QString iconName() const;
143
7b62c52835a1 Fix memory corruption involving document tools.
Teemu Piippo <teemu@hecknology.net>
parents: 126
diff changeset
26 protected:
7b62c52835a1 Fix memory corruption involving document tools.
Teemu Piippo <teemu@hecknology.net>
parents: 126
diff changeset
27 QWidget* const parentWidget;
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 143
diff changeset
28 Document* const document;
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 };
103
Teemu Piippo <teemu@hecknology.net>
parents: 100
diff changeset
30

mercurial