@@ -18,14 +18,14 @@ Item {
18 keys: ['workspace']
18 keys: ['workspace']
20 onEntered: {
20 onEntered: {
21− var index = listView.getDropIndex(drag);
21+ var index = listView.getWorkspaceDropIndex(drag);
22 listView.model.insert(index, {text: drag.source.text})
22 listView.model.insert(index, {text: drag.source.text})
23 listView.dropItemIndex = index;
23 listView.dropItemIndex = index;
24 drag.source.inDropArea = true;
24 drag.source.inDropArea = true;
27 onPositionChanged: {
27 onPositionChanged: {
28− var index = listView.getDropIndex(drag);
28+ var index = listView.getWorkspaceDropIndex(drag);
29 if (listView.dropItemIndex == index) return;
29 if (listView.dropItemIndex == index) return;
30 listView.model.move(listView.dropItemIndex, index, 1);
30 listView.model.move(listView.dropItemIndex, index, 1);
31 listView.dropItemIndex = index;
31 listView.dropItemIndex = index;
@@ -42,6 +42,18 @@ Item {
42 drag.source.inDropArea = false;
42 drag.source.inDropArea = false;
47+ keys: ["application"]
50+ listView.progressiveScroll(drag.x)
51+ listView.hoveredWorkspaceIndex = listView.getApplicationDropIndex(drag)
54+ listView.hoveredWorkspaceIndex = -1
46 ListView {
58 ListView {
47 id: listView
59 id: listView
@@ -59,8 +71,18 @@ Item {
59 property int foldingAreaWidth: units.gu(10)
71 property int foldingAreaWidth: units.gu(10)
60 property real realContentX: contentX - originX + leftMargin
72 property real realContentX: contentX - originX + leftMargin
61 property int dropItemIndex: -1
73 property int dropItemIndex: -1
74+ property int hoveredWorkspaceIndex: -1
76+ function getWorkspaceDropIndex(drag) {
77+ var coords = mapToItem(listView.contentItem, drag.x, drag.y)
78+ var index = Math.floor((drag.x + listView.realContentX) / (listView.itemWidth + listView.spacing));
79+ if (index < 0) index = 0;
80+ var upperLimit = dropItemIndex == -1 ? listView.count : listView.count - 1
81+ if (index > upperLimit) index = upperLimit;
63− function getDropIndex(drag) {
85+ function getApplicationDropIndex(drag) {
64 var coords = mapToItem(listView.contentItem, drag.x, drag.y)
86 var coords = mapToItem(listView.contentItem, drag.x, drag.y)
65 var index = Math.floor((drag.x + listView.realContentX) / (listView.itemWidth + listView.spacing));
87 var index = Math.floor((drag.x + listView.realContentX) / (listView.itemWidth + listView.spacing));
66 if (index < 0) index = 0;
88 if (index < 0) index = 0;
@@ -69,6 +91,12 @@ Item {
69 return index;
91 return index;
94+ function progressiveScroll(mouseX) {
95+ var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.leftMargin * 2 - listView.foldingAreaWidth * 2)))
96+ print("p", progress, mouseX)
97+ listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
72 displaced: Transition { UbuntuNumberAnimation { properties: "x" } }
100 displaced: Transition { UbuntuNumberAnimation { properties: "x" } }
74 delegate: Item {
102 delegate: Item {
@@ -164,6 +192,7 @@ Item {
164 width: listView.itemWidth
192 width: listView.itemWidth
165 background: root.background
193 background: root.background
166 screenHeight: root.screen.physicalSize.height
194 screenHeight: root.screen.physicalSize.height
195+ containsDrag: listView.hoveredWorkspaceIndex == index
169 anchors.centerIn: parent
198 anchors.centerIn: parent
@@ -189,8 +218,7 @@ Item {
190 onMouseXChanged: {
219 onMouseXChanged: {
191 if (!pressed || dragging) {
220 if (!pressed || dragging) {
192− var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.foldingAreaWidth * 2)))
221+ listView.progressiveScroll(mouseX)
193− listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
196 onMouseYChanged: {
224 onMouseYChanged: {