File indexing completed on 2024-09-08 04:17:06
0001 /* 0002 * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "resizehandle.h" 0010 0011 #include <QQmlComponent> 0012 #include <QQuickItem> 0013 0014 /// \deprecated 0015 class ResizeRectangle : public QQuickItem 0016 { 0017 Q_OBJECT 0018 0019 Q_PROPERTY(qreal insideX READ insideX WRITE setInsideX NOTIFY insideXChanged) 0020 Q_PROPERTY(qreal insideY READ insideY WRITE setInsideY NOTIFY insideYChanged) 0021 Q_PROPERTY(qreal insideWidth READ insideWidth WRITE setInsideWidth NOTIFY insideWidthChanged) 0022 Q_PROPERTY(qreal insideHeight READ insideHeight WRITE setInsideHeight NOTIFY insideHeightChanged) 0023 0024 public: 0025 ResizeRectangle(QQuickItem *parent = nullptr); 0026 ~ResizeRectangle() = default; 0027 0028 qreal insideX() const; 0029 void setInsideX(qreal x); 0030 qreal insideY() const; 0031 void setInsideY(qreal y); 0032 qreal insideWidth() const; 0033 void setInsideWidth(qreal width); 0034 qreal insideHeight() const; 0035 void setInsideHeight(qreal height); 0036 0037 virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; 0038 0039 protected: 0040 void mouseReleaseEvent(QMouseEvent *event) override; 0041 void mousePressEvent(QMouseEvent *event) override; 0042 void mouseMoveEvent(QMouseEvent *event) override; 0043 void mouseDoubleClickEvent(QMouseEvent *event) override; 0044 virtual void componentComplete() override; 0045 0046 Q_SIGNALS: 0047 /// Double click event signal 0048 void acceptSize(); 0049 void insideXChanged(); 0050 void insideYChanged(); 0051 void insideWidthChanged(); 0052 void insideHeightChanged(); 0053 void handleComponentChanged(); 0054 0055 private: 0056 void updateHandles(); 0057 0058 qreal m_insideX; 0059 qreal m_insideY; 0060 qreal m_insideWidth; 0061 qreal m_insideHeight; 0062 QPointF m_mouseDownPosition; 0063 QPointF m_mouseDownGeometry; 0064 bool m_mouseClickedOnRectangle = false; 0065 QQmlComponent *m_handleComponent = nullptr; 0066 ResizeHandle *m_handleBottomLeft = nullptr; 0067 ResizeHandle *m_handleBottomRight = nullptr; 0068 ResizeHandle *m_handleTopLeft = nullptr; 0069 ResizeHandle *m_handleTopRight = nullptr; 0070 };