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.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_H
6#define QQUICKANCHORS_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 <qqml.h>
20
21#include <QtCore/QObject>
22
23#include <private/qtquickglobal_p.h>
24
26
27class QQuickItem;
29class QQuickAnchorLine;
30class Q_QUICK_EXPORT QQuickAnchors : public QObject
31{
32 Q_OBJECT
33
34 Q_PROPERTY(QQuickAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged FINAL)
35 Q_PROPERTY(QQuickAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged FINAL)
36 Q_PROPERTY(QQuickAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged FINAL)
37 Q_PROPERTY(QQuickAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged FINAL)
38 Q_PROPERTY(QQuickAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged FINAL)
39 Q_PROPERTY(QQuickAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged FINAL)
40 Q_PROPERTY(QQuickAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged FINAL)
41 Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged FINAL)
42 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin RESET resetLeftMargin NOTIFY leftMarginChanged FINAL)
43 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin RESET resetRightMargin NOTIFY rightMarginChanged FINAL)
44 Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged FINAL)
45 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin RESET resetTopMargin NOTIFY topMarginChanged FINAL)
46 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin RESET resetBottomMargin NOTIFY bottomMarginChanged FINAL)
47 Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged FINAL)
48 Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged FINAL)
49 Q_PROPERTY(QQuickItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged FINAL)
50 Q_PROPERTY(QQuickItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged FINAL)
51 Q_PROPERTY(bool alignWhenCentered READ alignWhenCentered WRITE setAlignWhenCentered NOTIFY centerAlignedChanged FINAL)
52 QML_ANONYMOUS
53 QML_ADDED_IN_VERSION(2, 0)
54
55public:
56 QQuickAnchors(QQuickItem *item, QObject *parent=nullptr);
57 ~QQuickAnchors() override;
58
59 enum Anchor
60#if defined(Q_CC_CLANG) || !defined(Q_CC_GNU) // meaning: clang and msvc, but NOT gcc proper (because, you know, Q_CC_CLANG implies Q_CC_GNU)
61 // Not specifying the enum base type will have MSVC 'interpret' it as signed instead of an unsigned bit-field.
62 // However, specifying the enum base type breaks many GCCs, which complain that it can't store all values in a 7 bit bitfield.
63 : uint
64#endif
65 {
66 InvalidAnchor = 0x0,
67 LeftAnchor = 0x01,
68 RightAnchor = 0x02,
69 TopAnchor = 0x04,
70 BottomAnchor = 0x08,
71 HCenterAnchor = 0x10,
72 VCenterAnchor = 0x20,
73 BaselineAnchor = 0x40,
74 Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor,
75 Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
76 };
77 Q_DECLARE_FLAGS(Anchors, Anchor)
78 Q_FLAG(Anchors)
79
80 QQuickAnchorLine left() const;
81 void setLeft(const QQuickAnchorLine &edge);
82 void resetLeft();
83
84 QQuickAnchorLine right() const;
85 void setRight(const QQuickAnchorLine &edge);
86 void resetRight();
87
88 QQuickAnchorLine horizontalCenter() const;
89 void setHorizontalCenter(const QQuickAnchorLine &edge);
90 void resetHorizontalCenter();
91
92 QQuickAnchorLine top() const;
93 void setTop(const QQuickAnchorLine &edge);
94 void resetTop();
95
96 QQuickAnchorLine bottom() const;
97 void setBottom(const QQuickAnchorLine &edge);
98 void resetBottom();
99
100 QQuickAnchorLine verticalCenter() const;
101 void setVerticalCenter(const QQuickAnchorLine &edge);
102 void resetVerticalCenter();
103
104 QQuickAnchorLine baseline() const;
105 void setBaseline(const QQuickAnchorLine &edge);
106 void resetBaseline();
107
108 qreal leftMargin() const;
109 void setLeftMargin(qreal);
110 void resetLeftMargin();
111
112 qreal rightMargin() const;
113 void setRightMargin(qreal);
114 void resetRightMargin();
115
116 qreal horizontalCenterOffset() const;
117 void setHorizontalCenterOffset(qreal);
118
119 qreal topMargin() const;
120 void setTopMargin(qreal);
121 void resetTopMargin();
122
123 qreal bottomMargin() const;
124 void setBottomMargin(qreal);
125 void resetBottomMargin();
126
127 qreal margins() const;
128 void setMargins(qreal);
129
130 qreal verticalCenterOffset() const;
131 void setVerticalCenterOffset(qreal);
132
133 qreal baselineOffset() const;
134 void setBaselineOffset(qreal);
135
136 QQuickItem *fill() const;
137 void setFill(QQuickItem *);
138 void resetFill();
139
140 QQuickItem *centerIn() const;
141 void setCenterIn(QQuickItem *);
142 void resetCenterIn();
143
144 Anchors usedAnchors() const;
145 Qt::Orientations activeDirections() const;
146
147 bool mirrored();
148
149 bool alignWhenCentered() const;
150 void setAlignWhenCentered(bool);
151
152 void classBegin();
153 void componentComplete();
154
155Q_SIGNALS:
156 void leftChanged();
157 void rightChanged();
158 void topChanged();
159 void bottomChanged();
160 void verticalCenterChanged();
161 void horizontalCenterChanged();
162 void baselineChanged();
163 void fillChanged();
164 void centerInChanged();
165 void leftMarginChanged();
166 void rightMarginChanged();
167 void topMarginChanged();
168 void bottomMarginChanged();
169 void marginsChanged();
170 void verticalCenterOffsetChanged();
171 void horizontalCenterOffsetChanged();
172 void baselineOffsetChanged();
173 void centerAlignedChanged();
174
175private:
176 friend class QQuickItemPrivate;
177 Q_DISABLE_COPY(QQuickAnchors)
178 Q_DECLARE_PRIVATE(QQuickAnchors)
179};
180Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAnchors::Anchors)
181
182QT_END_NAMESPACE
183
184#endif // QQUICKANCHORS_P_H
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)