-
Notifications
You must be signed in to change notification settings - Fork 281
/
Copy pathselecttool.h
75 lines (53 loc) · 1.96 KB
/
selecttool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Pencil2D - Traditional Animation Software
Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
Copyright (C) 2012-2020 Matthew Chiawen Chang
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef SELECTTOOL_H
#define SELECTTOOL_H
#include "basetool.h"
#include "movemode.h"
#include <QRectF>
class Layer;
class SelectionManager;
class SelectTool : public BaseTool
{
Q_OBJECT
public:
explicit SelectTool(QObject* parent = nullptr);
ToolType type() override { return SELECT; }
void loadSettings() override;
QCursor cursor() override;
void resetToDefault() override;
void setShowSelectionInfo(const bool b) override;
bool selectChanging();
private:
void pointerPressEvent(PointerEvent*) override;
void pointerReleaseEvent(PointerEvent*) override;
void pointerMoveEvent(PointerEvent*) override;
bool keyPressEvent(QKeyEvent* event) override;
void manageSelectionOrigin(QPointF currentPoint, QPointF originPoint);
void controlOffsetOrigin(QPointF currentPoint, QPointF anchorPoint);
void beginSelection();
void keepSelection();
QPointF offsetFromPressPos();
inline bool isSelectionPointValid() { return mAnchorOriginPoint != getLastPoint(); }
bool maybeDeselect();
// Store selection origin so we can calculate
// the selection rectangle in mousePressEvent.
QPointF mAnchorOriginPoint;
MoveMode mMoveMode;
MoveMode mStartMoveMode = MoveMode::NONE;
QRectF mSelectionRect;
Layer* mCurrentLayer = nullptr;
bool mSelectChanging = false;
QPixmap mCursorPixmap = QPixmap(24, 24);
};
#endif