on xenial help sign in
Remove edge-drag hint animations.

Only show the animation related to an edge-drag action (e.g. showing launcher, switching applications) once a proper directional drag gesture is recognized. Otherwise hint animations would disrupt the user while he's just interacting with some visual element close to a screen edge (i.e., not doing an edge swipe). Approved by Michael Terry, PS Jenkins bot.

commit9916819fbf3773b0dfe1385995f270b3bda2fca0 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 11 Jun 2013, 00:33 (13 years ago) parent289eb1da166628
3 files changed+37−80
Components/Stage.qml+19−29 Launcher/Launcher.qml+13−3 tests/qmltests/Components/tst_Stage.qml+5−48
Components/Stage.qml+19−29
@@ -406,28 +406,6 @@ Showable {
406406 }
407407
408408 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− }
431409
432410 AnimationControllerWithSignals {
433411 id: switchToApplicationAnimationController
@@ -465,6 +443,24 @@ Showable {
465443 wideningAngle: 20
466444 distanceThreshold: units.gu(2)
467445
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+
468464 property bool gotRejected: false
469465
470466 onStatusChanged: {
@@ -474,7 +470,6 @@ Showable {
474470 } else if (status == DirectionalDragArea.Recognized) {
475471 onRecognized();
476472 } else if (status == DirectionalDragArea.Rejected) {
477− hintProgressAnimation.stop()
478473 switchToApplicationAnimationController.completeToBeginningWithSignal();
479474 gotRejected = true;
480475 } else if (status == DirectionalDragArea.WaitingForTouch) {
@@ -490,18 +485,13 @@ Showable {
490485 if (stage.applications.count > 1) {
491486 nextApplication = stage.applications.get(1);
492487 }
488+ switchToApplicationAnimationController.progress = 0
493489 switchToApplicationAnimation.prepare(nextApplication);
494490 switchToApplicationAnimationController.animation = switchToApplicationAnimation;
495491
496− hintProgressAnimation.start()
497− }
498−
499− function onRecognized() {
500− hintProgressAnimation.stop()
501492 }
502493
503494 function onGestureEnded() {
504− hintProgressAnimation.stop()
505495 if (stage.applications.count > 1 && dragVelocityCalculator.calculate() < 0) {
506496 switchToApplicationAnimationController.completeToEndWithSignal();
507497 } else {
Launcher/Launcher.qml+13−3
@@ -197,9 +197,19 @@ Item {
197197 height: root.height
198198
199199 onTouchXChanged: {
200− if (dragging) {
201− panel.x = Math.min(0, touchX - panel.width);
202− }
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.
209+ var targetPanelX = Math.min(0, touchX - panel.width)
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
203213 }
204214
205215 onDraggingChanged: {
tests/qmltests/Components/tst_Stage.qml+5−48
@@ -195,51 +195,6 @@ Rectangle {
195195 name: "Stage"
196196 when: windowShown
197197
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−
243198 function isCurrentAppFadingOut() {
244199 // it should get a bit translucent and smaller
245200 return oldAppScreenshot.opacity < 0.99
@@ -307,15 +262,17 @@ Rectangle {
307262
308263 var draggingAreaCenterX = stage.width - (stage.rightEdgeDraggingAreaWidth / 2)
309264 var draggingAreaCenterY = stage.height / 2
310− touchPress(stage, draggingAreaCenterX, draggingAreaCenterY)
265+ var finalTouchX = draggingAreaCenterX - units.gu(5)
266+ touchFlick(stage, draggingAreaCenterX, draggingAreaCenterY,
267+ finalTouchX, draggingAreaCenterY,
268+ true /* beginTouch */, false /* endTouch */)
311269
312270 // wait for the animation to start
313271 tryCompare(stage, "usingScreenshots", true)
314272
315273 compare(newAppScreenshot.withBackground, false, "switched app does have background enabled")
316274
317− tryCompareFunction(isShowingABitOfNewApp, true); // wait for the hint animation to finish
318− touchRelease(stage, draggingAreaCenterX, draggingAreaCenterY)
275+ touchRelease(stage, finalTouchX, draggingAreaCenterY)
319276 }
320277 }
321278}