on xenial help sign in
make the side stage stuff working properly again. might need some animation tweaking still
commit90536142cabb1a2b0df393199005954f7b08962b authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 29 Aug 2016, 17:29 (10 years ago) parent582ddf5
3 files changed+58−24
qml/Stage/Spread/StagedRightEdgeMaths.qml+28−15 qml/Stage/Stage.qml+28−7 qml/Stage/StageMaths.qml+2−2
qml/Stage/Spread/StagedRightEdgeMaths.qml+28−15
@@ -30,7 +30,7 @@ QtObject {
3030// onProgressChanged: if (itemIndex == 0) { print("progress", progress) }
3131
3232 // Config
33− property real breakPoint: 0.4
33+ property real breakPoint: units.gu(15) / sceneWidth
3434 property int tileDistance: units.gu(10)
3535
3636 // Output
@@ -46,40 +46,43 @@ QtObject {
4646 return progress < breakPoint ? root.sceneHeight : MathUtils.linearAnimation(breakPoint, 1, root.sceneHeight, targetHeight, progress)
4747 }
4848
49− readonly property var nextStage: appRepeater.itemAt(nextInStack) ? appRepeater.itemAt(nextInStack).stage : ApplicationInfoInterface.MainStage;
5049
5150 readonly property int animatedX: {
52− var stageCount = (priv.mainStageDelegate ? 1 : 0) + (priv.sideStageDelegate ? 1 : 0)
53−
54−// var nextStage = ApplicationInfoInterface.MainStage;
55−// if (topLevelSurfaceList.count > nextInStack) {
56−// nextStage = appRepeater.itemAt(nextInStack).stage;
57−// }
51+ var nextStage = appRepeater.itemAt(nextInStack) ? appRepeater.itemAt(nextInStack).stage : ApplicationInfoInterface.MainStage;
5852
5953 if (model.application.appId == "unity8-dash") {
60− print("calculating X for dash:", itemIndex, nextInStack)
54+ print("calculating X for dash:", itemIndex, nextInStack, nextStage, "(Main:", ApplicationInfoInterface.MainStage,")", appRepeater.itemAt(nextInStack).stage)
6155 }
6256
6357 var startX = 0;
6458 if (isMainStageApp) {
6559 if (progress < breakPoint) {
66− return MathUtils.linearAnimation(0, breakPoint, 0, -units.gu(4), progress);
60+ if (nextStage == ApplicationInfoInterface.MainStage) {
61+ return MathUtils.linearAnimation(0, breakPoint, 0, -units.gu(4), progress);
62+ } else {
63+ return 0;
64+ }
6765 } else {
68− return MathUtils.linearAnimation(breakPoint, 1, -units.gu(4), targetX, progress);
66+ if (nextStage == ApplicationInfoInterface.MainStage) {
67+ return MathUtils.linearAnimation(breakPoint, 1, -units.gu(4), targetX, progress);
68+ } else {
69+ return MathUtils.linearAnimation(breakPoint, 1, 0, targetX, progress);
70+ }
6971 }
7072 } else if (isSideStageApp) {
7173 startX = sceneWidth - sideStageWidth;
7274 } else if (itemIndex == nextInStack && itemIndex <= 2 && priv.sideStageDelegate && nextStage == ApplicationInfoInterface.MainStage) {
7375 startX = sceneWidth - sideStageWidth;
7476 } else {
77+ var stageCount = (priv.mainStageDelegate ? 1 : 0) + (priv.sideStageDelegate ? 1 : 0)
7578 startX = sceneWidth + Math.max(0, itemIndex - stageCount - 1) * tileDistance;
7679 }
7780
7881 if (itemIndex == nextInStack) {
7982 if (progress < breakPoint) {
80− return MathUtils.linearAnimation(0, breakPoint, startX, sceneWidth / 2, progress)
83+ return MathUtils.linearAnimation(0, breakPoint, startX, startX - units.gu(15), progress)
8184 }
82− return MathUtils.linearAnimation(breakPoint, 1, sceneWidth / 2, targetX, progress)
85+ return MathUtils.linearAnimation(breakPoint, 1, startX - units.gu(15), targetX, progress)
8386 }
8487
8588 if (progress < breakPoint) {
@@ -92,7 +95,12 @@ QtObject {
9295
9396 readonly property int animatedY: progress < breakPoint ? startY : MathUtils.linearAnimation(breakPoint, 1, startY, targetY, progress)
9497
95− readonly property int animatedZ: shuffledZ
98+ readonly property int animatedZ: {
99+ if (progress < breakPoint + (1 - breakPoint) / 2) {
100+ return shuffledZ
101+ }
102+ return itemIndex;
103+ }
96104
97105 readonly property real animatedAngle: {
98106 var startAngle = 0;
@@ -104,6 +112,8 @@ QtObject {
104112 startAngle = root.startAngle;
105113 }
106114
115+ var nextStage = appRepeater.itemAt(nextInStack) ? appRepeater.itemAt(nextInStack).stage : ApplicationInfoInterface.MainStage;
116+
107117 if (progress < breakPoint) {
108118 if (stage == nextStage) {
109119 return MathUtils.linearAnimation(0, 1, startAngle, targetAngle, progress);
@@ -111,7 +121,10 @@ QtObject {
111121 return 0;
112122 }
113123 }
114− return MathUtils.linearAnimation(0, 1, startAngle, targetAngle, progress);
124+ if (itemIndex == nextInStack || (stage == nextStage && (isMainStageApp || isSideStageApp))) {
125+ return MathUtils.linearAnimation(0, 1, startAngle, targetAngle, progress);
126+ }
127+ return MathUtils.linearAnimation(breakPoint, 1, startAngle, targetAngle, progress);
115128 }
116129
117130 readonly property real animatedScale: {
qml/Stage/Stage.qml+28−7
@@ -218,7 +218,21 @@ AbstractStage {
218218 print("*** updated! MainStage:", priv.mainStageAppId, "SideStage:", priv.sideStageAppId)
219219 }
220220
221− property int nextInStack: 1
221+ property int nextInStack: {
222+ var mainStageIndex = priv.mainStageDelegate ? priv.mainStageDelegate.itemIndex : -1;
223+ var sideStageIndex = priv.sideStageDelegate ? priv.sideStageDelegate.itemIndex : -1;
224+// print("calculating nextInStack:", mainStageIndex, sideStageIndex, priv.mainStageDelegate.itemIndex, priv.sideStageDelegate.itemIndex)
225+ if (sideStageIndex == -1) {
226+ return topLevelSurfaceList.count > 1 ? 1 : -1;
227+ }
228+ if (mainStageIndex == 0 || sideStageIndex == 0) {
229+ if (mainStageIndex == 1 || sideStageIndex == 1) {
230+ return 2;
231+ }
232+ return 1;
233+ }
234+ return -1;
235+ }
222236
223237 readonly property real virtualKeyboardHeight: SurfaceManager.inputMethodSurface
224238 ? SurfaceManager.inputMethodSurface.inputBounds.height
@@ -311,7 +325,7 @@ AbstractStage {
311325 },
312326 State {
313327 name: "sideStagedRightEdge"; when: rightEdgeDragArea.dragging && root.mode == "stagedWithSideStage"
314− PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
328+// PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
315329 },
316330 State {
317331 name: "windowedRightEdge"; when: rightEdgeDragArea.dragging && root.mode == "windowed"
@@ -322,7 +336,7 @@ AbstractStage {
322336 State {
323337 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
324338 PropertyChanges { target: triGestureArea; enabled: true }
325− PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
339+// PropertyChanges { target: priv; nextInStack: priv.sideStageDelegate && priv.sideStageDelegate.itemIndex < 2 ? 2 : 1 }
326340 PropertyChanges { target: sideStage; visible: true }
327341 },
328342 State {
@@ -430,7 +444,6 @@ AbstractStage {
430444 return 2;
431445 }
432446
433−
434447 onShownChanged: {
435448 print("sidestage shown changed:", shown)
436449 if (!shown && priv.mainStageDelegate) {
@@ -499,6 +512,8 @@ AbstractStage {
499512 }
500513 }
501514 z: normalZ
515+ onZChanged: print("app", model.application.appId, "z changed to:", z)
516+
502517
503518 // Normally we want x/y where we request it to be. Width/height of our delegate will
504519 // match what the actual surface size is.
@@ -1411,7 +1426,7 @@ AbstractStage {
14111426 gesturePoints = [];
14121427 } else {
14131428 // Ok. The user released. Did he drag far enough to go to full spread?
1414− if (gesturePoints[gesturePoints.length - 1] < -root.width * 0.4 ) {
1429+ if (gesturePoints[gesturePoints.length - 1] < -units.gu(15) ) {
14151430 print("gone to spread true")
14161431 priv.goneToSpread = true;
14171432 } else {
@@ -1427,8 +1442,14 @@ AbstractStage {
14271442 }
14281443
14291444 if (appRepeater.count > 1 &&
1430− (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > root.width * .3)) {
1431− appRepeater.itemAt(0).playHidingAnimation()
1445+ (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > units.gu(15))) {
1446+ var nextStage = appRepeater.itemAt(priv.nextInStack).stage
1447+ for (var i = 0; i < appRepeater.count; i++) {
1448+ if (appRepeater.itemAt(i).stage == nextStage) {
1449+ appRepeater.itemAt(i).playHidingAnimation()
1450+ break;
1451+ }
1452+ }
14321453 appRepeater.itemAt(priv.nextInStack).playFocusAnimation()
14331454 } else {
14341455 appRepeater.itemAt(0).playFocusAnimation();
qml/Stage/StageMaths.qml+2−2
@@ -25,7 +25,7 @@ QtObject {
2525 // We don't want to really reorder them in the model because that allows us to keep track
2626 // of the last focused order.
2727 readonly property int itemZ: {
28− // only shuffle when we've got a main and overlay
28+ // only shuffle when we've got a main and side stage
2929 if (!sideStageDelegate) return itemIndex;
3030
3131 // don't shuffle indexes greater than "actives or next"
@@ -36,8 +36,8 @@ QtObject {
3636 return 0;
3737 }
3838
39+ print("App:", model.application.appId, "index:", itemIndex, "nextInStack:", nextInStack)
3940 if (nextInStack > 0) {
40− print("App:", model.application.appId, "index:", itemIndex, "nextInStack:", nextInStack)
4141 var stageOfNextInStack = topLevelSurfaceList.applicationAt(nextInStack).stage;
4242
4343 if (itemIndex === nextInStack) {