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
  • tool
selecttool.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 SELECTTOOL_H
19#define SELECTTOOL_H
20
21#include "basetool.h"
22#include "movemode.h"
23#include "undoredomanager.h"
24
25#include <QRectF>
26
27class Layer;
28class SelectionManager;
29
30class SelectTool : public BaseTool
31{
32 Q_OBJECT
33
34public:
35 explicit SelectTool(QObject* parent = nullptr);
36 ToolType type() override { return SELECT; }
37 void loadSettings() override;
38 void saveSettings() override;
39 QCursor cursor() override;
40
41 void resetToDefault() override;
42 void setShowSelectionInfo(const bool b) override;
43
44private:
45
46 void pointerPressEvent(PointerEvent*) override;
47 void pointerReleaseEvent(PointerEvent*) override;
48 void pointerMoveEvent(PointerEvent*) override;
49
50 bool keyPressEvent(QKeyEvent* event) override;
51
52 void manageSelectionOrigin(QPointF currentPoint, QPointF originPoint);
53 void controlOffsetOrigin(QPointF currentPoint, QPointF anchorPoint);
54
55 void beginSelection(Layer* currentLayer, const QPointF& pos);
56 void keepSelection(Layer* currentLayer);
57
58 QPointF offsetFromPressPos(const QPointF& pos);
59
60 inline bool isSelectionPointValid(const QPointF& pos) { return mAnchorOriginPoint != pos; }
61 bool maybeDeselect(const QPointF& pos);
62
63 // Store selection origin, so we can calculate
64 // the selection rectangle in mousePressEvent.
65 QPointF mAnchorOriginPoint;
66 QPointF mPressPoint;
67 MoveMode mMoveMode;
68 MoveMode mStartMoveMode = MoveMode::NONE;
69 QRectF mSelectionRect;
70
71 QPixmap mCursorPixmap = QPixmap(24, 24);
72
73 const UndoSaveState* mUndoState = nullptr;
74};
75
76#endif
BaseTool
Definition: basetool.h:70
Layer
Definition: layer.h:33
PointerEvent
Definition: pointerevent.h:8
SelectTool
Definition: selecttool.h:31
SelectTool::keepSelection
void keepSelection(Layer *currentLayer)
SelectTool::keepSelection Keep selection rect and normalize if invalid.
Definition: selecttool.cpp:214
SelectTool::manageSelectionOrigin
void manageSelectionOrigin(QPointF currentPoint, QPointF originPoint)
SelectTool::manageSelectionOrigin switches anchor point when crossing threshold.
Definition: selecttool.cpp:257
SelectionManager
Definition: selectionmanager.h:33
QCursor
QKeyEvent
QObject
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::event
virtual bool event(QEvent *e)
QObject::parent
QObject * parent() const const
QPixmap
QPointF
QRectF
UndoSaveState
This is the main undo/redo state structure which is meant to populate whatever states that needs to b...
Definition: undoredomanager.h:80
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39