on xenial help sign in
initial try on progressive scrolling while dragging
commitd980c29d3e4c5022a8e12e4f270b6806659a4b6e authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 24 Jul 2013, 13:56 (13 years ago) parent55d26b9
1 file changed+40−5
Launcher/LauncherPanel.qml+40−5
Launcher/LauncherPanel.qml+40−5
@@ -28,7 +28,7 @@ Item {
2828 rotation: inverted ? 180 : 0
2929
3030 property var model
31− property bool inverted: true
31+ property bool inverted: false
3232 property bool dragging: false
3333 property bool moving: launcherListView.moving || launcherListView.flicking || dndArea.draggedItem !== undefined
3434 property int dragPosition: 0
@@ -42,9 +42,9 @@ Item {
4242
4343 var hiddenContentHeight = launcherListView.contentHeight - launcherListView.height
4444 // Shortening scrollable height because the first/last item needs to be fully expanded before reaching the top/bottom
45− var scrollableHeight = launcherListView.height - (launcherListView.itemSize + launcherColumn.spacing) *2
45+ var scrollableHeight = launcherListView.height - (launcherListView.itemSize + launcherListView.spacing) *2
4646 // As we shortened the scrollableHeight, lets move everything down by the itemSize
47− var shortenedEffectiveDragPosition = effectiveDragPosition - launcherListView.itemSize - launcherColumn.spacing
47+ var shortenedEffectiveDragPosition = effectiveDragPosition - launcherListView.itemSize - launcherListView.spacing
4848 var newContentY = shortenedEffectiveDragPosition * hiddenContentHeight / scrollableHeight
4949
5050 // limit top/bottom to prevent overshooting
@@ -54,7 +54,7 @@ Item {
5454 // > the current mouse position + the hidden/scolled content on top is the mouse position in the averall view
5555 // > adjust that removing all the margins
5656 // > divide by itemSize to get index
57− highlightIndex = (effectiveDragPosition + launcherListView.contentY - mainColumn.anchors.margins*3 - launcherColumn.spacing/2) / (launcherListView.itemSize + launcherColumn.spacing)
57+// highlightIndex = (effectiveDragPosition + launcherListView.contentY - mainColumn.anchors.margins*3 - launcherListView.spacing/2) / (launcherListView.itemSize + launcherColumn.spacing)
5858 }
5959
6060 BorderImage {
@@ -236,6 +236,8 @@ Item {
236236 draggedIndex = -1;
237237 drag.target = undefined
238238 launcherListView.interactive = true;
239+
240+ progressiveScrollingTimer.stop();
239241 }
240242
241243 onPressAndHold: {
@@ -279,7 +281,7 @@ Item {
279281 }
280282
281283 //launcherPanel.dragPosition = inverted ? launcherListView.height - y : y
282− //launcherPanel.dragPosition = mouseY
284+ //root.dragPosition = mouseY
283285
284286 var realContentY = launcherListView.contentY + launcherListView.topMargin
285287 var realItemSize = launcherListView.itemSize + launcherListView.spacing
@@ -288,6 +290,20 @@ Item {
288290 // Move it down by the the missing size to compensate index calculation with only expanded items
289291 itemCenterY += selectedItem.height / 2
290292
293+ print("mouseY", mouseY, launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin - realItemSize)
294+ if (mouseY > launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin - realItemSize) {
295+ print("entered bottom area")
296+ progressiveScrollingTimer.downwards = false
297+ progressiveScrollingTimer.start()
298+ } else if (mouseY < realItemSize) {
299+ progressiveScrollingTimer.downwards = true
300+ progressiveScrollingTimer.start()
301+ print("entered top area")
302+ } else {
303+ progressiveScrollingTimer.stop()
304+ print("not in any area")
305+ }
306+
291307 var newIndex = (itemCenterY + realContentY) / realItemSize
292308
293309 if (newIndex > draggedIndex + 1) {
@@ -306,6 +322,25 @@ Item {
306322 }
307323 }
308324 }
325+ Timer {
326+ id: progressiveScrollingTimer
327+ interval: 5
328+ repeat: true
329+ running: false
330+ property bool downwards: true
331+ onTriggered: {
332+ if (downwards) {
333+ if (launcherListView.contentY > launcherListView.contentHeight - launcherListView.height) {
334+ launcherListView.contentY -= 2
335+ }
336+ } else {
337+ if (launcherListView.contentY < 0) {
338+ launcherListView.contentY += 2
339+ }
340+ }
341+ }
342+ }
343+
309344 MouseArea {
310345 id: topFoldingArea
311346 anchors {