@@ -1,5 +1,6 @@
11import QtQuick 2.4
22import Ubuntu.Components 1.3
3+import Unity.Application 0.1
34import "MathUtils.js" as MathUtils
45
56QtObject {
@@ -9,6 +10,7 @@ QtObject {
910 property int itemIndex: 0
1011 property real progress: 0
1112 property int sceneWidth: 0
13+ property int sideStageWidth: 0
1214 property int sceneHeight: 0
1315 property int targetX: 0
1416 property int startY: 0
@@ -19,14 +21,17 @@ QtObject {
1921 property real startScale: 1.3
2022 property real targetScale: 0
2123
22− onProgressChanged: if (itemIndex == 0) { print("progress", progress) }
24+ property bool isMainStageApp: false
25+ property bool isSideStageApp: false
26+ property int nextInStack: 0
27+
28+
29+// onProgressChanged: if (itemIndex == 0) { print("progress", progress) }
2330
2431 // Config
2532 property real breakPoint: 0.4
2633 property int tileDistance: units.gu(10)
2734
28−
29−
3035 // Output
3136
3237 readonly property real scaleToPreviewProgress: {
@@ -42,29 +47,71 @@ QtObject {
4247 }
4348
4449 readonly property int animatedX: {
45− if (itemIndex == 0) {
46− return root.targetX * root.progress
50+ var stageCount = (priv.mainStageDelegate ? 1 : 0) + (priv.sideStageDelegate ? 1 : 0)
51+ var nextStage = appRepeater.itemAt(nextInStack).stage;
52+
53+ var startX = 0;
54+ if (isMainStageApp) {
55+ startX = 0;
56+ } else if (isSideStageApp) {
57+ startX = sceneWidth - sideStageWidth;
58+ } else if (itemIndex == nextInStack && itemIndex < 2 && priv.sideStageDelegate && nextStage == ApplicationInfoInterface.MainStage) {
59+ startX = sceneWidth - sideStageWidth;
60+ } else {
61+ startX = sceneWidth + Math.max(0, itemIndex - stageCount - 1) * tileDistance;
4762 }
48− var startX = sceneWidth //+ (itemIndex - 1) * tileDistance
49− if (itemIndex == 1) {
50− if (root.progress < breakPoint) {
51− return MathUtils.linearAnimation(0, breakPoint, startX, startX / 2 + (itemIndex - 1) * tileDistance, progress)
63+
64+ if (itemIndex == nextInStack) {
65+ if (progress < breakPoint) {
66+ return MathUtils.linearAnimation(0, breakPoint, startX, sceneWidth / 2, progress)
5267 }
53− return MathUtils.linearAnimation(breakPoint, 1, startX / 2 + (itemIndex - 1) * tileDistance, targetX, progress)
68+ return MathUtils.linearAnimation(breakPoint, 1, sceneWidth / 2, targetX, progress)
5469 }
70+
5571 if (progress < breakPoint) {
56− return startX
72+ return startX;
5773 }
58− return MathUtils.linearAnimation(breakPoint, 1, startX + (itemIndex - 1) * tileDistance, targetX, progress)
74+
75+ return MathUtils.linearAnimation(breakPoint, 1, startX, targetX, progress)
76+
5977 }
6078
6179 readonly property int animatedY: progress < breakPoint ? startY : MathUtils.linearAnimation(breakPoint, 1, startY, targetY, progress)
6280
63− readonly property real animatedAngle: itemIndex == 0 ? MathUtils.linearAnimation(0, 1, 0, targetAngle, progress)
64− : Math.max(MathUtils.linearAnimation(0, breakPoint, startAngle, targetAngle, progress), targetAngle)
81+ readonly property real animatedAngle: {
82+ var startAngle = 0;
83+ if (isMainStageApp) {
84+ startAngle = 0;
85+ } else if (isSideStageApp) {
86+ startAngle = 0;
87+ } else {
88+ startAngle = root.startAngle;
89+ }
6590
66− readonly property real animatedScale: itemIndex == 0 ? MathUtils.linearAnimation(0, 1, 1, targetScale, progress)
67− : MathUtils.linearAnimation(0, 1, startScale, targetScale, progress)
91+ return MathUtils.linearAnimation(0, 1, startAngle, targetAngle, progress);
92+ }
93+
94+ readonly property real animatedScale: {
95+ var startScale = 1;
96+ if (isMainStageApp) {
97+ startScale = 1;
98+ } else if (isSideStageApp) {
99+ startScale = 1;
100+ } else {
101+ startScale = root.startScale;
102+ }
103+
104+// print("main stage delegate:", priv.mainStageDelegate, "side delegate", priv.sideStageDelegate, "this", appDelegate, "scale:", startScale)
105+// return startScale;
106+ if (itemIndex == nextInStack) {
107+ return MathUtils.linearAnimation(0, 1, startScale, targetScale, progress)
108+ }
109+ if (progress < breakPoint) {
110+ return startScale;
111+ }
112+
113+ return MathUtils.linearAnimation(breakPoint, 1, startScale, targetScale, progress)
114+ }
68115
69116 readonly property bool itemVisible: true //animatedX < sceneWidth
70117}