on xenial help sign in
Remove edge-drag hint animations.
9916819Daniel d'Andrada
Components/Stage.qml+19−29
@@ -406,28 +406,6 @@ Showable {
406 }
406 }
407
407
408 property real __startValue: stage.width
408 property real __startValue: stage.width
409− property real __hintValue: units.gu(1.5) // Should be 3, but 1.5 balances the not-Linear easing of switchToApplicationAnimation
410−
411− Binding {
412− target: switchToApplicationAnimationController
413− property: "progress"
414− value: stage.__dragValueToProgress(-rightEdgeDraggingArea.distance,
415− stage.__startValue, stage.applications.count)
416− when: rightEdgeDraggingArea.status === DirectionalDragArea.Recognized
417− }
418−
419− NumberAnimation {
420− id: hintProgressAnimation
421− target: switchToApplicationAnimationController
422− property: "progress"
423− easing.type: Easing.OutQuad
424− from: 0.0
425− to: stage.__dragValueToProgress(stage.__hintValue,
426− stage.__startValue,
427− stage.applications.count)
428− duration: 150
429−
430− }
431
409
432 AnimationControllerWithSignals {
410 AnimationControllerWithSignals {
433 id: switchToApplicationAnimationController
411 id: switchToApplicationAnimationController
@@ -465,6 +443,24 @@ Showable {
465 wideningAngle: 20
443 wideningAngle: 20
466 distanceThreshold: units.gu(2)
444 distanceThreshold: units.gu(2)
467
445
446+ onDistanceChanged: {
447+ if (status !== DirectionalDragArea.Recognized)
448+ return
449+
450+ var targetProgress = __dragValueToProgress(-distance, __startValue,
451+ stage.applications.count)
452+ var delta = targetProgress - switchToApplicationAnimationController.progress
453+
454+ // When the gesture finally gets recognized, the finger will likely be
455+ // reasonably far from the edge. If we made the progress immediately
456+ // follow the finger position it would be visually unpleasant as there
457+ // would be a jump to meet the finger's current position.
458+ //
459+ // The trick is not to go all the way (1.0) as it would cause the
460+ // aforementioned jump.
461+ switchToApplicationAnimationController.progress += 0.4 * delta
462+ }
463+
468 property bool gotRejected: false
464 property bool gotRejected: false
469
465
470 onStatusChanged: {
466 onStatusChanged: {
@@ -474,7 +470,6 @@ Showable {
474 } else if (status == DirectionalDragArea.Recognized) {
470 } else if (status == DirectionalDragArea.Recognized) {
475 onRecognized();
471 onRecognized();
476 } else if (status == DirectionalDragArea.Rejected) {
472 } else if (status == DirectionalDragArea.Rejected) {
477− hintProgressAnimation.stop()
478 switchToApplicationAnimationController.completeToBeginningWithSignal();
473 switchToApplicationAnimationController.completeToBeginningWithSignal();
479 gotRejected = true;
474 gotRejected = true;
480 } else if (status == DirectionalDragArea.WaitingForTouch) {
475 } else if (status == DirectionalDragArea.WaitingForTouch) {
@@ -490,18 +485,13 @@ Showable {
490 if (stage.applications.count > 1) {
485 if (stage.applications.count > 1) {
491 nextApplication = stage.applications.get(1);
486 nextApplication = stage.applications.get(1);
492 }
487 }
488+ switchToApplicationAnimationController.progress = 0
493 switchToApplicationAnimation.prepare(nextApplication);
489 switchToApplicationAnimation.prepare(nextApplication);
494 switchToApplicationAnimationController.animation = switchToApplicationAnimation;
490 switchToApplicationAnimationController.animation = switchToApplicationAnimation;
495
491
496− hintProgressAnimation.start()
497− }
498−
499− function onRecognized() {
500− hintProgressAnimation.stop()
501 }
492 }
502
493
503 function onGestureEnded() {
494 function onGestureEnded() {
504− hintProgressAnimation.stop()
505 if (stage.applications.count > 1 && dragVelocityCalculator.calculate() < 0) {
495 if (stage.applications.count > 1 && dragVelocityCalculator.calculate() < 0) {
506 switchToApplicationAnimationController.completeToEndWithSignal();
496 switchToApplicationAnimationController.completeToEndWithSignal();
507 } else {
497 } else {
Launcher/Launcher.qml+13−3
@@ -197,9 +197,19 @@ Item {
197 height: root.height
197 height: root.height
198
198
199 onTouchXChanged: {
199 onTouchXChanged: {
200− if (dragging) {
200+ if (status !== DirectionalDragArea.Recognized)
201+ return;
202+
203+ // When the gesture finally gets recognized, the finger will likely be
204+ // reasonably far from the edge. If we made the panel immediately
205+ // follow the finger position it would be visually unpleasant as it
206+ // would appear right next to the user's finger out of nowhere.
207+ // Instead, we make the panel go towards the user's finger in several
208+ // steps. ie., in an animated way.
201− panel.x = Math.min(0, touchX - panel.width);
209+ var targetPanelX = Math.min(0, touchX - panel.width)
202− }
210+ var delta = targetPanelX - panel.x
211+ // the trick is not to go all the way (1.0) as it would cause a sudden jump
212+ panel.x += 0.4 * delta
203 }
213 }
204
214
205 onDraggingChanged: {
215 onDraggingChanged: {
tests/qmltests/Components/tst_Stage.qml+5−48
@@ -195,51 +195,6 @@ Rectangle {
195 name: "Stage"
195 name: "Stage"
196 when: windowShown
196 when: windowShown
197
197
198− /* If you press Stage's right edge it should show the hint that it's possible to
199− switch to the next running application. This means (graphically) sliding the
200− next application window from Stage's right edge for a small part of its width */
201− function test_pressingRightEdgeShowsHint() {
202− redControl.checked = true
203−
204− tryCompare(stage, "usingScreenshots", true) // wait for the animation to start
205− tryCompare(stage, "usingScreenshots", false) // and then for it to end
206− compare(fakeAppManager.mainStageFocusedApplication.desktopFile, "red")
207− compare(fakeAppManager.mainStageApplications.get(0).desktopFile, "red")
208−
209− greenControl.checked = true
210−
211− tryCompare(stage, "usingScreenshots", true) // wait for the animation to start
212− tryCompare(stage, "usingScreenshots", false) // and then for it to end
213− compare(fakeAppManager.mainStageFocusedApplication.desktopFile, "green")
214− compare(fakeAppManager.mainStageApplications.get(0).desktopFile, "green")
215−
216− var draggingAreaCenterX = stage.width - (stage.rightEdgeDraggingAreaWidth / 2)
217− var draggingAreaCenterY = stage.height / 2
218− touchPress(stage, draggingAreaCenterX, draggingAreaCenterY)
219−
220− // wait for the animation to start
221− tryCompare(stage, "usingScreenshots", true)
222−
223− // "red" should be the new/next application being shown
224− compare(newAppScreenshot.application.desktopFile, "red")
225− tryCompareFunction(isShowingABitOfNewApp, true);
226−
227− // "green" should be the current application being shown
228− compare(oldAppScreenshot.application.desktopFile, "green")
229− tryCompareFunction(isCurrentAppFadingOut, true);
230−
231− touchRelease(stage, draggingAreaCenterX, draggingAreaCenterY)
232− }
233−
234− function isShowingABitOfNewApp() {
235− // it should come from the right and take less than half of the screen
236− // but at least 5% of it
237− return newAppScreenshot.x > stage.width/2
238− && newAppScreenshot.x < stage.width*(95/100)
239− && newAppScreenshot.y === 0
240− && newAppScreenshot.visible
241− }
242−
243 function isCurrentAppFadingOut() {
198 function isCurrentAppFadingOut() {
244 // it should get a bit translucent and smaller
199 // it should get a bit translucent and smaller
245 return oldAppScreenshot.opacity < 0.99
200 return oldAppScreenshot.opacity < 0.99
@@ -307,15 +262,17 @@ Rectangle {
307
262
308 var draggingAreaCenterX = stage.width - (stage.rightEdgeDraggingAreaWidth / 2)
263 var draggingAreaCenterX = stage.width - (stage.rightEdgeDraggingAreaWidth / 2)
309 var draggingAreaCenterY = stage.height / 2
264 var draggingAreaCenterY = stage.height / 2
265+ var finalTouchX = draggingAreaCenterX - units.gu(5)
310− touchPress(stage, draggingAreaCenterX, draggingAreaCenterY)
266+ touchFlick(stage, draggingAreaCenterX, draggingAreaCenterY,
267+ finalTouchX, draggingAreaCenterY,
268+ true /* beginTouch */, false /* endTouch */)
311
269
312 // wait for the animation to start
270 // wait for the animation to start
313 tryCompare(stage, "usingScreenshots", true)
271 tryCompare(stage, "usingScreenshots", true)
314
272
315 compare(newAppScreenshot.withBackground, false, "switched app does have background enabled")
273 compare(newAppScreenshot.withBackground, false, "switched app does have background enabled")
316
274
317− tryCompareFunction(isShowingABitOfNewApp, true); // wait for the hint animation to finish
318− touchRelease(stage, draggingAreaCenterX, draggingAreaCenterY)
275+ touchRelease(stage, finalTouchX, draggingAreaCenterY)
319 }
276 }
320 }
277 }
321}
278}