on xenial help sign in
Fix the positioning of the application window screenshot
commit16d5266b0a00e7d357d17eec7f4b17f328cdbfe0 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateThu 23 Apr 2015, 13:12 (11 years ago) parentcb15f2c
2 files changed+34−21
qml/Stages/OrientationChangeAnimation.qml+9−11 qml/Stages/SpreadDelegate.qml+25−10
qml/Stages/OrientationChangeAnimation.qml+9−11
@@ -23,7 +23,7 @@ QtObject {
2323 property Item spreadDelegate
2424 property Item background
2525 property Item window
26− property Image screenshot
26+ property Item screenshot
2727
2828 function start() {
2929 if (window.orientationAngle === 0) {
@@ -77,9 +77,6 @@ QtObject {
7777
7878 property int duration: 450
7979 property int easingType: Easing.InOutCubic
80− // Those values are good for debugging/development
81− //property int duration: 6000
82− //property int easingType: Easing.Linear
8380
8481 property int shortestDimension: spreadDelegate.width < spreadDelegate.height
8582 ? spreadDelegate.width : spreadDelegate.height
@@ -92,23 +89,24 @@ QtObject {
9289 function setup90Animation() {
9390 background.visible = true;
9491
95− screenshot.width = window.width
96− screenshot.height = window.height
92+ screenshot.width = window.width;
93+ screenshot.height = window.height;
94+ screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
9795 screenshot.take();
98− screenshot.transformOriginX = root.shortestDimension / 2
99− screenshot.transformOriginY = root.shortestDimension / 2
96+ screenshot.transformOriginX = root.shortestDimension / 2;
97+ screenshot.transformOriginY = root.shortestDimension / 2;
10098 screenshot.visible = true;
10199
102100 window.rotation = 0;
103101 window.width = spreadDelegate.width;
104102 window.height = spreadDelegate.height;
105− window.transformOriginX = root.shortestDimension / 2
106− window.transformOriginY = root.shortestDimension / 2
103+ window.transformOriginX = root.shortestDimension / 2;
104+ window.transformOriginY = root.shortestDimension / 2;
107105 }
108106
109107 function tearDown90Animation() {
110108 window.orientationAngle = spreadDelegate.shellOrientationAngle;
111− screenshot.source = "";
109+ screenshot.discard();
112110 screenshot.visible = false;
113111 background.visible = false;
114112 }
qml/Stages/SpreadDelegate.qml+25−10
@@ -68,7 +68,7 @@ FocusScope {
6868 spreadDelegate: root
6969 background: background
7070 window: appWindowWithShadow
71− screenshot: appWindowScreenshot
71+ screenshot: appWindowScreenshotWithShadow
7272 }
7373
7474 QtObject {
@@ -110,6 +110,8 @@ FocusScope {
110110 property real transformOriginX
111111 property real transformOriginY
112112
113+ property var window: appWindow
114+
113115 transform: Rotation {
114116 origin.x: appWindowWithShadow.transformOriginX
115117 origin.y: appWindowWithShadow.transformOriginY
@@ -267,9 +269,10 @@ FocusScope {
267269 }
268270 }
269271
270− Image {
271− id: appWindowScreenshot
272− source: ""
272+ Item {
273+ // mimics appWindowWithShadow. Do the positioning of screenshots of non-fullscreen
274+ // app windows
275+ id: appWindowScreenshotWithShadow
273276 visible: false
274277
275278 property real transformRotationAngle: 0
@@ -277,21 +280,33 @@ FocusScope {
277280 property real transformOriginY
278281
279282 transform: Rotation {
280− origin.x: appWindowScreenshot.transformOriginX
281− origin.y: appWindowScreenshot.transformOriginY
283+ origin.x: appWindowScreenshotWithShadow.transformOriginX
284+ origin.y: appWindowScreenshotWithShadow.transformOriginY
282285 axis { x: 0; y: 0; z: 1 }
283− angle: appWindowScreenshot.transformRotationAngle
286+ angle: appWindowScreenshotWithShadow.transformRotationAngle
284287 }
285288
289+ property var window: appWindowScreenshot
290+
286291 function take() {
287292 // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
288293 // eg: "image://application/calculator-app/123456"
289294 var timeMs = new Date().getTime();
290− source = "image://application/" + root.application.appId + "/" + timeMs;
295+ appWindowScreenshot.source = "image://application/" + root.application.appId + "/" + timeMs;
296+ }
297+ function discard() {
298+ appWindowScreenshot.source = "";
291299 }
292300
293− sourceSize.width: width
294− sourceSize.height: height
301+ Image {
302+ id: appWindowScreenshot
303+ source: ""
304+
305+ anchors.fill: parent
306+
307+ sourceSize.width: width
308+ sourceSize.height: height
309+ }
295310 }
296311
297312 DraggingArea {