~loic.molinari/+junk/qtdeclarative-shadereffectsource-changes

« back to all changes in this revision

Viewing changes to tests/auto/quick/qquickpositioners/data/transitions.qml

  • Committer: Loïc Molinari
  • Date: 2012-04-21 17:59:51 UTC
  • Revision ID: loic.molinari@canonical.com-20120421175951-bqx68caaf5zrp76l
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
 
 
3
Rectangle {
 
4
    id: root
 
5
    width: 500
 
6
    height: 500
 
7
 
 
8
    property int duration: 50
 
9
 
 
10
    property int targetTransitionsDone
 
11
    property int displaceTransitionsDone
 
12
 
 
13
    property var targetTrans_items: new Object()
 
14
    property var targetTrans_targetIndexes: new Array()
 
15
    property var targetTrans_targetItems: new Array()
 
16
 
 
17
    property var displacedTrans_items: new Object()
 
18
    property var displacedTrans_targetIndexes: new Array()
 
19
    property var displacedTrans_targetItems: new Array()
 
20
 
 
21
    // for QQmlListProperty types
 
22
    function copyList(propList) {
 
23
        var temp = new Array()
 
24
        for (var i=0; i<propList.length; i++)
 
25
            temp.push(propList[i])
 
26
        return temp
 
27
    }
 
28
 
 
29
    function checkPos(x, y, name) {
 
30
        if (Qt.point(x, y) == targetItems_transitionFrom)
 
31
            model_targetItems_transitionFrom.addItem(name, "")
 
32
        if (Qt.point(x, y) == displacedItems_transitionVia)
 
33
            model_displacedItems_transitionVia.addItem(name, "")
 
34
    }
 
35
 
 
36
    Transition {
 
37
        id: targetTransition
 
38
        enabled: enableAddTransition
 
39
 
 
40
        SequentialAnimation {
 
41
            ScriptAction {
 
42
                script: {
 
43
                    root.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
 
44
                    root.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
 
45
                    root.targetTrans_targetItems.push(root.copyList(targetTransition.ViewTransition.targetItems))
 
46
                }
 
47
            }
 
48
            ParallelAnimation {
 
49
                NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
 
50
                NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
 
51
            }
 
52
 
 
53
            ScriptAction { script: root.targetTransitionsDone += 1 }
 
54
        }
 
55
    }
 
56
 
 
57
    Transition {
 
58
        id: displaced
 
59
 
 
60
        SequentialAnimation {
 
61
            ScriptAction {
 
62
                script: {
 
63
                    root.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
 
64
                    root.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
 
65
                    root.displacedTrans_targetItems.push(root.copyList(displaced.ViewTransition.targetItems))
 
66
                }
 
67
            }
 
68
            ParallelAnimation {
 
69
                NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
 
70
                NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
 
71
            }
 
72
            NumberAnimation { properties: "x,y"; duration: root.duration }
 
73
 
 
74
            ScriptAction { script: root.displaceTransitionsDone += 1 }
 
75
        }
 
76
 
 
77
    }
 
78
 
 
79
    Row {
 
80
        objectName: "row"
 
81
 
 
82
        property int count: children.length - 1 // omit Repeater
 
83
 
 
84
        x: 50; y: 50
 
85
        width: 400; height: 400
 
86
        Repeater {
 
87
            objectName: "repeater"
 
88
            Rectangle {
 
89
                property string nameData: name
 
90
                objectName: "wrapper"
 
91
                width: 30 + index*5
 
92
                height: 30 + index*5
 
93
                border.width: 1
 
94
                Column {
 
95
                    Text { text: index }
 
96
                    Text { objectName: "name"; text: name }
 
97
                    Text { text: parent.parent.y }
 
98
                }
 
99
                onXChanged: root.checkPos(x, y, name)
 
100
                onYChanged: root.checkPos(x, y, name)
 
101
            }
 
102
        }
 
103
 
 
104
        add: targetTransition
 
105
        move: displaced
 
106
    }
 
107
 
 
108
    Column {
 
109
        objectName: "column"
 
110
 
 
111
        property int count: children.length - 1 // omit Repeater
 
112
 
 
113
        x: 50; y: 50
 
114
        width: 400; height: 400
 
115
        Repeater {
 
116
            objectName: "repeater"
 
117
            Rectangle {
 
118
                property string nameData: name
 
119
                objectName: "wrapper"
 
120
                width: 30 + index*5
 
121
                height: 30 + index*5
 
122
                border.width: 1
 
123
                Column {
 
124
                    Text { text: index }
 
125
                    Text { objectName: "name"; text: name }
 
126
                    Text { text: parent.parent.y }
 
127
                }
 
128
                onXChanged: root.checkPos(x, y, name)
 
129
                onYChanged: root.checkPos(x, y, name)
 
130
            }
 
131
        }
 
132
 
 
133
        add: targetTransition
 
134
        move: displaced
 
135
    }
 
136
 
 
137
    Grid {
 
138
        objectName: "grid"
 
139
 
 
140
        property int count: children.length - 1 // omit Repeater
 
141
 
 
142
        x: 50; y: 50
 
143
        width: 400; height: 400
 
144
        Repeater {
 
145
            objectName: "repeater"
 
146
            Rectangle {
 
147
                property string nameData: name
 
148
                objectName: "wrapper"
 
149
                width: 30 + index*5
 
150
                height: 30 + index*5
 
151
                border.width: 1
 
152
                Column {
 
153
                    Text { text: index }
 
154
                    Text { objectName: "name"; text: name }
 
155
                    Text { text: parent.parent.y }
 
156
                }
 
157
 
 
158
                onXChanged: root.checkPos(x, y, name)
 
159
                onYChanged: root.checkPos(x, y, name)
 
160
            }
 
161
        }
 
162
 
 
163
        add: targetTransition
 
164
        move: displaced
 
165
    }
 
166
 
 
167
    Flow {
 
168
        objectName: "flow"
 
169
 
 
170
        property int count: children.length - 1 // omit Repeater
 
171
 
 
172
        x: 50; y: 50
 
173
        width: 400; height: 400
 
174
        Repeater {
 
175
            objectName: "repeater"
 
176
            Rectangle {
 
177
                property string nameData: name
 
178
                objectName: "wrapper"
 
179
                width: 30 + index*5
 
180
                height: 30 + index*5
 
181
                border.width: 1
 
182
                Column {
 
183
                    Text { text: index }
 
184
                    Text { objectName: "name"; text: name }
 
185
                    Text { text: parent.parent.x + " " + parent.parent.y }
 
186
                }
 
187
                onXChanged: root.checkPos(x, y, name)
 
188
                onYChanged: root.checkPos(x, y, name)
 
189
            }
 
190
        }
 
191
 
 
192
        add: targetTransition
 
193
        move: displaced
 
194
    }
 
195
}
 
196