src/tools/basetool.h

Mon, 26 Jul 2021 11:50:45 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 26 Jul 2021 11:50:45 +0300
changeset 113
c0d064521ee0
parent 111
1f42c03fafca
child 121
000781318c36
permissions
-rw-r--r--

refactor

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:
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 BaseTool(QObject* parent = nullptr);
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;
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 virtual bool mousePressed(QMouseEvent*) { return false; }
111
1f42c03fafca Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents: 109
diff changeset
18 virtual bool mouseClick(Document*, Canvas*) { return false; }
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 virtual bool mouseDoubleClicked(QMouseEvent*) { return false; }
111
1f42c03fafca Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents: 109
diff changeset
20 virtual bool mouseMove(Document*, Canvas*) { return false; }
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 virtual bool keyReleased(QKeyEvent*) { return false; }
106
128efb9d148b work on draw preview
Teemu Piippo <teemu@hecknology.net>
parents: 104
diff changeset
22 virtual void reset() {}
109
40a1cf2f38f5 replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents: 108
diff changeset
23 virtual void overpaint(Canvas*, QPainter*) const {}
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 };
103
Teemu Piippo <teemu@hecknology.net>
parents: 100
diff changeset
25

mercurial