@@ -26,109 +26,22 @@ Item {
26 property real maxAngle: 0
26 property real maxAngle: 0
27 property bool inverted: false
27 property bool inverted: false
29− readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * height
29+ readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
30− readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * height
30+ readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
32+ property int itemWidth
33+ property int itemHeight
36 // The angle used for rotating
34 // The angle used for rotating
37− property real angle: {
35+ property real angle: 0
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
44− return 0; // Don't fold first/last item as long as inside the view
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
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;
61 // This is the offset that keeps the items inside the panel
36 // This is the offset that keeps the items inside the panel
62− property real offset: {
37+ property real offset: 0
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;
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;
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
84− property real itemOpacity: {
38+ property real itemOpacity: 1
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))
91− return 1; // Don't make first/last item transparent as long as inside the view
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))
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)
108− property real brightness: {
39+ property real brightness: 0
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))
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))
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)
129 id: iconItem
42 id: iconItem
130− width: parent.width
43+ width: parent.itemWidth
131− height: parent.height
44+ height: parent.itemHeight
132 anchors.centerIn: parent
45 anchors.centerIn: parent
134 UbuntuShape {
47 UbuntuShape {
@@ -150,8 +63,8 @@ Item {
150 anchors.centerIn: iconItem
63 anchors.centerIn: iconItem
151 rotation: inverted ? 180 : 0
64 rotation: inverted ? 180 : 0
152 source: isSelected ? "graphics/selected.sci" : "graphics/non-selected.sci"
65 source: isSelected ? "graphics/selected.sci" : "graphics/non-selected.sci"
153− width: root.width + units.gu(0.5)
66+ width: root.itemWidth + units.gu(0.5)
154− height: width
67+ height: root.itemHeight + units.gu(0.5)
155 property bool isSelected: root.highlighted
68 property bool isSelected: root.highlighted
156 onIsSelectedChanged: shaderEffectSource.scheduleUpdate();
69 onIsSelectedChanged: shaderEffectSource.scheduleUpdate();
@@ -161,8 +74,8 @@ Item {
161 id: transformEffect
74 id: transformEffect
162 anchors.centerIn: parent
75 anchors.centerIn: parent
163 anchors.verticalCenterOffset: root.offset
76 anchors.verticalCenterOffset: root.offset
164− width: parent.width
77+ width: parent.itemWidth
165− height: parent.height
78+ height: parent.itemHeight
166 property real itemOpacity: root.itemOpacity
79 property real itemOpacity: root.itemOpacity
167 property real brightness: root.brightness
80 property real brightness: root.brightness
168 property real angle: root.angle
81 property real angle: root.angle
@@ -219,22 +132,4 @@ Item {
219 gl_FragColor = sourceColor;
132 gl_FragColor = sourceColor;
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
234− property real distanceFromEdge: Math.abs(distanceFromBottomEdge) < Math.abs(distanceFromTopEdge) ? distanceFromBottomEdge : distanceFromTopEdge
235− property real orientationFlag: Math.abs(distanceFromBottomEdge) < Math.abs(distanceFromTopEdge) ? -1 : 1
237− property real overlapWithFoldingArea: listView.foldingAreaHeight - distanceFromEdge