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

source code of qtdeclarative/src/quick/items/qquickanchors_p.h