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 "transformtool.h"
22#include "movemode.h"
23#include "undoredomanager.h"
24
25#include "layer.h"
26
27#include <QRectF>
28
29class Layer;
30class SelectionManager;
31
32class SelectTool : public TransformTool
33{
34 Q_OBJECT
35
36public:
37 explicit SelectTool(QObject* parent = nullptr);
38
39 ToolType type() const override { return SELECT; }
40
41 void loadSettings() override;
42 QCursor cursor() 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 controlOffsetOrigin(QPointF currentPoint, QPointF anchorPoint, Layer::LAYER_TYPE layerType);
53
54 void beginSelection(Layer* currentLayer, const QPointF& pos);
55 void keepSelection(Layer* currentLayer);
56
57 QPointF offsetFromPressPos(const QPointF& pos);
58
59 inline bool isSelectionPointValid(const QPointF& pos) { return mAnchorOriginPoint != pos; }
60 bool maybeDeselect(const QPointF& pos);
61
62 // Store selection origin, so we can calculate
63 // the selection rectangle in mousePressEvent.
64 QPointF mAnchorOriginPoint;
65 QPointF mPressPoint;
66 MoveMode mMoveMode;
67 MoveMode mStartMoveMode = MoveMode::NONE;
68 QRectF mSelectionRect;
69
70 QPixmap mCursorPixmap = QPixmap(24, 24);
71
72 const UndoSaveState* mUndoState = nullptr;
73};
74
75#endif
Layer
Definition: layer.h:33
PointerEvent
Definition: pointerevent.h:8
SelectTool
Definition: selecttool.h:33
SelectTool::keepSelection
void keepSelection(Layer *currentLayer)
SelectTool::keepSelection Keep selection rect and normalize if invalid.
Definition: selecttool.cpp:217
SelectionManager
The SelectionManager class acts as the "Brain" of the selection system.
Definition: selectionmanager.h:51
TransformTool
Definition: transformtool.h:23
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 Tue Jan 6 2026 11:38:51 for Pencil2D by doxygen 1.9.6 based on revision f91a96748ec6712509b9b0ff47979db9c34d556f