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
qquickanchors_p_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 QQUICKANCHORS_P_P_H
6#define QQUICKANCHORS_P_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
21#include <private/qobject_p.h>
22
24
25class Q_QUICK_EXPORT QQuickAnchorLine
26{
27 Q_GADGET
28 QML_ANONYMOUS
29 QML_ADDED_IN_VERSION(2, 0)
30public:
31 QQuickAnchorLine() {}
32 QQuickAnchorLine(QQuickItem *i, QQuickAnchors::Anchor l) : item(i), anchorLine(l) {}
33 QQuickAnchorLine(QQuickItem *i, uint l)
34 : item(i)
35 , anchorLine(static_cast<QQuickAnchors::Anchor>(l))
36 { Q_ASSERT(l < ((QQuickAnchors::BaselineAnchor << 1) - 1)); }
37
38 QQuickItem *item = nullptr;
39 QQuickAnchors::Anchor anchorLine = QQuickAnchors::InvalidAnchor;
40};
41
42inline bool operator==(const QQuickAnchorLine& a, const QQuickAnchorLine& b)
43{
44 return a.item == b.item && a.anchorLine == b.anchorLine;
45}
46
49{
50 Q_DECLARE_PUBLIC(QQuickAnchors)
51public:
93
94 void clearItem(QQuickItem *);
95
96 QQuickGeometryChange calculateDependency(QQuickItem *) const;
97 void addDepend(QQuickItem *);
98 void remDepend(QQuickItem *);
99 bool isItemComplete() const;
100
101 void setItemHeight(qreal);
102 void setItemWidth(qreal);
103 void setItemX(qreal);
104 void setItemY(qreal);
105 void setItemPos(const QPointF &);
106 void setItemSize(const QSizeF &);
107
108 void update();
109 void updateOnComplete();
110 void updateMe();
111
112 // QQuickItemGeometryListener interface
113 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override;
115
116 bool checkHValid() const;
117 bool checkVValid() const;
118 bool checkHAnchorValid(QQuickAnchorLine anchor) const;
119 bool checkVAnchorValid(QQuickAnchorLine anchor) const;
120 bool calcStretch(QQuickItem *edge1Item, QQuickAnchors::Anchor edge1Line,
121 QQuickItem *edge2Item, QQuickAnchors::Anchor edge2Line,
122 qreal offset1, qreal offset2, QQuickAnchors::Anchor line, qreal &stretch) const;
123
124 bool isMirrored() const;
127 void fillChanged();
128 void centerInChanged();
129
138
139 QQuickItem *item;
140
141 QQuickItem *fill;
142 QQuickItem *centerIn;
143
144 QQuickItem *leftAnchorItem;
145 QQuickItem *rightAnchorItem;
146 QQuickItem *topAnchorItem;
147 QQuickItem *bottomAnchorItem;
148 QQuickItem *vCenterAnchorItem;
149 QQuickItem *hCenterAnchorItem;
151
152 // The bit fields below are carefully laid out in chunks of 1 byte, so the compiler doesn't
153 // need to generate 2 loads (and combining shifts/ors) to create a single field.
154
163
170 uint usedAnchors : 7; // QQuickAnchors::Anchors
172
173 // Instead of using a mostly empty bit field, we can stretch the following fields up to be full
174 // bytes. The advantage is that incrementing/decrementing does not need any combining ands/ors.
179
180
181 static inline QQuickAnchorsPrivate *get(QQuickAnchors *o) {
182 return static_cast<QQuickAnchorsPrivate *>(QObjectPrivate::get(o));
183 }
184};
185
186QT_END_NAMESPACE
187
188Q_DECLARE_METATYPE(QQuickAnchorLine)
189
190#endif
bool checkHAnchorValid(QQuickAnchorLine anchor) const
bool isItemComplete() const
void remDepend(QQuickItem *)
QQuickGeometryChange calculateDependency(QQuickItem *) const
bool checkVAnchorValid(QQuickAnchorLine anchor) const
void addDepend(QQuickItem *)
void setItemSize(const QSizeF &)
static QQuickAnchorsPrivate * get(QQuickAnchors *o)
void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override
bool isMirrored() const
QQuickItem * baselineAnchorItem
QQuickAnchorsPrivate * anchorPrivate() override
bool calcStretch(QQuickItem *edge1Item, QQuickAnchors::Anchor edge1Line, QQuickItem *edge2Item, QQuickAnchors::Anchor edge2Line, qreal offset1, qreal offset2, QQuickAnchors::Anchor line, qreal &stretch) const
void setItemPos(const QPointF &)
void setVerticalChange(bool enabled)
void setHorizontalChange(bool enabled)
static qreal hcenter(const QQuickItem *item)
static qreal vcenter(const QQuickItem *item)
static QQuickAnchors::Anchor reverseAnchorLine(QQuickAnchors::Anchor anchorLine)
static qreal adjustedPosition(QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
bool operator==(const QQuickAnchorLine &a, const QQuickAnchorLine &b)