@@ -26,109 +26,22 @@ Item {
2626 property real maxAngle: 0
2727 property bool inverted: false
2828
29− readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * height
30− readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * height
31−
32− signal clicked()
33− signal longtap()
34− signal released()
29+ readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
30+ readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
3531
32+ property int itemWidth
33+ property int itemHeight
3634 // 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−
35+ property real angle: 0
6136 // 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− }
37+ property real offset: 0
38+ property real itemOpacity: 1
39+ property real brightness: 0
12740
12841 Item {
12942 id: iconItem
130− width: parent.width
131− height: parent.height
43+ width: parent.itemWidth
44+ height: parent.itemHeight
13245 anchors.centerIn: parent
13346
13447 UbuntuShape {
@@ -150,8 +63,8 @@ Item {
15063 anchors.centerIn: iconItem
15164 rotation: inverted ? 180 : 0
15265 source: isSelected ? "graphics/selected.sci" : "graphics/non-selected.sci"
153− width: root.width + units.gu(0.5)
154− height: width
66+ width: root.itemWidth + units.gu(0.5)
67+ height: root.itemHeight + units.gu(0.5)
15568 property bool isSelected: root.highlighted
15669 onIsSelectedChanged: shaderEffectSource.scheduleUpdate();
15770 }
@@ -161,8 +74,8 @@ Item {
16174 id: transformEffect
16275 anchors.centerIn: parent
16376 anchors.verticalCenterOffset: root.offset
164− width: parent.width
165− height: parent.height
77+ width: parent.itemWidth
78+ height: parent.itemHeight
16679 property real itemOpacity: root.itemOpacity
16780 property real brightness: root.brightness
16881 property real angle: root.angle
@@ -219,22 +132,4 @@ Item {
219132 gl_FragColor = sourceColor;
220133 }"
221134 }
222−
223− QtObject {
224− id: priv
225−
226− property ListView listView: root.ListView.view
227− property real totalUnfoldedHeight: listView.itemSize + listView.spacing
228− property real totalEffectiveHeight: effectiveHeight + listView.spacing
229− property real effectiveContentY: listView.contentY - listView.originY
230− property real effectiveY: y - listView.originY
231− property real distanceFromTopEdge: -(effectiveContentY + listView.topMargin - index*totalUnfoldedHeight)
232− property real distanceFromBottomEdge: listView.height - listView.bottomMargin - (effectiveY+height) + effectiveContentY
233−
234− property real distanceFromEdge: Math.abs(distanceFromBottomEdge) < Math.abs(distanceFromTopEdge) ? distanceFromBottomEdge : distanceFromTopEdge
235− property real orientationFlag: Math.abs(distanceFromBottomEdge) < Math.abs(distanceFromTopEdge) ? -1 : 1
236−
237− property real overlapWithFoldingArea: listView.foldingAreaHeight - distanceFromEdge
238− }
239−
240135}