1 // Commit: 2c7cab4172f1acc86fd49345a2847417e162f2c3
2 /****************************************************************************
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this
15 ** file. Please review the following information to ensure the GNU Lesser
16 ** General Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
23 ** GNU General Public License Usage
24 ** Alternatively, this file may be used under the terms of the GNU General
25 ** Public License version 3.0 as published by the Free Software Foundation
26 ** and appearing in the file LICENSE.GPL included in the packaging of this
27 ** file. Please review the following information to ensure the GNU General
28 ** Public License version 3.0 requirements will be met:
29 ** http://www.gnu.org/copyleft/gpl.html.
32 ** Alternatively, this file may be used in accordance with the terms and
33 ** conditions contained in a signed written agreement between you and Nokia.
41 ****************************************************************************/
43 #ifndef QQUICKANCHORS_P_P_H
44 #define QQUICKANCHORS_P_P_H
50 // This file is not part of the Qt API. It exists purely as an
51 // implementation detail. This header file may change from version to
52 // version without notice, or even be removed.
57 #include "qquickanchors_p.h"
58 #include "qquickitemchangelistener_p.h"
59 #include <private/qobject_p.h>
63 class QQuickAnchorLine
66 QQuickAnchorLine() : item(0), anchorLine(Invalid) {}
77 Horizontal_Mask = Left | Right | HCenter,
78 Vertical_Mask = Top | Bottom | VCenter | Baseline
82 AnchorLine anchorLine;
85 inline bool operator==(const QQuickAnchorLine& a, const QQuickAnchorLine& b)
87 return a.item == b.item && a.anchorLine == b.anchorLine;
90 class QQuickAnchorsPrivate : public QObjectPrivate, public QQuickItemChangeListener
92 Q_DECLARE_PUBLIC(QQuickAnchors)
94 QQuickAnchorsPrivate(QQuickItem *i)
95 : componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0),
96 updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0),
97 centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
98 margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)
102 void clearItem(QQuickItem *);
104 void addDepend(QQuickItem *);
105 void remDepend(QQuickItem *);
106 bool isItemComplete() const;
108 bool componentComplete:1;
110 uint updatingHorizontalAnchor:2;
111 uint updatingVerticalAnchor:2;
113 uint updatingCenterIn:2;
115 void setItemHeight(qreal);
116 void setItemWidth(qreal);
117 void setItemX(qreal);
118 void setItemY(qreal);
119 void setItemPos(const QPointF &);
120 void setItemSize(const QSizeF &);
122 void updateOnComplete();
125 // QQuickItemGeometryListener interface
126 void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &);
127 QQuickAnchorsPrivate *anchorPrivate() { return this; }
129 bool checkHValid() const;
130 bool checkVValid() const;
131 bool checkHAnchorValid(QQuickAnchorLine anchor) const;
132 bool checkVAnchorValid(QQuickAnchorLine anchor) const;
133 bool calcStretch(const QQuickAnchorLine &edge1, const QQuickAnchorLine &edge2, qreal offset1, qreal offset2, QQuickAnchorLine::AnchorLine line, qreal &stretch);
135 bool isMirrored() const;
136 void updateHorizontalAnchors();
137 void updateVerticalAnchors();
139 void centerInChanged();
142 QQuickAnchors::Anchors usedAnchors;
145 QQuickItem *centerIn;
147 QQuickAnchorLine left;
148 QQuickAnchorLine right;
149 QQuickAnchorLine top;
150 QQuickAnchorLine bottom;
151 QQuickAnchorLine vCenter;
152 QQuickAnchorLine hCenter;
153 QQuickAnchorLine baseline;
162 qreal baselineOffset;
164 static inline QQuickAnchorsPrivate *get(QQuickAnchors *o) {
165 return static_cast<QQuickAnchorsPrivate *>(QObjectPrivate::get(o));
171 Q_DECLARE_METATYPE(QQuickAnchorLine)