Merge lp:~gordallott/unity/keynav-fixes-11-03-10 into lp:unity

Proposed by Gord Allott
Status: Merged
Merged at revision: 943
Proposed branch: lp:~gordallott/unity/keynav-fixes-11-03-10
Merge into: lp:unity
Prerequisite: lp:~unity-team/unity/various-fixes-2011-03-08
Diff against target: 454 lines (+120/-34)
14 files modified
src/IconTexture.cpp (+2/-1)
src/IconTexture.h (+2/-3)
src/PlacesGroup.cpp (+60/-13)
src/PlacesGroup.h (+4/-0)
src/PlacesResultsView.cpp (+19/-0)
src/PlacesResultsView.h (+2/-0)
src/PlacesSearchBar.cpp (+4/-6)
src/PlacesSearchBar.h (+0/-2)
src/PlacesTile.cpp (+7/-0)
src/PlacesTile.h (+2/-2)
src/PlacesView.cpp (+15/-1)
src/StaticCairoText.cpp (+1/-5)
src/StaticCairoText.h (+0/-1)
tests/TestPlaces.cpp (+2/-0)
To merge this branch: bzr merge lp:~gordallott/unity/keynav-fixes-11-03-10
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+52843@code.launchpad.net

Description of the change

Bunch of keynav fixes - still a few issues;

Can't click to focus the search bar anymore, not sure why, but as a consequence you don't get a cursor
when keynav is used on a group that has more items than are visible, you can navigate "into" that group, effectively losing focus on your keynav - should be fixed once groups are updated to not create more items than they can fit or groups at least make the items return false on IsVisible (); - unity bug not a keynav one
Keynav doesn't scroll the window
Combo-box isn't supported so you can't keynav to that yet.

requires https://code.launchpad.net/~gordallott/nux/keynav-fixes-11-03-10/+merge/52842

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Very, very cool, works well and we can fix the remaining things for next week. Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/IconTexture.cpp'
2--- src/IconTexture.cpp 2011-03-01 09:22:43 +0000
3+++ src/IconTexture.cpp 2011-03-10 15:06:55 +0000
4@@ -46,6 +46,7 @@
5 LoadIcon ();
6
7 _can_pass_focus_to_composite_layout = false;
8+ SetCanFocus (false);
9 }
10
11 IconTexture::~IconTexture ()
12@@ -187,7 +188,7 @@
13 }
14
15 bool
16-IconTexture::CanFocus ()
17+IconTexture::DoCanFocus ()
18 {
19 return false;
20 }
21
22=== modified file 'src/IconTexture.h'
23--- src/IconTexture.h 2011-02-28 16:49:11 +0000
24+++ src/IconTexture.h 2011-03-10 15:06:55 +0000
25@@ -42,7 +42,8 @@
26 protected:
27 const gchar* GetName ();
28 void AddProperties (GVariantBuilder *builder);
29-
30+ virtual bool DoCanFocus ();
31+
32 private:
33 void Draw (nux::GraphicsEngine& GfxContext, bool force_draw);
34
35@@ -53,8 +54,6 @@
36 char *_icon_name;
37 unsigned int _size;
38
39- virtual bool CanFocus ();
40-
41 GdkPixbuf *_pixbuf_cached;
42 nux::BaseTexture *_texture_cached;
43 int _texture_width;
44
45=== modified file 'src/PlacesGroup.cpp'
46--- src/PlacesGroup.cpp 2011-03-07 10:40:56 +0000
47+++ src/PlacesGroup.cpp 2011-03-10 15:06:55 +0000
48@@ -58,7 +58,8 @@
49 {
50 PlacesStyle *style = PlacesStyle::GetDefault ();
51 nux::BaseTexture *arrow = style->GetGroupUnexpandIcon ();
52-
53+
54+ _cached_name = NULL;
55 _group_layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
56
57 _header_layout = new nux::HLayout (NUX_TRACKER_LOCATION);
58@@ -77,11 +78,17 @@
59 _expand_label->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_END);
60 _expand_label->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_LEFT);
61 _expand_label->SetTextColor (kExpandDefaultTextColor);
62+ _expand_label->SetCanFocus (true);
63+ _expand_label->FocusActivated.connect (sigc::mem_fun (this, &PlacesGroup::OnLabelActivated));
64+ _expand_label->FocusChanged.connect (sigc::mem_fun (this, &PlacesGroup::OnLabelFocusChanged));
65+
66+
67 _header_layout->AddView (_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
68
69 _expand_icon = new nux::TextureArea ();
70 _expand_icon->SetTexture (arrow);
71 _expand_icon->SetMinimumSize (arrow->GetWidth (), arrow->GetHeight ());
72+ _expand_icon->SetCanFocus (false);
73 _header_layout->AddView (_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
74
75 SetLayout (_group_layout);
76@@ -107,17 +114,39 @@
77 }
78
79 void
80+PlacesGroup::OnLabelActivated (nux::Area *label)
81+{
82+ SetExpanded (!_is_expanded);
83+}
84+
85+void
86+PlacesGroup::OnLabelFocusChanged (nux::Area *label)
87+{
88+ RefreshLabel ();
89+}
90+void
91 PlacesGroup::SetName (const char *name)
92 {
93 // Spaces are on purpose, want padding to be proportional to the size of the text
94 // Bear with me, I'm trying something different :)
95 const gchar *temp = " <big>%s</big> ";
96- gchar *tmp, *final;
97+ const gchar *temp_focused = " <big><b>%s</b></big> ";
98+ gchar *tmp = NULL;
99+ gchar *final = NULL;
100+ if (_cached_name != NULL)
101+ {
102+ g_free (_cached_name);
103+ }
104+
105+ _cached_name = g_strdup (name);
106
107 tmp = g_markup_escape_text (name, -1);
108
109- final = g_strdup_printf (temp, tmp);
110-
111+ if (_expand_label->GetFocused ())
112+ final = g_strdup_printf (temp_focused, tmp);
113+ else
114+ final = g_strdup_printf (temp, tmp);
115+
116 _name->SetText (final);
117
118 g_free (tmp);
119@@ -149,7 +178,7 @@
120 }
121
122 void
123-PlacesGroup::Refresh ()
124+PlacesGroup::RefreshLabel ()
125 {
126 const char *temp = "<small>%s</small>";
127 char *result_string;
128@@ -166,26 +195,38 @@
129 else
130 {
131 result_string = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
132- "See one more result",
133- "See %d more results",
134- _n_total_items - _n_visible_items_in_unexpand_mode),
135+ "See one more result",
136+ "See %d more results",
137+ _n_total_items - _n_visible_items_in_unexpand_mode),
138 _n_total_items - _n_visible_items_in_unexpand_mode);
139 }
140-
141+
142 _expand_icon->SetVisible (!(_n_visible_items_in_unexpand_mode >= _n_total_items && _n_total_items != 0));
143
144+ char *tmpname = g_strdup (_cached_name);
145+ SetName (tmpname);
146+ g_free (tmpname);
147+
148 final = g_strdup_printf (temp, result_string);
149-
150+
151 _expand_label->SetText (final);
152 _expand_label->SetVisible (_n_visible_items_in_unexpand_mode < _n_total_items);
153
154+ QueueDraw ();
155+
156+ g_free ((result_string));
157+ g_free (final);
158+}
159+
160+void
161+PlacesGroup::Refresh ()
162+{
163+ RefreshLabel ();
164 ComputeChildLayout ();
165 QueueDraw ();
166-
167- g_free ((result_string));
168- g_free (final);
169 }
170
171+
172 void
173 PlacesGroup::Relayout ()
174 {
175@@ -203,6 +244,12 @@
176 self->ComputeChildLayout ();
177 self->_idle_id = 0;
178
179+ if (self->GetFocused ())
180+ {
181+ self->SetFocused (false); // unset focus on all children
182+ self->SetFocused (true); // set focus on first child
183+ }
184+
185 return FALSE;
186 }
187
188
189=== modified file 'src/PlacesGroup.h'
190--- src/PlacesGroup.h 2011-03-06 17:40:56 +0000
191+++ src/PlacesGroup.h 2011-03-10 15:06:55 +0000
192@@ -65,6 +65,9 @@
193 void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
194 void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
195 void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
196+ void OnLabelActivated (nux::Area *label);
197+ void OnLabelFocusChanged (nux::Area *label);
198+ void RefreshLabel ();
199
200 private:
201 nux::VLayout *_group_layout;
202@@ -81,6 +84,7 @@
203 bool _is_expanded;
204 guint _n_visible_items_in_unexpand_mode;
205 guint _n_total_items;
206+ char *_cached_name;
207 };
208
209 #endif
210
211=== modified file 'src/PlacesResultsView.cpp'
212--- src/PlacesResultsView.cpp 2011-02-28 16:49:11 +0000
213+++ src/PlacesResultsView.cpp 2011-03-10 15:06:55 +0000
214@@ -41,6 +41,7 @@
215
216 EnableVerticalScrollBar (true);
217 EnableHorizontalScrollBar (false);
218+ _idle_id = 0;
219 }
220
221 PlacesResultsView::~PlacesResultsView ()
222@@ -55,8 +56,24 @@
223 ResetScrollToUp ();
224 _groups.push_back (group);
225 _layout->AddView (group, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
226+
227+ if (_idle_id == 0)
228+ _idle_id = g_idle_add ((GSourceFunc)OnIdleFocus, this);
229 }
230
231+gboolean
232+PlacesResultsView::OnIdleFocus (PlacesResultsView *self)
233+{
234+ self->_idle_id = 0;
235+
236+ if (self->GetFocused ())
237+ {
238+ self->SetFocused (false); // unset focus on all children
239+ self->SetFocused (true); // set focus on first child
240+ }
241+
242+ return FALSE;
243+}
244 void
245 PlacesResultsView::RemoveGroup (PlacesGroup *group)
246 {
247@@ -64,6 +81,8 @@
248 ResetScrollToUp ();
249 _groups.remove (group);
250 _layout->RemoveChildObject (group);
251+ if (_idle_id == 0)
252+ _idle_id = g_idle_add ((GSourceFunc)OnIdleFocus, this);
253 }
254
255 void
256
257=== modified file 'src/PlacesResultsView.h'
258--- src/PlacesResultsView.h 2011-02-28 10:08:19 +0000
259+++ src/PlacesResultsView.h 2011-03-10 15:06:55 +0000
260@@ -54,6 +54,8 @@
261 private:
262 nux::Layout *_layout;
263 std::list<PlacesGroup *> _groups;
264+ uint _idle_id;
265+ static gboolean OnIdleFocus (PlacesResultsView *self);
266 };
267
268 #endif // PLACE_RESULTS_VIEW_H
269
270=== modified file 'src/PlacesSearchBar.cpp'
271--- src/PlacesSearchBar.cpp 2011-03-08 18:01:39 +0000
272+++ src/PlacesSearchBar.cpp 2011-03-10 15:06:55 +0000
273@@ -65,15 +65,18 @@
274 _search_icon->SetMinMaxSize (icon->GetWidth (), icon->GetHeight ());
275 _layout->AddView (_search_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
276 _search_icon->OnMouseClick.connect (sigc::mem_fun (this, &PlacesSearchBar::OnClearClicked));
277+ _search_icon->SetCanFocus (false);
278
279 _layered_layout = new nux::LayeredLayout ();
280
281 _hint = new nux::StaticCairoText (" ");
282 _hint->SetTextColor (nux::Color (1.0f, 1.0f, 1.0f, 0.5f));
283+ _hint->SetCanFocus (false);
284 _layered_layout->AddLayer (_hint);
285
286 _pango_entry = new nux::TextEntry ("", NUX_TRACKER_LOCATION);
287 _pango_entry->sigTextChanged.connect (sigc::mem_fun (this, &PlacesSearchBar::OnSearchChanged));
288+ _pango_entry->SetCanFocus (true);
289 _pango_entry->activated.connect (sigc::mem_fun (this, &PlacesSearchBar::OnEntryActivated));
290 _layered_layout->AddLayer (_pango_entry);
291
292@@ -87,6 +90,7 @@
293 _combo->SetVisible (false);
294 _combo->sigTriggered.connect (sigc::mem_fun (this, &PlacesSearchBar::OnComboChanged));
295 _combo->GetMenuPage ()->sigMouseDownOutsideMenuCascade.connect (sigc::mem_fun (this, &PlacesSearchBar::OnMenuClosing));
296+ _combo->SetCanFocus (false); // NOT SUPPORTING THIS QUITE YET
297 _layout->AddView (_combo, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
298
299 _layout->SetVerticalExternalMargin (18);
300@@ -119,12 +123,6 @@
301 return "";
302 }
303
304-bool
305-PlacesSearchBar::CanFocus ()
306-{
307- return false;
308-}
309-
310 void PlacesSearchBar::AddProperties (GVariantBuilder *builder)
311 {
312 nux::Geometry geo = GetGeometry ();
313
314=== modified file 'src/PlacesSearchBar.h'
315--- src/PlacesSearchBar.h 2011-03-08 18:01:39 +0000
316+++ src/PlacesSearchBar.h 2011-03-10 15:06:55 +0000
317@@ -57,8 +57,6 @@
318 sigc::signal<void, const char *> search_changed;
319 sigc::signal<void> activated;
320
321- bool CanFocus ();
322-
323 protected:
324 // Introspectable methods
325 const gchar * GetName ();
326
327=== modified file 'src/PlacesTile.cpp'
328--- src/PlacesTile.cpp 2011-03-09 14:13:41 +0000
329+++ src/PlacesTile.cpp 2011-03-10 15:06:55 +0000
330@@ -41,6 +41,7 @@
331 OnMouseEnter.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseEnter));
332 OnMouseLeave.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseLeave));
333 FocusChanged.connect (sigc::mem_fun (this, &PlacesTile::OnFocusChanged));
334+ FocusActivated.connect (sigc::mem_fun (this, &PlacesTile::OnFocusActivated));
335 _can_pass_focus_to_composite_layout = false;
336 }
337
338@@ -349,3 +350,9 @@
339 {
340 QueueDraw ();
341 }
342+
343+void
344+PlacesTile::OnFocusActivated (nux::Area *area)
345+{
346+ sigClick.emit (this);
347+}
348
349=== modified file 'src/PlacesTile.h'
350--- src/PlacesTile.h 2011-03-09 14:13:41 +0000
351+++ src/PlacesTile.h 2011-03-10 15:06:55 +0000
352@@ -40,7 +40,7 @@
353
354 protected:
355 virtual nux::Geometry GetHighlightGeometry ();
356-
357+
358 private:
359 void Draw (nux::GraphicsEngine &GfxContext, bool force_draw);
360 void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
361@@ -69,7 +69,7 @@
362 nux::TextureLayer *_hilight_layer;
363
364 void OnFocusChanged (nux::Area *area);
365-
366+ void OnFocusActivated (nux::Area *area);
367 int _last_width;
368 int _last_height;
369
370
371=== modified file 'src/PlacesView.cpp'
372--- src/PlacesView.cpp 2011-03-09 19:57:01 +0000
373+++ src/PlacesView.cpp 2011-03-10 15:06:55 +0000
374@@ -303,11 +303,13 @@
375 _group_added_conn = _entry->group_added.connect (sigc::mem_fun (this, &PlacesView::OnGroupAdded));
376 _result_added_conn = _entry->result_added.connect (sigc::mem_fun (this, &PlacesView::OnResultAdded));
377 _result_removed_conn = _entry->result_removed.connect (sigc::mem_fun (this, &PlacesView::OnResultRemoved));
378-
379+
380 if (_entry == _home_entry && (g_strcmp0 (search_string, "") == 0))
381 _layered_layout->SetActiveLayer (_home_view);
382 else
383 _layered_layout->SetActiveLayer (_results_view);
384+
385+
386 }
387
388 PlaceEntry *
389@@ -605,6 +607,18 @@
390
391 self->PlaceEntryActivateRequest (id, section, search_string);
392
393+ if (self->GetFocused ())
394+ {
395+ // reset the focus
396+ self->SetFocused (false);
397+ self->SetFocused (true);
398+ }
399+ else
400+ {
401+ // Not focused but we really should be
402+ self->SetFocused (true);
403+ }
404+
405 g_free (id);
406 g_free (search_string);
407 }
408
409=== modified file 'src/StaticCairoText.cpp'
410--- src/StaticCairoText.cpp 2011-02-28 16:27:57 +0000
411+++ src/StaticCairoText.cpp 2011-03-10 15:06:55 +0000
412@@ -50,6 +50,7 @@
413 _ellipsize = NUX_ELLIPSIZE_END;
414 _align = NUX_ALIGN_LEFT;
415 _fontstring = NULL;
416+ SetCanFocus (false);
417 }
418
419 StaticCairoText::~StaticCairoText ()
420@@ -477,9 +478,4 @@
421 self->sigFontChanged.emit (self);
422 }
423
424-bool StaticCairoText::CanFocus ()
425-{
426- return false;
427-}
428-
429 }
430
431=== modified file 'src/StaticCairoText.h'
432--- src/StaticCairoText.h 2011-02-28 16:27:57 +0000
433+++ src/StaticCairoText.h 2011-03-10 15:06:55 +0000
434@@ -89,7 +89,6 @@
435 sigc::signal<void, StaticCairoText*> sigTextChanged;
436 sigc::signal<void, StaticCairoText*> sigTextColorChanged;
437 sigc::signal<void, StaticCairoText*> sigFontChanged;
438- virtual bool CanFocus ();
439
440 private:
441 int _cached_extent_width;
442
443=== modified file 'tests/TestPlaces.cpp'
444--- tests/TestPlaces.cpp 2011-02-28 23:17:14 +0000
445+++ tests/TestPlaces.cpp 2011-03-10 15:06:55 +0000
446@@ -46,6 +46,8 @@
447 _combo = new nux::ComboBoxSimple (NUX_TRACKER_LOCATION);
448 _combo->SetMinimumWidth (150);
449 _combo->sigTriggered.connect (sigc::mem_fun (this, &TestApp::OnComboChangedFoRealz));
450+ _combo->SetCanFocus (false);
451+ g_debug ("can we focus? %s", _combo->CanFocus () ? "yes :(" : "no! :D");
452 layout->AddView (_combo, 0, nux::eCenter, nux::eFix);
453
454 _factory = PlaceFactory::GetDefault ();