on xenial help sign in
improve the right edge gesture
commit9633901cb365fb96dc1e3955c8d094b7c0684a01 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 30 Aug 2016, 18:38 (10 years ago) parent9a152f1
3 files changed+43−10
qml/Stage/Spread/Spread.qml+1 qml/Stage/Spread/StagedRightEdgeMaths.qml+3−5 qml/Stage/Stage.qml+39−5
qml/Stage/Spread/Spread.qml+1
@@ -20,6 +20,7 @@ Item {
2020 property real rightRotationAngle: 32
2121 property real leftStackScale: .82
2222 property real rightStackScale: 1
23+ property real rightEdgeBreakPoint: Math.min(units.gu(40) / root.width, .35)
2324
2425 signal leaveSpread()
2526
qml/Stage/Spread/StagedRightEdgeMaths.qml+3−5
@@ -20,6 +20,7 @@ QtObject {
2020 property int targetHeight: 0
2121 property real startScale: 1.3
2222 property real targetScale: 0
23+ property real breakPoint: units.gu(15) / sceneWidth
2324
2425 property bool isMainStageApp: false
2526 property bool isSideStageApp: false
@@ -27,10 +28,7 @@ QtObject {
2728 property int shuffledZ: 0
2829
2930
30−// onProgressChanged: if (itemIndex == 0) { print("progress", progress) }
31−
3231 // Config
33− property real breakPoint: units.gu(15) / sceneWidth
3432 property int tileDistance: units.gu(10)
3533
3634 // Output
@@ -76,9 +74,9 @@ QtObject {
7674
7775 if (itemIndex == nextInStack) {
7876 if (progress < breakPoint) {
79− return MathUtils.linearAnimation(0, breakPoint, startX, startX - units.gu(15), progress)
77+ return MathUtils.linearAnimation(0, breakPoint, startX, startX * (1 - breakPoint), progress)
8078 }
81− return MathUtils.linearAnimation(breakPoint, 1, startX - units.gu(15), targetX, progress)
79+ return MathUtils.linearAnimation(breakPoint, 1, startX * (1 - breakPoint), targetX, progress)
8280 }
8381
8482 if (progress < breakPoint) {
qml/Stage/Stage.qml+39−5
@@ -857,6 +857,7 @@ AbstractStage {
857857 targetAngle: spreadMaths.targetAngle
858858 targetScale: spreadMaths.targetScale
859859 shuffledZ: stageMaths.itemZ
860+ breakPoint: spreadItem.rightEdgeBreakPoint
860861 }
861862
862863 WindowedRightEdgeMaths {
@@ -870,6 +871,7 @@ AbstractStage {
870871 normalZ: appDelegate.normalZ
871872 targetAngle: spreadMaths.targetAngle
872873 targetScale: spreadMaths.targetScale
874+ breakPoint: spreadItem.rightEdgeBreakPoint
873875 }
874876
875877 states: [
@@ -1206,6 +1208,17 @@ AbstractStage {
12061208 }
12071209 }
12081210 }
1211+ },
1212+ Transition {
1213+ from: "stagedRightEdge"; to: "staged"
1214+ SequentialAnimation {
1215+ ParallelAnimation {
1216+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,height,width,scale"; duration: priv.animationDuration }
1217+ UbuntuNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1218+ }
1219+ // // We need to release scaleToPreviewSize at last
1220+ PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1221+ }
12091222 }
12101223
12111224 ]
@@ -1412,6 +1425,9 @@ AbstractStage {
14121425
14131426 onTouchPositionChanged: {
14141427 gesturePoints.push(touchPosition.x);
1428+ if (gesturePoints.length > 10) {
1429+ gesturePoints.splice(0, gesturePoints.length - 10)
1430+ }
14151431 }
14161432
14171433 onDraggingChanged: {
@@ -1421,11 +1437,29 @@ AbstractStage {
14211437 gesturePoints = [];
14221438 } else {
14231439 // Ok. The user released. Did he drag far enough to go to full spread?
1424− if (gesturePoints[gesturePoints.length - 1] < -units.gu(15) ) {
1425− print("gone to spread true")
1426− priv.goneToSpread = true;
1440+ if (gesturePoints[gesturePoints.length - 1] < -spreadItem.rightEdgeBreakPoint * spreadItem.width ) {
1441+
1442+ // He dragged far enough, but if the last movement was a flick to the right again, he wants to cancel the spread again.
1443+ var oneWayFlickToRight = true;
1444+ var smallestX = gesturePoints[0]-1;
1445+ for (var i = 0; i < gesturePoints.length; i++) {
1446+ print("have point:", gesturePoints[i])
1447+ if (gesturePoints[i] <= smallestX) {
1448+ oneWayFlickToRight = false;
1449+ break;
1450+ }
1451+ smallestX = gesturePoints[i];
1452+ }
1453+
1454+ if (!oneWayFlickToRight) {
1455+ // Ok, the user made it, let's go to spread!
1456+ priv.goneToSpread = true;
1457+// } else {
1458+// appRepeater.itemAt(0).playFocusAnimation();
1459+ }
14271460 } else {
1428− // Find out if it was a one-way movement.
1461+ // Ok, the user didn't drag far enough to cross the breakPoint
1462+ // Find out if it was a one-way movement to the left, in which case we just switch directly to next app.
14291463 var oneWayFlick = true;
14301464 var smallestX = rightEdgeDragArea.width;
14311465 for (var i = 0; i < gesturePoints.length; i++) {
@@ -1437,7 +1471,7 @@ AbstractStage {
14371471 }
14381472
14391473 if (appRepeater.count > 1 &&
1440− (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > units.gu(15))) {
1474+ (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > spreadItem.rightEdgeBreakPoint * spreadItem.width)) {
14411475 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
14421476 for (var i = 0; i < appRepeater.count; i++) {
14431477 if (appRepeater.itemAt(i).stage == nextStage) {