KQuickImageEditor

resizehandle.h
1/*
2 * SPDX-FileCopyrightText: (C) 2019 Marco Martin <mart@kde.org>
3 * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8#pragma once
9
10#include <QQuickItem>
11
12class ResizeRectangle;
13
14class ResizeHandle : public QQuickItem
15{
17 Q_PROPERTY(bool resizeBlocked READ resizeBlocked NOTIFY resizeBlockedChanged)
18 Q_PROPERTY(QQuickItem *rectangle READ rectangle WRITE setRectangle NOTIFY rectangleChanged)
19
20public:
21 enum Corner {
22 Left = 0,
23 TopLeft,
24 Top,
25 TopRight,
26 Right,
27 BottomRight,
28 Bottom,
29 BottomLeft,
30 };
31 Q_ENUM(Corner)
32
33 ResizeHandle(QQuickItem *parent = nullptr);
34 ~ResizeHandle() = default;
35
36 QQuickItem *rectangle() const;
37 void setRectangle(QQuickItem *rectangle);
38
39 bool resizeBlocked() const;
40
41 void setResizeCorner(Corner corner);
42
43protected:
44 void mousePressEvent(QMouseEvent *event) override;
45 void mouseReleaseEvent(QMouseEvent *event) override;
46 void mouseMoveEvent(QMouseEvent *event) override;
47
49 void resizeCornerChanged();
50 void resizeBlockedChanged();
51 void rectangleChanged();
52
53private:
54 inline bool resizeLeft() const;
55 inline bool resizeTop() const;
56 inline bool resizeRight() const;
57 inline bool resizeBottom() const;
58 void setResizeBlocked(bool width, bool height);
59
60 QPointF m_mouseDownPosition;
61 QRectF m_mouseDownGeometry;
62
63 Corner m_resizeCorner = Left;
64 bool m_resizeWidthBlocked = false;
65 bool m_resizeHeightBlocked = false;
66 ResizeRectangle *m_rectangle = nullptr;
67};
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
virtual bool event(QEvent *ev) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:40 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.