Merge lp:~townsend/unity/fix-dash-page-up-down into lp:unity

Proposed by Christopher Townsend on 2015-04-29
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2015-05-08
Approved revision: 3958
Merged at revision: 3970
Proposed branch: lp:~townsend/unity/fix-dash-page-up-down
Merge into: lp:unity
Diff against target: 155 lines (+35/-9)
7 files modified
dash/DashView.cpp (+8/-2)
dash/ScopeView.cpp (+5/-0)
dash/ScopeView.h (+2/-0)
unity-shared/OverlayScrollView.cpp (+5/-1)
unity-shared/OverlayScrollView.h (+2/-0)
unity-shared/PlacesOverlayVScrollBar.cpp (+5/-0)
unity-shared/PlacesOverlayVScrollBar.h (+8/-6)
To merge this branch: bzr merge lp:~townsend/unity/fix-dash-page-up-down
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2015-04-29 Approve on 2015-05-08
PS Jenkins bot (community) continuous-integration Approve on 2015-05-05
Review via email: mp+257751@code.launchpad.net

Commit message

Enable real page up/page down key navigation in the Dash. When using these keys the view scrolls the length of the visible view.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
3956. By Christopher Townsend on 2015-04-30

Clean up the case handling of the page up and page down keys and also only do these when a preview is not showing.

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

Code looks fine, but... I'm not that favourable to the usage of a bool signature on those methods.

Couldn't we use something else (ScrollDir probably can't be exported easily, but maybe nux::KeyNavDirection could be fine).

Christopher Townsend (townsend) wrote :

I would have to add a couple of new KeyNavDirection enum types to handle this and I'm a bit loathe to touch Nux which is why I did it the way I did.

What is the reason why your not in favor of the bool?

3957. By Christopher Townsend on 2015-05-04

Move the ScrollDir enum class to the anonymous namespace and use ScrollDir instead of a bool when signalling which direction to page.

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
3958. By Christopher Townsend on 2015-05-05

Use a signal instead of a nux::Property since we are not storing any value.

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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 'dash/DashView.cpp'
2--- dash/DashView.cpp 2015-03-20 18:03:15 +0000
3+++ dash/DashView.cpp 2015-05-05 13:08:22 +0000
4@@ -1576,11 +1576,9 @@
5 direction = KEY_NAV_RIGHT;
6 break;
7 case NUX_VK_LEFT_TAB:
8- case NUX_VK_PAGE_UP:
9 direction = KEY_NAV_TAB_PREVIOUS;
10 break;
11 case NUX_VK_TAB:
12- case NUX_VK_PAGE_DOWN:
13 direction = KEY_NAV_TAB_NEXT;
14 break;
15 case NUX_VK_ENTER:
16@@ -1588,6 +1586,14 @@
17 // Not sure if Enter should be a navigation key
18 direction = KEY_NAV_ENTER;
19 break;
20+ case NUX_VK_PAGE_UP:
21+ case NUX_VK_PAGE_DOWN:
22+ if (!preview_displaying_)
23+ {
24+ active_scope_view_->PerformPageNavigation((x11_key_code == NUX_VK_PAGE_UP) ? ScrollDir::UP : ScrollDir::DOWN);
25+ return nux::GetWindowCompositor().GetKeyFocusArea();
26+ }
27+ break;
28 default:
29 auto const& close_key = WindowManager::Default().close_window_key();
30
31
32=== modified file 'dash/ScopeView.cpp'
33--- dash/ScopeView.cpp 2014-07-11 22:26:26 +0000
34+++ dash/ScopeView.cpp 2015-05-05 13:08:22 +0000
35@@ -1007,6 +1007,11 @@
36 scroll_view_->ScrollToPosition(nux::Geometry(0, 0, 0, 0));
37 }
38
39+void ScopeView::PerformPageNavigation(ScrollDir dir)
40+{
41+ scroll_view_->page_direction.emit(dir);
42+}
43+
44 void ScopeView::ActivateFirst()
45 {
46 if (!scope_)
47
48=== modified file 'dash/ScopeView.h'
49--- dash/ScopeView.h 2015-02-03 09:46:48 +0000
50+++ dash/ScopeView.h 2015-05-05 13:08:22 +0000
51@@ -37,6 +37,7 @@
52 #include "ResultViewGrid.h"
53 #include "unity-shared/NuxObjectPtrHash.h"
54 #include "unity-shared/UBusWrapper.h"
55+#include "unity-shared/PlacesOverlayVScrollBar.h"
56
57 namespace unity
58 {
59@@ -62,6 +63,7 @@
60 int GetNumRows();
61 void AboutToShow();
62 void JumpToTop();
63+ void PerformPageNavigation(ScrollDir dir);
64
65 virtual void ActivateFirst();
66
67
68=== modified file 'unity-shared/OverlayScrollView.cpp'
69--- unity-shared/OverlayScrollView.cpp 2014-07-11 22:57:51 +0000
70+++ unity-shared/OverlayScrollView.cpp 2015-05-05 13:08:22 +0000
71@@ -50,7 +50,11 @@
72 scale.changed.connect([this] (double scale) {
73 m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale);
74 });
75+
76+ page_direction.connect([scrollbar] (ScrollDir dir) {
77+ scrollbar->PerformPageNavigation(dir);
78+ });
79 }
80
81 } // dash namespace
82-} // unity namespace
83\ No newline at end of file
84+} // unity namespace
85
86=== modified file 'unity-shared/OverlayScrollView.h'
87--- unity-shared/OverlayScrollView.h 2014-07-11 22:24:13 +0000
88+++ unity-shared/OverlayScrollView.h 2015-05-05 13:08:22 +0000
89@@ -21,6 +21,7 @@
90 #define _UNITY_SCROLL_VIEW_H_
91
92 #include <Nux/Nux.h>
93+#include "PlacesOverlayVScrollBar.h"
94
95 namespace unity
96 {
97@@ -33,6 +34,7 @@
98 ScrollView(NUX_FILE_LINE_PROTO);
99
100 nux::RWProperty<double> scale;
101+ sigc::signal<void, ScrollDir> page_direction;
102
103 using nux::ScrollView::SetVScrollBar;
104 };
105
106=== modified file 'unity-shared/PlacesOverlayVScrollBar.cpp'
107--- unity-shared/PlacesOverlayVScrollBar.cpp 2014-07-11 22:43:08 +0000
108+++ unity-shared/PlacesOverlayVScrollBar.cpp 2015-05-05 13:08:22 +0000
109@@ -121,6 +121,11 @@
110 animation_.SetFinishValue(stop);
111 }
112
113+void PlacesOverlayVScrollBar::PerformPageNavigation(ScrollDir dir)
114+{
115+ StartScrollAnimation(dir, _slider->GetBaseHeight());
116+}
117+
118 void PlacesOverlayVScrollBar::StartScrollAnimation(ScrollDir dir, int stop)
119 {
120 if (animation_.CurrentState() == nux::animation::Animation::State::Stopped)
121
122=== modified file 'unity-shared/PlacesOverlayVScrollBar.h'
123--- unity-shared/PlacesOverlayVScrollBar.h 2014-07-11 22:43:08 +0000
124+++ unity-shared/PlacesOverlayVScrollBar.h 2015-05-05 13:08:22 +0000
125@@ -34,22 +34,24 @@
126 namespace dash
127 {
128
129+enum class ScrollDir : unsigned int
130+{
131+ UP,
132+ DOWN,
133+};
134+
135 class PlacesOverlayVScrollBar: public PlacesVScrollBar
136 {
137 public:
138 PlacesOverlayVScrollBar(NUX_FILE_LINE_PROTO);
139 virtual ~PlacesOverlayVScrollBar() {}
140
141+ void PerformPageNavigation(ScrollDir dir);
142+
143 protected:
144 void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw);
145
146 private:
147- enum class ScrollDir : unsigned int
148- {
149- UP,
150- DOWN,
151- };
152-
153 void OnTrackGeometryChanged(nux::Area* area, nux::Geometry& geo);
154 void OnVisibilityChanged(nux::Area* area, bool visible);
155 void OnSensitivityChanged(nux::Area* area, bool sensitive);