on xenial help sign in
add proper folding
0805931Michael Zanetti
qml/Stages/DesktopStage.qml+1−1
@@ -315,7 +315,7 @@ FocusScope {
315 Transition {
315 Transition {
316 from: "*"
316 from: "*"
317 to: "altTab"
317 to: "altTab"
318− PropertyAction { target: spreadFlickable; property: "contentX"; value: (1.88 / ApplicationManager.count) * (spreadFlickable.contentWidth - spreadFlickable.width) }
318+ PropertyAction { target: spreadFlickable; property: "contentX"; value: (2.6 / ApplicationManager.count) * (spreadFlickable.contentWidth - spreadFlickable.width) }
319 }
319 }
320 ]
320 ]
321}
321}
qml/Stages/SpreadMaths.qml+23−11
@@ -8,7 +8,7 @@ Item {
8 Label {
8 Label {
9 anchors {left: parent.left; top: parent.top }
9 anchors {left: parent.left; top: parent.top }
10 text: "prog:" + transitionCurve.progress.toFixed(2)
10 text: "prog:" + transitionCurve.progress.toFixed(2)
11− color: isInLeftFoldingArea ? "red" : "black"
11+ color: leftFoldingAreaProgress > 0 || rightFoldingAreaProgress > 0 ? "red" : "black"
12 }
12 }
13
13
14 id: root
14 id: root
@@ -20,7 +20,7 @@ Item {
20 property int margins: units.gu(5)
20 property int margins: units.gu(5)
21 property int foldingAreaWidth: units.gu(10)
21 property int foldingAreaWidth: units.gu(10)
22
22
23− property int maxVisibleItems: 5
23+ property int maxVisibleItems: 10
24
24
25 readonly property int flickableWidth: flickable ? flickable.width : 0
25 readonly property int flickableWidth: flickable ? flickable.width : 0
26 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
26 readonly property int flickableContentWidth: flickable ? flickable.contentWidth: 0
@@ -32,8 +32,8 @@ Item {
32
32
33 // Internal
33 // Internal
34 readonly property real progressSlice: 1 / totalItems;
34 readonly property real progressSlice: 1 / totalItems;
35− readonly property real startProgress: (index - 2) * progressSlice
35+ readonly property real startProgress: (index - maxVisibleItems/2) * progressSlice
36− readonly property real endProgress: (index + 3) * progressSlice
36+ readonly property real endProgress: (index + maxVisibleItems/2) * progressSlice
37
37
38// readonly property real startX: index < maxVisibleItems ?
38// readonly property real startX: index < maxVisibleItems ?
39// margins + index * unfoldedDistance
39// margins + index * unfoldedDistance
@@ -53,17 +53,24 @@ Item {
53 return sceneHeight - itemHeight - (sceneHeight * 0.2);
53 return sceneHeight - itemHeight - (sceneHeight * 0.2);
54 }
54 }
55
55
56− property int leftEndFoldedAngle: 80
56+ property int leftEndFoldedAngle: 70
57− property int rightEndFoldedAngle: 60
57+ property int rightEndFoldedAngle: 65
58 property int unfoldedAngle: 30
58 property int unfoldedAngle: 30
59
59
60+ // faw : 1 = x : p
60− property bool isInLeftFoldingArea: animatedX < foldingAreaWidth + margins
61+ property real leftFoldingAreaProgress: (foldingAreaWidth + margins - animatedX) / foldingAreaWidth
62+ property real rightFoldingAreaProgress: (animatedX + margins*2 - contentWidth) / foldingAreaWidth
61
63
62− // x : foldingAreaWidth = leftEndFoldedAngle: unfoldedAngle:
63
64
65+ // x : foldingAreaWidth = leftEndFoldedAngle: unfoldedAngle
66+
64− readonly property int animatedAngle: isInLeftFoldingArea ?
67+ readonly property int animatedAngle: leftFoldingAreaProgress > 0 ?
65− ((foldingAreaWidth + margins) - x) * unfoldedAngle / leftEndFoldedAngle
68+ linearAnimation(0, 1, unfoldedAngle, leftEndFoldedAngle, leftFoldingAreaProgress)
66− : unfoldedAngle
69+ : rightFoldingAreaProgress > 0 ?
70+ linearAnimation(0, 1, unfoldedAngle, rightEndFoldedAngle, rightFoldingAreaProgress)
71+ : unfoldedAngle
72+
73+ onAnimatedAngleChanged: if (index == 10) print("**** animated angle", animatedAngle, rightFoldingAreaProgress)
67
74
68
75
69 function desktopScale(sceneHeight, itemHeight) {
76 function desktopScale(sceneHeight, itemHeight) {
@@ -78,6 +85,11 @@ Item {
78 return true;
85 return true;
79 }
86 }
80
87
88+ function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
89+ // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
90+ return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;
91+ }
92+
81 EasingCurve {
93 EasingCurve {
82 id: transitionCurve
94 id: transitionCurve
83 type: EasingCurve.InOutSine
95 type: EasingCurve.InOutSine
tests/qmltests/tst_DesktopShell.qml+6−3
@@ -78,7 +78,7 @@ Item {
78 id: shellLoader
78 id: shellLoader
79
79
80 active: false
80 active: false
81− width: units.gu(110)
81+ width: parent.width - units.gu(30)
82 height: parent.height
82 height: parent.height
83
83
84 property bool itemDestroyed: false
84 property bool itemDestroyed: false
@@ -130,8 +130,11 @@ Item {
130 text: "Start all apps"
130 text: "Start all apps"
131 onClicked: {
131 onClicked: {
132 for (var i = 0; i < ApplicationManager.availableApplications.length; i++) {
132 for (var i = 0; i < ApplicationManager.availableApplications.length; i++) {
133− print("starting", ApplicationManager.availableApplications[i])
133+ var appId = ApplicationManager.availableApplications[i];
134+ if (ApplicationManager.findApplication(appId) == null) {
135+ print("starting", appId)
134− ApplicationManager.startApplication(ApplicationManager.availableApplications[i])
136+ ApplicationManager.startApplication(appId)
137+ }
135 }
138 }
136 }
139 }
137 }
140 }