Merge lp:~azzar1/unity/fix-bug-955158-5.0 into lp:unity/5.0

Proposed by Andrea Azzarone
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2382
Proposed branch: lp:~azzar1/unity/fix-bug-955158-5.0
Merge into: lp:unity/5.0
Diff against target: 330 lines (+22/-145)
2 files modified
plugins/unityshell/src/QuicklistView.cpp (+22/-141)
plugins/unityshell/src/QuicklistView.h (+0/-4)
To merge this branch: bzr merge lp:~azzar1/unity/fix-bug-955158-5.0
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+113282@code.launchpad.net

Commit message

Description of the change

== Problem ==
padding between last quicklist item and bottom edge is non-deterministic (changes randomly)

== Test ==
Not applicable: visual change.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/QuicklistView.cpp'
2--- plugins/unityshell/src/QuicklistView.cpp 2012-04-13 13:20:05 +0000
3+++ plugins/unityshell/src/QuicklistView.cpp 2012-07-04 06:13:21 +0000
4@@ -65,8 +65,6 @@
5 , _corner_radius(4)
6 , _padding(13)
7 , _left_padding_correction(-1)
8- , _bottom_padding_correction_normal(-2)
9- , _bottom_padding_correction_single_item(-4)
10 , _offset_correction(-1)
11 , _cairo_text_has_changed(true)
12 , _current_item_index(-1)
13@@ -101,8 +99,6 @@
14 _item_layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
15 _vlayout->AddLayout(_item_layout, 0);
16
17- _default_item_layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
18- _vlayout->AddLayout(_default_item_layout, 0);
19 _vlayout->AddLayout(_bottom_space, 0);
20 _vlayout->SetMinimumWidth(140);
21
22@@ -329,14 +325,6 @@
23 (*it)->UnReference();
24 }
25
26- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
27- {
28- // Remove from introspection
29- RemoveChild(*it);
30- (*it)->UnReference();
31- }
32-
33- _default_item_list.clear();
34 _item_list.clear();
35 }
36
37@@ -353,7 +341,7 @@
38
39 if (!_enable_quicklist_for_testing)
40 {
41- if ((_item_list.size() != 0) || (_default_item_list.size() != 0))
42+ if ((_item_list.size() != 0))
43 {
44 int offscreen_size = GetBaseY() +
45 GetBaseHeight() -
46@@ -441,12 +429,6 @@
47 (*it)->ProcessDraw(gfxContext, forceDraw);
48 }
49
50- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
51- {
52- if ((*it)->GetVisible())
53- (*it)->ProcessDraw(gfxContext, forceDraw);
54- }
55-
56 gfxContext.PopClippingRectangle();
57 }
58
59@@ -475,45 +457,34 @@
60 (*it)->GetTextExtents(textWidth, textHeight);
61 if (textWidth > MaxItemWidth)
62 MaxItemWidth = textWidth;
63- TotalItemHeight += textHeight;
64- }
65-
66- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
67- {
68- // Make sure item is in layout if it should be
69- if (!(*it)->GetVisible())
70- {
71- _default_item_layout->RemoveChildObject(*it);
72- continue;
73- }
74- else if (!(*it)->GetParentObject())
75- _default_item_layout->AddView(*it, 1, nux::eCenter, nux::eFull);
76-
77- int textWidth = 0;
78- int textHeight = 0;
79- (*it)->GetTextExtents(textWidth, textHeight);
80- if (textWidth > MaxItemWidth)
81- MaxItemWidth = textWidth;
82+ textHeight += QuicklistMenuItem::ITEM_MARGIN * 2;
83 TotalItemHeight += textHeight;
84 }
85
86 if (TotalItemHeight < _anchor_height)
87 {
88- _top_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight) / 2 + 1 + _padding + _corner_radius);
89- _bottom_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight) / 2 + 1 +
90- _padding + _corner_radius +
91- _bottom_padding_correction_single_item);
92+ int b = (_anchor_height - TotalItemHeight) / 2 + _padding + _corner_radius;
93+ int t = b + _offset_correction;
94+
95+ _top_space->SetMinimumHeight(t);
96+ _top_space->SetMaximumHeight(t);
97+
98+ _bottom_space->SetMinimumHeight(b);
99+ _bottom_space->SetMaximumHeight(b);
100 }
101 else
102 {
103- _top_space->SetMinMaxSize(_padding + _corner_radius, _padding + _corner_radius);
104- _bottom_space->SetMinMaxSize(_padding + _corner_radius - 2,
105- _padding + _corner_radius +
106- _bottom_padding_correction_normal);
107+ int b = _padding + _corner_radius;
108+ int t = b + _offset_correction;
109+
110+ _top_space->SetMinimumHeight(t);
111+ _top_space->SetMaximumHeight(t);
112+
113+ _bottom_space->SetMinimumHeight(b);
114+ _bottom_space->SetMaximumHeight(b);
115 }
116
117 _item_layout->SetMinimumWidth(MaxItemWidth);
118- _default_item_layout->SetMinimumWidth(MaxItemWidth);
119
120 BaseWindow::PreLayoutManagement();
121 }
122@@ -525,7 +496,7 @@
123 UpdateTexture();
124
125 int x = _padding + _anchor_width + _corner_radius + _offset_correction;
126- int y = _padding + _corner_radius + _offset_correction;
127+ int y = _top_space->GetMinimumHeight();
128
129 std::list<QuicklistMenuItem*>::iterator it;
130 for (it = _item_list.begin(); it != _item_list.end(); it++)
131@@ -539,23 +510,12 @@
132 y += (*it)->GetBaseHeight();
133 }
134
135- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
136- {
137- if (!(*it)->GetVisible())
138- continue;
139-
140- (*it)->SetBaseX(x);
141- (*it)->SetBaseY(y);
142-
143- y += (*it)->GetBaseHeight();
144- }
145-
146 // We must correct the width of line separators. The rendering of the separator can be smaller than the width of the
147 // quicklist. The reason for that is, the quicklist width is determined by the largest entry it contains. That size is
148 // only after MaxItemWidth is computed in QuicklistView::PreLayoutManagement.
149 // The setting of the separator width is done here after the Layout cycle for this widget is over. The width of the separator
150 // has bee set correctly during the layout cycle, but the cairo rendering still need to be adjusted.
151- int separator_width = nux::Max<int>(_default_item_layout->GetBaseWidth(), _item_layout->GetBaseWidth());
152+ int separator_width = _item_layout->GetBaseWidth();
153
154 for (it = _item_list.begin(); it != _item_list.end(); it++)
155 {
156@@ -567,16 +527,6 @@
157 }
158 }
159
160- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
161- {
162- QuicklistMenuItem* item = (QuicklistMenuItem*)(*it);
163- if (item->GetVisible() && item->CairoSurfaceWidth() != separator_width)
164- {
165- // Compute textures of the item.
166- item->UpdateTexture();
167- }
168- }
169-
170 return result;
171 }
172
173@@ -623,24 +573,6 @@
174 }
175 }
176 }
177-
178- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
179- {
180- if (!(*it)->GetVisible())
181- continue;
182-
183- geo = (*it)->GetGeometry();
184- geo.width = _default_item_layout->GetBaseWidth();
185-
186- if (geo.IsPointInside(x, y))
187- {
188- // An action is performed: send the signal back to the application
189- if ((*it)->_menuItem)
190- {
191- dbusmenu_menuitem_handle_event((*it)->_menuItem, "clicked", NULL, 0);
192- }
193- }
194- }
195 }
196
197 void QuicklistView::RecvItemMouseRelease(QuicklistMenuItem* item, int x, int y)
198@@ -664,11 +596,6 @@
199 {
200 (*it)->_prelight = false;
201 }
202-
203- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
204- {
205- (*it)->_prelight = false;
206- }
207 }
208
209 void QuicklistView::RecvItemMouseDrag(QuicklistMenuItem* item, int x, int y)
210@@ -690,22 +617,6 @@
211 SelectItem(item_index);
212 }
213 }
214-
215- for (auto it : _default_item_list)
216- {
217- int item_index = GetItemIndex(it);
218-
219- if (!IsMenuItemSelectable(item_index))
220- continue;
221-
222- geo = it->GetGeometry();
223- geo.width = _default_item_layout->GetBaseWidth();
224-
225- if (geo.IsPointInside(x + item->GetBaseX(), y + item->GetBaseY()))
226- {
227- SelectItem(item_index);
228- }
229- }
230 }
231
232 void QuicklistView::RecvItemMouseEnter(QuicklistMenuItem* item)
233@@ -773,18 +684,9 @@
234 (*it)->UnReference();
235 }
236
237- for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
238- {
239- // Remove from introspection
240- RemoveChild(*it);
241- (*it)->UnReference();
242- }
243-
244 _item_list.clear();
245- _default_item_list.clear();
246
247 _item_layout->Clear();
248- _default_item_layout->Clear();
249 _cairo_text_has_changed = true;
250 nux::GetWindowThread()->QueueObjectLayout(this);
251 }
252@@ -819,7 +721,7 @@
253
254 int QuicklistView::GetNumItems()
255 {
256- return _item_list.size() + _default_item_list.size();
257+ return _item_list.size();
258 }
259
260 QuicklistMenuItem* QuicklistView::GetNthItems(int index)
261@@ -835,19 +737,6 @@
262 }
263 }
264
265- if (index < (int)_item_list.size() + (int)_default_item_list.size())
266- {
267- int i = 0;
268- if (_item_list.size() > 0)
269- i = _item_list.size() - 1;
270- std::list<QuicklistMenuItem*>::iterator it;
271- for (it = _default_item_list.begin(); it != _default_item_list.end(); i++, it++)
272- {
273- if (i == index)
274- return *it;
275- }
276- }
277-
278 return nullptr;
279 }
280
281@@ -863,14 +752,6 @@
282 return index;
283 }
284
285- for (auto it : _default_item_list)
286- {
287- ++index;
288-
289- if (it == item)
290- return index;
291- }
292-
293 return index;
294 }
295
296@@ -1304,7 +1185,7 @@
297
298 if (!_enable_quicklist_for_testing)
299 {
300- if (!_item_list.empty() || !_default_item_list.empty())
301+ if (!_item_list.empty())
302 {
303 int offscreen_size = GetBaseY() +
304 height -
305
306=== modified file 'plugins/unityshell/src/QuicklistView.h'
307--- plugins/unityshell/src/QuicklistView.h 2012-04-11 15:49:58 +0000
308+++ plugins/unityshell/src/QuicklistView.h 2012-07-04 06:13:21 +0000
309@@ -151,13 +151,10 @@
310 float _corner_radius;
311 float _padding;
312 float _left_padding_correction;
313- float _bottom_padding_correction_normal;
314- float _bottom_padding_correction_single_item;
315 float _offset_correction;
316 nux::HLayout* _hlayout;
317 nux::VLayout* _vlayout;
318 nux::VLayout* _item_layout;
319- nux::VLayout* _default_item_layout;
320 nux::SpaceLayout* _left_space; //!< Space from the left of the widget to the left of the text.
321 nux::SpaceLayout* _right_space; //!< Space from the right of the text to the right of the widget.
322 nux::SpaceLayout* _top_space; //!< Space from the left of the widget to the left of the text.
323@@ -166,7 +163,6 @@
324 bool _cairo_text_has_changed;
325 void UpdateTexture();
326 std::list<QuicklistMenuItem*> _item_list;
327- std::list<QuicklistMenuItem*> _default_item_list;
328
329 // used by keyboard/a11y-navigation
330 int _current_item_index;

Subscribers

People subscribed via source and target branches

to all changes: