on xenial help sign in
added scaling on stacked ends, some cleanup
c4a9918Michael Zanetti
qml/Stages/DesktopStage.qml+6−2
@@ -158,9 +158,9 @@ FocusScope {
158 PropertyChanges {
158 PropertyChanges {
159 target: appDelegate
159 target: appDelegate
160 x: spreadMaths.animatedX
160 x: spreadMaths.animatedX
161− y: spreadMaths.desktopY(root.height, appDelegate.height)
161+ y: spreadMaths.animatedY
162 angle: spreadMaths.animatedAngle
162 angle: spreadMaths.animatedAngle
163− itemScale: spreadMaths.desktopScale(root.height, appDelegate.height)
163+ itemScale: spreadMaths.scale
164 itemScaleOriginY: appDelegate.height;
164 itemScaleOriginY: appDelegate.height;
165 color: "green"
165 color: "green"
166 z: index
166 z: index
@@ -196,6 +196,10 @@ FocusScope {
196 flickable: spreadFlickable
196 flickable: spreadFlickable
197 itemIndex: index
197 itemIndex: index
198 totalItems: ApplicationManager.count
198 totalItems: ApplicationManager.count
199+ sceneHeight: root.height
200+ spreadHeight: root.height * 0.35
201+ spreadBottomOffset: sceneHeight * 0.2
202+ itemHeight: appDelegate.height
199 }
203 }
200
204
201 WindowMoveResizeArea {
205 WindowMoveResizeArea {
qml/Stages/SpreadMaths.qml+32−26
@@ -14,14 +14,28 @@ Item {
14 id: root
14 id: root
15 anchors { left: parent.left; top: parent.top; margins: units.gu(1) }
15 anchors { left: parent.left; top: parent.top; margins: units.gu(1) }
16
16
17+ // Information about the transformed item
17 property int itemIndex: 0
18 property int itemIndex: 0
19+ property real itemHeight: units.gu(10)
20+
21+ // Information about the environment
18 property int totalItems: 0
22 property int totalItems: 0
19 property Item flickable: null
23 property Item flickable: null
20− property int margins: units.gu(5)
24+ property int sceneHeight: units.gu(20)
21− property int foldingAreaWidth: units.gu(10)
22
25
26+ // Spread properties
27+ property real spreadHeight: units.gu(10)
28+ property int spreadBottomOffset: units.gu(5)
29+ property int foldingAreaWidth: units.gu(10)
23 property int maxVisibleItems: 10
30 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
24
36
37+
38+ // Internal
25 readonly property int flickableWidth: flickable ? flickable.width : 0
39 readonly property int flickableWidth: flickable ? flickable.width : 0
26 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
40 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
27 readonly property real flickableProgress: flickable ? flickable.contentX / (flickable.contentWidth - flickableWidth) : 0
41 readonly property real flickableProgress: flickable ? flickable.contentX / (flickable.contentWidth - flickableWidth) : 0
@@ -39,32 +53,25 @@ Item {
39
53
40 readonly property int unfoldedDistance: (contentWidth - foldingAreaWidth) / maxVisibleItems
54 readonly property int unfoldedDistance: (contentWidth - foldingAreaWidth) / maxVisibleItems
41
55
42− // Internal
43 readonly property real progressSlice: 1 / totalItems;
56 readonly property real progressSlice: 1 / totalItems;
44 readonly property real startProgress: (index - maxVisibleItems/2) * progressSlice
57 readonly property real startProgress: (index - maxVisibleItems/2) * progressSlice
45 readonly property real endProgress: (index + maxVisibleItems/2) * progressSlice
58 readonly property real endProgress: (index + maxVisibleItems/2) * progressSlice
46
59
47−// readonly property real startX: index < maxVisibleItems ?
48−// margins + index * unfoldedDistance
49−// : contentWidth - foldingAreaWidth + (startLayout.value * foldingAreaWidth)
50−
51 readonly property real startX: contentWidth - foldingAreaWidth + (startLayout.value * foldingAreaWidth)
60 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−
57 readonly property real endX: margins + foldingAreaWidth - (endLayout.value * foldingAreaWidth)
61 readonly property real endX: margins + foldingAreaWidth - (endLayout.value * foldingAreaWidth)
58
62
59 readonly property int animatedX: transitionCurve.value * (endX - startX) + startX
63 readonly property int animatedX: transitionCurve.value * (endX - startX) + startX
60
64
61− function desktopY(sceneHeight, itemHeight) {
65+ // The y offset we need to add because of scaled tiles in the stacks
62− return sceneHeight - itemHeight - (sceneHeight * 0.2);
66+ readonly property int yOffset: -spreadHeight * stackScale / 2
63− }
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)
64
74
65− property int leftEndFoldedAngle: 70
66− property int rightEndFoldedAngle: 65
67− property int unfoldedAngle: 30
68
75
69 // faw : 1 = x : p
76 // faw : 1 = x : p
70 property real leftFoldingAreaProgress: (foldingAreaWidth + margins - animatedX) / foldingAreaWidth
77 property real leftFoldingAreaProgress: (foldingAreaWidth + margins - animatedX) / foldingAreaWidth
@@ -79,21 +86,20 @@ Item {
79 linearAnimation(0, 1, unfoldedAngle, rightEndFoldedAngle, rightFoldingAreaProgress)
86 linearAnimation(0, 1, unfoldedAngle, rightEndFoldedAngle, rightFoldingAreaProgress)
80 : unfoldedAngle
87 : unfoldedAngle
81
88
82− onAnimatedAngleChanged: if (index == 10) print("**** animated angle", animatedAngle, rightFoldingAreaProgress)
83
89
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
84
96
85− function desktopScale(sceneHeight, itemHeight) {
86− var maxHeight = sceneHeight * 0.35;
87− if (itemHeight > maxHeight) {
88− return maxHeight / itemHeight
89− }
90− return 1;
91− }
92
97
93 function desktopTitleInfoShown(index, flickableX) {
98 function desktopTitleInfoShown(index, flickableX) {
94 return true;
99 return true;
95 }
100 }
96
101
102+ // Helpers
97 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
103 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
98 // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
104 // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
99 return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;
105 return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;