@@ -1,43 +1,66 @@
1import QtQuick 2.2
1import QtQuick 2.2
2+import Ubuntu.Components 1.1
2import Utils 0.1
3import Utils 0.1
3import Unity.Application 0.1
4import Unity.Application 0.1
8− function desktopX(index, totalWidth, flickableX) {
8+ Label {
9− var margins = units.gu(5);
9+ anchors {left: parent.left; top: parent.top }
10− var distance = (totalWidth - margins * 2) / 5;
10+ text: "prog:" + transitionCurve.progress.toFixed(2)
11− var foldedDistance = units.gu(0.5)
11+ color: isInLeftFoldingArea ? "red" : "black"
12− var reverseIndex = ApplicationManager.count - index
14− var x = (index * distance) - flickableX + margins;
16− x = Math.max(margins + foldedDistance * index, x);
18− x = Math.min(totalWidth - margins - distance - foldedDistance * reverseIndex, x);
23− var startProgress = 0;
25− var startValue = index * distance;
27− var progress = 1.0 * flickableX / startValue;
28− print("progress for tile", index, ":", startProgress, endProgress, startValue, endValue, progress)
29− var x = easingAnimation(startProgress, endProgress, startValue, endValue, progress);
30− print("resulting x:", x)
31− return x + units.gu(5);
15+ anchors { left: parent.left; top: parent.top; margins: units.gu(1) }
17+ property int itemIndex: 0
18+ property int totalItems: 0
19+ property Item flickable: null
20+ property int margins: units.gu(5)
21+ property int foldingAreaWidth: units.gu(5)
23+ property int maxVisibleItems: 5
25+ readonly property int flickableWidth: flickable ? flickable.width : 0
26+ readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
27+ readonly property real flickableProgress: flickable ? flickable.contentX / (flickable.contentWidth - flickableWidth) : 0
29+ readonly property int contentWidth: flickableWidth - root.margins * 2
31+ readonly property int unfoldedDistance: (contentWidth - foldingAreaWidth) / maxVisibleItems
34+ readonly property real progressSlice: 1 / totalItems;
35+ readonly property real startProgress: Math.max(0, index - 2) * progressSlice
36+ readonly property real endProgress: (index + 3) * progressSlice
38+ readonly property real startX: index < maxVisibleItems ?
39+ margins + index * unfoldedDistance
40+ : contentWidth - foldingAreaWidth + (startLayout.value * foldingAreaWidth)
42+ readonly property real endX: totalItems - maxVisibleItems < index ?
43+ contentWidth - (totalItems - index) * unfoldedDistance
44+ : margins + foldingAreaWidth - (endLayout.value * foldingAreaWidth)
46+ readonly property int animatedX: transitionCurve.value * (endX - startX) + startX
34 function desktopY(sceneHeight, itemHeight) {
48 function desktopY(sceneHeight, itemHeight) {
35 return sceneHeight - itemHeight - (sceneHeight * 0.2);
49 return sceneHeight - itemHeight - (sceneHeight * 0.2);
38− function desktopAngle(index, flickableX) {
52+ property int leftEndFoldedAngle: 80
39− return 40;
53+ property int rightEndFoldedAngle: 60
40− }
54+ property int unfoldedAngle: 30
56+ property bool isInLeftFoldingArea: animatedX < foldingAreaWidth + margins
58+ // x : foldingAreaWidth = leftEndFoldedAngle: unfoldedAngle:
60+ readonly property int animatedAngle: isInLeftFoldingArea ?
61+ ((foldingAreaWidth + margins) - x) * unfoldedAngle / leftEndFoldedAngle
42 function desktopScale(sceneHeight, itemHeight) {
65 function desktopScale(sceneHeight, itemHeight) {
43 var maxHeight = sceneHeight * 0.35;
66 var maxHeight = sceneHeight * 0.35;
@@ -47,14 +70,30 @@ QtObject {
50− function easingAnimation(startProgress, endProgress, startValue, endValue, progress) {
73+ function desktopTitleInfoShown(index, flickableX) {
51− easingCurve.progress = progress - startProgress;
74+ return true;
52− easingCurve.period = endProgress - startProgress;
75+ }
53− return easingCurve.value * (endValue - startValue) + startValue;
76+
79+ type: easingCurve.InOutSine
81+ readonly property real normalizedEndProgress: endProgress - startProgress
82+ readonly property real normalizedProgress: (root.flickableProgress - root.startProgress) / normalizedEndProgress
83+ progress: normalizedProgress
88+ type: EasingCurve.OutSine
89+ // total : 1 = index : p
90+ progress: 1.0 * index / root.totalItems
56− property var easingCurve: EasingCurve {
93+ EasingCurve {
57 type: EasingCurve.OutSine
95 type: EasingCurve.OutSine
58− period: 1
96+ // total : 1 = index : p
97+ progress: 1 - (1.0 * index / root.totalItems)