on xenial help sign in
treat leftmost item special and make it fold later to use up all the available screen estate
commitec403a51cf8e2320fa96035af104053ed4ca366a authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 21 Apr 2015, 14:24 (12 years ago) parent17e4b12
1 file changed+40−25
qml/Stages/SpreadMaths.qml+40−25
qml/Stages/SpreadMaths.qml+40−25
@@ -35,11 +35,8 @@ Item {
3535
3636 readonly property int contentWidth: flickableWidth - root.margins * 2
3737
38− // The y offset we need to add because of scaled tiles in the stacks
39− readonly property int yOffset: -spreadHeight * stackScale / 2
40−
41− readonly property int distance: (flickableContentWidth - (margins * 2) - (foldingAreaWidth * 2)) / totalItems
42− readonly property int startPos: margins + foldingAreaWidth + itemIndex * distance
38+ readonly property int distance: (flickableContentWidth - (margins * 2) - (foldingAreaWidth * 2)) / (totalItems - 2)
39+ readonly property int startPos: margins + foldingAreaWidth + (itemIndex - 1) * distance
4340 readonly property int linearX: startPos - flickableProgress * (flickableContentWidth - flickableWidth)
4441
4542 readonly property int leftFoldingAreaX: margins + foldingAreaWidth
@@ -51,17 +48,33 @@ Item {
5148 readonly property real limitedLeftProgress: Math.min(2, leftFoldingAreaProgress)
5249 readonly property real limitedRightProgress: Math.min(2, rightFoldingAreaProgress)
5350
51+// Label {
52+// anchors { left: parent.left; top: parent.top; topMargin: - 100 }
53+// text: leftFoldingAreaProgress.toFixed(2)
54+// color: "green"
55+// fontSize: "x-large"
56+// }
57+
5458 // Output
5559 readonly property int animatedX: {
56− if (leftFoldingAreaProgress > 4) {
60+ if (leftFoldingAreaProgress > 4) { // Stop it at the edge
5761 return margins;
5862 }
59− if (leftFoldingAreaProgress > 2) {
63+ if (leftFoldingAreaProgress > 2) { // move it slowly through the stack
6064 return linearAnimation(2, 4, margins + stackWidth, margins, leftFoldingAreaProgress)
6165 }
62− if (leftFoldingAreaProgress > 0) {
66+ if (leftFoldingAreaProgress > 1 && itemIndex == 0) {
67+ // The leftmost runs faster... make it stop before the stack and wait for others
68+ return margins + stackWidth;
69+ }
70+
71+ if (leftFoldingAreaProgress > 0) { // slow it down in a curve
72+ if (itemIndex == 0) { // except if it's the leftmost. that one goes straigt
73+ return linearAnimation(0, 1, leftFoldingAreaX, margins + stackWidth, leftFoldingAreaProgress)
74+ }
6375 return linearAnimation(0, 1, leftFoldingAreaX, margins + stackWidth, leftEasing.value)
6476 }
77+ // same for the right side stack... mostly... don't need to treat the rightmost special...
6578 if (rightFoldingAreaProgress > 4) {
6679 return flickableWidth - margins
6780 }
@@ -76,23 +89,25 @@ Item {
7689 return linearX;
7790 }
7891
79− readonly property int animatedY: sceneHeight - itemHeight - spreadBottomOffset +
80− (limitedLeftProgress > 0 ?
81− 0
82−// linearAnimation(0, 1, yOffset, 0, leftEasing.value)
83− : limitedRightProgress > 0 ?
84− 0
85−// linearAnimation(0, 1, yOffset, 0, rightEasing.value)
86− : 0)
87−
88−
89−
90− readonly property int animatedAngle: limitedLeftProgress > 0 ?
91− linearAnimation(0, 2, unfoldedAngle, leftEndFoldedAngle, limitedLeftProgress)
92− : limitedRightProgress > 0 ?
93− linearAnimation(0, 2, unfoldedAngle, rightEndFoldedAngle, limitedRightProgress)
94− : unfoldedAngle
95−
92+ readonly property int animatedY: sceneHeight - itemHeight - spreadBottomOffset
93+
94+ readonly property int animatedAngle: {
95+ if (limitedLeftProgress > 0) {
96+ // Leftmost is special...
97+ if (index == 0) {
98+ if (limitedLeftProgress < 1) {
99+ return unfoldedAngle;
100+ } else {
101+ return linearAnimation(1, 2, unfoldedAngle, leftEndFoldedAngle, limitedLeftProgress)
102+ }
103+ }
104+ return linearAnimation(0, 2, unfoldedAngle, leftEndFoldedAngle, limitedLeftProgress)
105+ } else if (limitedRightProgress > 0) {
106+ return linearAnimation(0, 2, unfoldedAngle, rightEndFoldedAngle, limitedRightProgress)
107+ } else {
108+ return unfoldedAngle
109+ }
110+ }
96111
97112 readonly property real scale: limitedLeftProgress > 0 ?
98113 linearAnimation(0, 1, 1, 1 + stackScale, leftEasing.value)