Merge lp:~townsend/unity/fix-dash-no-expand-category into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3996
Proposed branch: lp:~townsend/unity/fix-dash-no-expand-category
Merge into: lp:unity
Diff against target: 115 lines (+50/-2)
4 files modified
dash/DashView.cpp (+34/-0)
dash/DashView.h (+2/-0)
dash/PlacesGroup.cpp (+13/-2)
dash/PlacesGroup.h (+1/-0)
To merge this branch: bzr merge lp:~townsend/unity/fix-dash-no-expand-category
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+258289@code.launchpad.net

Commit message

When using keyboard navigation in the Dash, skip category headers that are not expandable. Also, do not highlight the category header when the mouse cursor is over it.

Description of the change

Note: I ran the unity.tests.test_dash Autopilot tests against this branch with no failures.

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
Marco Trevisan (Treviño) (3v1n0) wrote :

Mh so now using tab on dash results, if the header is not expandable, then the tab highlights the first item on that category... Is this something expected?

I like it (I was worried this was causing the focus to jump to the next selectable category), but just to be sure...

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashView.cpp'
2--- dash/DashView.cpp 2015-03-20 18:03:15 +0000
3+++ dash/DashView.cpp 2015-05-08 13:49:57 +0000
4@@ -1546,6 +1546,32 @@
5 ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
6 }
7
8+nux::Area* DashView::SkipUnexpandableHeaderKeyNav()
9+{
10+ PlacesGroup::Ptr prev_view;
11+ auto category_views = active_scope_view_->GetOrderedCategoryViews();
12+
13+ for (auto category : category_views)
14+ {
15+ if (category->GetLayout() != nullptr)
16+ {
17+ auto header = category->GetHeaderFocusableView();
18+ if (header && header->HasKeyFocus() && !category->IsExpandable())
19+ {
20+ if (prev_view)
21+ return prev_view->GetChildView();
22+ else
23+ return search_bar_->text_entry();
24+ }
25+
26+ if (category->IsVisible())
27+ prev_view = category;
28+ }
29+ }
30+
31+ return nullptr;
32+}
33+
34 nux::Area* DashView::FindKeyFocusArea(unsigned int key_symbol,
35 unsigned long x11_key_code,
36 unsigned long special_keys_state)
37@@ -1691,6 +1717,14 @@
38 }
39 }
40
41+ if (direction == KEY_NAV_UP)
42+ {
43+ if (auto skip_view = SkipUnexpandableHeaderKeyNav())
44+ {
45+ return skip_view;
46+ }
47+ }
48+
49 bool search_key = false;
50
51 if (direction == KEY_NAV_NONE)
52
53=== modified file 'dash/DashView.h'
54--- dash/DashView.h 2015-02-03 09:46:48 +0000
55+++ dash/DashView.h 2015-05-08 13:49:57 +0000
56@@ -137,6 +137,8 @@
57
58 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
59
60+ nux::Area* SkipUnexpandableHeaderKeyNav();
61+
62 UBusManager ubus_manager_;
63 Scopes::Ptr scopes_;
64 ScopeViews scope_views_;
65
66=== modified file 'dash/PlacesGroup.cpp'
67--- dash/PlacesGroup.cpp 2014-07-10 16:39:12 +0000
68+++ dash/PlacesGroup.cpp 2015-05-08 13:49:57 +0000
69@@ -212,7 +212,12 @@
70 if(direction == nux::KEY_NAV_UP)
71 nux::GetWindowCompositor().SetKeyFocusArea(_child_view, direction);
72 else
73- nux::GetWindowCompositor().SetKeyFocusArea(GetHeaderFocusableView(), direction);
74+ {
75+ if (IsExpandable())
76+ nux::GetWindowCompositor().SetKeyFocusArea(GetHeaderFocusableView(), direction);
77+ else
78+ nux::GetWindowCompositor().SetKeyFocusArea(_child_view, direction);
79+ }
80 });
81
82 UpdatePlacesGroupSize();
83@@ -567,6 +572,12 @@
84 }
85
86 bool
87+PlacesGroup::IsExpandable() const
88+{
89+ return (_n_visible_items_in_unexpand_mode < _n_total_items);
90+}
91+
92+bool
93 PlacesGroup::GetExpanded() const
94 {
95 return _is_expanded;
96@@ -649,7 +660,7 @@
97
98 bool PlacesGroup::ShouldBeHighlighted() const
99 {
100- return HeaderHasKeyFocus();
101+ return (HeaderHasKeyFocus() && IsExpandable());
102 }
103
104 void PlacesGroup::SetResultsPreviewAnimationValue(float preview_animation)
105
106=== modified file 'dash/PlacesGroup.h'
107--- dash/PlacesGroup.h 2014-03-20 04:05:39 +0000
108+++ dash/PlacesGroup.h 2015-05-08 13:49:57 +0000
109@@ -77,6 +77,7 @@
110
111 void SetCounts(unsigned n_total_items);
112
113+ virtual bool IsExpandable() const;
114 virtual void SetExpanded(bool is_expanded);
115 virtual bool GetExpanded() const;
116