Merge lp:~mzanetti/unity8/launcher-fix-displacement into lp:unity8

Proposed by Michael Zanetti
Status: Merged
Approved by: MichaƂ Sawicz
Approved revision: 220
Merged at revision: 236
Proposed branch: lp:~mzanetti/unity8/launcher-fix-displacement
Merge into: lp:unity8
Diff against target: 152 lines (+64/-18)
2 files modified
Launcher/LauncherPanel.qml (+30/-4)
tests/qmltests/Launcher/tst_Launcher.qml (+34/-14)
To merge this branch: bzr merge lp:~mzanetti/unity8/launcher-fix-displacement
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Approve
Review via email: mp+181433@code.launchpad.net

Commit message

delay move operations if the start dragging operation is running

This prevents items to left in wrong places when transitions clash

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

It does indeed fix the problem.

If we can have a test case it'd be great, if not i understand it's hard to test, just say so and i'll approve.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Ok. Added a test which drags only downwards. This doesn't really check if the painting issue happens or not, but it tests the newly added code path if it still works moving the items around in the model.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good :-)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Launcher/LauncherPanel.qml'
2--- Launcher/LauncherPanel.qml 2013-08-21 11:28:05 +0000
3+++ Launcher/LauncherPanel.qml 2013-08-22 09:08:15 +0000
4@@ -121,6 +121,12 @@
5 property real realContentY: contentY - originY + topMargin
6 property int realItemHeight: itemHeight + spacing
7
8+ // In case the start dragging transition is running, we need to delay the
9+ // move because the displaced transition would clash with it and cause items
10+ // to be moved to wrong places
11+ property bool draggingTransitionRunning: false
12+ property int scheduledMoveTo: -1
13+
14 displaced: Transition {
15 NumberAnimation { properties: "x,y"; duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
16 }
17@@ -202,10 +208,26 @@
18 UbuntuNumberAnimation { properties: "angle,offset" }
19 },
20 Transition {
21+ id: draggingTransition
22 from: "selected"
23 to: "dragging"
24- UbuntuNumberAnimation { properties: "height" }
25- NumberAnimation { target: dropIndicator; properties: "opacity"; duration: UbuntuAnimation.FastDuration }
26+ SequentialAnimation {
27+ PropertyAction { target: launcherListView; property: "draggingTransitionRunning"; value: true }
28+ ParallelAnimation {
29+ UbuntuNumberAnimation { properties: "height" }
30+ NumberAnimation { target: dropIndicator; properties: "opacity"; duration: UbuntuAnimation.FastDuration }
31+ }
32+ ScriptAction {
33+ script: {
34+ if (launcherListView.scheduledMoveTo > -1) {
35+ launcherListView.model.move(dndArea.draggedIndex, launcherListView.scheduledMoveTo)
36+ dndArea.draggedIndex = launcherListView.scheduledMoveTo
37+ launcherListView.scheduledMoveTo = -1
38+ }
39+ }
40+ }
41+ PropertyAction { target: launcherListView; property: "draggingTransitionRunning"; value: false }
42+ }
43 },
44 Transition {
45 from: "dragging"
46@@ -387,8 +409,12 @@
47 }
48
49 if (newIndex >= 0 && newIndex < launcherListView.count) {
50- launcherListView.model.move(draggedIndex, newIndex)
51- draggedIndex = newIndex
52+ if (launcherListView.draggingTransitionRunning) {
53+ launcherListView.scheduledMoveTo = newIndex
54+ } else {
55+ launcherListView.model.move(draggedIndex, newIndex)
56+ draggedIndex = newIndex
57+ }
58 }
59 }
60 }
61
62=== modified file 'tests/qmltests/Launcher/tst_Launcher.qml'
63--- tests/qmltests/Launcher/tst_Launcher.qml 2013-08-20 17:39:58 +0000
64+++ tests/qmltests/Launcher/tst_Launcher.qml 2013-08-22 09:08:15 +0000
65@@ -277,8 +277,9 @@
66
67 function test_dragndrop_data() {
68 return [
69- {tag: "startDrag", fullDrag: false},
70- {tag: "fullDrag", fullDrag: true},
71+ {tag: "startDrag", fullDrag: false },
72+ {tag: "fullDrag horizontal", fullDrag: true, orientation: ListView.Horizontal },
73+ {tag: "fullDrag vertical", fullDrag: true, orientation: ListView.Vertical },
74 ];
75 }
76
77@@ -288,8 +289,8 @@
78 var item0 = findChild(launcher, "launcherDelegate0")
79 var fakeDragItem = findChild(launcher, "fakeDragItem")
80 var initialItemHeight = draggedItem.height
81- var item5Name = LauncherModel.get(5).iconName
82- var item4Name = LauncherModel.get(4).iconName
83+ var item5 = LauncherModel.get(5).appId
84+ var item4 = LauncherModel.get(4).appId
85
86 // Initial state
87 compare(draggedItem.itemOpacity, 1, "Item's opacity is not 1 at beginning")
88@@ -297,28 +298,43 @@
89 tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
90
91 // Doing longpress
92- mousePress(draggedItem, draggedItem.width / 2, draggedItem.height / 2)
93+ var currentMouseX = draggedItem.width / 2
94+ var currentMouseY = draggedItem.height / 2
95+ mousePress(draggedItem, currentMouseX, currentMouseY)
96 // DraggedItem needs to hide and fakeDragItem become visible
97 tryCompare(draggedItem, "itemOpacity", 0)
98 tryCompare(fakeDragItem, "visible", true)
99
100 // Dragging a bit (> 1.5 gu)
101- mouseMove(draggedItem, -units.gu(2), draggedItem.height / 2)
102+ currentMouseX -= units.gu(2)
103+ mouseMove(draggedItem, currentMouseX, currentMouseY)
104 // Other items need to expand and become 0.6 opaque
105 tryCompare(item0, "angle", 0)
106 tryCompare(item0, "itemOpacity", 0.6)
107
108 if (data.fullDrag) {
109 // Dragging a bit more
110- mouseMove(draggedItem, -units.gu(15), draggedItem.height / 2, 100)
111- tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
112- tryCompare(draggedItem, "height", units.gu(1))
113-
114- // Dragging downwards. Item needs to move in the model
115- mouseMove(draggedItem, -units.gu(15), -initialItemHeight)
116+ if (data.orientation == ListView.Horizontal) {
117+ currentMouseX -= units.gu(15)
118+ mouseMove(draggedItem, currentMouseX, currentMouseY, 100)
119+
120+ tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
121+ tryCompare(draggedItem, "height", units.gu(1))
122+
123+ // Dragging downwards. Item needs to move in the model
124+ currentMouseY -= initialItemHeight * 1.5
125+ mouseMove(draggedItem, currentMouseX, currentMouseY)
126+ } else if (data.orientation == ListView.Vertical) {
127+ currentMouseY -= initialItemHeight * 1.5
128+ mouseMove(draggedItem, currentMouseX, currentMouseY, 100)
129+
130+ tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
131+ tryCompare(draggedItem, "height", units.gu(1))
132+ }
133+
134 waitForRendering(draggedItem)
135- compare(LauncherModel.get(5).iconName, item4Name)
136- compare(LauncherModel.get(5).iconName, item5Name)
137+ compare(LauncherModel.get(5).appId, item4)
138+ compare(LauncherModel.get(4).appId, item5)
139 }
140
141 // Releasing and checking if initial values are restored
142@@ -326,6 +342,10 @@
143 tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
144 tryCompare(draggedItem, "itemOpacity", 1)
145 tryCompare(fakeDragItem, "visible", false)
146+
147+ // Click somewhere in the empty space to make it hide in case it isn't
148+ mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
149+ revealer.waitUntilLauncherDisappears();
150 }
151
152 function test_quicklist_dismiss() {

Subscribers

People subscribed via source and target branches