on xenial help sign in
rename stage to phase to avoid the obvious naming collision
commit3856e15ca2ce7e012b75ec7f1af7f18f80e7b40a authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 19 Mar 2014, 18:08 (13 years ago) parent3f99a87
2 files changed+65−65
qml/Stages/PhoneStage.qml+19−19 qml/Stages/TransformedSpreadDelegate.qml+46−46
qml/Stages/PhoneStage.qml+19−19
@@ -74,7 +74,7 @@ Item {
7474 }
7575 } else {
7676 spreadView.selectedIndex = -1;
77− spreadView.stage = 0;
77+ spreadView.phase = 0;
7878 spreadView.contentX = -spreadView.shift;
7979 }
8080 }
@@ -240,7 +240,7 @@ Item {
240240 EdgeDragArea {
241241 id: spreadDragArea
242242 direction: Direction.Leftwards
243− enabled: ApplicationManager.count > 1 && spreadView.stage != 2
243+ enabled: ApplicationManager.count > 1 && spreadView.phase != 2
244244
245245 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
246246 width: root.dragAreaWidth
@@ -256,7 +256,7 @@ Item {
256256 if (!dragging && !priv.waitingForScreenshot) {
257257 // Initial touch. Let's update the screenshot and reset the spreadView to the starting position.
258258 priv.requestNewScreenshot();
259− spreadView.stage = 0;
259+ spreadView.phase = 0;
260260 spreadView.contentX = -spreadView.shift;
261261 }
262262 if (dragging && attachedToView) {
@@ -323,7 +323,7 @@ Item {
323323 id: spreadView
324324 objectName: "spreadView"
325325 anchors.fill: parent
326− visible: spreadDragArea.status == DirectionalDragArea.Recognized || stage > 1 || snapAnimation.running
326+ visible: spreadDragArea.status == DirectionalDragArea.Recognized || phase > 1 || snapAnimation.running
327327 contentWidth: spreadRow.width - shift
328328 contentX: -shift
329329
@@ -350,26 +350,26 @@ Item {
350350 // This is where the first app snaps to when bringing it in from the right edge.
351351 property real snapPosition: 0.75
352352
353− // Stage of the animation:
353+ // Phase of the animation:
354354 // 0: Starting from right edge, a new app (index 1) comes in from the right
355355 // 1: The app has reached the first snap position.
356− // 2: The list is dragged further and snaps into the spread view when entering stage 2
357− property int stage: 0
356+ // 2: The list is dragged further and snaps into the spread view when entering phase 2
357+ property int phase: 0
358358
359359 property int selectedIndex: -1
360360
361361 onShiftedContentXChanged: {
362− switch (stage) {
362+ switch (phase) {
363363 case 0:
364364 if (shiftedContentX > width * positionMarker2) {
365− stage = 1;
365+ phase = 1;
366366 }
367367 break;
368368 case 1:
369369 if (shiftedContentX < width * positionMarker2) {
370− stage = 0;
370+ phase = 0;
371371 } else if (shiftedContentX >= width * positionMarker4) {
372− stage = 2;
372+ phase = 2;
373373 }
374374 }
375375 }
@@ -382,7 +382,7 @@ Item {
382382 snapTo(1)
383383 } else if (shiftedContentX < positionMarker3 * width) {
384384 snapTo(1)
385− } else if (stage < 2){
385+ } else if (phase < 2){
386386 // Add 1 pixel to make sure we definitely hit positionMarker4 even with rounding errors of the animation.
387387 snapAnimation.targetContentX = width * positionMarker4 + 1 - shift;
388388 snapAnimation.start();
@@ -411,12 +411,12 @@ Item {
411411 if (spreadView.selectedIndex >= 0) {
412412 ApplicationManager.focusApplication(ApplicationManager.get(spreadView.selectedIndex).appId);
413413 spreadView.selectedIndex = -1
414− spreadView.stage = 0;
414+ spreadView.phase = 0;
415415 spreadView.contentX = -spreadView.shift;
416416 }
417417 if (spreadView.shiftedContentX == spreadView.width * spreadView.positionMarker2) {
418− spreadView.stage = 4;
419− spreadView.stage = 0;
418+ spreadView.phase = 4;
419+ spreadView.phase = 0;
420420 spreadView.contentX = -spreadView.shift;
421421 }
422422 }
@@ -454,15 +454,15 @@ Item {
454454 progress: {
455455 var tileProgress = (spreadView.shiftedContentX - index * spreadView.tileDistance) / spreadView.width;
456456 // Tile 1 needs to move directly from the beginning...
457− if (index == 1 && spreadView.stage < 2) {
457+ if (index == 1 && spreadView.phase < 2) {
458458 tileProgress += spreadView.tileDistance / spreadView.width;
459459 }
460460 return tileProgress;
461461 }
462462
463− // This mostly is the same as progress, just adds the snapping to stage 1 for tiles 0 and 1
463+ // This mostly is the same as progress, just adds the snapping to phase 1 for tiles 0 and 1
464464 animatedProgress: {
465− if (spreadView.stage == 0 && index < 2) {
465+ if (spreadView.phase == 0 && index < 2) {
466466 if (progress < spreadView.positionMarker1) {
467467 return progress;
468468 } else if (progress < spreadView.positionMarker1 + snappingCurve.period){
@@ -482,7 +482,7 @@ Item {
482482 }
483483
484484 onClicked: {
485− if (spreadView.stage == 2) {
485+ if (spreadView.phase == 2) {
486486 if (ApplicationManager.focusedApplicationId == ApplicationManager.get(index).appId) {
487487 spreadView.snapTo(index);
488488 } else {
qml/Stages/TransformedSpreadDelegate.qml+46−46
@@ -58,20 +58,20 @@ SpreadDelegate {
5858
5959 Connections {
6060 target: spreadView
61− onStageChanged: {
62− if (spreadView.stage == 1) {
61+ onPhaseChanged: {
62+ if (spreadView.phase == 1) {
6363 if (index == 0) {
64− priv.stage2startTranslate = priv.easingAnimation(0, spreadView.positionMarker4, 0, -spreadView.width, spreadView.positionMarker4) + spreadView.width;
65− priv.stage2startAngle = priv.easingAnimation(0, spreadView.positionMarker4, root.startAngle, root.endAngle, spreadView.positionMarker4);
66− priv.stage2startScale = priv.easingAnimation(0, spreadView.positionMarker4, root.startScale, root.endScale, spreadView.positionMarker4);
67− priv.stage2startTopMarginProgress = priv.easingAnimation(0, 1, 0, 1, spreadView.positionMarker4);
64+ priv.phase2startTranslate = priv.easingAnimation(0, spreadView.positionMarker4, 0, -spreadView.width, spreadView.positionMarker4) + spreadView.width;
65+ priv.phase2startAngle = priv.easingAnimation(0, spreadView.positionMarker4, root.startAngle, root.endAngle, spreadView.positionMarker4);
66+ priv.phase2startScale = priv.easingAnimation(0, spreadView.positionMarker4, root.startScale, root.endScale, spreadView.positionMarker4);
67+ priv.phase2startTopMarginProgress = priv.easingAnimation(0, 1, 0, 1, spreadView.positionMarker4);
6868 } else if (index == 1) {
69− // find where the main easing for Tile 1 would be when reaching stage 2
70− var stage2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
71− priv.stage2startTranslate = priv.easingAnimation(0, stage2Progress, 0, -spreadView.width + root.endDistance, stage2Progress);
72− priv.stage2startAngle = priv.easingAnimation(0, stage2Progress, root.startAngle, root.endAngle, stage2Progress);
73− priv.stage2startScale = priv.easingAnimation(0, stage2Progress, root.startScale, root.endScale, stage2Progress);
74− priv.stage2startTopMarginProgress = priv.easingAnimation(0, 1, 0, spreadView.positionMarker4, stage2Progress);
69+ // find where the main easing for Tile 1 would be when reaching phase 2
70+ var phase2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
71+ priv.phase2startTranslate = priv.easingAnimation(0, phase2Progress, 0, -spreadView.width + root.endDistance, phase2Progress);
72+ priv.phase2startAngle = priv.easingAnimation(0, phase2Progress, root.startAngle, root.endAngle, phase2Progress);
73+ priv.phase2startScale = priv.easingAnimation(0, phase2Progress, root.startScale, root.endScale, phase2Progress);
74+ priv.phase2startTopMarginProgress = priv.easingAnimation(0, 1, 0, spreadView.positionMarker4, phase2Progress);
7575 }
7676 }
7777 }
@@ -88,12 +88,12 @@ SpreadDelegate {
8888 property real selectedOpacity
8989 property real selectedTopMarginProgress
9090
91− // Those values are needed as target values for the end of stage 1.
92− // As they are static values, lets caluclate them once when entering stage 1 instead of calculating them in each animation pass.
93− property real stage2startTranslate
94− property real stage2startAngle
95− property real stage2startScale
96− property real stage2startTopMarginProgress
91+ // Those values are needed as target values for the end of phase 1.
92+ // As they are static values, lets caluclate them once when entering phase 1 instead of calculating them in each animation pass.
93+ property real phase2startTranslate
94+ property real phase2startAngle
95+ property real phase2startScale
96+ property real phase2startTopMarginProgress
9797
9898 function snapshot() {
9999 selectedProgress = root.progress;
@@ -106,7 +106,7 @@ SpreadDelegate {
106106 }
107107
108108 property real negativeProgress: {
109− if (index == 1 && spreadView.stage < 2) {
109+ if (index == 1 && spreadView.phase < 2) {
110110 return 0;
111111 }
112112 return -index * spreadView.tileDistance / spreadView.width;
@@ -127,7 +127,7 @@ SpreadDelegate {
127127
128128 property real xTranslate: {
129129 if (otherSelected) {
130− if (spreadView.stage < 2 && index == 0) {
130+ if (spreadView.phase < 2 && index == 0) {
131131 return linearAnimation(selectedProgress, negativeProgress, selectedXTranslate, selectedXTranslate - spreadView.tileDistance, root.progress);
132132 }
133133
@@ -136,13 +136,13 @@ SpreadDelegate {
136136
137137 switch (index) {
138138 case 0:
139− if (spreadView.stage == 0) {
139+ if (spreadView.phase == 0) {
140140 return Math.min(0, linearAnimation(0, spreadView.positionMarker2,
141141 0, -spreadView.width * .25, root.animatedProgress));
142− } else if (spreadView.stage == 1){
142+ } else if (spreadView.phase == 1){
143143 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
144− -spreadView.width * .25, priv.stage2startTranslate, root.progress);
145− } else if (!priv.isSelected){ // Stage 2
144+ -spreadView.width * .25, priv.phase2startTranslate, root.progress);
145+ } else if (!priv.isSelected){ // phase 2
146146 // Apply the same animation as with the rest but add spreadView.width to align it with the others.
147147 return -easingCurve.value * spreadView.width + spreadView.width;
148148 } else if (priv.isSelected) {
@@ -150,12 +150,12 @@ SpreadDelegate {
150150 }
151151
152152 case 1:
153− if (spreadView.stage == 0 && !priv.isSelected) {
153+ if (spreadView.phase == 0 && !priv.isSelected) {
154154 return linearAnimation(0, spreadView.positionMarker2,
155155 0, -spreadView.width * spreadView.snapPosition, root.animatedProgress);
156− } else if (spreadView.stage == 1 && !priv.isSelected) {
156+ } else if (spreadView.phase == 1 && !priv.isSelected) {
157157 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
158− -spreadView.width * spreadView.snapPosition, priv.stage2startTranslate,
158+ -spreadView.width * spreadView.snapPosition, priv.phase2startTranslate,
159159 root.progress);
160160 }
161161 }
@@ -183,20 +183,20 @@ SpreadDelegate {
183183 }
184184 switch (index) {
185185 case 0:
186− if (spreadView.stage == 0) {
186+ if (spreadView.phase == 0) {
187187 return Math.max(0, linearAnimation(0, spreadView.positionMarker2,
188188 0, root.tile0SnapAngle, root.animatedProgress));
189− } else if (spreadView.stage == 1) {
189+ } else if (spreadView.phase == 1) {
190190 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
191− root.tile0SnapAngle, stage2startAngle, root.progress);
191+ root.tile0SnapAngle, phase2startAngle, root.progress);
192192 }
193193 case 1:
194− if (spreadView.stage == 0) {
194+ if (spreadView.phase == 0) {
195195 return linearAnimation(0, spreadView.positionMarker2, root.startAngle,
196196 root.startAngle * (1-spreadView.snapPosition), root.animatedProgress);
197− } else if (spreadView.stage == 1) {
197+ } else if (spreadView.phase == 1) {
198198 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
199− root.startAngle * (1-spreadView.snapPosition), priv.stage2startAngle,
199+ root.startAngle * (1-spreadView.snapPosition), priv.phase2startAngle,
200200 root.progress);
201201 }
202202 }
@@ -213,21 +213,21 @@ SpreadDelegate {
213213
214214 switch (index) {
215215 case 0:
216− if (spreadView.stage == 0) {
216+ if (spreadView.phase == 0) {
217217 return 1;
218− } else if(spreadView.stage == 1) {
218+ } else if(spreadView.phase == 1) {
219219 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
220− 1, stage2startScale, root.progress);
220+ 1, phase2startScale, root.progress);
221221 }
222222 case 1:
223− if (spreadView.stage == 0) {
223+ if (spreadView.phase == 0) {
224224 var targetScale = tile1StartScale - ((tile1StartScale - 1) * spreadView.snapPosition);
225225 return linearAnimation(0, spreadView.positionMarker2,
226226 root.tile1StartScale, targetScale, root.animatedProgress);
227− } else if (spreadView.stage == 1) {
227+ } else if (spreadView.phase == 1) {
228228 var startScale = tile1StartScale - ((tile1StartScale - 1) * spreadView.snapPosition);
229229 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
230− startScale, priv.stage2startScale, root.progress);
230+ startScale, priv.phase2startScale, root.progress);
231231 }
232232 }
233233 return root.startScale - easingCurve.value * (root.startScale - root.endScale);
@@ -239,7 +239,7 @@ SpreadDelegate {
239239 selectedOpacity, 0, root.progress);
240240 }
241241 if (index == 0) {
242− switch (spreadView.stage) {
242+ switch (spreadView.phase) {
243243 case 0:
244244 return linearAnimation(0, spreadView.positionMarker2, 1, .3, root.animatedProgress);
245245 case 1:
@@ -258,19 +258,19 @@ SpreadDelegate {
258258
259259 switch (index) {
260260 case 0:
261− if (spreadView.stage == 0) {
261+ if (spreadView.phase == 0) {
262262 return 0;
263− } else if (spreadView.stage == 1) {
263+ } else if (spreadView.phase == 1) {
264264 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
265− 0, priv.stage2startTopMarginProgress, root.progress);
265+ 0, priv.phase2startTopMarginProgress, root.progress);
266266 }
267267 break;
268268 case 1:
269− if (spreadView.stage == 0) {
269+ if (spreadView.phase == 0) {
270270 return 0;
271− } else if (spreadView.stage == 1) {
271+ } else if (spreadView.phase == 1) {
272272 return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
273− 0, priv.stage2startTopMarginProgress, root.progress);
273+ 0, priv.phase2startTopMarginProgress, root.progress);
274274 }
275275 }
276276