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 ** No Commercial Usage
12 ** This file contains pre-release code and may not be distributed.
13 ** You may use this file in accordance with the terms and conditions
14 ** contained in the Technology Preview License Agreement accompanying
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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
41 ****************************************************************************/
43 #ifndef QSGPOSITIONERS_P_H
44 #define QSGPOSITIONERS_P_H
46 #include "qsgimplicitsizeitem_p.h"
48 #include <private/qdeclarativestate_p.h>
49 #include <private/qpodvector_p.h>
51 #include <QtCore/qobject.h>
52 #include <QtCore/qstring.h>
58 QT_MODULE(Declarative)
60 class QSGBasePositionerPrivate;
62 class Q_DECLARATIVE_PRIVATE_EXPORT QSGBasePositioner : public QSGImplicitSizeItem
66 Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
67 Q_PROPERTY(QDeclarativeTransition *move READ move WRITE setMove NOTIFY moveChanged)
68 Q_PROPERTY(QDeclarativeTransition *add READ add WRITE setAdd NOTIFY addChanged)
70 enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
71 QSGBasePositioner(PositionerType, QSGItem *parent);
77 QDeclarativeTransition *move() const;
78 void setMove(QDeclarativeTransition *);
80 QDeclarativeTransition *add() const;
81 void setAdd(QDeclarativeTransition *);
84 QSGBasePositioner(QSGBasePositionerPrivate &dd, PositionerType at, QSGItem *parent);
85 virtual void componentComplete();
86 virtual void itemChange(ItemChange, const ItemChangeData &);
87 void finishApplyTransitions();
90 void spacingChanged();
95 void prePositioning();
98 virtual void doPositioning(QSizeF *contentSize)=0;
99 virtual void reportConflictingAnchors()=0;
100 class PositionedItem {
102 PositionedItem(QSGItem *i) : item(i), isNew(false), isVisible(true) {}
103 bool operator==(const PositionedItem &other) const { return other.item == item; }
109 QPODVector<PositionedItem,8> positionedItems;
110 void positionX(int,const PositionedItem &target);
111 void positionY(int,const PositionedItem &target);
114 Q_DISABLE_COPY(QSGBasePositioner)
115 Q_DECLARE_PRIVATE(QSGBasePositioner)
118 class Q_AUTOTEST_EXPORT QSGColumn : public QSGBasePositioner
122 QSGColumn(QSGItem *parent=0);
124 virtual void doPositioning(QSizeF *contentSize);
125 virtual void reportConflictingAnchors();
127 Q_DISABLE_COPY(QSGColumn)
130 class Q_AUTOTEST_EXPORT QSGRow: public QSGBasePositioner
133 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
134 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
136 QSGRow(QSGItem *parent=0);
138 Qt::LayoutDirection layoutDirection() const;
139 void setLayoutDirection (Qt::LayoutDirection);
140 Qt::LayoutDirection effectiveLayoutDirection() const;
143 void layoutDirectionChanged();
144 void effectiveLayoutDirectionChanged();
147 virtual void doPositioning(QSizeF *contentSize);
148 virtual void reportConflictingAnchors();
150 Q_DISABLE_COPY(QSGRow)
153 class Q_AUTOTEST_EXPORT QSGGrid : public QSGBasePositioner
156 Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
157 Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
158 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
159 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
160 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
163 QSGGrid(QSGItem *parent=0);
165 int rows() const {return m_rows;}
166 void setRows(const int rows);
168 int columns() const {return m_columns;}
169 void setColumns(const int columns);
172 enum Flow { LeftToRight, TopToBottom };
176 Qt::LayoutDirection layoutDirection() const;
177 void setLayoutDirection (Qt::LayoutDirection);
178 Qt::LayoutDirection effectiveLayoutDirection() const;
182 void columnsChanged();
184 void layoutDirectionChanged();
185 void effectiveLayoutDirectionChanged();
188 virtual void doPositioning(QSizeF *contentSize);
189 virtual void reportConflictingAnchors();
195 Q_DISABLE_COPY(QSGGrid)
198 class QSGFlowPrivate;
199 class Q_AUTOTEST_EXPORT QSGFlow: public QSGBasePositioner
202 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
203 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
204 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
206 QSGFlow(QSGItem *parent=0);
209 enum Flow { LeftToRight, TopToBottom };
213 Qt::LayoutDirection layoutDirection() const;
214 void setLayoutDirection (Qt::LayoutDirection);
215 Qt::LayoutDirection effectiveLayoutDirection() const;
219 void layoutDirectionChanged();
220 void effectiveLayoutDirectionChanged();
223 virtual void doPositioning(QSizeF *contentSize);
224 virtual void reportConflictingAnchors();
226 QSGFlow(QSGFlowPrivate &dd, QSGItem *parent);
228 Q_DISABLE_COPY(QSGFlow)
229 Q_DECLARE_PRIVATE(QSGFlow)
235 QML_DECLARE_TYPE(QSGColumn)
236 QML_DECLARE_TYPE(QSGRow)
237 QML_DECLARE_TYPE(QSGGrid)
238 QML_DECLARE_TYPE(QSGFlow)
242 #endif // QSGPOSITIONERS_P_H