on xenial help sign in
Avoid having Rotation animations accessing context from parent
8f9ea33Daniel d'Andrada
qml/Rotation/HalfLoopRotationAnimation.qml+6−3
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -19,13 +19,16 @@ import QtQuick 2.3
19SequentialAnimation {
19SequentialAnimation {
20 id: root
20 id: root
21
21
22+ // set from outside
22 property int fromAngle
23 property int fromAngle
23 property int toAngle
24 property int toAngle
25+ property var info
26+ property var shell
24
27
25 readonly property bool flipShellDimensions: toAngle == 90 || toAngle == 270
28 readonly property bool flipShellDimensions: toAngle == 90 || toAngle == 270
26
29
27 ScriptAction { script: {
30 ScriptAction { script: {
28− d.transitioning = true;
31+ info.transitioning = true;
29 shell.orientationAngle = root.toAngle;
32 shell.orientationAngle = root.toAngle;
30 shell.x = (orientedShell.width - shell.width) / 2
33 shell.x = (orientedShell.width - shell.width) / 2
31 shell.y = (orientedShell.height - shell.height) / 2;
34 shell.y = (orientedShell.height - shell.height) / 2;
@@ -39,5 +42,5 @@ SequentialAnimation {
39 from: root.fromAngle; to: root.toAngle
42 from: root.fromAngle; to: root.toAngle
40 duration: rotationDuration; easing.type: rotationEasing
43 duration: rotationDuration; easing.type: rotationEasing
41 }
44 }
42− ScriptAction { script: { d.transitioning = false; } }
45+ ScriptAction { script: { info.transitioning = false; } }
43}
46}
qml/Rotation/ImmediateRotationAction.qml+25−20
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -16,25 +16,30 @@
16
16
17import QtQuick 2.3
17import QtQuick 2.3
18
18
19−ScriptAction { script: {
19+ScriptAction {
20− d.transitioning = true;
20+ property var info
21− shell.orientationAngle = d.requestedOrientationAngle;
21+ property var shell
22− shell.transformRotationAngle = d.requestedOrientationAngle;
23
22
23+ script: {
24+ info.transitioning = true;
25+ shell.orientationAngle = info.requestedOrientationAngle;
26+ shell.transformRotationAngle = info.requestedOrientationAngle;
27+
24− // Making bindings as orientedShell's dimensions might wiggle during startup.
28+ // Making bindings as orientedShell's dimensions might wiggle during startup.
25− if (d.requestedOrientationAngle === 90 || d.requestedOrientationAngle === 270) {
29+ if (info.requestedOrientationAngle === 90 || info.requestedOrientationAngle === 270) {
26− shell.width = Qt.binding(function() { return orientedShell.height; });
30+ shell.width = Qt.binding(function() { return orientedShell.height; });
27− shell.height = Qt.binding(function() { return orientedShell.width; });
31+ shell.height = Qt.binding(function() { return orientedShell.width; });
28− } else {
32+ } else {
29− shell.width = Qt.binding(function() { return orientedShell.width; });
33+ shell.width = Qt.binding(function() { return orientedShell.width; });
30− shell.height = Qt.binding(function() { return orientedShell.height; });
34+ shell.height = Qt.binding(function() { return orientedShell.height; });
31− }
35+ }
32
36
33− shell.x = Qt.binding(function() { return (orientedShell.width - shell.width) / 2; });
37+ shell.x = Qt.binding(function() { return (orientedShell.width - shell.width) / 2; });
34− shell.y = Qt.binding(function() { return (orientedShell.height - shell.height) / 2; });
38+ shell.y = Qt.binding(function() { return (orientedShell.height - shell.height) / 2; });
35− shell.transformOriginX = Qt.binding(function() { return shell.width / 2; });
39+ shell.transformOriginX = Qt.binding(function() { return shell.width / 2; });
36− shell.transformOriginY = Qt.binding(function() { return shell.height / 2; });
40+ shell.transformOriginY = Qt.binding(function() { return shell.height / 2; });
37
41
38− shell.updateFocusedAppOrientation();
42+ shell.updateFocusedAppOrientation();
39− d.transitioning = false;
43+ info.transitioning = false;
40−} }
44+ }
45+}
qml/Rotation/NinetyRotationAnimation.qml+5−3
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -21,13 +21,15 @@ SequentialAnimation {
21
21
22 property int fromAngle
22 property int fromAngle
23 property int toAngle
23 property int toAngle
24+ property var info
25+ property var shell
24
26
25 readonly property real fromY: fromAngle === 0 || fromAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
27 readonly property real fromY: fromAngle === 0 || fromAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
26 readonly property real toY: toAngle === 0 || toAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
28 readonly property real toY: toAngle === 0 || toAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
27 readonly property bool flipShellDimensions: toAngle == 90 || toAngle == 270
29 readonly property bool flipShellDimensions: toAngle == 90 || toAngle == 270
28
30
29 ScriptAction { script: {
31 ScriptAction { script: {
30− d.transitioning = true;
32+ info.transitioning = true;
31 windowScreenshot.take();
33 windowScreenshot.take();
32 windowScreenshot.visible = true;
34 windowScreenshot.visible = true;
33 shell.orientationAngle = root.toAngle;
35 shell.orientationAngle = root.toAngle;
@@ -83,6 +85,6 @@ SequentialAnimation {
83 windowScreenshot.visible = false;
85 windowScreenshot.visible = false;
84 windowScreenshot.discard();
86 windowScreenshot.discard();
85 shellCover.visible = false;
87 shellCover.visible = false;
86− d.transitioning = false;
88+ info.transitioning = false;
87 } }
89 } }
88}
90}
qml/Rotation/RotationStates.qml+27−15
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -170,67 +170,79 @@ StateGroup {
170 Transition {
170 Transition {
171 from: "90"; to: "0"
171 from: "90"; to: "0"
172 enabled: d.animationType == d.fullAnimation
172 enabled: d.animationType == d.fullAnimation
173− NinetyRotationAnimation { fromAngle: 90; toAngle: 0 }
173+ NinetyRotationAnimation { fromAngle: 90; toAngle: 0
174+ info: d; shell: root.shell }
174 },
175 },
175 Transition {
176 Transition {
176 from: "0"; to: "90"
177 from: "0"; to: "90"
177 enabled: d.animationType == d.fullAnimation
178 enabled: d.animationType == d.fullAnimation
178− NinetyRotationAnimation { fromAngle: 0; toAngle: 90 }
179+ NinetyRotationAnimation { fromAngle: 0; toAngle: 90
180+ info: d; shell: root.shell }
179 },
181 },
180 Transition {
182 Transition {
181 from: "0"; to: "270"
183 from: "0"; to: "270"
182 enabled: d.animationType == d.fullAnimation
184 enabled: d.animationType == d.fullAnimation
183− NinetyRotationAnimation { fromAngle: 0; toAngle: 270 }
185+ NinetyRotationAnimation { fromAngle: 0; toAngle: 270
186+ info: d; shell: root.shell }
184 },
187 },
185 Transition {
188 Transition {
186 from: "270"; to: "0"
189 from: "270"; to: "0"
187 enabled: d.animationType == d.fullAnimation
190 enabled: d.animationType == d.fullAnimation
188− NinetyRotationAnimation { fromAngle: 270; toAngle: 0 }
191+ NinetyRotationAnimation { fromAngle: 270; toAngle: 0
192+ info: d; shell: root.shell }
189 },
193 },
190 Transition {
194 Transition {
191 from: "90"; to: "180"
195 from: "90"; to: "180"
192 enabled: d.animationType == d.fullAnimation
196 enabled: d.animationType == d.fullAnimation
193− NinetyRotationAnimation { fromAngle: 90; toAngle: 180 }
197+ NinetyRotationAnimation { fromAngle: 90; toAngle: 180
198+ info: d; shell: root.shell }
194 },
199 },
195 Transition {
200 Transition {
196 from: "180"; to: "90"
201 from: "180"; to: "90"
197 enabled: d.animationType == d.fullAnimation
202 enabled: d.animationType == d.fullAnimation
198− NinetyRotationAnimation { fromAngle: 180; toAngle: 90 }
203+ NinetyRotationAnimation { fromAngle: 180; toAngle: 90
204+ info: d; shell: root.shell }
199 },
205 },
200 Transition {
206 Transition {
201 from: "180"; to: "270"
207 from: "180"; to: "270"
202 enabled: d.animationType == d.fullAnimation
208 enabled: d.animationType == d.fullAnimation
203− NinetyRotationAnimation { fromAngle: 180; toAngle: 270 }
209+ NinetyRotationAnimation { fromAngle: 180; toAngle: 270
210+ info: d; shell: root.shell }
204 },
211 },
205 Transition {
212 Transition {
206 from: "270"; to: "180"
213 from: "270"; to: "180"
207 enabled: d.animationType == d.fullAnimation
214 enabled: d.animationType == d.fullAnimation
208− NinetyRotationAnimation { fromAngle: 270; toAngle: 180 }
215+ NinetyRotationAnimation { fromAngle: 270; toAngle: 180
216+ info: d; shell: root.shell }
209 },
217 },
210 Transition {
218 Transition {
211 from: "0"; to: "180"
219 from: "0"; to: "180"
212 enabled: d.animationType == d.fullAnimation
220 enabled: d.animationType == d.fullAnimation
213− HalfLoopRotationAnimation { fromAngle: 0; toAngle: 180 }
221+ HalfLoopRotationAnimation { fromAngle: 0; toAngle: 180
222+ info: d; shell: root.shell }
214 },
223 },
215 Transition {
224 Transition {
216 from: "180"; to: "0"
225 from: "180"; to: "0"
217 enabled: d.animationType == d.fullAnimation
226 enabled: d.animationType == d.fullAnimation
218− HalfLoopRotationAnimation { fromAngle: 180; toAngle: 0 }
227+ HalfLoopRotationAnimation { fromAngle: 180; toAngle: 0
228+ info: d; shell: root.shell }
219 },
229 },
220 Transition {
230 Transition {
221 from: "90"; to: "270"
231 from: "90"; to: "270"
222 enabled: d.animationType == d.fullAnimation
232 enabled: d.animationType == d.fullAnimation
223− HalfLoopRotationAnimation { fromAngle: 90; toAngle: 270 }
233+ HalfLoopRotationAnimation { fromAngle: 90; toAngle: 270
234+ info: d; shell: root.shell }
224 },
235 },
225 Transition {
236 Transition {
226 from: "270"; to: "90"
237 from: "270"; to: "90"
227 enabled: d.animationType == d.fullAnimation
238 enabled: d.animationType == d.fullAnimation
228− HalfLoopRotationAnimation { fromAngle: 270; toAngle: 90 }
239+ HalfLoopRotationAnimation { fromAngle: 270; toAngle: 90
240+ info: d; shell: root.shell }
229 },
241 },
230 Transition {
242 Transition {
231 objectName: "immediateTransition"
243 objectName: "immediateTransition"
232 enabled: d.animationType == d.noAnimation
244 enabled: d.animationType == d.noAnimation
233− ImmediateRotationAction {}
245+ ImmediateRotationAction { info: d; shell: root.shell }
234 },
246 },
235 Transition {
247 Transition {
236 enabled: d.animationType == d.indicatorsBarAnimation
248 enabled: d.animationType == d.indicatorsBarAnimation
@@ -243,7 +255,7 @@ StateGroup {
243 target: root.shell; property: "indicatorAreaShowProgress"
255 target: root.shell; property: "indicatorAreaShowProgress"
244 from: 1.0; to: 0.0
256 from: 1.0; to: 0.0
245 }
257 }
246− ImmediateRotationAction {}
258+ ImmediateRotationAction { info: d; shell: root.shell }
247 NumberAnimation {
259 NumberAnimation {
248 duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing
260 duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing
249 target: root.shell; property: "indicatorAreaShowProgress"
261 target: root.shell; property: "indicatorAreaShowProgress"