Initial import from qtquick2.
[profile/ivi/qtdeclarative.git] / src / declarative / items / qsgstateoperations_p.h
1 // Commit: 84c47bbb133304d7ef35642fa1fbb17619d4a43d
2 /****************************************************************************
3 **
4 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 **
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
15 ** this package.
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 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.
24 **
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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QSGSTATEOPERATIONS_H
44 #define QSGSTATEOPERATIONS_H
45
46 #include "qsgitem.h"
47 #include "qsganchors_p.h"
48
49 #include <private/qdeclarativestate_p.h>
50
51 #include <QtDeclarative/qdeclarativescriptstring.h>
52
53 QT_BEGIN_HEADER
54
55 QT_BEGIN_NAMESPACE
56
57 QT_MODULE(Declarative)
58
59 class QSGParentChangePrivate;
60 class Q_AUTOTEST_EXPORT QSGParentChange : public QDeclarativeStateOperation, public QDeclarativeActionEvent
61 {
62     Q_OBJECT
63     Q_DECLARE_PRIVATE(QSGParentChange)
64
65     Q_PROPERTY(QSGItem *target READ object WRITE setObject)
66     Q_PROPERTY(QSGItem *parent READ parent WRITE setParent)
67     Q_PROPERTY(QDeclarativeScriptString x READ x WRITE setX)
68     Q_PROPERTY(QDeclarativeScriptString y READ y WRITE setY)
69     Q_PROPERTY(QDeclarativeScriptString width READ width WRITE setWidth)
70     Q_PROPERTY(QDeclarativeScriptString height READ height WRITE setHeight)
71     Q_PROPERTY(QDeclarativeScriptString scale READ scale WRITE setScale)
72     Q_PROPERTY(QDeclarativeScriptString rotation READ rotation WRITE setRotation)
73 public:
74     QSGParentChange(QObject *parent=0);
75     ~QSGParentChange();
76
77     QSGItem *object() const;
78     void setObject(QSGItem *);
79
80     QSGItem *parent() const;
81     void setParent(QSGItem *);
82
83     QSGItem *originalParent() const;
84
85     QDeclarativeScriptString x() const;
86     void setX(QDeclarativeScriptString x);
87     bool xIsSet() const;
88
89     QDeclarativeScriptString y() const;
90     void setY(QDeclarativeScriptString y);
91     bool yIsSet() const;
92
93     QDeclarativeScriptString width() const;
94     void setWidth(QDeclarativeScriptString width);
95     bool widthIsSet() const;
96
97     QDeclarativeScriptString height() const;
98     void setHeight(QDeclarativeScriptString height);
99     bool heightIsSet() const;
100
101     QDeclarativeScriptString scale() const;
102     void setScale(QDeclarativeScriptString scale);
103     bool scaleIsSet() const;
104
105     QDeclarativeScriptString rotation() const;
106     void setRotation(QDeclarativeScriptString rotation);
107     bool rotationIsSet() const;
108
109     virtual ActionList actions();
110
111     virtual void saveOriginals();
112     //virtual void copyOriginals(QDeclarativeActionEvent*);
113     virtual void execute(Reason reason = ActualChange);
114     virtual bool isReversable();
115     virtual void reverse(Reason reason = ActualChange);
116     virtual QString typeName() const;
117     virtual bool override(QDeclarativeActionEvent*other);
118     virtual void rewind();
119     virtual void saveCurrentValues();
120 };
121
122 class QSGAnchorChanges;
123 class QSGAnchorSetPrivate;
124 class Q_AUTOTEST_EXPORT QSGAnchorSet : public QObject
125 {
126     Q_OBJECT
127
128     Q_PROPERTY(QDeclarativeScriptString left READ left WRITE setLeft RESET resetLeft)
129     Q_PROPERTY(QDeclarativeScriptString right READ right WRITE setRight RESET resetRight)
130     Q_PROPERTY(QDeclarativeScriptString horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter)
131     Q_PROPERTY(QDeclarativeScriptString top READ top WRITE setTop RESET resetTop)
132     Q_PROPERTY(QDeclarativeScriptString bottom READ bottom WRITE setBottom RESET resetBottom)
133     Q_PROPERTY(QDeclarativeScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
134     Q_PROPERTY(QDeclarativeScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline)
135     //Q_PROPERTY(QSGItem *fill READ fill WRITE setFill RESET resetFill)
136     //Q_PROPERTY(QSGItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn)
137
138     /*Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
139     Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
140     Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
141     Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
142     Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
143     Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
144     Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
145     Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())*/
146
147 public:
148     QSGAnchorSet(QObject *parent=0);
149     virtual ~QSGAnchorSet();
150
151     QDeclarativeScriptString left() const;
152     void setLeft(const QDeclarativeScriptString &edge);
153     void resetLeft();
154
155     QDeclarativeScriptString right() const;
156     void setRight(const QDeclarativeScriptString &edge);
157     void resetRight();
158
159     QDeclarativeScriptString horizontalCenter() const;
160     void setHorizontalCenter(const QDeclarativeScriptString &edge);
161     void resetHorizontalCenter();
162
163     QDeclarativeScriptString top() const;
164     void setTop(const QDeclarativeScriptString &edge);
165     void resetTop();
166
167     QDeclarativeScriptString bottom() const;
168     void setBottom(const QDeclarativeScriptString &edge);
169     void resetBottom();
170
171     QDeclarativeScriptString verticalCenter() const;
172     void setVerticalCenter(const QDeclarativeScriptString &edge);
173     void resetVerticalCenter();
174
175     QDeclarativeScriptString baseline() const;
176     void setBaseline(const QDeclarativeScriptString &edge);
177     void resetBaseline();
178
179     QSGItem *fill() const;
180     void setFill(QSGItem *);
181     void resetFill();
182
183     QSGItem *centerIn() const;
184     void setCenterIn(QSGItem *);
185     void resetCenterIn();
186
187     /*qreal leftMargin() const;
188     void setLeftMargin(qreal);
189
190     qreal rightMargin() const;
191     void setRightMargin(qreal);
192
193     qreal horizontalCenterOffset() const;
194     void setHorizontalCenterOffset(qreal);
195
196     qreal topMargin() const;
197     void setTopMargin(qreal);
198
199     qreal bottomMargin() const;
200     void setBottomMargin(qreal);
201
202     qreal margins() const;
203     void setMargins(qreal);
204
205     qreal verticalCenterOffset() const;
206     void setVerticalCenterOffset(qreal);
207
208     qreal baselineOffset() const;
209     void setBaselineOffset(qreal);*/
210
211     QSGAnchors::Anchors usedAnchors() const;
212
213 /*Q_SIGNALS:
214     void leftMarginChanged();
215     void rightMarginChanged();
216     void topMarginChanged();
217     void bottomMarginChanged();
218     void marginsChanged();
219     void verticalCenterOffsetChanged();
220     void horizontalCenterOffsetChanged();
221     void baselineOffsetChanged();*/
222
223 private:
224     friend class QSGAnchorChanges;
225     Q_DISABLE_COPY(QSGAnchorSet)
226     Q_DECLARE_PRIVATE(QSGAnchorSet)
227 };
228
229 class QSGAnchorChangesPrivate;
230 class Q_AUTOTEST_EXPORT QSGAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent
231 {
232     Q_OBJECT
233     Q_DECLARE_PRIVATE(QSGAnchorChanges)
234
235     Q_PROPERTY(QSGItem *target READ object WRITE setObject)
236     Q_PROPERTY(QSGAnchorSet *anchors READ anchors CONSTANT)
237
238 public:
239     QSGAnchorChanges(QObject *parent=0);
240     ~QSGAnchorChanges();
241
242     virtual ActionList actions();
243
244     QSGAnchorSet *anchors();
245
246     QSGItem *object() const;
247     void setObject(QSGItem *);
248
249     virtual void execute(Reason reason = ActualChange);
250     virtual bool isReversable();
251     virtual void reverse(Reason reason = ActualChange);
252     virtual QString typeName() const;
253     virtual bool override(QDeclarativeActionEvent*other);
254     virtual bool changesBindings();
255     virtual void saveOriginals();
256     virtual bool needsCopy() { return true; }
257     virtual void copyOriginals(QDeclarativeActionEvent*);
258     virtual void clearBindings();
259     virtual void rewind();
260     virtual void saveCurrentValues();
261
262     QList<QDeclarativeAction> additionalActions();
263     virtual void saveTargetValues();
264 };
265
266 QT_END_NAMESPACE
267
268 QML_DECLARE_TYPE(QSGParentChange)
269 QML_DECLARE_TYPE(QSGAnchorSet)
270 QML_DECLARE_TYPE(QSGAnchorChanges)
271
272 QT_END_HEADER
273
274 #endif // QSGSTATEOPERATIONS_H
275