blob: ca07b11965211968d9e2f77dd280f1f3f5c1b952 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include "widgethostconstants.h"
#include <QWidget>
#include <QPoint>
namespace SharedTools {
namespace Internal {
class SizeHandleRect : public QWidget
{
Q_OBJECT
public:
enum Direction { LeftTop, Top, RightTop, Right, RightBottom, Bottom, LeftBottom, Left };
SizeHandleRect(QWidget *parent, Direction d, QWidget *resizable);
Direction dir() const { return m_dir; }
void updateCursor();
void setState(SelectionHandleState st);
signals:
void mouseButtonReleased(const QRect &, const QRect &);
protected:
void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
private:
void tryResize(const QSize &delta);
private:
const Direction m_dir;
QPoint m_startPos;
QPoint m_curPos;
QSize m_startSize;
QSize m_curSize;
QWidget *m_resizable;
SelectionHandleState m_state;
};
}
} // namespace SharedTools
|