Changeset View
Changeset View
Standalone View
Standalone View
components/containmentlayoutmanager/resizehandle.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2019 by Marco Martin <mart@kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Library General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
18 | * | ||||
19 | */ | ||||
20 | | ||||
21 | #pragma once | ||||
22 | | ||||
23 | #include <QQuickItem> | ||||
24 | | ||||
25 | #include "configoverlay.h" | ||||
26 | | ||||
27 | class ResizeHandle: public QQuickItem | ||||
28 | { | ||||
29 | Q_OBJECT | ||||
30 | Q_PROPERTY(Corner resizeCorner MEMBER m_resizeCorner NOTIFY resizeCornerChanged) | ||||
31 | Q_PROPERTY(bool resizeBlocked READ resizeBlocked NOTIFY resizeBlockedChanged) | ||||
32 | | ||||
33 | public: | ||||
34 | enum Corner { | ||||
35 | Left = 0, | ||||
36 | TopLeft, | ||||
37 | Top, | ||||
38 | TopRight, | ||||
39 | Right, | ||||
40 | BottomRight, | ||||
41 | Bottom, | ||||
42 | BottomLeft | ||||
43 | }; | ||||
44 | Q_ENUMS(Corner) | ||||
45 | | ||||
46 | ResizeHandle(QQuickItem *parent = nullptr); | ||||
47 | ~ResizeHandle(); | ||||
48 | | ||||
49 | bool resizeBlocked() const; | ||||
50 | | ||||
51 | protected: | ||||
52 | void mousePressEvent(QMouseEvent *event) override; | ||||
53 | void mouseReleaseEvent(QMouseEvent *event) override; | ||||
54 | void mouseMoveEvent(QMouseEvent *event) override; | ||||
55 | | ||||
56 | Q_SIGNALS: | ||||
57 | void resizeCornerChanged(); | ||||
58 | void resizeBlockedChanged(); | ||||
59 | | ||||
60 | private: | ||||
61 | void setConfigOverlay(ConfigOverlay *configOverlay); | ||||
62 | | ||||
63 | inline bool resizeLeft() const; | ||||
64 | inline bool resizeTop() const; | ||||
65 | inline bool resizeRight() const; | ||||
66 | inline bool resizeBottom() const; | ||||
67 | void setResizeBlocked(bool width, bool height); | ||||
68 | | ||||
69 | QPointF m_mouseDownPosition; | ||||
70 | QRectF m_mouseDownGeometry; | ||||
71 | | ||||
72 | QPointer<ConfigOverlay> m_configOverlay; | ||||
73 | Corner m_resizeCorner = Left; | ||||
74 | bool m_resizeWidthBlocked = false; | ||||
75 | bool m_resizeHeightBlocked = false; | ||||
76 | }; | ||||
77 | |