Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • managers
toolmanager.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU 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 "pencildef.h"
25#include "basemanager.h"
26#include "camerafieldoption.h"
27
28class StrokeTool;
29class TransformTool;
30
31class ToolManager : public BaseManager
32{
33 Q_OBJECT
34public:
35 explicit ToolManager(Editor* editor);
36 ~ToolManager() override;
37
38 bool init() override;
39 Status load(Object*) override;
40 Status save(Object*) override;
41
42 BaseTool* currentTool() const;
43 BaseTool* getTool(ToolType eToolType);
44 void setDefaultTool();
45 void setCurrentTool(ToolType eToolType);
46 void tabletSwitchToEraser();
47 void tabletRestorePrevTool();
48 bool setTemporaryTool(ToolType eToolType, QFlags<Qt::Key> keys, Qt::KeyboardModifiers modifiers);
49 bool setTemporaryTool(ToolType eToolType, Qt::MouseButtons buttons);
50 bool tryClearTemporaryTool(Qt::Key key);
51 bool tryClearTemporaryTool(Qt::MouseButton button);
52 void clearTemporaryTool();
53 void cleanupAllToolsData();
54 bool leavingThisTool();
55
56 bool isTransformTool(const BaseTool* baseTool) const;
57 bool isStrokeTool(const BaseTool* baseTool) const;
58
59 StrokeTool* currentStrokeTool() const;
60 TransformTool* currentTransformTool() const;
61
62signals:
63 void toolChanged(ToolType);
64 void toolsReset();
65
66public slots:
67 void resetAllTools();
68
69private:
70 void setTemporaryTool(ToolType eToolType);
71
72 BaseTool* mCurrentTool = nullptr;
73 BaseTool* mTabletEraserTool = nullptr;
74 BaseTool* mTemporaryTool = nullptr;
75
76 Qt::KeyboardModifiers mTemporaryTriggerModifiers = Qt::NoModifier;
77 QFlags<Qt::Key> mTemporaryTriggerKeys;
78 Qt::MouseButtons mTemporaryTriggerMouseButtons = Qt::NoButton;
79
80 QHash<ToolType, BaseTool*> mToolSetHash;
81};
82
83#endif // TOOLMANAGER_H
BaseManager
Definition: basemanager.h:29
BaseTool
Definition: basetool.h:47
Editor
Definition: editor.h:71
Object
Definition: object.h:42
Status
Definition: pencilerror.h:40
StrokeTool
Definition: stroketool.h:35
ToolManager
Definition: toolmanager.h:32
TransformTool
Definition: transformtool.h:23
QFlags
QHash
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
Qt::Key
Key
Qt::KeyboardModifiers
typedef KeyboardModifiers
Qt::MouseButtons
typedef MouseButtons
Generated on Tue Jan 6 2026 11:38:51 for Pencil2D by doxygen 1.9.6 based on revision f91a96748ec6712509b9b0ff47979db9c34d556f