Merge lp:~smspillaz/unity/switcher_view_interface into lp:unity

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Brandon Schaefer
Proposed branch: lp:~smspillaz/unity/switcher_view_interface
Merge into: lp:unity
Prerequisite: lp:~smspillaz/unity/mock_switcher_controller
Diff against target: 1466 lines (+733/-139)
14 files modified
launcher/StandaloneSwitcher.cpp (+13/-13)
launcher/SwitcherController.cpp (+25/-18)
launcher/SwitcherController.h (+6/-4)
launcher/SwitcherView.cpp (+407/-32)
launcher/SwitcherView.h (+221/-41)
plugins/unityshell/src/GesturalWindowSwitcher.cpp (+9/-9)
plugins/unityshell/src/unity-switcher-accessible.cpp (+11/-11)
plugins/unityshell/src/unitya11y.cpp (+1/-1)
plugins/unityshell/src/unityshell.cpp (+1/-1)
tests/MockSwitcherController.h (+1/-1)
tests/StubSwitcherController.h (+3/-3)
tests/test-gestures/SwitcherControllerMock.h (+32/-3)
tests/test-gestures/sed_script_switcher (+2/-1)
tests/test-gestures/test_gestural_window_switcher.cpp (+1/-1)
To merge this branch: bzr merge lp:~smspillaz/unity/switcher_view_interface
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Disapprove
Brandon Schaefer (community) Needs Fixing
Review via email: mp+140683@code.launchpad.net

Commit message

Pull an NVI out of SwitcherView so we can use it in testing purpose later.

Description of the change

Pull an NVI out of SwitcherView so we can use it in testing purpose later.

I know that the jury is still out on NVIs. I really don't care. I was asked to do it like this, and both virtual interfaces and nonvirtual interfaces have their merits.

Added convenience methods to replace direct access to properties within the NVI where it made sense.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Bah.

Nux's insistence on its own pointer types actually makes this branch not-workable. WIP for now.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

At the moment we're just using the nux view by composition then.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Text conflict in launcher/SwitcherController.cpp
Text conflict in launcher/SwitcherController.h
Text conflict in launcher/SwitcherView.cpp
Text conflict in launcher/SwitcherView.h
Text conflict in plugins/unityshell/src/GesturalWindowSwitcher.cpp
Text conflict in plugins/unityshell/src/unityshell.cpp
Contents conflict in tests/StubSwitcherController.h
Text conflict in tests/test-gestures/sed_script_switcher
8 conflicts encountered.

:(

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Not working on this as we're not putting any more substantial effort into UnityNux

review: Disapprove
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(Someone please reject this)

Unmerged revisions

3006. By Sam Spilsbury

Use the nux view by composition

3005. By Sam Spilsbury

The object returned to use in the a11y handler is the nux one, use that

3004. By Sam Spilsbury

Pull a non-virtual interface out of SwitcherView

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/StandaloneSwitcher.cpp'
2--- launcher/StandaloneSwitcher.cpp 2012-12-20 16:52:21 +0000
3+++ launcher/StandaloneSwitcher.cpp 2012-12-20 16:52:21 +0000
4@@ -74,37 +74,37 @@
5
6 void OnBorderSizeChanged (nux::RangeValueInteger *self)
7 {
8- controller->GetView ()->border_size = self->GetValue ();
9+ controller->GetView ()->SetBorderSize(self->GetValue ());
10 controller->GetView ()->QueueDraw ();
11 }
12
13 void OnFlatSpacingSizeChanged (nux::RangeValueInteger *self)
14 {
15- controller->GetView ()->flat_spacing = self->GetValue ();
16+ controller->GetView ()->SetFlatSpacing(self->GetValue ());
17 controller->GetView ()->QueueDraw ();
18 }
19
20 void OnTextSizeChanged (nux::RangeValueInteger *self)
21 {
22- controller->GetView ()->text_size = self->GetValue ();
23+ controller->GetView ()->SetTextSize(self->GetValue ());
24 controller->GetView ()->QueueDraw ();
25 }
26
27 void OnIconSizeChanged (nux::RangeValueInteger *self)
28 {
29- controller->GetView ()->icon_size = self->GetValue ();
30+ controller->GetView ()->SetIconSize(self->GetValue ());
31 controller->GetView ()->QueueDraw ();
32 }
33
34 void OnTileSizeChanged (nux::RangeValueInteger *self)
35 {
36- controller->GetView ()->tile_size = self->GetValue ();
37+ controller->GetView ()->SetTileSize(self->GetValue ());
38 controller->GetView ()->QueueDraw ();
39 }
40
41 void OnAnimationLengthChanged (nux::RangeValueInteger *self)
42 {
43- controller->GetView ()->animation_length = self->GetValue ();
44+ controller->GetView ()->SetAnimationLength(self->GetValue ());
45 controller->GetView ()->QueueDraw ();
46 }
47
48@@ -153,7 +153,7 @@
49
50 controller->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, icons);
51
52- controller->GetView ()->render_boxes = true;
53+ controller->GetView ()->SetRenderBoxes(true);
54
55 nux::CheckBox* flipping_check = new nux::CheckBox(TEXT("Enable Automatic Flipping"), false, NUX_TRACKER_LOCATION);
56 flipping_check->SetMaximumWidth(250);
57@@ -185,7 +185,7 @@
58 nux::StaticText* border_label = new nux::StaticText(TEXT("Border Size:"), NUX_TRACKER_LOCATION);
59 border_layout->AddView(border_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
60
61- nux::RangeValueInteger * border_size_range = new nux::RangeValueInteger (controller->GetView ()->border_size, 0, 200, NUX_TRACKER_LOCATION);
62+ nux::RangeValueInteger * border_size_range = new nux::RangeValueInteger (controller->GetView ()->GetBorderSize(), 0, 200, NUX_TRACKER_LOCATION);
63 border_size_range->sigValueChanged.connect (sigc::ptr_fun (OnBorderSizeChanged));
64 border_layout->AddView(border_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
65
66@@ -201,7 +201,7 @@
67 nux::StaticText* flat_spacing_label = new nux::StaticText(TEXT("Flat Spacing:"), NUX_TRACKER_LOCATION);
68 flat_spacing_layout->AddView(flat_spacing_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
69
70- nux::RangeValueInteger * flat_spacing_size_range = new nux::RangeValueInteger (controller->GetView ()->flat_spacing, 0, 200, NUX_TRACKER_LOCATION);
71+ nux::RangeValueInteger * flat_spacing_size_range = new nux::RangeValueInteger (controller->GetView ()->GetFlatSpacing(), 0, 200, NUX_TRACKER_LOCATION);
72 flat_spacing_size_range->sigValueChanged.connect (sigc::ptr_fun (OnFlatSpacingSizeChanged));
73 flat_spacing_layout->AddView(flat_spacing_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
74
75@@ -216,7 +216,7 @@
76 nux::StaticText* text_size_label = new nux::StaticText(TEXT("Text Size:"), NUX_TRACKER_LOCATION);
77 text_size_layout->AddView(text_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
78
79- nux::RangeValueInteger * text_size_size_range = new nux::RangeValueInteger (controller->GetView ()->text_size, 0, 200, NUX_TRACKER_LOCATION);
80+ nux::RangeValueInteger * text_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetTextSize(), 0, 200, NUX_TRACKER_LOCATION);
81 text_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTextSizeChanged));
82 text_size_layout->AddView(text_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
83
84@@ -231,7 +231,7 @@
85 nux::StaticText* icon_size_label = new nux::StaticText(TEXT("Icon Size:"), NUX_TRACKER_LOCATION);
86 icon_size_layout->AddView(icon_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
87
88- nux::RangeValueInteger * icon_size_size_range = new nux::RangeValueInteger (controller->GetView ()->icon_size, 0, 200, NUX_TRACKER_LOCATION);
89+ nux::RangeValueInteger * icon_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetIconSize(), 0, 200, NUX_TRACKER_LOCATION);
90 icon_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnIconSizeChanged));
91 icon_size_layout->AddView(icon_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
92
93@@ -246,7 +246,7 @@
94 nux::StaticText* tile_size_label = new nux::StaticText(TEXT("Tile Size:"), NUX_TRACKER_LOCATION);
95 tile_size_layout->AddView(tile_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
96
97- nux::RangeValueInteger * tile_size_size_range = new nux::RangeValueInteger (controller->GetView ()->tile_size, 0, 200, NUX_TRACKER_LOCATION);
98+ nux::RangeValueInteger * tile_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetTileSize(), 0, 200, NUX_TRACKER_LOCATION);
99 tile_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTileSizeChanged));
100 tile_size_layout->AddView(tile_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
101
102@@ -261,7 +261,7 @@
103 nux::StaticText* animation_length_label = new nux::StaticText(TEXT("Animation Length:"), NUX_TRACKER_LOCATION);
104 animation_length_layout->AddView(animation_length_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
105
106- nux::RangeValueInteger * animation_length_size_range = new nux::RangeValueInteger (controller->GetView ()->animation_length, 0, 2000, NUX_TRACKER_LOCATION);
107+ nux::RangeValueInteger * animation_length_size_range = new nux::RangeValueInteger (controller->GetView ()->GetAnimationLength(), 0, 2000, NUX_TRACKER_LOCATION);
108 animation_length_size_range->sigValueChanged.connect (sigc::ptr_fun (OnAnimationLengthChanged));
109 animation_length_layout->AddView(animation_length_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
110
111
112=== modified file 'launcher/SwitcherController.cpp'
113--- launcher/SwitcherController.cpp 2012-12-20 16:52:21 +0000
114+++ launcher/SwitcherController.cpp 2012-12-20 16:52:21 +0000
115@@ -91,7 +91,7 @@
116 impl_->Prev();
117 }
118
119-SwitcherView* Controller::GetView()
120+View* Controller::GetView()
121 {
122 return impl_->GetView();
123 }
124@@ -175,7 +175,7 @@
125 bg_color_ = nux::Color(red, green, blue, alpha);
126
127 if (view_)
128- view_->background_color = bg_color_;
129+ view_->SetBackgroundColor(bg_color_);
130 }
131
132 bool ShellController::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const
133@@ -311,16 +311,21 @@
134
135 sources_.Remove(VIEW_CONSTRUCT_IDLE);
136
137- view_ = SwitcherView::Ptr(new SwitcherView());
138- AddChild(view_.GetPointer());
139+ view_.reset (new switcher::View ([this]{
140+ nux::ObjectPtr<switcher::NuxView> p(new switcher::NuxView());
141+ introspectable_view_ = p.GetPointer();
142+ nux_view_ = p.GetPointer();
143+ return std::unique_ptr<switcher::View::Impl>(new switcher::NuxViewWrapper(p));
144+ }));
145+ AddChild(introspectable_view_);
146 view_->SetModel(model_);
147- view_->background_color = bg_color_;
148- view_->monitor = monitor_;
149+ view_->SetBackgroundColor(bg_color_);
150+ view_->SetMonitor(monitor_);
151 view_->SetupBackground();
152
153 ConstructWindow();
154- main_layout_->AddView(view_.GetPointer(), 1);
155- view_window_->SetEnterFocusInputArea(view_.GetPointer());
156+ main_layout_->AddView(nux_view_, 1);
157+ view_window_->SetEnterFocusInputArea(nux_view_);
158 view_window_->SetGeometry(workarea_);
159 view_window_->SetOpacity(0.0f);
160
161@@ -333,7 +338,7 @@
162 workarea_ = geo;
163
164 if (view_)
165- view_->monitor = monitor_;
166+ view_->SetMonitor(monitor_);
167 }
168
169 void ShellController::Hide(bool accept_state)
170@@ -375,7 +380,15 @@
171 visible_ = false;
172
173 if (view_)
174- main_layout_->RemoveChildObject(view_.GetPointer());
175+ main_layout_->RemoveChildObject(nux_view_);
176+
177+ ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", false, monitor_));
178+
179+ last_active_selection_ = nullptr;
180+
181+ view_.reset();
182+ nux_view_ = nullptr;
183+ introspectable_view_ = nullptr;
184
185 if (view_window_)
186 {
187@@ -384,12 +397,6 @@
188 view_window_->PushToBack();
189 view_window_->EnableInputWindow(false);
190 }
191-
192- ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", false, monitor_));
193-
194- last_active_selection_ = nullptr;
195-
196- view_.Release();
197 }
198
199 bool ShellController::Visible()
200@@ -455,9 +462,9 @@
201 }
202 }
203
204-SwitcherView* ShellController::GetView()
205+View *ShellController::GetView()
206 {
207- return view_.GetPointer();
208+ return view_.get();
209 }
210
211 void ShellController::SetDetail(bool value, unsigned int min_windows)
212
213=== modified file 'launcher/SwitcherController.h'
214--- launcher/SwitcherController.h 2012-12-20 16:52:21 +0000
215+++ launcher/SwitcherController.h 2012-12-20 16:52:21 +0000
216@@ -94,7 +94,7 @@
217 void SetWorkspace(nux::Geometry geo,
218 int monitor);
219
220- SwitcherView * GetView ();
221+ View * GetView ();
222
223 ui::LayoutWindow::Vector ExternalRenderTargets ();
224
225@@ -142,7 +142,7 @@
226 virtual void SetWorkspace(nux::Geometry geo,
227 int monitor) = 0;
228
229- virtual SwitcherView * GetView () = 0;
230+ virtual View * GetView () = 0;
231
232 virtual ui::LayoutWindow::Vector ExternalRenderTargets () = 0;
233
234@@ -190,7 +190,7 @@
235
236 void SetWorkspace(nux::Geometry geo, int monitor);
237
238- virtual SwitcherView* GetView();
239+ virtual View* GetView();
240
241 ui::LayoutWindow::Vector ExternalRenderTargets ();
242
243@@ -226,7 +226,9 @@
244 static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon::Ptr const& first, launcher::AbstractLauncherIcon::Ptr const& second);
245
246 SwitcherModel::Ptr model_;
247- SwitcherView::Ptr view_;
248+ debug::Introspectable *introspectable_view_;
249+ NuxView *nux_view_;
250+ View::Ptr view_;
251
252 nux::Geometry workarea_;
253 nux::ObjectPtr<nux::BaseWindow> view_window_;
254
255=== modified file 'launcher/SwitcherView.cpp'
256--- launcher/SwitcherView.cpp 2012-12-14 12:14:34 +0000
257+++ launcher/SwitcherView.cpp 2012-12-20 16:52:21 +0000
258@@ -32,10 +32,282 @@
259 namespace switcher
260 {
261
262-NUX_IMPLEMENT_OBJECT_TYPE(SwitcherView);
263-
264-SwitcherView::SwitcherView()
265- : render_boxes(false)
266+View::View(const ViewFactoryFunc &create)
267+ : impl_(create())
268+{
269+}
270+
271+
272+ui::LayoutWindow::Vector View::ExternalTargets()
273+{
274+ return impl_->ExternalTargets();
275+}
276+
277+void View::SetModel(SwitcherModel::Ptr model)
278+{
279+ impl_->SetModel(model);
280+}
281+
282+SwitcherModel::Ptr View::GetModel()
283+{
284+ return impl_->GetModel();
285+}
286+
287+View::MouseEventConnections
288+View::ConnectToMouseEvents(const View::MouseButtonCallback &mouse_down_callback,
289+ const View::MouseButtonCallback &mouse_up_callback,
290+ const View::MouseDragCallback &mouse_drag_callback)
291+{
292+ return impl_->ConnectToMouseEvents(mouse_down_callback,
293+ mouse_up_callback,
294+ mouse_drag_callback);
295+}
296+
297+void View::QueueDraw()
298+{
299+ impl_->QueueDraw();
300+}
301+
302+nux::Geometry View::GetAbsoluteGeometry() const
303+{
304+ return impl_->GetAbsoluteGeometry();
305+}
306+
307+// Returns the index of the icon at the given position, in window coordinates.
308+// If there's no icon there, -1 is returned.
309+int View::IconIndexAt(int x, int y)
310+{
311+ return impl_->IconIndexAt(x, y);
312+}
313+
314+// Property setters
315+void View::SetBackgroundColor(nux::Color const& color)
316+{
317+ impl_->SetBackgroundColor(color);
318+}
319+
320+void View::SetMonitor(unsigned int monitor)
321+{
322+ impl_->SetMonitor(monitor);
323+}
324+
325+void View::SetBorderSize(unsigned int size)
326+{
327+ impl_->SetBorderSize(size);
328+}
329+
330+void View::SetFlatSpacing(int spacing)
331+{
332+ impl_->SetFlatSpacing(spacing);
333+}
334+
335+void View::SetTextSize(unsigned int size)
336+{
337+ impl_->SetTextSize(size);
338+}
339+
340+void View::SetIconSize(unsigned int size)
341+{
342+ impl_->SetIconSize(size);
343+}
344+
345+void View::SetTileSize(unsigned int size)
346+{
347+ impl_->SetTileSize(size);
348+}
349+
350+void View::SetAnimationLength(unsigned int length)
351+{
352+ impl_->SetAnimationLength(length);
353+}
354+
355+void View::SetRenderBoxes(bool render)
356+{
357+ impl_->SetRenderBoxes(render);
358+}
359+
360+// Property getters
361+unsigned int View::GetBorderSize()
362+{
363+ return impl_->GetBorderSize();
364+}
365+
366+unsigned int View::GetFlatSpacing()
367+{
368+ return impl_->GetFlatSpacing();
369+}
370+
371+unsigned int View::GetTextSize()
372+{
373+ return impl_->GetTextSize();
374+}
375+
376+unsigned int View::GetIconSize()
377+{
378+ return impl_->GetIconSize();
379+}
380+
381+unsigned int View::GetTileSize()
382+{
383+ return impl_->GetTileSize();
384+}
385+
386+unsigned int View::GetAnimationLength()
387+{
388+ return impl_->GetAnimationLength();
389+}
390+
391+void View::SetupBackground(bool enabled)
392+{
393+ return impl_->SetupBackground(enabled);
394+}
395+
396+View::Impl::Impl()
397+{
398+}
399+
400+NuxViewWrapper::NuxViewWrapper(const nux::ObjectPtr<NuxView> &nuxView)
401+ : reference_(nuxView),
402+ impl_(nuxView.GetPointer())
403+{
404+}
405+
406+
407+ui::LayoutWindow::Vector NuxViewWrapper::ExternalTargets()
408+{
409+ return impl_->ExternalTargets();
410+}
411+
412+void NuxViewWrapper::SetModel(SwitcherModel::Ptr model)
413+{
414+ impl_->SetModel(model);
415+}
416+
417+SwitcherModel::Ptr NuxViewWrapper::GetModel()
418+{
419+ return impl_->GetModel();
420+}
421+
422+View::MouseEventConnections
423+NuxViewWrapper::ConnectToMouseEvents(View::MouseButtonCallback const& mouse_down_callback,
424+ View::MouseButtonCallback const& mouse_up_callback,
425+ View::MouseDragCallback const& mouse_drag_callback)
426+{
427+ return impl_->ConnectToMouseEvents(mouse_down_callback,
428+ mouse_up_callback,
429+ mouse_drag_callback);
430+}
431+
432+void NuxViewWrapper::QueueDraw()
433+{
434+ impl_->QueueDraw();
435+}
436+
437+nux::Geometry NuxViewWrapper::GetAbsoluteGeometry() const
438+{
439+ return impl_->GetAbsoluteGeometry();
440+}
441+
442+nux::Area * NuxViewWrapper::GetTopLevelViewWindow()
443+{
444+ return impl_->GetTopLevelViewWindow();
445+}
446+
447+// Returns the index of the icon at the given position, in window coordinates.
448+// If there's no icon there, -1 is returned.
449+int NuxViewWrapper::IconIndexAt(int x, int y)
450+{
451+ return impl_->IconIndexAt(x, y);
452+}
453+
454+// Property setters
455+void NuxViewWrapper::SetBackgroundColor(nux::Color const& color)
456+{
457+ impl_->SetBackgroundColor(color);
458+}
459+
460+void NuxViewWrapper::SetMonitor(unsigned int monitor)
461+{
462+ impl_->SetMonitor(monitor);
463+}
464+
465+void NuxViewWrapper::SetBorderSize(unsigned int size)
466+{
467+ impl_->SetBorderSize(size);
468+}
469+
470+void NuxViewWrapper::SetFlatSpacing(int spacing)
471+{
472+ impl_->SetFlatSpacing(spacing);
473+}
474+
475+void NuxViewWrapper::SetTextSize(unsigned int size)
476+{
477+ impl_->SetTextSize(size);
478+}
479+
480+void NuxViewWrapper::SetIconSize(unsigned int size)
481+{
482+ impl_->SetIconSize(size);
483+}
484+
485+void NuxViewWrapper::SetTileSize(unsigned int size)
486+{
487+ impl_->SetTileSize(size);
488+}
489+
490+void NuxViewWrapper::SetAnimationLength(unsigned int length)
491+{
492+ impl_->SetAnimationLength(length);
493+}
494+
495+void NuxViewWrapper::SetRenderBoxes(bool render)
496+{
497+ impl_->SetRenderBoxes(render);
498+}
499+
500+// Property getters
501+unsigned int NuxViewWrapper::GetBorderSize()
502+{
503+ return impl_->GetBorderSize();
504+}
505+
506+unsigned int NuxViewWrapper::GetFlatSpacing()
507+{
508+ return impl_->GetFlatSpacing();
509+}
510+
511+unsigned int NuxViewWrapper::GetTextSize()
512+{
513+ return impl_->GetTextSize();
514+}
515+
516+unsigned int NuxViewWrapper::GetIconSize()
517+{
518+ return impl_->GetIconSize();
519+}
520+
521+unsigned int NuxViewWrapper::GetTileSize()
522+{
523+ return impl_->GetTileSize();
524+}
525+
526+unsigned int NuxViewWrapper::GetAnimationLength()
527+{
528+ return impl_->GetAnimationLength();
529+}
530+
531+void NuxViewWrapper::SetupBackground(bool enabled)
532+{
533+ return impl_->SetupBackground(enabled);
534+}
535+
536+NUX_IMPLEMENT_OBJECT_TYPE(NuxView);
537+
538+NuxView::NuxView()
539+ : UnityWindowView()
540+ , switcher::View::Impl ()
541+ , render_boxes(false)
542 , border_size(50)
543 , flat_spacing(10)
544 , icon_size(128)
545@@ -60,18 +332,28 @@
546 text_view_->SetTextColor(nux::color::White);
547 text_view_->SetFont("Ubuntu Bold 10");
548
549- icon_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnIconSizeChanged));
550- tile_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnTileSizeChanged));
551+ icon_size.changed.connect (sigc::mem_fun (this, &NuxView::OnIconSizeChanged));
552+ tile_size.changed.connect (sigc::mem_fun (this, &NuxView::OnTileSizeChanged));
553
554 CaptureMouseDownAnyWhereElse(true);
555 }
556
557-std::string SwitcherView::GetName() const
558+void NuxView::SetBackgroundColor(nux::Color const& color)
559+{
560+ background_color = color;
561+}
562+
563+void NuxView::SetupBackground(bool enabled)
564+{
565+ UnityWindowView::SetupBackground(enabled);
566+}
567+
568+std::string NuxView::GetName() const
569 {
570 return "SwitcherView";
571 }
572
573-void SwitcherView::AddProperties(GVariantBuilder* builder)
574+void NuxView::AddProperties(GVariantBuilder* builder)
575 {
576 unity::variant::BuilderWrapper(builder)
577 .add("render-boxes", render_boxes)
578@@ -88,17 +370,17 @@
579 .add("label_visible", text_view_->IsVisible());
580 }
581
582-LayoutWindow::Vector SwitcherView::ExternalTargets ()
583+LayoutWindow::Vector NuxView::ExternalTargets ()
584 {
585 return render_targets_;
586 }
587
588-void SwitcherView::SetModel(SwitcherModel::Ptr model)
589+void NuxView::SetModel(SwitcherModel::Ptr model)
590 {
591 model_ = model;
592- model->selection_changed.connect(sigc::mem_fun(this, &SwitcherView::OnSelectionChanged));
593- model->detail_selection.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionChanged));
594- model->detail_selection_index.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionIndexChanged));
595+ model->selection_changed.connect(sigc::mem_fun(this, &NuxView::OnSelectionChanged));
596+ model->detail_selection.changed.connect (sigc::mem_fun (this, &NuxView::OnDetailSelectionChanged));
597+ model->detail_selection_index.changed.connect (sigc::mem_fun (this, &NuxView::OnDetailSelectionIndexChanged));
598
599 if (!model->Selection())
600 return;
601@@ -109,30 +391,30 @@
602 text_view_->SetText(model->Selection()->tooltip_text());
603 }
604
605-void SwitcherView::OnIconSizeChanged (int size)
606+void NuxView::OnIconSizeChanged (int size)
607 {
608 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
609 }
610
611-void SwitcherView::OnTileSizeChanged (int size)
612+void NuxView::OnTileSizeChanged (int size)
613 {
614 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
615 vertical_size = tile_size + 80;
616 }
617
618-void SwitcherView::SaveLast ()
619+void NuxView::SaveLast ()
620 {
621 saved_args_ = last_args_;
622 saved_background_ = last_background_;
623 clock_gettime(CLOCK_MONOTONIC, &save_time_);
624 }
625
626-void SwitcherView::OnDetailSelectionIndexChanged(unsigned int index)
627+void NuxView::OnDetailSelectionIndexChanged(unsigned int index)
628 {
629 QueueDraw ();
630 }
631
632-void SwitcherView::OnDetailSelectionChanged(bool detail)
633+void NuxView::OnDetailSelectionChanged (bool detail)
634 {
635 text_view_->SetVisible(!detail);
636
637@@ -143,7 +425,7 @@
638 QueueDraw();
639 }
640
641-void SwitcherView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
642+void NuxView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
643 {
644 if (selection)
645 text_view_->SetText(selection->tooltip_text());
646@@ -152,12 +434,12 @@
647 QueueDraw();
648 }
649
650-SwitcherModel::Ptr SwitcherView::GetModel()
651+SwitcherModel::Ptr NuxView::GetModel()
652 {
653 return model_;
654 }
655
656-RenderArg SwitcherView::CreateBaseArgForIcon(AbstractLauncherIcon::Ptr const& icon)
657+RenderArg NuxView::CreateBaseArgForIcon(AbstractLauncherIcon::Ptr const& icon)
658 {
659 RenderArg arg;
660 arg.icon = icon.GetPointer();
661@@ -185,7 +467,7 @@
662 return arg;
663 }
664
665-RenderArg SwitcherView::InterpolateRenderArgs(RenderArg const& start, RenderArg const& end, float progress)
666+RenderArg NuxView::InterpolateRenderArgs(RenderArg const& start, RenderArg const& end, float progress)
667 {
668 // easing
669 progress = -pow(progress - 1.0f, 2) + 1;
670@@ -205,7 +487,7 @@
671 return result;
672 }
673
674-nux::Geometry SwitcherView::InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress)
675+nux::Geometry NuxView::InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress)
676 {
677 progress = -pow(progress - 1.0f, 2) + 1;
678
679@@ -219,7 +501,7 @@
680 return result;
681 }
682
683-nux::Geometry SwitcherView::UpdateRenderTargets(nux::Point const& center, timespec const& current)
684+nux::Geometry NuxView::UpdateRenderTargets (nux::Point const& center, timespec const& current)
685 {
686 std::vector<Window> const& xids = model_->DetailXids();
687
688@@ -262,7 +544,7 @@
689 return final_bounds;
690 }
691
692-void SwitcherView::OffsetRenderTargets (int x, int y)
693+void NuxView::OffsetRenderTargets (int x, int y)
694 {
695 for (LayoutWindow::Ptr const& target : render_targets_)
696 {
697@@ -271,7 +553,7 @@
698 }
699 }
700
701-nux::Size SwitcherView::SpreadSize()
702+nux::Size NuxView::SpreadSize()
703 {
704 nux::Geometry const& base = GetGeometry();
705 nux::Size result(base.width - border_size * 2, base.height - border_size * 2);
706@@ -282,7 +564,7 @@
707 return result;
708 }
709
710-void SwitcherView::GetFlatIconPositions (int n_flat_icons,
711+void NuxView::GetFlatIconPositions (int n_flat_icons,
712 int size,
713 int selection,
714 int &first_flat,
715@@ -356,7 +638,7 @@
716 }
717 }
718
719-std::list<RenderArg> SwitcherView::RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current)
720+std::list<RenderArg> NuxView::RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current)
721 {
722 std::list<RenderArg> results;
723 nux::Geometry const& base = GetGeometry();
724@@ -506,7 +788,7 @@
725 return results;
726 }
727
728-void SwitcherView::PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
729+void NuxView::PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
730 {
731 clock_gettime(CLOCK_MONOTONIC, &current_);
732
733@@ -523,12 +805,22 @@
734 icon_renderer_->PreprocessIcons(last_args_, GetGeometry());
735 }
736
737-nux::Geometry SwitcherView::GetBackgroundGeometry()
738+nux::Geometry NuxView::GetBackgroundGeometry()
739 {
740 return last_background_;
741 }
742
743-void SwitcherView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry internal_clip)
744+void NuxView::QueueDraw()
745+{
746+ ui::UnityWindowView::QueueDraw();
747+}
748+
749+nux::Geometry NuxView::GetAbsoluteGeometry() const
750+{
751+ return ui::UnityWindowView::GetAbsoluteGeometry();
752+}
753+
754+void NuxView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry internal_clip)
755 {
756 nux::Geometry base = GetGeometry();
757
758@@ -600,7 +892,7 @@
759 animation_draw_ = false;
760 }
761
762-int SwitcherView::IconIndexAt(int x, int y)
763+int NuxView::IconIndexAt(int x, int y)
764 {
765 int half_size = icon_size.Get() / 2;
766 int icon_index = -1;
767@@ -633,5 +925,88 @@
768 return icon_index;
769 }
770
771+NuxView::MouseEventConnections
772+NuxView::ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
773+ const MouseButtonCallback &mouse_up_callback,
774+ const MouseDragCallback &mouse_drag_callback)
775+{
776+ return NuxView::MouseEventConnections
777+ (mouse_down.connect (mouse_down_callback),
778+ mouse_up.connect (mouse_up_callback),
779+ mouse_drag.connect (mouse_drag_callback));
780+}
781+
782+}
783+
784+// Property setters
785+void NuxView::SetMonitor(unsigned int monitor_id)
786+{
787+ monitor = monitor_id;
788+}
789+
790+void NuxView::SetBorderSize(unsigned int size)
791+{
792+ border_size = size;
793+}
794+
795+void NuxView::SetFlatSpacing(int spacing)
796+{
797+ flat_spacing = spacing;
798+}
799+
800+void NuxView::SetTextSize(unsigned int size)
801+{
802+ text_size = size;
803+}
804+
805+void NuxView::SetIconSize(unsigned int size)
806+{
807+ icon_size = size;
808+}
809+
810+void NuxView::SetTileSize(unsigned int size)
811+{
812+ tile_size = size;
813+}
814+
815+void NuxView::SetAnimationLength(unsigned int length)
816+{
817+ animation_length = length;
818+}
819+
820+void NuxView::SetRenderBoxes(bool render)
821+{
822+ render_boxes = render;
823+}
824+
825+// Property getters
826+unsigned int NuxView::GetBorderSize()
827+{
828+ return border_size;
829+}
830+
831+unsigned int NuxView::GetFlatSpacing()
832+{
833+ return flat_spacing;
834+}
835+
836+unsigned int NuxView::GetTextSize()
837+{
838+ return text_size;
839+}
840+
841+unsigned int NuxView::GetIconSize()
842+{
843+ return icon_size;
844+}
845+
846+unsigned int NuxView::GetTileSize()
847+{
848+ return tile_size;
849+}
850+
851+unsigned int NuxView::GetAnimationLength()
852+{
853+ return animation_length;
854 }
855 }
856
857=== modified file 'launcher/SwitcherView.h'
858--- launcher/SwitcherView.h 2012-12-14 12:14:34 +0000
859+++ launcher/SwitcherView.h 2012-12-20 16:52:21 +0000
860@@ -20,6 +20,8 @@
861 #ifndef SWITCHERVIEW_H
862 #define SWITCHERVIEW_H
863
864+#include <tuple>
865+
866 #include "SwitcherModel.h"
867 #include "unity-shared/AbstractIconRenderer.h"
868 #include "unity-shared/StaticCairoText.h"
869@@ -41,73 +43,204 @@
870 }
871 namespace switcher
872 {
873-
874-class SwitcherView : public ui::UnityWindowView
875-{
876- NUX_DECLARE_OBJECT_TYPE(SwitcherView, ui::UnityWindowView);
877-public:
878- typedef nux::ObjectPtr<SwitcherView> Ptr;
879-
880- SwitcherView();
881+class View
882+{
883+ public:
884+
885+ typedef sigc::slot<void, int, int, int, int> MouseButtonCallback;
886+ typedef sigc::slot <void, int, int, int, int, unsigned int, unsigned int> MouseDragCallback;
887+
888+ typedef std::tuple <sigc::connection,
889+ sigc::connection,
890+ sigc::connection> MouseEventConnections;
891+
892+ class Impl;
893+ typedef std::unique_ptr<Impl> ImplPtr;
894+ typedef std::shared_ptr<View> Ptr;
895+ typedef std::function<ImplPtr()> ViewFactoryFunc;
896+
897+ View(ViewFactoryFunc const&);
898+
899+ ui::LayoutWindow::Vector ExternalTargets();
900+
901+ void SetModel(SwitcherModel::Ptr model);
902+ SwitcherModel::Ptr GetModel();
903+
904+ MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
905+ const MouseButtonCallback &mouse_up_callback,
906+ const MouseDragCallback &mouse_drag_callback);
907+ void QueueDraw();
908+ nux::Geometry GetAbsoluteGeometry() const;
909+
910+ // Returns the index of the icon at the given position, in window coordinates.
911+ // If there's no icon there, -1 is returned.
912+ int IconIndexAt(int x, int y);
913+
914+ // Property setters
915+ void SetBackgroundColor(nux::Color const& color);
916+ void SetMonitor(unsigned int monitor);
917+ void SetBorderSize(unsigned int);
918+ void SetFlatSpacing(int);
919+ void SetTextSize(unsigned int);
920+ void SetIconSize(unsigned int);
921+ void SetTileSize(unsigned int);
922+ void SetAnimationLength(unsigned int);
923+ void SetRenderBoxes(bool);
924+
925+ // Property getters
926+ unsigned int GetBorderSize();
927+ unsigned int GetFlatSpacing();
928+ unsigned int GetTextSize();
929+ unsigned int GetIconSize();
930+ unsigned int GetTileSize();
931+ unsigned int GetAnimationLength();
932+
933+ void SetupBackground(bool enabled = true);
934+
935+ private:
936+ std::unique_ptr<Impl> impl_;
937+};
938+
939+class View::Impl
940+{
941+public:
942+
943+ typedef switcher::View::MouseButtonCallback MouseButtonCallback;
944+ typedef switcher::View::MouseDragCallback MouseDragCallback;
945+ typedef switcher::View::MouseEventConnections MouseEventConnections;
946+
947+ Impl();
948+
949+ virtual ~Impl() {};
950+
951+ virtual ui::LayoutWindow::Vector ExternalTargets() = 0;
952+
953+ virtual void SetModel(SwitcherModel::Ptr model) = 0;
954+ virtual SwitcherModel::Ptr GetModel() = 0;
955+
956+ virtual MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
957+ const MouseButtonCallback &mouse_up_callback,
958+ const MouseDragCallback &mouse_drag_callback) = 0;
959+ virtual void QueueDraw() = 0;
960+ virtual nux::Geometry GetAbsoluteGeometry() const = 0;
961+
962+ // Returns the index of the icon at the given position, in window coordinates.
963+ // If there's no icon there, -1 is returned.
964+ virtual int IconIndexAt(int x, int y) = 0;
965+
966+ // Property setters
967+ virtual void SetBackgroundColor(nux::Color const& color) = 0;
968+ virtual void SetMonitor(unsigned int monitor) = 0;
969+ virtual void SetBorderSize(unsigned int) = 0;
970+ virtual void SetFlatSpacing(int) = 0;
971+ virtual void SetTextSize(unsigned int) = 0;
972+ virtual void SetIconSize(unsigned int) = 0;
973+ virtual void SetTileSize(unsigned int) = 0;
974+ virtual void SetAnimationLength(unsigned int) = 0;
975+ virtual void SetRenderBoxes(bool) = 0;
976+
977+ // Property getters
978+ virtual unsigned int GetBorderSize() = 0;
979+ virtual unsigned int GetFlatSpacing() = 0;
980+ virtual unsigned int GetTextSize() = 0;
981+ virtual unsigned int GetIconSize() = 0;
982+ virtual unsigned int GetTileSize() = 0;
983+ virtual unsigned int GetAnimationLength() = 0;
984+ virtual void SetupBackground(bool enabled) = 0;
985+};
986+
987+class NuxView : public ui::UnityWindowView,
988+ public unity::switcher::View::Impl
989+{
990+ NUX_DECLARE_OBJECT_TYPE(NuxView, ui::UnityWindowView);
991+public:
992+
993+ NuxView();
994
995 ui::LayoutWindow::Vector ExternalTargets();
996
997 void SetModel(SwitcherModel::Ptr model);
998 SwitcherModel::Ptr GetModel();
999
1000- nux::Property<bool> render_boxes;
1001- nux::Property<int> border_size;
1002- nux::Property<int> flat_spacing;
1003- nux::Property<int> icon_size;
1004- nux::Property<int> minimum_spacing;
1005- nux::Property<int> tile_size;
1006- nux::Property<int> vertical_size;
1007- nux::Property<int> text_size;
1008- nux::Property<int> animation_length;
1009- nux::Property<int> monitor;
1010- nux::Property<double> spread_size;
1011-
1012 // Returns the index of the icon at the given position, in window coordinates.
1013 // If there's no icon there, -1 is returned.
1014 int IconIndexAt(int x, int y);
1015
1016+ MouseEventConnections ConnectToMouseEvents(MouseButtonCallback const& mouse_down_callback,
1017+ MouseButtonCallback const& mouse_up_callback,
1018+ MouseDragCallback const& mouse_drag_callback);
1019+
1020 protected:
1021 // Introspectable methods
1022+ void SetupBackground(bool enabled);
1023 std::string GetName() const;
1024 void AddProperties(GVariantBuilder* builder);
1025
1026 void PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
1027 void DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry clip);
1028+ void QueueDraw();
1029+ nux::Geometry GetAbsoluteGeometry() const;
1030 nux::Geometry GetBackgroundGeometry();
1031
1032 ui::RenderArg InterpolateRenderArgs(ui::RenderArg const& start, ui::RenderArg const& end, float progress);
1033- nux::Geometry InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress);
1034+ nux::Geometry InterpolateBackground(nux::Geometry const& start, nux::Geometry const& end, float progress);
1035
1036 std::list<ui::RenderArg> RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current);
1037
1038 ui::RenderArg CreateBaseArgForIcon(launcher::AbstractLauncherIcon::Ptr const& icon);
1039 private:
1040 void OnSelectionChanged(launcher::AbstractLauncherIcon::Ptr const& selection);
1041- void OnDetailSelectionChanged (bool detail);
1042- void OnDetailSelectionIndexChanged (unsigned int index);
1043-
1044- void OnIconSizeChanged (int size);
1045- void OnTileSizeChanged (int size);
1046-
1047- nux::Geometry UpdateRenderTargets (nux::Point const& center, timespec const& current);
1048- void OffsetRenderTargets (int x, int y);
1049-
1050- nux::Size SpreadSize ();
1051-
1052- void GetFlatIconPositions (int n_flat_icons,
1053- int size,
1054- int selection,
1055- int &first_flat,
1056- int &last_flat,
1057- int &half_fold_left,
1058- int &half_fold_right);
1059-
1060- void SaveLast ();
1061+ void OnDetailSelectionChanged(bool detail);
1062+ void OnDetailSelectionIndexChanged(unsigned int index);
1063+
1064+ void OnIconSizeChanged(int size);
1065+ void OnTileSizeChanged(int size);
1066+
1067+ nux::Geometry UpdateRenderTargets(nux::Point const& center, timespec const& current);
1068+ void OffsetRenderTargets(int x, int y);
1069+
1070+ nux::Size SpreadSize();
1071+
1072+ void GetFlatIconPositions(int n_flat_icons,
1073+ int size,
1074+ int selection,
1075+ int &first_flat,
1076+ int &last_flat,
1077+ int &half_fold_left,
1078+ int &half_fold_right);
1079+
1080+ void SaveLast();
1081+
1082+ // Property setters
1083+ void SetBackgroundColor(nux::Color const& color);
1084+ void SetMonitor(unsigned int monitor);
1085+ void SetBorderSize(unsigned int);
1086+ void SetFlatSpacing(int);
1087+ void SetTextSize(unsigned int);
1088+ void SetIconSize(unsigned int);
1089+ void SetTileSize(unsigned int);
1090+ void SetAnimationLength(unsigned int);
1091+ void SetRenderBoxes(bool);
1092+
1093+ // Property getters
1094+ unsigned int GetBorderSize();
1095+ unsigned int GetFlatSpacing();
1096+ unsigned int GetTextSize();
1097+ unsigned int GetIconSize();
1098+ unsigned int GetTileSize();
1099+ unsigned int GetAnimationLength();
1100+
1101+ nux::Property<bool> render_boxes;
1102+ nux::Property<int> border_size;
1103+ nux::Property<int> flat_spacing;
1104+ nux::Property<int> icon_size;
1105+ nux::Property<int> minimum_spacing;
1106+ nux::Property<int> tile_size;
1107+ nux::Property<int> vertical_size;
1108+ nux::Property<int> text_size;
1109+ nux::Property<int> animation_length;
1110+ nux::Property<int> monitor;
1111+ nux::Property<double> spread_size;
1112
1113 SwitcherModel::Ptr model_;
1114 ui::LayoutSystem layout_system_;
1115@@ -132,6 +265,53 @@
1116 glib::Source::UniquePtr redraw_idle_;
1117 };
1118
1119+class NuxViewWrapper : public unity::switcher::View::Impl
1120+{
1121+ public:
1122+
1123+ NuxViewWrapper(nux::ObjectPtr<NuxView> const& nuxView);
1124+
1125+ ui::LayoutWindow::Vector ExternalTargets();
1126+
1127+ void SetModel(SwitcherModel::Ptr model);
1128+ SwitcherModel::Ptr GetModel();
1129+
1130+ MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
1131+ const MouseButtonCallback &mouse_up_callback,
1132+ const MouseDragCallback &mouse_drag_callback);
1133+ void QueueDraw();
1134+ nux::Geometry GetAbsoluteGeometry() const;
1135+
1136+ // Returns the index of the icon at the given position, in window coordinates.
1137+ // If there's no icon there, -1 is returned.
1138+ int IconIndexAt(int x, int y);
1139+
1140+ // Property setters
1141+ void SetBackgroundColor(nux::Color const& color);
1142+ void SetMonitor(unsigned int monitor);
1143+ void SetBorderSize(unsigned int);
1144+ void SetFlatSpacing(int);
1145+ void SetTextSize(unsigned int);
1146+ void SetIconSize(unsigned int);
1147+ void SetTileSize(unsigned int);
1148+ void SetAnimationLength(unsigned int);
1149+ void SetRenderBoxes(bool);
1150+
1151+ // Property getters
1152+ unsigned int GetBorderSize();
1153+ unsigned int GetFlatSpacing();
1154+ unsigned int GetTextSize();
1155+ unsigned int GetIconSize();
1156+ unsigned int GetTileSize();
1157+ unsigned int GetAnimationLength();
1158+
1159+ void SetupBackground(bool enabled = true);
1160+
1161+ nux::Area * GetTopLevelViewWindow();
1162+ private:
1163+ nux::ObjectPtr<nux::Object> reference_;
1164+ unity::switcher::View::Impl *impl_;
1165+};
1166 }
1167 }
1168
1169
1170=== modified file 'plugins/unityshell/src/GesturalWindowSwitcher.cpp'
1171--- plugins/unityshell/src/GesturalWindowSwitcher.cpp 2012-12-20 16:52:21 +0000
1172+++ plugins/unityshell/src/GesturalWindowSwitcher.cpp 2012-12-20 16:52:21 +0000
1173@@ -335,7 +335,7 @@
1174
1175 state = State::RecognizingMouseClickOrDrag;
1176
1177- unity::switcher::SwitcherView *view = switcher_controller->GetView();
1178+ unity::switcher::View *view = switcher_controller->GetView();
1179
1180 index_icon_hit = view->IconIndexAt(x, y);
1181 accumulated_horizontal_drag = 0.0f;
1182@@ -413,17 +413,17 @@
1183
1184 void GesturalWindowSwitcherPrivate::ConnectToSwitcherViewMouseEvents()
1185 {
1186- unity::switcher::SwitcherView *switcher_view = switcher_controller->GetView();
1187+ unity::switcher::View *switcher_view = switcher_controller->GetView();
1188 g_assert(switcher_view);
1189
1190- mouse_down_connection = switcher_view->mouse_down.connect(
1191- sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDown));
1192-
1193- mouse_up_connection = switcher_view->mouse_up.connect(
1194- sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseUp));
1195-
1196- mouse_drag_connection = switcher_view->mouse_drag.connect(
1197+ auto connections =
1198+ switcher_view->ConnectToMouseEvents(sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDown),
1199+ sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseUp),
1200 sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDrag));
1201+
1202+ std::tie (mouse_down_connection,
1203+ mouse_up_connection,
1204+ mouse_drag_connection) = connections;
1205 }
1206
1207 ///////////////////////////////////////////
1208
1209=== modified file 'plugins/unityshell/src/unity-switcher-accessible.cpp'
1210--- plugins/unityshell/src/unity-switcher-accessible.cpp 2012-10-11 01:44:15 +0000
1211+++ plugins/unityshell/src/unity-switcher-accessible.cpp 2012-12-20 16:52:21 +0000
1212@@ -139,7 +139,7 @@
1213 {
1214 AtkObject* accessible = NULL;
1215
1216- g_return_val_if_fail(dynamic_cast<SwitcherView*>(object), NULL);
1217+ g_return_val_if_fail(dynamic_cast<NuxView*>(object), NULL);
1218
1219 accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SWITCHER_ACCESSIBLE, NULL));
1220
1221@@ -154,7 +154,7 @@
1222 unity_switcher_accessible_initialize(AtkObject* accessible,
1223 gpointer data)
1224 {
1225- SwitcherView* switcher = NULL;
1226+ NuxView* switcher = NULL;
1227 nux::Object* nux_object = NULL;
1228 UnitySwitcherAccessible* self = NULL;
1229 SwitcherModel::Ptr model;
1230@@ -165,7 +165,7 @@
1231
1232 self = UNITY_SWITCHER_ACCESSIBLE(accessible);
1233 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
1234- switcher = dynamic_cast<SwitcherView*>(nux_object);
1235+ switcher = dynamic_cast<NuxView*>(nux_object);
1236 if (switcher == NULL)
1237 return;
1238
1239@@ -276,7 +276,7 @@
1240 unity_switcher_accessible_ref_selection(AtkSelection* selection,
1241 gint i)
1242 {
1243- SwitcherView* switcher = NULL;
1244+ NuxView* switcher = NULL;
1245 SwitcherModel::Ptr switcher_model;
1246 nux::Object* nux_object = NULL;
1247 gint selected_index = 0;
1248@@ -292,7 +292,7 @@
1249 if (!nux_object) /* state is defunct */
1250 return 0;
1251
1252- switcher = dynamic_cast<SwitcherView*>(nux_object);
1253+ switcher = dynamic_cast<NuxView*>(nux_object);
1254
1255 switcher_model = switcher->GetModel();
1256 selected_index = switcher_model->SelectionIndex();
1257@@ -309,7 +309,7 @@
1258 static gint
1259 unity_switcher_accessible_get_selection_count(AtkSelection* selection)
1260 {
1261- SwitcherView* switcher = NULL;
1262+ NuxView* switcher = NULL;
1263 SwitcherModel::Ptr switcher_model;
1264 nux::Object* nux_object = NULL;
1265
1266@@ -319,7 +319,7 @@
1267 if (!nux_object) /* state is defunct */
1268 return 0;
1269
1270- switcher = dynamic_cast<SwitcherView*>(nux_object);
1271+ switcher = dynamic_cast<NuxView*>(nux_object);
1272 switcher_model = switcher->GetModel();
1273
1274 if (!switcher_model->Selection())
1275@@ -332,7 +332,7 @@
1276 unity_switcher_accessible_is_child_selected(AtkSelection* selection,
1277 gint i)
1278 {
1279- SwitcherView* switcher = NULL;
1280+ NuxView* switcher = NULL;
1281 SwitcherModel::Ptr switcher_model;
1282 SwitcherModel::iterator it;
1283 nux::Object* nux_object = NULL;
1284@@ -344,7 +344,7 @@
1285 if (!nux_object) /* state is defunct */
1286 return 0;
1287
1288- switcher = dynamic_cast<SwitcherView*>(nux_object);
1289+ switcher = dynamic_cast<NuxView*>(nux_object);
1290 switcher_model = switcher->GetModel();
1291 selected_index = switcher_model->SelectionIndex();
1292
1293@@ -385,7 +385,7 @@
1294 {
1295 gint index = 0;
1296 nux::Object* nux_object = NULL;
1297- SwitcherView* switcher = NULL;
1298+ NuxView* switcher = NULL;
1299 SwitcherModel::iterator it;
1300 AtkObject* child_accessible = NULL;
1301
1302@@ -393,7 +393,7 @@
1303 if (!nux_object) /* state is defunct */
1304 return;
1305
1306- switcher = dynamic_cast<SwitcherView*>(nux_object);
1307+ switcher = dynamic_cast<NuxView*>(nux_object);
1308 SwitcherModel::Ptr const& switcher_model = switcher->GetModel();
1309
1310 if (!switcher_model)
1311
1312=== modified file 'plugins/unityshell/src/unitya11y.cpp'
1313--- plugins/unityshell/src/unitya11y.cpp 2012-12-14 12:14:34 +0000
1314+++ plugins/unityshell/src/unitya11y.cpp 2012-12-20 16:52:21 +0000
1315@@ -183,7 +183,7 @@
1316 if (object->Type().IsDerivedFromType(unity::SearchBar::StaticObjectType))
1317 return unity_search_bar_accessible_new(object);
1318
1319- if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType))
1320+ if (object->Type().IsDerivedFromType(unity::switcher::NuxView::StaticObjectType))
1321 return unity_switcher_accessible_new(object);
1322
1323 /* NUX classes */
1324
1325=== modified file 'plugins/unityshell/src/unityshell.cpp'
1326--- plugins/unityshell/src/unityshell.cpp 2012-12-20 16:52:21 +0000
1327+++ plugins/unityshell/src/unityshell.cpp 2012-12-20 16:52:21 +0000
1328@@ -1438,7 +1438,7 @@
1329
1330 if (switcher_controller_ && switcher_controller_->Visible())
1331 {
1332- unity::switcher::SwitcherView* view = switcher_controller_->GetView();
1333+ unity::switcher::View* view = switcher_controller_->GetView();
1334
1335 if (G_LIKELY(view))
1336 {
1337
1338=== modified file 'tests/MockSwitcherController.h'
1339--- tests/MockSwitcherController.h 2012-12-20 16:52:21 +0000
1340+++ tests/MockSwitcherController.h 2012-12-20 16:52:21 +0000
1341@@ -43,7 +43,7 @@
1342 MOCK_METHOD0(Next, void());
1343 MOCK_METHOD0(Prev, void());
1344 MOCK_METHOD1(Select, void(int));
1345- MOCK_METHOD0(GetView, unity::switcher::SwitcherView * ());
1346+ MOCK_METHOD0(GetView, unity::switcher::View * ());
1347 MOCK_CONST_METHOD1(CanShowSwitcher, bool(const std::vector<launcher::AbstractLauncherIcon::Ptr> &));
1348 MOCK_METHOD0(NextDetail, void());
1349 MOCK_METHOD0(PrevDetail, void());
1350
1351=== modified file 'tests/StubSwitcherController.h'
1352--- tests/StubSwitcherController.h 2012-12-20 16:52:21 +0000
1353+++ tests/StubSwitcherController.h 2012-12-20 16:52:21 +0000
1354@@ -59,12 +59,12 @@
1355 Reset ();
1356 };
1357
1358- void SetView (SwitcherView *view)
1359+ void SetView (View *view)
1360 {
1361 mock_view_ = view;
1362 }
1363
1364- SwitcherView * GetView ()
1365+ View * GetView ()
1366 {
1367 return mock_view_;
1368 }
1369@@ -147,7 +147,7 @@
1370 int index_selected_;
1371
1372 private:
1373- SwitcherView *mock_view_;
1374+ View *mock_view_;
1375 };
1376 }
1377 }
1378
1379=== modified file 'tests/test-gestures/SwitcherControllerMock.h'
1380--- tests/test-gestures/SwitcherControllerMock.h 2012-12-20 16:52:21 +0000
1381+++ tests/test-gestures/SwitcherControllerMock.h 2012-12-20 16:52:21 +0000
1382@@ -24,13 +24,42 @@
1383 namespace unity {
1384 namespace switcher {
1385
1386-class SwitcherViewMock : public nux::ViewMock
1387+class ViewMock
1388+{
1389+ public:
1390+
1391+ typedef sigc::slot<void, int, int, int, int> MouseButtonCallback;
1392+ typedef sigc::slot <void, int, int, int, int, unsigned int, unsigned int> MouseDragCallback;
1393+
1394+ typedef std::tuple <sigc::connection,
1395+ sigc::connection,
1396+ sigc::connection> MouseEventConnections;
1397+
1398+ virtual int IconIndexAt(int x, int y) = 0;
1399+
1400+ virtual MouseEventConnections ConnectToMouseEvents (const MouseButtonCallback &mouse_down_callback,
1401+ const MouseButtonCallback &mouse_up_callback,
1402+ const MouseDragCallback &mouse_drag_callback) = 0;
1403+
1404+
1405+};
1406+
1407+class NuxViewMock : public nux::ViewMock, public switcher::ViewMock
1408 {
1409 public:
1410 int IconIndexAt(int x, int y)
1411 {
1412 return x*y;
1413 }
1414+
1415+ MouseEventConnections ConnectToMouseEvents (const MouseButtonCallback &mouse_down_callback,
1416+ const MouseButtonCallback &mouse_up_callback,
1417+ const MouseDragCallback &mouse_drag_callback)
1418+ {
1419+ return MouseEventConnections (mouse_down.connect (mouse_down_callback),
1420+ mouse_up.connect (mouse_up_callback),
1421+ mouse_drag.connect (mouse_drag_callback));
1422+ }
1423 };
1424
1425 class ControllerMock
1426@@ -78,7 +107,7 @@
1427 is_visible_ = false;
1428 }
1429
1430- SwitcherViewMock *GetView()
1431+ ViewMock *GetView()
1432 {
1433 return &view_;
1434 }
1435@@ -89,7 +118,7 @@
1436 }
1437
1438 bool is_visible_;
1439- SwitcherViewMock view_;
1440+ NuxViewMock view_;
1441 int prev_count_;
1442 int next_count_;
1443 int index_selected_;
1444
1445=== modified file 'tests/test-gestures/sed_script_switcher'
1446--- tests/test-gestures/sed_script_switcher 2012-07-27 20:24:01 +0000
1447+++ tests/test-gestures/sed_script_switcher 2012-12-20 16:52:21 +0000
1448@@ -22,4 +22,5 @@
1449 s|\<SwitcherController\>|SwitcherControllerMock|g
1450 s|\<switcher\:\:Controller\>|switcher\:\:ControllerMock|g
1451 s|\<launcher\:\:Controller\>|launcher\:\:ControllerMock|g
1452-s|\<SwitcherView\>|SwitcherViewMock|g
1453+s|\<switcher\:\:View\>|switcher\:\:ViewMock|g
1454+s|\<switcher\:\:NuxView\>|switcher\:\:NuxViewMock|g
1455
1456=== modified file 'tests/test-gestures/test_gestural_window_switcher.cpp'
1457--- tests/test-gestures/test_gestural_window_switcher.cpp 2012-08-14 12:48:21 +0000
1458+++ tests/test-gestures/test_gestural_window_switcher.cpp 2012-12-20 16:52:21 +0000
1459@@ -290,7 +290,7 @@
1460
1461 TEST_F(GesturalWindowSwitcherTest, MouseDragAfterTapAndHoldSelectsNextWindow)
1462 {
1463- unity::switcher::SwitcherViewMock &switcher_view =
1464+ unity::switcher::NuxViewMock &switcher_view =
1465 unity_screen->switcher_controller()->view_;
1466 int drag_delta = GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION * 1.5f;
1467