DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickrectangle_p.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DQUICKRECTANGLE_P_H
6#define DQUICKRECTANGLE_P_H
7
8#include <dtkdeclarative_global.h>
9#include <DObject>
10
11#include <QQuickItem>
12
13DQUICK_BEGIN_NAMESPACE
14
15class DQuickRectanglePrivate;
16class Q_DECL_EXPORT DQuickRectangle : public QQuickItem
17{
18 Q_OBJECT
19 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
20 Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
21 Q_PROPERTY(Corners corners READ corners WRITE setCorners NOTIFY cornersChanged)
22#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
23 QML_NAMED_ELEMENT(RoundRectangle)
24#endif
25
26public:
27 enum Corner {
28 NoneCorner = 0x0,
29 TopLeftCorner = 0x1,
30 TopRightCorner = 0x2,
31 BottomLeftCorner = 0x4,
32 BottomRightCorner = 0x8,
33 TopCorner = TopLeftCorner | TopRightCorner,
34 BottomCorner = BottomLeftCorner| BottomRightCorner,
35 LeftCorner = TopLeftCorner| BottomLeftCorner,
36 RightCorner = TopRightCorner| BottomRightCorner,
37 AllCorner = TopCorner | BottomCorner
38 };
39 Q_DECLARE_FLAGS(Corners, Corner)
40 Q_FLAG(Corners)
41
42 explicit DQuickRectangle(QQuickItem *parent = nullptr);
44
45 QColor color() const;
46 void setColor(const QColor &color);
47
48 qreal radius() const;
49 void setRadius(qreal radius);
50
51 DQuickRectangle::Corners corners() const;
52 void setCorners(Corners corners);
53
54private Q_SLOTS:
55 void invalidateSceneGraph();
56
57Q_SIGNALS:
58 void colorChanged();
59 void radiusChanged();
60 void cornersChanged();
61
62protected:
63 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
64
65protected:
66 DQuickRectangle(DQuickRectanglePrivate &dd, QQuickItem *parent = nullptr);
67
68private:
69 Q_DISABLE_COPY(DQuickRectangle)
70 Q_DECLARE_PRIVATE(DQuickRectangle)
71
72 void releaseResources() override;
73};
74
75DQUICK_END_NAMESPACE
76
77Q_DECLARE_OPERATORS_FOR_FLAGS(DTK_QUICK_NAMESPACE::DQuickRectangle::Corners)
78Q_DECLARE_METATYPE(DTK_QUICK_NAMESPACE::DQuickRectangle::Corner)
79
80#endif // DQUICKRECTANGLE_P_H
Definition dquickrectangle_p_p.h:16
Definition dquickrectangle_p.h:17