Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickrectangle_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKRECTANGLE_P_H
6#define QQUICKRECTANGLE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qquickitem.h"
20
21#include <QtGui/qbrush.h>
22
23#include <private/qtquickglobal_p.h>
24
26
27class Q_QUICK_EXPORT QQuickPen : public QObject
28{
29 Q_OBJECT
30
31 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
32 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
33 Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged FINAL)
34 QML_ANONYMOUS
35 QML_ADDED_IN_VERSION(2, 0)
36public:
37 QQuickPen(QObject *parent=nullptr);
38
39 qreal width() const;
40 void setWidth(qreal w);
41
42 QColor color() const;
43 void setColor(const QColor &c);
44
45 bool pixelAligned() const;
46 void setPixelAligned(bool aligned);
47
48 bool isValid() const;
49
50Q_SIGNALS:
51 void widthChanged();
52 void colorChanged();
53 void pixelAlignedChanged();
54
55private:
56 qreal m_width;
57 QColor m_color;
58 bool m_aligned : 1;
59 bool m_valid : 1;
60};
61
62class Q_QUICK_EXPORT QQuickGradientStop : public QObject
63{
64 Q_OBJECT
65
66 Q_PROPERTY(qreal position READ position WRITE setPosition)
67 Q_PROPERTY(QColor color READ color WRITE setColor)
68 QML_NAMED_ELEMENT(GradientStop)
69 QML_ADDED_IN_VERSION(2, 0)
70
71public:
72 QQuickGradientStop(QObject *parent=nullptr);
73
74 qreal position() const;
75 void setPosition(qreal position);
76
77 QColor color() const;
78 void setColor(const QColor &color);
79
80private:
81 void updateGradient();
82
83private:
84 qreal m_position = 0.0;
85 QColor m_color;
86};
87
88class Q_QUICK_EXPORT QQuickGradient : public QObject
89{
90 Q_OBJECT
91
92 Q_PROPERTY(QQmlListProperty<QQuickGradientStop> stops READ stops)
93 Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged REVISION(2, 12))
94 Q_CLASSINFO("DefaultProperty", "stops")
95 QML_NAMED_ELEMENT(Gradient)
96 QML_ADDED_IN_VERSION(2, 0)
97 QML_EXTENDED_NAMESPACE(QGradient)
98
99public:
100 QQuickGradient(QObject *parent=nullptr);
101 ~QQuickGradient() override;
102
103 enum Orientation { Vertical = Qt::Vertical,
104 Horizontal = Qt::Horizontal };
105 Q_ENUM(Orientation)
106
107 QQmlListProperty<QQuickGradientStop> stops();
108
109 Orientation orientation() const { return m_orientation; }
110 void setOrientation(Orientation orientation);
111
112 QGradientStops gradientStops() const;
113
114Q_SIGNALS:
115 void updated();
116 void orientationChanged();
117
118private:
119 void doUpdate();
120
121private:
122 QList<QQuickGradientStop *> m_stops;
123 Orientation m_orientation = Vertical;
124 friend class QQuickRectangle;
125 friend class QQuickGradientStop;
126};
127
129class Q_QUICK_EXPORT QQuickRectangle : public QQuickItem
130{
131 Q_OBJECT
132
133 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
134 Q_PROPERTY(QJSValue gradient READ gradient WRITE setGradient RESET resetGradient)
135 Q_PROPERTY(QQuickPen * border READ border CONSTANT)
136 Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
137 Q_PROPERTY(qreal topLeftRadius READ topLeftRadius WRITE setTopLeftRadius NOTIFY topLeftRadiusChanged RESET resetTopLeftRadius REVISION(6, 7) FINAL)
138 Q_PROPERTY(qreal topRightRadius READ topRightRadius WRITE setTopRightRadius NOTIFY topRightRadiusChanged RESET resetTopRightRadius REVISION(6, 7) FINAL)
139 Q_PROPERTY(qreal bottomLeftRadius READ bottomLeftRadius WRITE setBottomLeftRadius NOTIFY bottomLeftRadiusChanged RESET resetBottomLeftRadius REVISION(6, 7) FINAL)
140 Q_PROPERTY(qreal bottomRightRadius READ bottomRightRadius WRITE setBottomRightRadius NOTIFY bottomRightRadiusChanged RESET resetBottomRightRadius REVISION(6, 7) FINAL)
141 QML_NAMED_ELEMENT(Rectangle)
142 QML_ADDED_IN_VERSION(2, 0)
143public:
144 QQuickRectangle(QQuickItem *parent=nullptr);
145
146 QColor color() const;
147 void setColor(const QColor &);
148
149 QQuickPen *border();
150
151 QJSValue gradient() const;
152 void setGradient(const QJSValue &gradient);
153 void resetGradient();
154
155 qreal radius() const;
156 void setRadius(qreal radius);
157
158 qreal topLeftRadius() const;
159 void setTopLeftRadius(qreal radius);
160 void resetTopLeftRadius();
161 qreal topRightRadius() const;
162 void setTopRightRadius(qreal radius);
163 void resetTopRightRadius();
164 qreal bottomLeftRadius() const;
165 void setBottomLeftRadius(qreal radius);
166 void resetBottomLeftRadius();
167 qreal bottomRightRadius() const;
168 void setBottomRightRadius(qreal radius);
169 void resetBottomRightRadius();
170
171Q_SIGNALS:
172 void colorChanged();
173 void radiusChanged();
174 Q_REVISION(6, 7) void topLeftRadiusChanged();
175 Q_REVISION(6, 7) void topRightRadiusChanged();
176 Q_REVISION(6, 7) void bottomLeftRadiusChanged();
177 Q_REVISION(6, 7) void bottomRightRadiusChanged();
178
179protected:
180 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
181
182private Q_SLOTS:
183 void doUpdate();
184
185private:
186 Q_DISABLE_COPY(QQuickRectangle)
187 Q_DECLARE_PRIVATE(QQuickRectangle)
188};
189
190QT_END_NAMESPACE
191
192#endif // QQUICKRECTANGLE_P_H
For specifying a pen used for drawing rectangle borders on a QQuickView.
static void qt_quickitems_defineModule()