Merge lp:~azzar1/unity/fix-987223-5.0 into lp:unity/5.0

Proposed by Andrea Azzarone on 2012-08-03
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2012-08-03
Approved revision: 2395
Merged at revision: 2396
Proposed branch: lp:~azzar1/unity/fix-987223-5.0
Merge into: lp:unity/5.0
Diff against target: 175 lines (+46/-33)
3 files modified
manual-tests/Launcher.txt (+12/-0)
plugins/unityshell/src/Launcher.cpp (+32/-33)
plugins/unityshell/src/Launcher.h (+2/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-987223-5.0
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2012-08-03 Approve on 2012-08-03
Review via email: mp+118155@code.launchpad.net

Commit message

Description of the change

== Problem ==
Launcher doesn't autoscroll when holding an icon (can't reach trash)

== Fix ==
Don't use _scroll_limit_reached. _launcher_drag_delta_max and _launcher_drag_delta_min should be just fine.

== Test ==
Manual test added.

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'manual-tests/Launcher.txt'
2--- manual-tests/Launcher.txt 2012-07-26 04:38:01 +0000
3+++ manual-tests/Launcher.txt 2012-08-03 17:05:27 +0000
4@@ -601,3 +601,15 @@
5 Expected Results:
6 * All the valid drop icons should unfold during the drag and drop.
7
8+
9+Test launcher autoscrolls when holding an icon
10+----------------------------------------------
11+Setup:
12+ * Add icons to the laucnher so that some of them in the bottom are folded.
13+
14+Actions:
15+ * Drag a launcher icon of the top side of the launcher. Don't release the mouse.
16+ * Move the mouse at the bottom of the launcher.
17+
18+Expected Results:
19+ * The launcher should autoscroll so you can reach the trash icon.
20
21=== modified file 'plugins/unityshell/src/Launcher.cpp'
22--- plugins/unityshell/src/Launcher.cpp 2012-07-26 04:27:23 +0000
23+++ plugins/unityshell/src/Launcher.cpp 2012-08-03 17:05:27 +0000
24@@ -140,6 +140,8 @@
25 Launcher::Launcher(nux::BaseWindow* parent,
26 NUX_FILE_LINE_DECL)
27 : View(NUX_FILE_LINE_PARAM)
28+ , _launcher_drag_delta_max(0)
29+ , _launcher_drag_delta_min(0)
30 , _model(0)
31 , _collection_window(NULL)
32 , _background_color(nux::color::DimGray)
33@@ -200,7 +202,6 @@
34 _folded_angle = 1.0f;
35 _neg_folded_angle = -1.0f;
36 _space_between_icons = 5;
37- _last_delta_y = 0.0f;
38 _folded_z_distance = 10.0f;
39 _launcher_action_state = ACTION_NONE;
40 _icon_under_mouse = NULL;
41@@ -225,7 +226,6 @@
42 _shortcuts_shown = false;
43 _hovered = false;
44 _hidden = false;
45- _scroll_limit_reached = false;
46 _render_drag_window = false;
47 _drag_edge_touching = false;
48 _steal_drag = false;
49@@ -1202,28 +1202,28 @@
50 last_geo = box_geo;
51 _enter_y = 0;
52
53+ // logically dnd exit only restores to the clamped ranges
54+ // hover_progress restores to 0
55+ _launcher_drag_delta_max = 0.0f;
56+ _launcher_drag_delta_min = std::min(0.0f, launcher_height - sum);
57+
58 if (hover_progress > 0.0f && _launcher_drag_delta != 0)
59 {
60 float delta_y = _launcher_drag_delta;
61
62- // logically dnd exit only restores to the clamped ranges
63- // hover_progress restores to 0
64- float max = 0.0f;
65- float min = MIN(0.0f, launcher_height - sum);
66-
67- if (_launcher_drag_delta > max)
68- delta_y = max + DragLimiter(delta_y - max);
69- else if (_launcher_drag_delta < min)
70- delta_y = min + DragLimiter(delta_y - min);
71+ if (_launcher_drag_delta > _launcher_drag_delta_max)
72+ delta_y = _launcher_drag_delta_max + DragLimiter(delta_y - _launcher_drag_delta_max);
73+ else if (_launcher_drag_delta < _launcher_drag_delta_min)
74+ delta_y = _launcher_drag_delta_min + DragLimiter(delta_y - _launcher_drag_delta_min);
75
76 if (GetActionState() != ACTION_DRAG_LAUNCHER)
77 {
78 float dnd_progress = DnDExitProgress(current);
79
80- if (_launcher_drag_delta > max)
81- delta_y = max + (delta_y - max) * dnd_progress;
82- else if (_launcher_drag_delta < min)
83- delta_y = min + (delta_y - min) * dnd_progress;
84+ if (_launcher_drag_delta > _launcher_drag_delta_max)
85+ delta_y = _launcher_drag_delta_max + (delta_y - _launcher_drag_delta_max) * dnd_progress;
86+ else if (_launcher_drag_delta < _launcher_drag_delta_min)
87+ delta_y = _launcher_drag_delta_min + (delta_y - _launcher_drag_delta_min) * dnd_progress;
88
89 if (dnd_progress == 0.0f)
90 _launcher_drag_delta = (int) delta_y;
91@@ -1232,9 +1232,6 @@
92 delta_y *= hover_progress;
93 center.y += delta_y;
94 folding_threshold += delta_y;
95-
96- _scroll_limit_reached = (delta_y == _last_delta_y);
97- _last_delta_y = delta_y;
98 }
99 else
100 {
101@@ -1729,44 +1726,46 @@
102 gboolean Launcher::OnScrollTimeout(gpointer data)
103 {
104 Launcher* self = (Launcher*) data;
105- nux::Geometry geo = self->GetGeometry();
106- gboolean anim = TRUE;
107+ gboolean continue_animation = TRUE;
108
109- //
110- // Always check _scroll_limit_reached to ensure we don't keep spinning
111- // this timer if the mouse happens to be left idle over one of the autoscroll
112- // hotspots on the launcher.
113- //
114 if (self->IsInKeyNavMode() || !self->_hovered ||
115- self->_scroll_limit_reached ||
116 self->GetActionState() == ACTION_DRAG_LAUNCHER)
117- anim = FALSE;
118+ {
119+ continue_animation = FALSE;
120+ }
121 else if (self->MouseOverTopScrollArea())
122 {
123- if (self->MouseOverTopScrollExtrema())
124+ if (self->_launcher_drag_delta >= self->_launcher_drag_delta_max)
125+ continue_animation = FALSE;
126+ else if (self->MouseOverTopScrollExtrema())
127 self->_launcher_drag_delta += 6;
128 else
129 self->_launcher_drag_delta += 3;
130 }
131 else if (self->MouseOverBottomScrollArea())
132 {
133- if (self->MouseOverBottomScrollExtrema())
134+ if (self->_launcher_drag_delta <= self->_launcher_drag_delta_min)
135+ continue_animation = FALSE;
136+ else if (self->MouseOverBottomScrollExtrema())
137 self->_launcher_drag_delta -= 6;
138 else
139 self->_launcher_drag_delta -= 3;
140 }
141 else
142- anim = FALSE;
143+ {
144+ continue_animation = FALSE;
145+ }
146
147- if (anim)
148+ if (continue_animation != FALSE)
149+ {
150 self->EnsureAnimation();
151+ }
152 else
153 {
154 self->_autoscroll_handle = 0;
155- self->_scroll_limit_reached = false;
156 }
157
158- return anim;
159+ return continue_animation;
160 }
161
162 void Launcher::EnsureScrollTimer()
163
164=== modified file 'plugins/unityshell/src/Launcher.h'
165--- plugins/unityshell/src/Launcher.h 2012-07-26 04:27:23 +0000
166+++ plugins/unityshell/src/Launcher.h 2012-08-03 17:05:27 +0000
167@@ -359,6 +359,8 @@
168 int _postreveal_mousemove_delta_x;
169 int _postreveal_mousemove_delta_y;
170 int _launcher_drag_delta;
171+ int _launcher_drag_delta_max;
172+ int _launcher_drag_delta_min;
173 int _enter_y;
174 int _last_button_press;
175 int _drag_out_id;

Subscribers

People subscribed via source and target branches

to all changes: