@@ -5,6 +5,8 @@ import Ubuntu.Components 0.1
5SpreadDelegate {
5SpreadDelegate {
8+ property bool selected: false
8 property real progress: 0
10 property real progress: 0
9 property real animatedProgress: 0
11 property real animatedProgress: 0
@@ -18,20 +20,16 @@ SpreadDelegate {
18 property real startDistance: units.gu(5)
20 property real startDistance: units.gu(5)
19 property real endDistance: units.gu(.5)
21 property real endDistance: units.gu(.5)
21− onClicked: {
23+ onSelectedChanged: {
22− priv.selectedProgress = root.progress
25+ priv.selectedProgress = root.progress
23− priv.selectedXTranslate = priv.xTranslate;
26+ priv.selectedXTranslate = priv.xTranslate;
24− priv.selectedAngle = priv.angle;
27+ priv.selectedAngle = priv.angle;
25− priv.selectedScale = priv.scale;
28+ priv.selectedScale = priv.scale;
26− priv.isSelected = true;
29+ priv.isSelected = true;
27− }
30+ print("tile", index, "selected!!!!!!!!!!!!!!!!")
33− priv.isSelected = false;
32+ priv.isSelected = false;
@@ -44,12 +42,10 @@ SpreadDelegate {
44 property real selectedScale
42 property real selectedScale
46 property real negativeProgress: {
44 property real negativeProgress: {
47− if (index == 0) {
45+ if (index < 2) {
48− return spreadView.positionMarker2;
46+ return 0;
49− } else if (index == 1) {
50− return spreadView.positionMarker2 - (spreadView.tileDistance / spreadView.width);
52− return -(index - 2) * (spreadView.tileDistance / spreadView.width);
48+ return -spreadView.positionMarker2 -(index - 2) * (spreadView.tileDistance / spreadView.width);
55 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
51 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
@@ -67,6 +63,7 @@ SpreadDelegate {
67 var translation = 0;
63 var translation = 0;
68 switch (index) {
64 switch (index) {
66+ print("+++++++++++++++++++++++++++", spreadView.stage, priv.isSelected)
70 if (spreadView.stage == 0) {
67 if (spreadView.stage == 0) {
71 translation = linearAnimation(0, spreadView.positionMarker2, 0, -spreadView.width * .25, root.animatedProgress)
68 translation = linearAnimation(0, spreadView.positionMarker2, 0, -spreadView.width * .25, root.animatedProgress)
@@ -75,22 +72,22 @@ SpreadDelegate {
75 var targetTranslate = easingAnimation(0, spreadView.positionMarker4, 0, -spreadView.width, spreadView.positionMarker4) + spreadView.width
72 var targetTranslate = easingAnimation(0, spreadView.positionMarker4, 0, -spreadView.width, spreadView.positionMarker4) + spreadView.width
76 translation = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, -spreadView.width * .25, targetTranslate, root.progress)
73 translation = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, -spreadView.width * .25, targetTranslate, root.progress)
78− } else if (!isSelected){ // Stage 2
75+ } else if (!priv.isSelected){ // Stage 2
79 // Move the first tile a bit to the right to be aligned with the others
76 // Move the first tile a bit to the right to be aligned with the others
80 translation += spreadView.width
77 translation += spreadView.width
81 // apply the same animation as with the rest
78 // apply the same animation as with the rest
82 translation += -easingCurve.value * spreadView.width
79 translation += -easingCurve.value * spreadView.width
84− } else if (isSelected) {
81+ } else if (priv.isSelected) {
85 translation = linearAnimation(selectedProgress, negativeProgress, selectedXTranslate, 0, root.progress)
82 translation = linearAnimation(selectedProgress, negativeProgress, selectedXTranslate, 0, root.progress)
90− if (spreadView.stage == 0) {
87+ if (spreadView.stage == 0 && !priv.isSelected) {
91 translation = linearAnimation(0, spreadView.positionMarker2, 0, -spreadView.width * spreadView.snapPosition, root.animatedProgress)
88 translation = linearAnimation(0, spreadView.positionMarker2, 0, -spreadView.width * spreadView.snapPosition, root.animatedProgress)
93− } else if (spreadView.stage == 1) {
90+ } else if (spreadView.stage == 1 && !priv.isSelected) {
94 // find where the main easing would be when reaching stage 2
91 // find where the main easing would be when reaching stage 2
95 var stage2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
92 var stage2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
96 targetTranslate = easingAnimation(0, stage2Progress, 0, -spreadView.width + root.endDistance, stage2Progress);
93 targetTranslate = easingAnimation(0, stage2Progress, 0, -spreadView.width + root.endDistance, stage2Progress);
@@ -106,9 +103,10 @@ SpreadDelegate {
106 translation += -((index - 1) * root.startDistance)
103 translation += -((index - 1) * root.startDistance)
107 // ...and use our easing to move them to the left. Stop a bit earlier for each tile
104 // ...and use our easing to move them to the left. Stop a bit earlier for each tile
108 translation += -easingCurve.value * spreadView.width + (index * root.endDistance)
105 translation += -easingCurve.value * spreadView.width + (index * root.endDistance)
109− if (isSelected) {
106+ if (priv.isSelected) {
110 // Distance to left edge
107 // Distance to left edge
111 var targetTranslate = -spreadView.width - ((index - 1) * root.startDistance)
108 var targetTranslate = -spreadView.width - ((index - 1) * root.startDistance)
109+ print("selectedProgress:", selectedProgress, "negativeProgress:", negativeProgress, "progress", root.progress)
112 translation = linearAnimation(selectedProgress, negativeProgress, selectedXTranslate, targetTranslate, root.progress)
110 translation = linearAnimation(selectedProgress, negativeProgress, selectedXTranslate, targetTranslate, root.progress)
@@ -126,10 +124,10 @@ SpreadDelegate {
129− if (spreadView.stage == 0) {
127+ if (spreadView.stage == 0 && !priv.isSelected) {
130 newAngle = linearAnimation(0, spreadView.positionMarker2, root.startAngle, root.startAngle * (1-spreadView.snapPosition), root.animatedProgress)
128 newAngle = linearAnimation(0, spreadView.positionMarker2, root.startAngle, root.startAngle * (1-spreadView.snapPosition), root.animatedProgress)
132− } else if (spreadView.stage == 1) {
130+ } else if (spreadView.stage == 1 && !priv.isSelected) {
133 // find where the main easing would be when reaching stage 2
131 // find where the main easing would be when reaching stage 2
134 var stage2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
132 var stage2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
135 var targetAngle = easingAnimation(0, stage2Progress, root.startAngle, root.endAngle, stage2Progress)
133 var targetAngle = easingAnimation(0, stage2Progress, root.startAngle, root.endAngle, stage2Progress)
@@ -139,7 +137,7 @@ SpreadDelegate {
141 newAngle = root.startAngle - easingCurve.value * (root.startAngle - root.endAngle)
139 newAngle = root.startAngle - easingCurve.value * (root.startAngle - root.endAngle)
142− if (isSelected) {
140+ if (priv.isSelected) {
143 newAngle = linearAnimation(selectedProgress, negativeProgress, selectedAngle, 0, root.progress)
141 newAngle = linearAnimation(selectedProgress, negativeProgress, selectedAngle, 0, root.progress)
@@ -158,10 +156,10 @@ SpreadDelegate {
161− if (spreadView.stage == 0) {
159+ if (spreadView.stage == 0 && !priv.isSelected) {
162 newScale = linearAnimation(0, spreadView.positionMarker2, root.tile1StartScale, 1, root.animatedProgress)
160 newScale = linearAnimation(0, spreadView.positionMarker2, root.tile1StartScale, 1, root.animatedProgress)
164− } else if (spreadView.stage == 1) {
162+ } else if (spreadView.stage == 1 && !priv.isSelected) {
165 // find where the main easing would be when reaching positionMarker4
163 // find where the main easing would be when reaching positionMarker4
166 var targetScale = easingAnimation(0, spreadView.positionMarker4, root.startScale, root.endScale, spreadView.positionMarker4);
164 var targetScale = easingAnimation(0, spreadView.positionMarker4, root.startScale, root.endScale, spreadView.positionMarker4);
167 newScale = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, 1, targetScale, root.progress)
165 newScale = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, 1, targetScale, root.progress)
@@ -170,7 +168,7 @@ SpreadDelegate {
172 newScale = root.startScale - easingCurve.value * (root.startScale - root.endScale)
170 newScale = root.startScale - easingCurve.value * (root.startScale - root.endScale)
173− if (isSelected) {
171+ if (priv.isSelected) {
174 newScale = linearAnimation(selectedProgress, negativeProgress, selectedScale, 1, root.progress)
172 newScale = linearAnimation(selectedProgress, negativeProgress, selectedScale, 1, root.progress)