on xenial help sign in
added scaling on stacked ends, some cleanup
commitc4a991814211a773d3e5498b4cc11f50ee616141 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 1 Apr 2015, 17:14 (12 years ago) parent05e8cb5
2 files changed+38−28
qml/Stages/DesktopStage.qml+6−2 qml/Stages/SpreadMaths.qml+32−26
qml/Stages/DesktopStage.qml+6−2
@@ -158,9 +158,9 @@ FocusScope {
158158 PropertyChanges {
159159 target: appDelegate
160160 x: spreadMaths.animatedX
161− y: spreadMaths.desktopY(root.height, appDelegate.height)
161+ y: spreadMaths.animatedY
162162 angle: spreadMaths.animatedAngle
163− itemScale: spreadMaths.desktopScale(root.height, appDelegate.height)
163+ itemScale: spreadMaths.scale
164164 itemScaleOriginY: appDelegate.height;
165165 color: "green"
166166 z: index
@@ -196,6 +196,10 @@ FocusScope {
196196 flickable: spreadFlickable
197197 itemIndex: index
198198 totalItems: ApplicationManager.count
199+ sceneHeight: root.height
200+ spreadHeight: root.height * 0.35
201+ spreadBottomOffset: sceneHeight * 0.2
202+ itemHeight: appDelegate.height
199203 }
200204
201205 WindowMoveResizeArea {
qml/Stages/SpreadMaths.qml+32−26
@@ -14,14 +14,28 @@ Item {
1414 id: root
1515 anchors { left: parent.left; top: parent.top; margins: units.gu(1) }
1616
17+ // Information about the transformed item
1718 property int itemIndex: 0
19+ property real itemHeight: units.gu(10)
20+
21+ // Information about the environment
1822 property int totalItems: 0
1923 property Item flickable: null
20− property int margins: units.gu(5)
21− property int foldingAreaWidth: units.gu(10)
24+ property int sceneHeight: units.gu(20)
2225
26+ // Spread properties
27+ property real spreadHeight: units.gu(10)
28+ property int spreadBottomOffset: units.gu(5)
29+ property int foldingAreaWidth: units.gu(10)
2330 property int maxVisibleItems: 10
31+ property int margins: units.gu(5)
32+ property real stackScale: 0.04
33+ property int leftEndFoldedAngle: 70
34+ property int rightEndFoldedAngle: 65
35+ property int unfoldedAngle: 30
2436
37+
38+ // Internal
2539 readonly property int flickableWidth: flickable ? flickable.width : 0
2640 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
2741 readonly property real flickableProgress: flickable ? flickable.contentX / (flickable.contentWidth - flickableWidth) : 0
@@ -39,32 +53,25 @@ Item {
3953
4054 readonly property int unfoldedDistance: (contentWidth - foldingAreaWidth) / maxVisibleItems
4155
42− // Internal
4356 readonly property real progressSlice: 1 / totalItems;
4457 readonly property real startProgress: (index - maxVisibleItems/2) * progressSlice
4558 readonly property real endProgress: (index + maxVisibleItems/2) * progressSlice
4659
47−// readonly property real startX: index < maxVisibleItems ?
48−// margins + index * unfoldedDistance
49−// : contentWidth - foldingAreaWidth + (startLayout.value * foldingAreaWidth)
50−
5160 readonly property real startX: contentWidth - foldingAreaWidth + (startLayout.value * foldingAreaWidth)
52−
53−// readonly property real endX: totalItems - maxVisibleItems < index ?
54−// contentWidth - (totalItems - index) * unfoldedDistance
55−// : margins + foldingAreaWidth - (endLayout.value * foldingAreaWidth)
56−
5761 readonly property real endX: margins + foldingAreaWidth - (endLayout.value * foldingAreaWidth)
5862
5963 readonly property int animatedX: transitionCurve.value * (endX - startX) + startX
6064
61− function desktopY(sceneHeight, itemHeight) {
62− return sceneHeight - itemHeight - (sceneHeight * 0.2);
63− }
65+ // The y offset we need to add because of scaled tiles in the stacks
66+ readonly property int yOffset: -spreadHeight * stackScale / 2
67+
68+ readonly property int animatedY: sceneHeight - itemHeight - spreadBottomOffset +
69+ (leftFoldingAreaProgress > 0 ?
70+ linearAnimation(0, 1, yOffset, 0, leftFoldingAreaProgress)
71+ : rightFoldingAreaProgress > 0 ?
72+ linearAnimation(0, 1, yOffset, 0, rightFoldingAreaProgress)
73+ : yOffset)
6474
65− property int leftEndFoldedAngle: 70
66− property int rightEndFoldedAngle: 65
67− property int unfoldedAngle: 30
6875
6976 // faw : 1 = x : p
7077 property real leftFoldingAreaProgress: (foldingAreaWidth + margins - animatedX) / foldingAreaWidth
@@ -79,21 +86,20 @@ Item {
7986 linearAnimation(0, 1, unfoldedAngle, rightEndFoldedAngle, rightFoldingAreaProgress)
8087 : unfoldedAngle
8188
82− onAnimatedAngleChanged: if (index == 10) print("**** animated angle", animatedAngle, rightFoldingAreaProgress)
8389
90+ readonly property real scale: (leftFoldingAreaProgress > 0 ?
91+ linearAnimation(0, 1, spreadHeight * (1 - stackScale), spreadHeight, leftFoldingAreaProgress)
92+ : rightFoldingAreaProgress > 0 ?
93+ linearAnimation(0, 1, spreadHeight * (1 - stackScale), spreadHeight, rightFoldingAreaProgress)
94+ : spreadHeight * (1 - stackScale)
95+ ) / itemHeight
8496
85− function desktopScale(sceneHeight, itemHeight) {
86− var maxHeight = sceneHeight * 0.35;
87− if (itemHeight > maxHeight) {
88− return maxHeight / itemHeight
89− }
90− return 1;
91− }
9297
9398 function desktopTitleInfoShown(index, flickableX) {
9499 return true;
95100 }
96101
102+ // Helpers
97103 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
98104 // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
99105 return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;