All Classes Namespaces Functions Variables Enumerations Properties Pages
toolmanager.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 #ifndef TOOLMANAGER_H
19 #define TOOLMANAGER_H
20 
21 #include <QObject>
22 #include <QHash>
23 #include "basetool.h"
24 #include "basemanager.h"
25 
26 class ScribbleArea;
27 
28 class ToolManager : public BaseManager
29 {
30  Q_OBJECT
31 public:
32  explicit ToolManager(Editor* editor);
33 
34  bool init() override;
35  Status load(Object*) override;
36  Status save(Object*) override;
37 
38  BaseTool* currentTool();
39  BaseTool* getTool(ToolType eToolType);
40  void setDefaultTool();
41  void setCurrentTool(ToolType eToolType);
42  void tabletSwitchToEraser();
43  void tabletRestorePrevTool();
44  bool setTemporaryTool(ToolType eToolType, QFlags<Qt::Key> keys, Qt::KeyboardModifiers modifiers);
45  bool setTemporaryTool(ToolType eToolType, Qt::MouseButtons buttons);
46  bool tryClearTemporaryTool(Qt::Key key);
47  bool tryClearTemporaryTool(Qt::MouseButton button);
48  void clearTemporaryTool();
49  void cleanupAllToolsData();
50  bool leavingThisTool();
51 
52  int propertySwitch(bool condition, int property);
53 
54 signals:
55  void penWidthValueChanged(float);
56  void penFeatherValueChanged(float);
57  void toleranceValueChanged(qreal);
58 
59  void toolChanged(ToolType);
60  void toolPropertyChanged(ToolType, ToolPropertyType);
61 
62 public slots:
63  void resetAllTools();
64 
65  void setWidth(float);
66  void setFeather(float);
67  void setUseFeather(bool);
68  void setInvisibility(bool);
69  void setPreserveAlpha(bool);
70  void setVectorMergeEnabled(bool);
71  void setBezier(bool);
72  void setPressure(bool);
73  void setAA(int);
74  void setFillMode(int);
75  void setStabilizerLevel(int);
76  void setTolerance(int);
77  void setBucketColorToleranceEnabled(bool enabled);
78  void setBucketFillExpandEnabled(bool enabled);
79  void setBucketFillToLayer(int layerIndex);
80  void setBucketFillReferenceMode(int referenceMode);
81  void setBucketFillExpand(int);
82  void setUseFillContour(bool);
83  void setShowSelectionInfo(bool b);
84 
85 private:
86  void setTemporaryTool(ToolType eToolType);
87 
88  BaseTool* mCurrentTool = nullptr;
89  BaseTool* mTabletEraserTool = nullptr;
90  BaseTool* mTemporaryTool = nullptr;
91  Qt::KeyboardModifiers mTemporaryTriggerModifiers = Qt::NoModifier;
92  QFlags<Qt::Key> mTemporaryTriggerKeys;
93  Qt::MouseButtons mTemporaryTriggerMouseButtons = Qt::NoButton;
94 
95  QHash<ToolType, BaseTool*> mToolSetHash;
96 
97  int mOldValue = 0;
98 
99 };
100 
101 #endif // TOOLMANAGER_H
typedef KeyboardModifiers
typedef MouseButtons
QVariant property(const char *name) const const
Q_OBJECTQ_OBJECT
Definition: object.h:41
Definition: editor.h:55