@@ -22,24 +22,109 @@ Item {
2222
2323 property string iconName
2424
25− property real angle: 0
2625 property bool highlighted: false
27− property real offset: 0
28− property alias brightness: transformEffect.brightness
29− property real itemOpacity: 1
30−
3126 property real maxAngle: 0
3227 property bool inverted: false
3328
3429 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * height
3530 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * height
3631
37− property bool dragging:false
38−
3932 signal clicked()
4033 signal longtap()
4134 signal released()
4235
36+ // The angle used for rotating
37+ property real angle: {
38+ // First/last items are special
39+ if (index == 0 || index == priv.listView.count-1) {
40+ if (priv.distanceFromEdge < 0) {
41+ // proportion equation: distanceFromTopEdge : angle = totalUnfoldedHeight/2 : maxAngle
42+ return Math.max(-maxAngle, priv.distanceFromEdge * maxAngle / (priv.listView.foldingAreaHeight)) * priv.orientationFlag
43+ }
44+ return 0; // Don't fold first/last item as long as inside the view
45+ }
46+
47+ // Are we in the already completely outside the flickable? Fold for the last 5 degrees
48+ if (priv.distanceFromEdge < 0) {
49+ // proportion equation: -distanceFromTopEdge : angle = totalUnfoldedHeight : 5
50+ return Math.max(-maxAngle, (priv.distanceFromEdge * 5 / priv.listView.foldingAreaHeight) - (maxAngle-5)) * priv.orientationFlag
51+ }
52+
53+ // We are overlapping with the folding area, fold the icon to maxAngle - 5 degrees
54+ if (priv.overlapWithFoldingArea > 0) {
55+ // proportion equation: overlap: totalHeight = angle : (maxAngle - 5)
56+ return -priv.overlapWithFoldingArea * (maxAngle -5) / priv.listView.foldingAreaHeight * priv.orientationFlag;
57+ }
58+ return 0;
59+ }
60+
61+ // This is the offset that keeps the items inside the panel
62+ property real offset: {
63+ // First/last items are special
64+ if (index == 0 || index == priv.listView.count-1) {
65+ // Just keep them bound to the edges in case they're outside of the visible area
66+ if (priv.distanceFromEdge < 0) {
67+ return (-priv.distanceFromEdge - (height - effectiveHeight)) * priv.orientationFlag;
68+ }
69+ return 0;
70+ }
71+
72+ // Are we already completely outside the flickable? Stop the icon here.
73+ if (priv.distanceFromEdge < -priv.totalUnfoldedHeight) {
74+ return (-priv.distanceFromEdge - (root.height - effectiveHeight)) * priv.orientationFlag;
75+ }
76+
77+ // We're touching the edge, move slower than the actual flicking speed.
78+ if (priv.distanceFromEdge < 0) {
79+ return (Math.abs(priv.distanceFromEdge) * priv.totalEffectiveHeight / priv.totalUnfoldedHeight) * priv.orientationFlag
80+ }
81+ return 0;
82+ }
83+
84+ property real itemOpacity: {
85+ // First/last items are special
86+ if (index == 0 || index == priv.listView.count-1) {
87+ if (priv.distanceFromEdge < 0) {
88+ // Fade from 1 to 0 in the distance of 3 * foldingAreaHeight (which is when the next item reaches the edge)
89+ return 1.0 - (-priv.distanceFromEdge / (priv.listView.foldingAreaHeight * 3))
90+ }
91+ return 1; // Don't make first/last item transparent as long as inside the view
92+ }
93+
94+ // Are we already completely outside the flickable? Fade from 0.75 to 0 in 2 items height
95+ if (priv.distanceFromEdge < 0) {
96+ // proportion equation: -distanceFromEdge : 1-opacity = totalUnfoldedHeight : 0.75
97+ return 0.75 - (-priv.distanceFromEdge * 0.75 / (priv.totalUnfoldedHeight*2))
98+ }
99+
100+ // We are overlapping with the folding area, fade out to 0.75
101+ if (priv.overlapWithFoldingArea > 0) {
102+ // proportion equation: overlap : totalHeight = 1-opacity : 0.25
103+ return 1 - (priv.overlapWithFoldingArea * 0.25 / priv.listView.foldingAreaHeight)
104+ }
105+ return 1;
106+ }
107+
108+ property real brightness: {
109+ // First/last items are special
110+ if (index == 0 || index == priv.listView.count-1) {
111+ if (priv.distanceFromEdge < 0) {
112+ return -(-priv.distanceFromEdge / (priv.listView.foldingAreaHeight * 3))
113+ }
114+ return 0;
115+ }
116+ // Are we already completely outside the flickable? Fade from 0.7 to 0 in 2 items height
117+ if (priv.distanceFromEdge < 0) {
118+ return -0.3 - (-priv.distanceFromEdge * 0.1 / (priv.totalUnfoldedHeight*2))
119+ }
120+
121+ // We are overlapping with the folding area, fade out to 0.7
122+ if (priv.overlapWithFoldingArea > 0) {
123+ return - (priv.overlapWithFoldingArea * 0.3 / priv.listView.foldingAreaHeight)
124+ }
125+ return 0;
126+ }
127+
43128 Item {
44129 id: iconItem
45130 width: parent.width
@@ -58,22 +143,8 @@ Item {
58143 sourceSize.height: iconShape.height
59144 source: "../graphics/applicationIcons/" + root.iconName + ".png"
60145 }
61−
62− MouseArea {
63− id: mouseArea
64− anchors.fill: parent
65− onClicked: root.clicked()
66− onCanceled: root.released()
67− preventStealing: false
68−
69− onPressAndHold: {
70− root.state = "moving"
71− }
72− onReleased: {
73− root.state = "docked"
74− }
75− }
76146 }
147+
77148 BorderImage {
78149 id: overlayHighlight
79150 anchors.centerIn: iconItem
@@ -81,7 +152,7 @@ Item {
81152 source: isSelected ? "graphics/selected.sci" : "graphics/non-selected.sci"
82153 width: root.width + units.gu(0.5)
83154 height: width
84− property bool isSelected: root.highlighted || mouseArea.pressed
155+ property bool isSelected: root.highlighted
85156 onIsSelectedChanged: shaderEffectSource.scheduleUpdate();
86157 }
87158 }
@@ -93,16 +164,15 @@ Item {
93164 width: parent.width
94165 height: parent.height
95166 property real itemOpacity: root.itemOpacity
96− property real brightness: 0
167+ property real brightness: root.brightness
97168 property real angle: root.angle
98169 rotation: root.inverted ? 180 : 0
99170
100−
101171 property variant source: ShaderEffectSource {
102172 id: shaderEffectSource
103173 sourceItem: iconItem
104174 hideSource: true
105− live: false
175+ //live: false
106176 }
107177
108178 transform: [
@@ -167,123 +237,4 @@ Item {
167237 property real overlapWithFoldingArea: listView.foldingAreaHeight - distanceFromEdge
168238 }
169239
170− states: [
171− State {
172− name: "docked"
173− PropertyChanges {
174− target: root
175−
176− // This is the offset that keeps the items inside the panel
177− offset: {
178− // First/last items are special
179− if (index == 0 || index == priv.listView.count-1) {
180− // Just keep them bound to the edges in case they're outside of the visible area
181− if (priv.distanceFromEdge < 0) {
182− return (-priv.distanceFromEdge - (height - effectiveHeight)) * priv.orientationFlag;
183− }
184− return 0;
185− }
186−
187− // Are we already completely outside the flickable? Stop the icon here.
188− if (priv.distanceFromEdge < -priv.totalUnfoldedHeight) {
189− return (-priv.distanceFromEdge - (root.height - effectiveHeight)) * priv.orientationFlag;
190− }
191−
192− // We're touching the edge, move slower than the actual flicking speed.
193− if (priv.distanceFromEdge < 0) {
194− return (Math.abs(priv.distanceFromEdge) * priv.totalEffectiveHeight / priv.totalUnfoldedHeight) * priv.orientationFlag
195− }
196− return 0;
197− }
198−
199− // The angle used for rotating
200− angle: {
201− // First/last items are special
202− if (index == 0 || index == priv.listView.count-1) {
203− if (priv.distanceFromEdge < 0) {
204− // proportion equation: distanceFromTopEdge : angle = totalUnfoldedHeight/2 : maxAngle
205− return Math.max(-maxAngle, priv.distanceFromEdge * maxAngle / (priv.listView.foldingAreaHeight)) * priv.orientationFlag
206− }
207− return 0; // Don't fold first/last item as long as inside the view
208− }
209−
210− // Are we in the already completely outside the flickable? Fold for the last 5 degrees
211− if (priv.distanceFromEdge < 0) {
212− // proportion equation: -distanceFromTopEdge : angle = totalUnfoldedHeight : 5
213− return Math.max(-maxAngle, (priv.distanceFromEdge * 5 / priv.listView.foldingAreaHeight) - (maxAngle-5)) * priv.orientationFlag
214− }
215−
216− // We are overlapping with the folding area, fold the icon to maxAngle - 5 degrees
217− if (priv.overlapWithFoldingArea > 0) {
218− // proportion equation: overlap: totalHeight = angle : (maxAngle - 5)
219− return -priv.overlapWithFoldingArea * (maxAngle -5) / priv.listView.foldingAreaHeight * priv.orientationFlag;
220− }
221− return 0;
222− }
223−
224− itemOpacity: {
225− // First/last items are special
226− if (index == 0 || index == priv.listView.count-1) {
227− if (priv.distanceFromEdge < 0) {
228− // Fade from 1 to 0 in the distance of 3 * foldingAreaHeight (which is when the next item reaches the edge)
229− return 1.0 - (-priv.distanceFromEdge / (priv.listView.foldingAreaHeight * 3))
230− }
231− return 1; // Don't make first/last item transparent as long as inside the view
232− }
233−
234− // Are we already completely outside the flickable? Fade from 0.75 to 0 in 2 items height
235− if (priv.distanceFromEdge < 0) {
236− // proportion equation: -distanceFromEdge : 1-opacity = totalUnfoldedHeight : 0.75
237− return 0.75 - (-priv.distanceFromEdge * 0.75 / (priv.totalUnfoldedHeight*2))
238− }
239−
240− // We are overlapping with the folding area, fade out to 0.75
241− if (priv.overlapWithFoldingArea > 0) {
242− // proportion equation: overlap : totalHeight = 1-opacity : 0.25
243− return 1 - (priv.overlapWithFoldingArea * 0.25 / priv.listView.foldingAreaHeight)
244− }
245− return 1;
246− }
247−
248− brightness: {
249− // First/last items are special
250− if (index == 0 || index == priv.listView.count-1) {
251− if (priv.distanceFromEdge < 0) {
252− return -(-priv.distanceFromEdge / (priv.listView.foldingAreaHeight * 3))
253− }
254− return 0;
255− }
256− // Are we already completely outside the flickable? Fade from 0.7 to 0 in 2 items height
257− if (priv.distanceFromEdge < 0) {
258− return -0.3 - (-priv.distanceFromEdge * 0.1 / (priv.totalUnfoldedHeight*2))
259− }
260−
261− // We are overlapping with the folding area, fade out to 0.7
262− if (priv.overlapWithFoldingArea > 0) {
263− return - (priv.overlapWithFoldingArea * 0.3 / priv.listView.foldingAreaHeight)
264− }
265− return 0;
266− }
267− }
268− },
269−
270− State {
271− name: "moving"
272− PropertyChanges {
273− target: launcherDelegate;
274− offset: 0
275− angle: 0
276− }
277− PropertyChanges {
278− target: root
279− highlighted: true
280− dragging: true
281− }
282− PropertyChanges {
283− target: mouseArea
284− preventStealing: true
285− drag.target: root
286− }
287− }
288− ]
289240}