on xenial help sign in
various fixes:

- increase extension of ListView to avoid destruction of dragging item - Don't overflow brightness with negative values < -1 - take margins into account when calculating drag position - remove some debug prints

commit5c06467b163718cbe760ddd36191a71649ac4d9d authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 15 Aug 2013, 22:03 (13 years ago) parent8493506
3 files changed+25−34
Launcher/LauncherDelegate.qml+1−1 Launcher/LauncherListDelegate.qml−4 Launcher/LauncherPanel.qml+24−29
Launcher/LauncherDelegate.qml+1−1
@@ -77,7 +77,7 @@ Item {
7777 width: parent.itemWidth
7878 height: parent.itemHeight
7979 property real itemOpacity: root.itemOpacity
80− property real brightness: root.brightness
80+ property real brightness: Math.max(-1, root.brightness)
8181 property real angle: root.angle
8282 rotation: root.inverted ? 180 : 0
8383
Launcher/LauncherListDelegate.qml−4
@@ -22,10 +22,6 @@ LauncherDelegate {
2222
2323 // The angle used for rotating
2424 angle: {
25− if (index == 1 || index == priv.listView.count - 2) {
26− print("index", index, iconName, "overlaps with folding area", priv.overlapWithFoldingArea, priv.distanceFromEdge, priv.bottomDraggingDistanceOffset)
27− }
28−
2925 // First/last items are special
3026 if (index == 0 || index == priv.listView.count-1) {
3127 if (priv.distanceFromEdge < 0) {
Launcher/LauncherPanel.qml+24−29
@@ -89,11 +89,11 @@ Item {
8989 objectName: "launcherListView"
9090 anchors {
9191 fill: parent
92− topMargin: -itemHeight + units.gu(0.5)
93− bottomMargin: -itemHeight + units.gu(1)
92+ topMargin: -extensionSize + units.gu(0.5)
93+ bottomMargin: -extensionSize + units.gu(1)
9494 }
95− topMargin: itemHeight
96− bottomMargin: itemHeight
95+ topMargin: extensionSize
96+ bottomMargin: extensionSize
9797 height: parent.height - dashItem.height - parent.spacing*2
9898 model: root.model
9999 cacheBuffer: itemHeight * 3
@@ -104,6 +104,11 @@ Item {
104104 layoutDirection: root.inverted ? Qt.RightToLeft : Qt.LeftToRight
105105 spacing: units.gu(0.5)
106106
107+ // The size of the area the ListView is extended to make sure items are not
108+ // destructed. Note that if the move() operation when dragging switches
109+ // the item with one that doesn't have a delegate yet everything breaks badly.
110+ property int extensionSize: itemHeight * 3
111+
107112 // The height of the area where icons start getting folded
108113 property int foldingAreaHeight: itemHeight * 0.75
109114 property int itemWidth: width
@@ -115,8 +120,6 @@ Item {
115120 NumberAnimation { properties: "x,y"; duration: 100 }
116121 }
117122
118− onContentYChanged: print("contentY", contentY)
119−
120123 delegate: LauncherListDelegate {
121124 id: launcherDelegate
122125 objectName: "launcherDelegate" + index
@@ -177,8 +180,19 @@ Item {
177180 Transition {
178181 from: "dragging"
179182 to: "*"
180− NumberAnimation { properties: "itemOpacity"; duration: 150 }
183+ NumberAnimation { properties: "itemOpacity"; duration: 1500 }
184+ },
185+ Transition {
186+ from: ""
187+ to: "expanded"
188+ NumberAnimation { properties: "angle"; duration: 150 }
189+ },
190+ Transition {
191+ from: "expanded"
192+ to: ""
193+ NumberAnimation { properties: "angle"; duration: 150 }
181194 }
195+
182196 ]
183197 }
184198
@@ -206,8 +220,6 @@ Item {
206220 var index = Math.floor((mouseY + realContentY) / realItemHeight);
207221 var clickedItem = launcherListView.itemAt(mouseX, mouseY + realContentY)
208222
209− print("clicked on", index, clickedItem)
210−
211223 // First/last item do the scrolling at more than 12 degrees
212224 if (index == 0 || index == launcherListView.count -1) {
213225 if (clickedItem.angle > 12) {
@@ -232,27 +244,20 @@ Item {
232244
233245 onCanceled: {
234246 selectedItem.highlighted = false
247+ selectedItem = undefined;
235248 }
236249
237250 onReleased: {
238− print("released");
239251 selectedItem.highlighted = false
240252 selectedItem.dragging = false;
241253 selectedItem = undefined;
242254
243− var droppedIndex = draggedIndex;
244255 draggedIndex = -1;
245256 drag.target = undefined
246257
247258 progressiveScrollingTimer.stop();
248−
249− // FIXME: remove the if condition once the ListView position bug is fixed.
250− // Right now setting currentIndex to 0 causes more issues than it helps.
251−// if (droppedIndex > 2) {
252−// launcherListView.currentIndex = -1;
253−// launcherListView.currentIndex = droppedIndex;
254−// }
255259 launcherListView.interactive = true;
260+
256261 }
257262
258263 onPressAndHold: {
@@ -271,7 +276,7 @@ Item {
271276
272277 fakeDragItem.iconName = launcherListView.model.get(draggedIndex).icon
273278 fakeDragItem.x = 0
274− fakeDragItem.y = mouseY - yOffset
279+ fakeDragItem.y = mouseY - yOffset + launcherListView.anchors.topMargin + launcherListView.topMargin
275280 drag.target = fakeDragItem
276281
277282 startX = mouseX
@@ -284,7 +289,6 @@ Item {
284289 if (!selectedItem.dragging) {
285290 var distance = Math.max(Math.abs(mouseX - startX), Math.abs(mouseY - startY))
286291 if (distance > launcherListView.itemHeight) {
287− print("starting drag")
288292 selectedItem.dragging = true
289293 PopupUtils.close(quickListPopover)
290294 }
@@ -293,9 +297,6 @@ Item {
293297 return
294298 }
295299
296− //launcherPanel.dragPosition = inverted ? launcherListView.height - y : y
297− //root.dragPosition = mouseY
298−
299300 var realContentY = launcherListView.contentY + launcherListView.topMargin
300301 var realItemHeight = launcherListView.itemHeight + launcherListView.spacing
301302 var itemCenterY = fakeDragItem.y + fakeDragItem.height / 2
@@ -303,18 +304,14 @@ Item {
303304 // Move it down by the the missing size to compensate index calculation with only expanded items
304305 itemCenterY += selectedItem.height / 2
305306
306−// print("mouseY", mouseY, launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin - realItemHeight)
307307 if (mouseY > launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin - realItemHeight) {
308−// print("entered bottom area")
309308 progressiveScrollingTimer.downwards = false
310309 progressiveScrollingTimer.start()
311310 } else if (mouseY < realItemHeight) {
312311 progressiveScrollingTimer.downwards = true
313312 progressiveScrollingTimer.start()
314−// print("entered top area")
315313 } else {
316314 progressiveScrollingTimer.stop()
317−// print("not in any area")
318315 }
319316
320317 var newIndex = (itemCenterY + realContentY) / realItemHeight
@@ -328,7 +325,6 @@ Item {
328325 }
329326
330327 if (newIndex >= 0 && newIndex < launcherListView.count) {
331− print("moving", draggedIndex, "to", newIndex)
332328 launcherListView.model.move(draggedIndex, newIndex)
333329 draggedIndex = newIndex
334330 }
@@ -350,7 +346,6 @@ Item {
350346 } else {
351347 var maxY = launcherListView.contentHeight - launcherListView.height + launcherListView.topMargin + dndArea.selectedItem.effectiveHeight*2
352348 if (launcherListView.contentY < maxY) {
353− print("moving upwards", launcherListView.contentHeight, launcherListView.height, launcherListView.topMargin, dndArea.selectedItem.height, dndArea.selectedItem.effectiveHeight)
354349 launcherListView.contentY = Math.min(launcherListView.contentY + units.dp(2), maxY)
355350 }
356351 }