1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtQuick module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QQUICKANCHORS_P_H
41#define QQUICKANCHORS_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <qqml.h>
55
56#include <QtCore/QObject>
57
58#include <private/qtquickglobal_p.h>
59
60QT_BEGIN_NAMESPACE
61
62class QQuickItem;
63class QQuickAnchorsPrivate;
64class QQuickAnchorLine;
65class Q_QUICK_PRIVATE_EXPORT QQuickAnchors : public QObject
66{
67 Q_OBJECT
68
69 Q_PROPERTY(QQuickAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged)
70 Q_PROPERTY(QQuickAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged)
71 Q_PROPERTY(QQuickAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged)
72 Q_PROPERTY(QQuickAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged)
73 Q_PROPERTY(QQuickAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged)
74 Q_PROPERTY(QQuickAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged)
75 Q_PROPERTY(QQuickAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged)
76 Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
77 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin RESET resetLeftMargin NOTIFY leftMarginChanged)
78 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin RESET resetRightMargin NOTIFY rightMarginChanged)
79 Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged)
80 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin RESET resetTopMargin NOTIFY topMarginChanged)
81 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin RESET resetBottomMargin NOTIFY bottomMarginChanged)
82 Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged)
83 Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
84 Q_PROPERTY(QQuickItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
85 Q_PROPERTY(QQuickItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
86 Q_PROPERTY(bool alignWhenCentered READ alignWhenCentered WRITE setAlignWhenCentered NOTIFY centerAlignedChanged)
87
88public:
89 QQuickAnchors(QQuickItem *item, QObject *parent=nullptr);
90 ~QQuickAnchors() override;
91
92 enum Anchor
93#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)
94 // Not specifying the enum base type will have MSVC 'interpret' it as signed instead of an unsigned bit-field.
95 // However, specifying the enum base type breaks many GCCs, which complain that it can't store all values in a 7 bit bitfield.
96 : uint
97#endif
98 {
99 InvalidAnchor = 0x0,
100 LeftAnchor = 0x01,
101 RightAnchor = 0x02,
102 TopAnchor = 0x04,
103 BottomAnchor = 0x08,
104 HCenterAnchor = 0x10,
105 VCenterAnchor = 0x20,
106 BaselineAnchor = 0x40,
107 Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor,
108 Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
109 };
110 Q_DECLARE_FLAGS(Anchors, Anchor)
111 Q_FLAG(Anchors)
112
113 QQuickAnchorLine left() const;
114 void setLeft(const QQuickAnchorLine &edge);
115 void resetLeft();
116
117 QQuickAnchorLine right() const;
118 void setRight(const QQuickAnchorLine &edge);
119 void resetRight();
120
121 QQuickAnchorLine horizontalCenter() const;
122 void setHorizontalCenter(const QQuickAnchorLine &edge);
123 void resetHorizontalCenter();
124
125 QQuickAnchorLine top() const;
126 void setTop(const QQuickAnchorLine &edge);
127 void resetTop();
128
129 QQuickAnchorLine bottom() const;
130 void setBottom(const QQuickAnchorLine &edge);
131 void resetBottom();
132
133 QQuickAnchorLine verticalCenter() const;
134 void setVerticalCenter(const QQuickAnchorLine &edge);
135 void resetVerticalCenter();
136
137 QQuickAnchorLine baseline() const;
138 void setBaseline(const QQuickAnchorLine &edge);
139 void resetBaseline();
140
141 qreal leftMargin() const;
142 void setLeftMargin(qreal);
143 void resetLeftMargin();
144
145 qreal rightMargin() const;
146 void setRightMargin(qreal);
147 void resetRightMargin();
148
149 qreal horizontalCenterOffset() const;
150 void setHorizontalCenterOffset(qreal);
151
152 qreal topMargin() const;
153 void setTopMargin(qreal);
154 void resetTopMargin();
155
156 qreal bottomMargin() const;
157 void setBottomMargin(qreal);
158 void resetBottomMargin();
159
160 qreal margins() const;
161 void setMargins(qreal);
162
163 qreal verticalCenterOffset() const;
164 void setVerticalCenterOffset(qreal);
165
166 qreal baselineOffset() const;
167 void setBaselineOffset(qreal);
168
169 QQuickItem *fill() const;
170 void setFill(QQuickItem *);
171 void resetFill();
172
173 QQuickItem *centerIn() const;
174 void setCenterIn(QQuickItem *);
175 void resetCenterIn();
176
177 Anchors usedAnchors() const;
178 Qt::Orientations activeDirections() const;
179
180 bool mirrored();
181
182 bool alignWhenCentered() const;
183 void setAlignWhenCentered(bool);
184
185 void classBegin();
186 void componentComplete();
187
188Q_SIGNALS:
189 void leftChanged();
190 void rightChanged();
191 void topChanged();
192 void bottomChanged();
193 void verticalCenterChanged();
194 void horizontalCenterChanged();
195 void baselineChanged();
196 void fillChanged();
197 void centerInChanged();
198 void leftMarginChanged();
199 void rightMarginChanged();
200 void topMarginChanged();
201 void bottomMarginChanged();
202 void marginsChanged();
203 void verticalCenterOffsetChanged();
204 void horizontalCenterOffsetChanged();
205 void baselineOffsetChanged();
206 void centerAlignedChanged();
207
208private:
209 friend class QQuickItemPrivate;
210 Q_DISABLE_COPY(QQuickAnchors)
211 Q_DECLARE_PRIVATE(QQuickAnchors)
212};
213Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAnchors::Anchors)
214
215QT_END_NAMESPACE
216
217QML_DECLARE_TYPE(QQuickAnchors)
218
219#endif // QQUICKANCHORS_P_H
220