on xenial help sign in
Fix SpreadDelegate rotation animations
a503754Daniel d'Andrada
qml/Stages/OrientationChangeAnimation.qml+30−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015, 2016 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 Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -68,12 +68,22 @@ QtObject {
68 }
68 }
69 }
69 }
70
70
71− if (chosenAnimation)
71+ if (chosenAnimation) {
72+ chosenAnimation.setup();
73+ }
74+ }
75+
76+ property Connections chosenAnimationConns: Connections {
77+ target: root.chosenAnimation
78+ onReadyChanged: {
79+ if (root.chosenAnimation.ready) {
72− chosenAnimation.start();
80+ root.chosenAnimation.start();
81+ }
82+ }
73 }
83 }
74
84
75 // to be read from outside
85 // to be read from outside
76− property bool running: chosenAnimation ? chosenAnimation.running : false
86+ property bool running: chosenAnimation !== null
77
87
78 property int duration: 450
88 property int duration: 450
79 property int easingType: Easing.InOutCubic
89 property int easingType: Easing.InOutCubic
@@ -84,7 +94,7 @@ QtObject {
84 ? spreadDelegate.width : spreadDelegate.height
94 ? spreadDelegate.width : spreadDelegate.height
85 property string longestAxis: spreadDelegate.width > spreadDelegate.height ? "x" : "y"
95 property string longestAxis: spreadDelegate.width > spreadDelegate.height ? "x" : "y"
86
96
87− property QtObject chosenAnimation
97+ property QtObject chosenAnimation: null
88
98
89 function setup90Animation() {
99 function setup90Animation() {
90 background.visible = true;
100 background.visible = true;
@@ -92,7 +102,6 @@ QtObject {
92 screenshot.width = window.width;
102 screenshot.width = window.width;
93 screenshot.height = window.height;
103 screenshot.height = window.height;
94 screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
104 screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
95− screenshot.take();
96 screenshot.transformOriginX = root.shortestDimension / 2;
105 screenshot.transformOriginX = root.shortestDimension / 2;
97 screenshot.transformOriginY = root.shortestDimension / 2;
106 screenshot.transformOriginY = root.shortestDimension / 2;
98 screenshot.visible = true;
107 screenshot.visible = true;
@@ -109,11 +118,17 @@ QtObject {
109 screenshot.discard();
118 screenshot.discard();
110 screenshot.visible = false;
119 screenshot.visible = false;
111 background.visible = false;
120 background.visible = false;
121+ chosenAnimation.ranSetup = false;
122+ chosenAnimation = null;
112 }
123 }
113
124
114 property QtObject simple90Animation: SequentialAnimation {
125 property QtObject simple90Animation: SequentialAnimation {
115 id: simple90Animation
126 id: simple90Animation
116
127
128+ function setup() { screenshot.take(); ranSetup = true; }
129+ property bool ranSetup: false
130+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
131+
117 ScriptAction { script: setup90Animation() }
132 ScriptAction { script: setup90Animation() }
118 ParallelAnimation {
133 ParallelAnimation {
119 RotationAnimation {
134 RotationAnimation {
@@ -155,6 +170,10 @@ QtObject {
155 property QtObject moving90Animation: SequentialAnimation {
170 property QtObject moving90Animation: SequentialAnimation {
156 id: moving90Animation
171 id: moving90Animation
157
172
173+ function setup() { screenshot.take(); ranSetup = true; }
174+ property bool ranSetup: false
175+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
176+
158 ScriptAction { script: setup90Animation() }
177 ScriptAction { script: setup90Animation() }
159 ParallelAnimation {
178 ParallelAnimation {
160 RotationAnimation {
179 RotationAnimation {
@@ -214,6 +233,9 @@ QtObject {
214 property QtObject halfLoopAnimation: SequentialAnimation {
233 property QtObject halfLoopAnimation: SequentialAnimation {
215 id: halfLoopAnimation
234 id: halfLoopAnimation
216
235
236+ function setup() { ready = true; }
237+ property bool ready: false
238+
217 ScriptAction { script: {
239 ScriptAction { script: {
218 background.visible = true;
240 background.visible = true;
219
241
@@ -236,6 +258,8 @@ QtObject {
236 ScriptAction { script: {
258 ScriptAction { script: {
237 window.orientationAngle = spreadDelegate.shellOrientationAngle;
259 window.orientationAngle = spreadDelegate.shellOrientationAngle;
238 background.visible = false;
260 background.visible = false;
261+ chosenAnimation = null;
262+ halfLoopAnimation.ready = false;
239 } }
263 } }
240 }
264 }
241}
265}
qml/Stages/SpreadDelegate.qml+7−11
@@ -323,13 +323,14 @@ FocusScope {
323 angle: appWindowScreenshotWithShadow.transformRotationAngle
323 angle: appWindowScreenshotWithShadow.transformRotationAngle
324 }
324 }
325
325
326− property var window: appWindowScreenshot
326+ readonly property Item window: appWindowScreenshot
327+ readonly property bool ready: appWindowScreenshot.status === Image.Ready
327
328
328 function take() {
329 function take() {
329− // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
330+ appWindow.grabToImage(
330− // eg: "image://application/calculator-app/123456"
331+ function(result) {
331− var timeMs = new Date().getTime();
332− appWindowScreenshot.source = "image://application/" + root.application.appId + "/" + timeMs;
332+ appWindowScreenshot.source = result.url;
333+ });
333 }
334 }
334 function discard() {
335 function discard() {
335 appWindowScreenshot.source = "";
336 appWindowScreenshot.source = "";
@@ -337,12 +338,7 @@ FocusScope {
337
338
338 Image {
339 Image {
339 id: appWindowScreenshot
340 id: appWindowScreenshot
340− source: ""
341−
342− anchors.fill: parent
341+ anchors.top: parent.top
343−
344− sourceSize.width: width
345− sourceSize.height: height
346 }
342 }
347 }
343 }
348
344