on xenial help sign in
improve the right edge gesture
9633901Michael Zanetti
qml/Stage/Spread/Spread.qml+1
@@ -20,6 +20,7 @@ Item {
20 property real rightRotationAngle: 32
20 property real rightRotationAngle: 32
21 property real leftStackScale: .82
21 property real leftStackScale: .82
22 property real rightStackScale: 1
22 property real rightStackScale: 1
23+ property real rightEdgeBreakPoint: Math.min(units.gu(40) / root.width, .35)
23
24
24 signal leaveSpread()
25 signal leaveSpread()
25
26
qml/Stage/Spread/StagedRightEdgeMaths.qml+3−5
@@ -20,6 +20,7 @@ QtObject {
20 property int targetHeight: 0
20 property int targetHeight: 0
21 property real startScale: 1.3
21 property real startScale: 1.3
22 property real targetScale: 0
22 property real targetScale: 0
23+ property real breakPoint: units.gu(15) / sceneWidth
23
24
24 property bool isMainStageApp: false
25 property bool isMainStageApp: false
25 property bool isSideStageApp: false
26 property bool isSideStageApp: false
@@ -27,10 +28,7 @@ QtObject {
27 property int shuffledZ: 0
28 property int shuffledZ: 0
28
29
29
30
30−// onProgressChanged: if (itemIndex == 0) { print("progress", progress) }
31−
32 // Config
31 // Config
33− property real breakPoint: units.gu(15) / sceneWidth
34 property int tileDistance: units.gu(10)
32 property int tileDistance: units.gu(10)
35
33
36 // Output
34 // Output
@@ -76,9 +74,9 @@ QtObject {
76
74
77 if (itemIndex == nextInStack) {
75 if (itemIndex == nextInStack) {
78 if (progress < breakPoint) {
76 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)
80 }
78 }
81− return MathUtils.linearAnimation(breakPoint, 1, startX - units.gu(15), targetX, progress)
79+ return MathUtils.linearAnimation(breakPoint, 1, startX * (1 - breakPoint), targetX, progress)
82 }
80 }
83
81
84 if (progress < breakPoint) {
82 if (progress < breakPoint) {
qml/Stage/Stage.qml+39−5
@@ -857,6 +857,7 @@ AbstractStage {
857 targetAngle: spreadMaths.targetAngle
857 targetAngle: spreadMaths.targetAngle
858 targetScale: spreadMaths.targetScale
858 targetScale: spreadMaths.targetScale
859 shuffledZ: stageMaths.itemZ
859 shuffledZ: stageMaths.itemZ
860+ breakPoint: spreadItem.rightEdgeBreakPoint
860 }
861 }
861
862
862 WindowedRightEdgeMaths {
863 WindowedRightEdgeMaths {
@@ -870,6 +871,7 @@ AbstractStage {
870 normalZ: appDelegate.normalZ
871 normalZ: appDelegate.normalZ
871 targetAngle: spreadMaths.targetAngle
872 targetAngle: spreadMaths.targetAngle
872 targetScale: spreadMaths.targetScale
873 targetScale: spreadMaths.targetScale
874+ breakPoint: spreadItem.rightEdgeBreakPoint
873 }
875 }
874
876
875 states: [
877 states: [
@@ -1206,6 +1208,17 @@ AbstractStage {
1206 }
1208 }
1207 }
1209 }
1208 }
1210 }
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+ }
1209 }
1222 }
1210
1223
1211 ]
1224 ]
@@ -1412,6 +1425,9 @@ AbstractStage {
1412
1425
1413 onTouchPositionChanged: {
1426 onTouchPositionChanged: {
1414 gesturePoints.push(touchPosition.x);
1427 gesturePoints.push(touchPosition.x);
1428+ if (gesturePoints.length > 10) {
1429+ gesturePoints.splice(0, gesturePoints.length - 10)
1430+ }
1415 }
1431 }
1416
1432
1417 onDraggingChanged: {
1433 onDraggingChanged: {
@@ -1421,11 +1437,29 @@ AbstractStage {
1421 gesturePoints = [];
1437 gesturePoints = [];
1422 } else {
1438 } else {
1423 // Ok. The user released. Did he drag far enough to go to full spread?
1439 // Ok. The user released. Did he drag far enough to go to full spread?
1424− if (gesturePoints[gesturePoints.length - 1] < -units.gu(15) ) {
1440+ if (gesturePoints[gesturePoints.length - 1] < -spreadItem.rightEdgeBreakPoint * spreadItem.width ) {
1425− print("gone to spread true")
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!
1426− priv.goneToSpread = true;
1456+ priv.goneToSpread = true;
1457+// } else {
1458+// appRepeater.itemAt(0).playFocusAnimation();
1459+ }
1427 } else {
1460 } else {
1461+ // Ok, the user didn't drag far enough to cross the breakPoint
1428− // Find out if it was a one-way movement.
1462+ // Find out if it was a one-way movement to the left, in which case we just switch directly to next app.
1429 var oneWayFlick = true;
1463 var oneWayFlick = true;
1430 var smallestX = rightEdgeDragArea.width;
1464 var smallestX = rightEdgeDragArea.width;
1431 for (var i = 0; i < gesturePoints.length; i++) {
1465 for (var i = 0; i < gesturePoints.length; i++) {
@@ -1437,7 +1471,7 @@ AbstractStage {
1437 }
1471 }
1438
1472
1439 if (appRepeater.count > 1 &&
1473 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)) {
1441 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
1475 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
1442 for (var i = 0; i < appRepeater.count; i++) {
1476 for (var i = 0; i < appRepeater.count; i++) {
1443 if (appRepeater.itemAt(i).stage == nextStage) {
1477 if (appRepeater.itemAt(i).stage == nextStage) {