Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickpaddedrectangle.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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
5
6#include <QtQuick/private/qsgadaptationlayer_p.h>
7
9
14
16{
17 return m_padding;
18}
19
21{
22 if (!qFuzzyCompare(m_padding, padding)) {
23 m_padding = padding;
24 update();
26 if (!m_hasTopPadding)
28 if (!m_hasLeftPadding)
30 if (!m_hasRightPadding)
32 if (!m_hasBottomPadding)
34 }
35}
36
41
43{
44 return m_hasTopPadding ? m_topPadding : m_padding;
45}
46
51
56
58{
59 return m_hasLeftPadding ? m_leftPadding : m_padding;
60}
61
66
71
73{
74 return m_hasRightPadding ? m_rightPadding : m_padding;
75}
76
81
86
88{
89 return m_hasBottomPadding ? m_bottomPadding : m_padding;
90}
91
96
101
102void QQuickPaddedRectangle::setTopPadding(qreal padding, bool has)
103{
104 qreal oldPadding = topPadding();
105 m_hasTopPadding = has;
106 m_topPadding = padding;
107 if (!qFuzzyCompare(oldPadding, padding)) {
108 update();
110 }
111}
112
113void QQuickPaddedRectangle::setLeftPadding(qreal padding, bool has)
114{
115 qreal oldPadding = leftPadding();
116 m_hasLeftPadding = has;
117 m_leftPadding = padding;
118 if (!qFuzzyCompare(oldPadding, padding)) {
119 update();
121 }
122}
123
124void QQuickPaddedRectangle::setRightPadding(qreal padding, bool has)
125{
126 qreal oldPadding = rightPadding();
127 m_hasRightPadding = has;
128 m_rightPadding = padding;
129 if (!qFuzzyCompare(oldPadding, padding)) {
130 update();
132 }
133}
134
136{
137 qreal oldPadding = bottomPadding();
138 m_hasBottomPadding = has;
139 m_bottomPadding = padding;
140 if (!qFuzzyCompare(oldPadding, padding)) {
141 update();
143 }
144}
145
147{
148 QSGTransformNode *transformNode = static_cast<QSGTransformNode *>(node);
149 if (!transformNode)
150 transformNode = new QSGTransformNode;
151
153
154 if (rectNode) {
155 if (!transformNode->firstChild())
156 transformNode->appendChildNode(rectNode);
157
158 qreal top = topPadding();
162
166 transformNode->setMatrix(m);
167
168 qreal w = qMax<qreal>(0.0, width() -left-right);
169 qreal h = qMax<qreal>(0.0, height() -top-bottom);
170
171 rectNode->setRect(QRectF(0, 0, w, h));
172 rectNode->update();
173 }
174 }
175 return transformNode;
176}
177
179
180#include "moc_qquickpaddedrectangle_p.cpp"
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
void translate(const QVector3D &vector)
Multiplies this matrix by another that translates coordinates by the components of vector.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
qreal width
This property holds the width of this item.
Definition qquickitem.h:75
qreal height
This property holds the height of this item.
Definition qquickitem.h:76
void update()
Schedules a call to updatePaintNode() for this item.
void setTopPadding(qreal padding)
void setBottomPadding(qreal padding)
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
void setLeftPadding(qreal padding)
void setRightPadding(qreal padding)
void setPadding(qreal padding)
QQuickPaddedRectangle(QQuickItem *parent=nullptr)
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
\inmodule QtCore\reentrant
Definition qrect.h:484
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
void appendChildNode(QSGNode *node)
Appends node to this node's list of children.
Definition qsgnode.cpp:398
QSGNode * firstChild() const
Returns the first child of this node.
Definition qsgnode.h:105
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:241
void setMatrix(const QMatrix4x4 &matrix)
Sets this transform node's matrix to matrix.
Definition qsgnode.cpp:1162
Combined button and popup list for selecting options.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
const GLfloat * m
GLfloat GLfloat GLfloat w
[0]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint left
GLint GLint bottom
GLfloat GLfloat GLfloat GLfloat h
#define emit
double qreal
Definition qtypes.h:187