Debian Codegraph @

src/gui/snippingArea/SnippingAreaResizer.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef KSNIP_SNIPPINGAREARESIZER_H
21 #define KSNIP_SNIPPINGAREARESIZER_H
22
23 #include <QPainter>
24 #include <QKeyEvent>
25 #include <QCursor>
26 #include <QVector>
27
28 #include "src/common/helper/RectHelper.h"
29 #include "src/backend/config/IConfig.h"
30
31 class SnippingAreaResizer : public QObject
32 {
33 Q_OBJECT
34 public:
35 explicit SnippingAreaResizer(const QSharedPointer<IConfig> &config, QObject *parent);
36 ~SnippingAreaResizer() override = default;
37 void activate(const QRectF &rect, const QPointF &pos);
38 void deactivate();
39 void paint(QPainter *painter);
40 bool isActive() const;
41 void handleMousePress(const QPointF &pos);
42 void handleMouseRelease();
43 void handleMouseMove(const QPointF &pos);
44 void handleKeyPress(QKeyEvent *event);
45 void handleKeyRelease(QKeyEvent *event);
46
47 signals:
48 void rectChanged(const QRectF &rect);
49 void cursorChanged(const QCursor &cursor);
50
51 private:
52 QRectF mCurrentRect;
53 bool mIsActive;
54 QPointF mGrabOffset;
55 bool mIsGrabbed;
56 int mGrabbedHandleIndex;
57 QVector<QRectF> mHandles;
58 QSharedPointer<IConfig> mConfig;
59 QColor mColor;
60 bool mControlPressed;
61 bool mAltPressed;
62
63 void updateHandlePositions();
64 void updateCurrentRect(const QPointF &point);
65 void updateCursor(const QPointF &pos);
66 void notifyRectChanged();
67 void arrowUpPressed();
68 void arrowDownPressed();
69 void arrowLeftPressed();
70 void arrowRightPressed();
71 void arrowKeyPressed(const QKeyEvent *event);
72 };
73
74 #endif //KSNIP_SNIPPINGAREARESIZER_H