on xenial help sign in
Fix SpreadDelegate rotation animations

They were broken by the support for multi-surface applications.

commite46eb4a2fd01f08947274fcb85b06d21d906f4fb authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 17 Jun 2016, 01:16 (10 years ago) parent35025c7a503754
2 files changed+37−17
qml/Stages/OrientationChangeAnimation.qml+30−6 qml/Stages/SpreadDelegate.qml+7−11
qml/Stages/OrientationChangeAnimation.qml+30−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015, 2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -68,12 +68,22 @@ QtObject {
6868 }
6969 }
7070
71− if (chosenAnimation)
72− chosenAnimation.start();
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) {
80+ root.chosenAnimation.start();
81+ }
82+ }
7383 }
7484
7585 // to be read from outside
76− property bool running: chosenAnimation ? chosenAnimation.running : false
86+ property bool running: chosenAnimation !== null
7787
7888 property int duration: 450
7989 property int easingType: Easing.InOutCubic
@@ -84,7 +94,7 @@ QtObject {
8494 ? spreadDelegate.width : spreadDelegate.height
8595 property string longestAxis: spreadDelegate.width > spreadDelegate.height ? "x" : "y"
8696
87− property QtObject chosenAnimation
97+ property QtObject chosenAnimation: null
8898
8999 function setup90Animation() {
90100 background.visible = true;
@@ -92,7 +102,6 @@ QtObject {
92102 screenshot.width = window.width;
93103 screenshot.height = window.height;
94104 screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
95− screenshot.take();
96105 screenshot.transformOriginX = root.shortestDimension / 2;
97106 screenshot.transformOriginY = root.shortestDimension / 2;
98107 screenshot.visible = true;
@@ -109,11 +118,17 @@ QtObject {
109118 screenshot.discard();
110119 screenshot.visible = false;
111120 background.visible = false;
121+ chosenAnimation.ranSetup = false;
122+ chosenAnimation = null;
112123 }
113124
114125 property QtObject simple90Animation: SequentialAnimation {
115126 id: simple90Animation
116127
128+ function setup() { screenshot.take(); ranSetup = true; }
129+ property bool ranSetup: false
130+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
131+
117132 ScriptAction { script: setup90Animation() }
118133 ParallelAnimation {
119134 RotationAnimation {
@@ -155,6 +170,10 @@ QtObject {
155170 property QtObject moving90Animation: SequentialAnimation {
156171 id: moving90Animation
157172
173+ function setup() { screenshot.take(); ranSetup = true; }
174+ property bool ranSetup: false
175+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
176+
158177 ScriptAction { script: setup90Animation() }
159178 ParallelAnimation {
160179 RotationAnimation {
@@ -214,6 +233,9 @@ QtObject {
214233 property QtObject halfLoopAnimation: SequentialAnimation {
215234 id: halfLoopAnimation
216235
236+ function setup() { ready = true; }
237+ property bool ready: false
238+
217239 ScriptAction { script: {
218240 background.visible = true;
219241
@@ -236,6 +258,8 @@ QtObject {
236258 ScriptAction { script: {
237259 window.orientationAngle = spreadDelegate.shellOrientationAngle;
238260 background.visible = false;
261+ chosenAnimation = null;
262+ halfLoopAnimation.ready = false;
239263 } }
240264 }
241265}
qml/Stages/SpreadDelegate.qml+7−11
@@ -323,13 +323,14 @@ FocusScope {
323323 angle: appWindowScreenshotWithShadow.transformRotationAngle
324324 }
325325
326− property var window: appWindowScreenshot
326+ readonly property Item window: appWindowScreenshot
327+ readonly property bool ready: appWindowScreenshot.status === Image.Ready
327328
328329 function take() {
329− // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
330− // eg: "image://application/calculator-app/123456"
331− var timeMs = new Date().getTime();
332− appWindowScreenshot.source = "image://application/" + root.application.appId + "/" + timeMs;
330+ appWindow.grabToImage(
331+ function(result) {
332+ appWindowScreenshot.source = result.url;
333+ });
333334 }
334335 function discard() {
335336 appWindowScreenshot.source = "";
@@ -337,12 +338,7 @@ FocusScope {
337338
338339 Image {
339340 id: appWindowScreenshot
340− source: ""
341−
342− anchors.fill: parent
343−
344− sourceSize.width: width
345− sourceSize.height: height
341+ anchors.top: parent.top
346342 }
347343 }
348344