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
=== modified file 'launcher/StandaloneSwitcher.cpp'
--- launcher/StandaloneSwitcher.cpp 2012-12-20 16:52:21 +0000
+++ launcher/StandaloneSwitcher.cpp 2012-12-20 16:52:21 +0000
@@ -74,37 +74,37 @@
7474
75void OnBorderSizeChanged (nux::RangeValueInteger *self)75void OnBorderSizeChanged (nux::RangeValueInteger *self)
76{76{
77 controller->GetView ()->border_size = self->GetValue ();77 controller->GetView ()->SetBorderSize(self->GetValue ());
78 controller->GetView ()->QueueDraw ();78 controller->GetView ()->QueueDraw ();
79}79}
8080
81void OnFlatSpacingSizeChanged (nux::RangeValueInteger *self)81void OnFlatSpacingSizeChanged (nux::RangeValueInteger *self)
82{82{
83 controller->GetView ()->flat_spacing = self->GetValue ();83 controller->GetView ()->SetFlatSpacing(self->GetValue ());
84 controller->GetView ()->QueueDraw ();84 controller->GetView ()->QueueDraw ();
85}85}
8686
87void OnTextSizeChanged (nux::RangeValueInteger *self)87void OnTextSizeChanged (nux::RangeValueInteger *self)
88{88{
89 controller->GetView ()->text_size = self->GetValue ();89 controller->GetView ()->SetTextSize(self->GetValue ());
90 controller->GetView ()->QueueDraw ();90 controller->GetView ()->QueueDraw ();
91}91}
9292
93void OnIconSizeChanged (nux::RangeValueInteger *self)93void OnIconSizeChanged (nux::RangeValueInteger *self)
94{94{
95 controller->GetView ()->icon_size = self->GetValue ();95 controller->GetView ()->SetIconSize(self->GetValue ());
96 controller->GetView ()->QueueDraw ();96 controller->GetView ()->QueueDraw ();
97}97}
9898
99void OnTileSizeChanged (nux::RangeValueInteger *self)99void OnTileSizeChanged (nux::RangeValueInteger *self)
100{100{
101 controller->GetView ()->tile_size = self->GetValue ();101 controller->GetView ()->SetTileSize(self->GetValue ());
102 controller->GetView ()->QueueDraw ();102 controller->GetView ()->QueueDraw ();
103}103}
104104
105void OnAnimationLengthChanged (nux::RangeValueInteger *self)105void OnAnimationLengthChanged (nux::RangeValueInteger *self)
106{106{
107 controller->GetView ()->animation_length = self->GetValue ();107 controller->GetView ()->SetAnimationLength(self->GetValue ());
108 controller->GetView ()->QueueDraw ();108 controller->GetView ()->QueueDraw ();
109}109}
110110
@@ -153,7 +153,7 @@
153153
154 controller->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, icons);154 controller->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, icons);
155155
156 controller->GetView ()->render_boxes = true;156 controller->GetView ()->SetRenderBoxes(true);
157157
158 nux::CheckBox* flipping_check = new nux::CheckBox(TEXT("Enable Automatic Flipping"), false, NUX_TRACKER_LOCATION);158 nux::CheckBox* flipping_check = new nux::CheckBox(TEXT("Enable Automatic Flipping"), false, NUX_TRACKER_LOCATION);
159 flipping_check->SetMaximumWidth(250);159 flipping_check->SetMaximumWidth(250);
@@ -185,7 +185,7 @@
185 nux::StaticText* border_label = new nux::StaticText(TEXT("Border Size:"), NUX_TRACKER_LOCATION);185 nux::StaticText* border_label = new nux::StaticText(TEXT("Border Size:"), NUX_TRACKER_LOCATION);
186 border_layout->AddView(border_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);186 border_layout->AddView(border_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
187187
188 nux::RangeValueInteger * border_size_range = new nux::RangeValueInteger (controller->GetView ()->border_size, 0, 200, NUX_TRACKER_LOCATION);188 nux::RangeValueInteger * border_size_range = new nux::RangeValueInteger (controller->GetView ()->GetBorderSize(), 0, 200, NUX_TRACKER_LOCATION);
189 border_size_range->sigValueChanged.connect (sigc::ptr_fun (OnBorderSizeChanged));189 border_size_range->sigValueChanged.connect (sigc::ptr_fun (OnBorderSizeChanged));
190 border_layout->AddView(border_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);190 border_layout->AddView(border_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
191191
@@ -201,7 +201,7 @@
201 nux::StaticText* flat_spacing_label = new nux::StaticText(TEXT("Flat Spacing:"), NUX_TRACKER_LOCATION);201 nux::StaticText* flat_spacing_label = new nux::StaticText(TEXT("Flat Spacing:"), NUX_TRACKER_LOCATION);
202 flat_spacing_layout->AddView(flat_spacing_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);202 flat_spacing_layout->AddView(flat_spacing_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
203203
204 nux::RangeValueInteger * flat_spacing_size_range = new nux::RangeValueInteger (controller->GetView ()->flat_spacing, 0, 200, NUX_TRACKER_LOCATION);204 nux::RangeValueInteger * flat_spacing_size_range = new nux::RangeValueInteger (controller->GetView ()->GetFlatSpacing(), 0, 200, NUX_TRACKER_LOCATION);
205 flat_spacing_size_range->sigValueChanged.connect (sigc::ptr_fun (OnFlatSpacingSizeChanged));205 flat_spacing_size_range->sigValueChanged.connect (sigc::ptr_fun (OnFlatSpacingSizeChanged));
206 flat_spacing_layout->AddView(flat_spacing_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);206 flat_spacing_layout->AddView(flat_spacing_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
207207
@@ -216,7 +216,7 @@
216 nux::StaticText* text_size_label = new nux::StaticText(TEXT("Text Size:"), NUX_TRACKER_LOCATION);216 nux::StaticText* text_size_label = new nux::StaticText(TEXT("Text Size:"), NUX_TRACKER_LOCATION);
217 text_size_layout->AddView(text_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);217 text_size_layout->AddView(text_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
218218
219 nux::RangeValueInteger * text_size_size_range = new nux::RangeValueInteger (controller->GetView ()->text_size, 0, 200, NUX_TRACKER_LOCATION);219 nux::RangeValueInteger * text_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetTextSize(), 0, 200, NUX_TRACKER_LOCATION);
220 text_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTextSizeChanged));220 text_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTextSizeChanged));
221 text_size_layout->AddView(text_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);221 text_size_layout->AddView(text_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
222222
@@ -231,7 +231,7 @@
231 nux::StaticText* icon_size_label = new nux::StaticText(TEXT("Icon Size:"), NUX_TRACKER_LOCATION);231 nux::StaticText* icon_size_label = new nux::StaticText(TEXT("Icon Size:"), NUX_TRACKER_LOCATION);
232 icon_size_layout->AddView(icon_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);232 icon_size_layout->AddView(icon_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
233233
234 nux::RangeValueInteger * icon_size_size_range = new nux::RangeValueInteger (controller->GetView ()->icon_size, 0, 200, NUX_TRACKER_LOCATION);234 nux::RangeValueInteger * icon_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetIconSize(), 0, 200, NUX_TRACKER_LOCATION);
235 icon_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnIconSizeChanged));235 icon_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnIconSizeChanged));
236 icon_size_layout->AddView(icon_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);236 icon_size_layout->AddView(icon_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
237237
@@ -246,7 +246,7 @@
246 nux::StaticText* tile_size_label = new nux::StaticText(TEXT("Tile Size:"), NUX_TRACKER_LOCATION);246 nux::StaticText* tile_size_label = new nux::StaticText(TEXT("Tile Size:"), NUX_TRACKER_LOCATION);
247 tile_size_layout->AddView(tile_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);247 tile_size_layout->AddView(tile_size_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
248248
249 nux::RangeValueInteger * tile_size_size_range = new nux::RangeValueInteger (controller->GetView ()->tile_size, 0, 200, NUX_TRACKER_LOCATION);249 nux::RangeValueInteger * tile_size_size_range = new nux::RangeValueInteger (controller->GetView ()->GetTileSize(), 0, 200, NUX_TRACKER_LOCATION);
250 tile_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTileSizeChanged));250 tile_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTileSizeChanged));
251 tile_size_layout->AddView(tile_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);251 tile_size_layout->AddView(tile_size_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
252252
@@ -261,7 +261,7 @@
261 nux::StaticText* animation_length_label = new nux::StaticText(TEXT("Animation Length:"), NUX_TRACKER_LOCATION);261 nux::StaticText* animation_length_label = new nux::StaticText(TEXT("Animation Length:"), NUX_TRACKER_LOCATION);
262 animation_length_layout->AddView(animation_length_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);262 animation_length_layout->AddView(animation_length_label, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
263263
264 nux::RangeValueInteger * animation_length_size_range = new nux::RangeValueInteger (controller->GetView ()->animation_length, 0, 2000, NUX_TRACKER_LOCATION);264 nux::RangeValueInteger * animation_length_size_range = new nux::RangeValueInteger (controller->GetView ()->GetAnimationLength(), 0, 2000, NUX_TRACKER_LOCATION);
265 animation_length_size_range->sigValueChanged.connect (sigc::ptr_fun (OnAnimationLengthChanged));265 animation_length_size_range->sigValueChanged.connect (sigc::ptr_fun (OnAnimationLengthChanged));
266 animation_length_layout->AddView(animation_length_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);266 animation_length_layout->AddView(animation_length_size_range, 1, nux::MINOR_POSITION_END, nux::MINOR_SIZE_FIX);
267267
268268
=== modified file 'launcher/SwitcherController.cpp'
--- launcher/SwitcherController.cpp 2012-12-20 16:52:21 +0000
+++ launcher/SwitcherController.cpp 2012-12-20 16:52:21 +0000
@@ -91,7 +91,7 @@
91 impl_->Prev();91 impl_->Prev();
92}92}
9393
94SwitcherView* Controller::GetView()94View* Controller::GetView()
95{95{
96 return impl_->GetView();96 return impl_->GetView();
97}97}
@@ -175,7 +175,7 @@
175 bg_color_ = nux::Color(red, green, blue, alpha);175 bg_color_ = nux::Color(red, green, blue, alpha);
176176
177 if (view_)177 if (view_)
178 view_->background_color = bg_color_;178 view_->SetBackgroundColor(bg_color_);
179}179}
180180
181bool ShellController::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const181bool ShellController::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& results) const
@@ -311,16 +311,21 @@
311311
312 sources_.Remove(VIEW_CONSTRUCT_IDLE);312 sources_.Remove(VIEW_CONSTRUCT_IDLE);
313313
314 view_ = SwitcherView::Ptr(new SwitcherView());314 view_.reset (new switcher::View ([this]{
315 AddChild(view_.GetPointer());315 nux::ObjectPtr<switcher::NuxView> p(new switcher::NuxView());
316 introspectable_view_ = p.GetPointer();
317 nux_view_ = p.GetPointer();
318 return std::unique_ptr<switcher::View::Impl>(new switcher::NuxViewWrapper(p));
319 }));
320 AddChild(introspectable_view_);
316 view_->SetModel(model_);321 view_->SetModel(model_);
317 view_->background_color = bg_color_;322 view_->SetBackgroundColor(bg_color_);
318 view_->monitor = monitor_;323 view_->SetMonitor(monitor_);
319 view_->SetupBackground();324 view_->SetupBackground();
320325
321 ConstructWindow();326 ConstructWindow();
322 main_layout_->AddView(view_.GetPointer(), 1);327 main_layout_->AddView(nux_view_, 1);
323 view_window_->SetEnterFocusInputArea(view_.GetPointer());328 view_window_->SetEnterFocusInputArea(nux_view_);
324 view_window_->SetGeometry(workarea_);329 view_window_->SetGeometry(workarea_);
325 view_window_->SetOpacity(0.0f);330 view_window_->SetOpacity(0.0f);
326331
@@ -333,7 +338,7 @@
333 workarea_ = geo;338 workarea_ = geo;
334339
335 if (view_)340 if (view_)
336 view_->monitor = monitor_;341 view_->SetMonitor(monitor_);
337}342}
338343
339void ShellController::Hide(bool accept_state)344void ShellController::Hide(bool accept_state)
@@ -375,7 +380,15 @@
375 visible_ = false;380 visible_ = false;
376381
377 if (view_)382 if (view_)
378 main_layout_->RemoveChildObject(view_.GetPointer());383 main_layout_->RemoveChildObject(nux_view_);
384
385 ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", false, monitor_));
386
387 last_active_selection_ = nullptr;
388
389 view_.reset();
390 nux_view_ = nullptr;
391 introspectable_view_ = nullptr;
379392
380 if (view_window_)393 if (view_window_)
381 {394 {
@@ -384,12 +397,6 @@
384 view_window_->PushToBack();397 view_window_->PushToBack();
385 view_window_->EnableInputWindow(false);398 view_window_->EnableInputWindow(false);
386 }399 }
387
388 ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", false, monitor_));
389
390 last_active_selection_ = nullptr;
391
392 view_.Release();
393}400}
394401
395bool ShellController::Visible()402bool ShellController::Visible()
@@ -455,9 +462,9 @@
455 }462 }
456}463}
457464
458SwitcherView* ShellController::GetView()465View *ShellController::GetView()
459{466{
460 return view_.GetPointer();467 return view_.get();
461}468}
462469
463void ShellController::SetDetail(bool value, unsigned int min_windows)470void ShellController::SetDetail(bool value, unsigned int min_windows)
464471
=== modified file 'launcher/SwitcherController.h'
--- launcher/SwitcherController.h 2012-12-20 16:52:21 +0000
+++ launcher/SwitcherController.h 2012-12-20 16:52:21 +0000
@@ -94,7 +94,7 @@
94 void SetWorkspace(nux::Geometry geo,94 void SetWorkspace(nux::Geometry geo,
95 int monitor);95 int monitor);
9696
97 SwitcherView * GetView ();97 View * GetView ();
9898
99 ui::LayoutWindow::Vector ExternalRenderTargets ();99 ui::LayoutWindow::Vector ExternalRenderTargets ();
100100
@@ -142,7 +142,7 @@
142 virtual void SetWorkspace(nux::Geometry geo,142 virtual void SetWorkspace(nux::Geometry geo,
143 int monitor) = 0;143 int monitor) = 0;
144144
145 virtual SwitcherView * GetView () = 0;145 virtual View * GetView () = 0;
146146
147 virtual ui::LayoutWindow::Vector ExternalRenderTargets () = 0;147 virtual ui::LayoutWindow::Vector ExternalRenderTargets () = 0;
148148
@@ -190,7 +190,7 @@
190190
191 void SetWorkspace(nux::Geometry geo, int monitor);191 void SetWorkspace(nux::Geometry geo, int monitor);
192192
193 virtual SwitcherView* GetView();193 virtual View* GetView();
194194
195 ui::LayoutWindow::Vector ExternalRenderTargets ();195 ui::LayoutWindow::Vector ExternalRenderTargets ();
196196
@@ -226,7 +226,9 @@
226 static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon::Ptr const& first, launcher::AbstractLauncherIcon::Ptr const& second);226 static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon::Ptr const& first, launcher::AbstractLauncherIcon::Ptr const& second);
227227
228 SwitcherModel::Ptr model_;228 SwitcherModel::Ptr model_;
229 SwitcherView::Ptr view_;229 debug::Introspectable *introspectable_view_;
230 NuxView *nux_view_;
231 View::Ptr view_;
230232
231 nux::Geometry workarea_;233 nux::Geometry workarea_;
232 nux::ObjectPtr<nux::BaseWindow> view_window_;234 nux::ObjectPtr<nux::BaseWindow> view_window_;
233235
=== modified file 'launcher/SwitcherView.cpp'
--- launcher/SwitcherView.cpp 2012-12-14 12:14:34 +0000
+++ launcher/SwitcherView.cpp 2012-12-20 16:52:21 +0000
@@ -32,10 +32,282 @@
32namespace switcher32namespace switcher
33{33{
3434
35NUX_IMPLEMENT_OBJECT_TYPE(SwitcherView);35View::View(const ViewFactoryFunc &create)
3636 : impl_(create())
37SwitcherView::SwitcherView()37{
38 : render_boxes(false)38}
39
40
41ui::LayoutWindow::Vector View::ExternalTargets()
42{
43 return impl_->ExternalTargets();
44}
45
46void View::SetModel(SwitcherModel::Ptr model)
47{
48 impl_->SetModel(model);
49}
50
51SwitcherModel::Ptr View::GetModel()
52{
53 return impl_->GetModel();
54}
55
56View::MouseEventConnections
57View::ConnectToMouseEvents(const View::MouseButtonCallback &mouse_down_callback,
58 const View::MouseButtonCallback &mouse_up_callback,
59 const View::MouseDragCallback &mouse_drag_callback)
60{
61 return impl_->ConnectToMouseEvents(mouse_down_callback,
62 mouse_up_callback,
63 mouse_drag_callback);
64}
65
66void View::QueueDraw()
67{
68 impl_->QueueDraw();
69}
70
71nux::Geometry View::GetAbsoluteGeometry() const
72{
73 return impl_->GetAbsoluteGeometry();
74}
75
76// Returns the index of the icon at the given position, in window coordinates.
77// If there's no icon there, -1 is returned.
78int View::IconIndexAt(int x, int y)
79{
80 return impl_->IconIndexAt(x, y);
81}
82
83// Property setters
84void View::SetBackgroundColor(nux::Color const& color)
85{
86 impl_->SetBackgroundColor(color);
87}
88
89void View::SetMonitor(unsigned int monitor)
90{
91 impl_->SetMonitor(monitor);
92}
93
94void View::SetBorderSize(unsigned int size)
95{
96 impl_->SetBorderSize(size);
97}
98
99void View::SetFlatSpacing(int spacing)
100{
101 impl_->SetFlatSpacing(spacing);
102}
103
104void View::SetTextSize(unsigned int size)
105{
106 impl_->SetTextSize(size);
107}
108
109void View::SetIconSize(unsigned int size)
110{
111 impl_->SetIconSize(size);
112}
113
114void View::SetTileSize(unsigned int size)
115{
116 impl_->SetTileSize(size);
117}
118
119void View::SetAnimationLength(unsigned int length)
120{
121 impl_->SetAnimationLength(length);
122}
123
124void View::SetRenderBoxes(bool render)
125{
126 impl_->SetRenderBoxes(render);
127}
128
129// Property getters
130unsigned int View::GetBorderSize()
131{
132 return impl_->GetBorderSize();
133}
134
135unsigned int View::GetFlatSpacing()
136{
137 return impl_->GetFlatSpacing();
138}
139
140unsigned int View::GetTextSize()
141{
142 return impl_->GetTextSize();
143}
144
145unsigned int View::GetIconSize()
146{
147 return impl_->GetIconSize();
148}
149
150unsigned int View::GetTileSize()
151{
152 return impl_->GetTileSize();
153}
154
155unsigned int View::GetAnimationLength()
156{
157 return impl_->GetAnimationLength();
158}
159
160void View::SetupBackground(bool enabled)
161{
162 return impl_->SetupBackground(enabled);
163}
164
165View::Impl::Impl()
166{
167}
168
169NuxViewWrapper::NuxViewWrapper(const nux::ObjectPtr<NuxView> &nuxView)
170 : reference_(nuxView),
171 impl_(nuxView.GetPointer())
172{
173}
174
175
176ui::LayoutWindow::Vector NuxViewWrapper::ExternalTargets()
177{
178 return impl_->ExternalTargets();
179}
180
181void NuxViewWrapper::SetModel(SwitcherModel::Ptr model)
182{
183 impl_->SetModel(model);
184}
185
186SwitcherModel::Ptr NuxViewWrapper::GetModel()
187{
188 return impl_->GetModel();
189}
190
191View::MouseEventConnections
192NuxViewWrapper::ConnectToMouseEvents(View::MouseButtonCallback const& mouse_down_callback,
193 View::MouseButtonCallback const& mouse_up_callback,
194 View::MouseDragCallback const& mouse_drag_callback)
195{
196 return impl_->ConnectToMouseEvents(mouse_down_callback,
197 mouse_up_callback,
198 mouse_drag_callback);
199}
200
201void NuxViewWrapper::QueueDraw()
202{
203 impl_->QueueDraw();
204}
205
206nux::Geometry NuxViewWrapper::GetAbsoluteGeometry() const
207{
208 return impl_->GetAbsoluteGeometry();
209}
210
211nux::Area * NuxViewWrapper::GetTopLevelViewWindow()
212{
213 return impl_->GetTopLevelViewWindow();
214}
215
216// Returns the index of the icon at the given position, in window coordinates.
217// If there's no icon there, -1 is returned.
218int NuxViewWrapper::IconIndexAt(int x, int y)
219{
220 return impl_->IconIndexAt(x, y);
221}
222
223// Property setters
224void NuxViewWrapper::SetBackgroundColor(nux::Color const& color)
225{
226 impl_->SetBackgroundColor(color);
227}
228
229void NuxViewWrapper::SetMonitor(unsigned int monitor)
230{
231 impl_->SetMonitor(monitor);
232}
233
234void NuxViewWrapper::SetBorderSize(unsigned int size)
235{
236 impl_->SetBorderSize(size);
237}
238
239void NuxViewWrapper::SetFlatSpacing(int spacing)
240{
241 impl_->SetFlatSpacing(spacing);
242}
243
244void NuxViewWrapper::SetTextSize(unsigned int size)
245{
246 impl_->SetTextSize(size);
247}
248
249void NuxViewWrapper::SetIconSize(unsigned int size)
250{
251 impl_->SetIconSize(size);
252}
253
254void NuxViewWrapper::SetTileSize(unsigned int size)
255{
256 impl_->SetTileSize(size);
257}
258
259void NuxViewWrapper::SetAnimationLength(unsigned int length)
260{
261 impl_->SetAnimationLength(length);
262}
263
264void NuxViewWrapper::SetRenderBoxes(bool render)
265{
266 impl_->SetRenderBoxes(render);
267}
268
269// Property getters
270unsigned int NuxViewWrapper::GetBorderSize()
271{
272 return impl_->GetBorderSize();
273}
274
275unsigned int NuxViewWrapper::GetFlatSpacing()
276{
277 return impl_->GetFlatSpacing();
278}
279
280unsigned int NuxViewWrapper::GetTextSize()
281{
282 return impl_->GetTextSize();
283}
284
285unsigned int NuxViewWrapper::GetIconSize()
286{
287 return impl_->GetIconSize();
288}
289
290unsigned int NuxViewWrapper::GetTileSize()
291{
292 return impl_->GetTileSize();
293}
294
295unsigned int NuxViewWrapper::GetAnimationLength()
296{
297 return impl_->GetAnimationLength();
298}
299
300void NuxViewWrapper::SetupBackground(bool enabled)
301{
302 return impl_->SetupBackground(enabled);
303}
304
305NUX_IMPLEMENT_OBJECT_TYPE(NuxView);
306
307NuxView::NuxView()
308 : UnityWindowView()
309 , switcher::View::Impl ()
310 , render_boxes(false)
39 , border_size(50)311 , border_size(50)
40 , flat_spacing(10)312 , flat_spacing(10)
41 , icon_size(128)313 , icon_size(128)
@@ -60,18 +332,28 @@
60 text_view_->SetTextColor(nux::color::White);332 text_view_->SetTextColor(nux::color::White);
61 text_view_->SetFont("Ubuntu Bold 10");333 text_view_->SetFont("Ubuntu Bold 10");
62334
63 icon_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnIconSizeChanged));335 icon_size.changed.connect (sigc::mem_fun (this, &NuxView::OnIconSizeChanged));
64 tile_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnTileSizeChanged));336 tile_size.changed.connect (sigc::mem_fun (this, &NuxView::OnTileSizeChanged));
65337
66 CaptureMouseDownAnyWhereElse(true);338 CaptureMouseDownAnyWhereElse(true);
67}339}
68340
69std::string SwitcherView::GetName() const341void NuxView::SetBackgroundColor(nux::Color const& color)
342{
343 background_color = color;
344}
345
346void NuxView::SetupBackground(bool enabled)
347{
348 UnityWindowView::SetupBackground(enabled);
349}
350
351std::string NuxView::GetName() const
70{352{
71 return "SwitcherView";353 return "SwitcherView";
72}354}
73355
74void SwitcherView::AddProperties(GVariantBuilder* builder)356void NuxView::AddProperties(GVariantBuilder* builder)
75{357{
76 unity::variant::BuilderWrapper(builder)358 unity::variant::BuilderWrapper(builder)
77 .add("render-boxes", render_boxes)359 .add("render-boxes", render_boxes)
@@ -88,17 +370,17 @@
88 .add("label_visible", text_view_->IsVisible());370 .add("label_visible", text_view_->IsVisible());
89}371}
90372
91LayoutWindow::Vector SwitcherView::ExternalTargets ()373LayoutWindow::Vector NuxView::ExternalTargets ()
92{374{
93 return render_targets_;375 return render_targets_;
94}376}
95377
96void SwitcherView::SetModel(SwitcherModel::Ptr model)378void NuxView::SetModel(SwitcherModel::Ptr model)
97{379{
98 model_ = model;380 model_ = model;
99 model->selection_changed.connect(sigc::mem_fun(this, &SwitcherView::OnSelectionChanged));381 model->selection_changed.connect(sigc::mem_fun(this, &NuxView::OnSelectionChanged));
100 model->detail_selection.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionChanged));382 model->detail_selection.changed.connect (sigc::mem_fun (this, &NuxView::OnDetailSelectionChanged));
101 model->detail_selection_index.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionIndexChanged));383 model->detail_selection_index.changed.connect (sigc::mem_fun (this, &NuxView::OnDetailSelectionIndexChanged));
102384
103 if (!model->Selection())385 if (!model->Selection())
104 return;386 return;
@@ -109,30 +391,30 @@
109 text_view_->SetText(model->Selection()->tooltip_text());391 text_view_->SetText(model->Selection()->tooltip_text());
110}392}
111393
112void SwitcherView::OnIconSizeChanged (int size)394void NuxView::OnIconSizeChanged (int size)
113{395{
114 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);396 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
115}397}
116398
117void SwitcherView::OnTileSizeChanged (int size)399void NuxView::OnTileSizeChanged (int size)
118{400{
119 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);401 icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
120 vertical_size = tile_size + 80;402 vertical_size = tile_size + 80;
121}403}
122404
123void SwitcherView::SaveLast ()405void NuxView::SaveLast ()
124{406{
125 saved_args_ = last_args_;407 saved_args_ = last_args_;
126 saved_background_ = last_background_;408 saved_background_ = last_background_;
127 clock_gettime(CLOCK_MONOTONIC, &save_time_);409 clock_gettime(CLOCK_MONOTONIC, &save_time_);
128}410}
129411
130void SwitcherView::OnDetailSelectionIndexChanged(unsigned int index)412void NuxView::OnDetailSelectionIndexChanged(unsigned int index)
131{413{
132 QueueDraw ();414 QueueDraw ();
133}415}
134416
135void SwitcherView::OnDetailSelectionChanged(bool detail)417void NuxView::OnDetailSelectionChanged (bool detail)
136{418{
137 text_view_->SetVisible(!detail);419 text_view_->SetVisible(!detail);
138420
@@ -143,7 +425,7 @@
143 QueueDraw();425 QueueDraw();
144}426}
145427
146void SwitcherView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)428void NuxView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
147{429{
148 if (selection)430 if (selection)
149 text_view_->SetText(selection->tooltip_text());431 text_view_->SetText(selection->tooltip_text());
@@ -152,12 +434,12 @@
152 QueueDraw();434 QueueDraw();
153}435}
154436
155SwitcherModel::Ptr SwitcherView::GetModel()437SwitcherModel::Ptr NuxView::GetModel()
156{438{
157 return model_;439 return model_;
158}440}
159441
160RenderArg SwitcherView::CreateBaseArgForIcon(AbstractLauncherIcon::Ptr const& icon)442RenderArg NuxView::CreateBaseArgForIcon(AbstractLauncherIcon::Ptr const& icon)
161{443{
162 RenderArg arg;444 RenderArg arg;
163 arg.icon = icon.GetPointer();445 arg.icon = icon.GetPointer();
@@ -185,7 +467,7 @@
185 return arg;467 return arg;
186}468}
187469
188RenderArg SwitcherView::InterpolateRenderArgs(RenderArg const& start, RenderArg const& end, float progress)470RenderArg NuxView::InterpolateRenderArgs(RenderArg const& start, RenderArg const& end, float progress)
189{471{
190 // easing472 // easing
191 progress = -pow(progress - 1.0f, 2) + 1;473 progress = -pow(progress - 1.0f, 2) + 1;
@@ -205,7 +487,7 @@
205 return result;487 return result;
206}488}
207489
208nux::Geometry SwitcherView::InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress)490nux::Geometry NuxView::InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress)
209{491{
210 progress = -pow(progress - 1.0f, 2) + 1;492 progress = -pow(progress - 1.0f, 2) + 1;
211493
@@ -219,7 +501,7 @@
219 return result;501 return result;
220}502}
221503
222nux::Geometry SwitcherView::UpdateRenderTargets(nux::Point const& center, timespec const& current)504nux::Geometry NuxView::UpdateRenderTargets (nux::Point const& center, timespec const& current)
223{505{
224 std::vector<Window> const& xids = model_->DetailXids();506 std::vector<Window> const& xids = model_->DetailXids();
225507
@@ -262,7 +544,7 @@
262 return final_bounds;544 return final_bounds;
263}545}
264546
265void SwitcherView::OffsetRenderTargets (int x, int y)547void NuxView::OffsetRenderTargets (int x, int y)
266{548{
267 for (LayoutWindow::Ptr const& target : render_targets_)549 for (LayoutWindow::Ptr const& target : render_targets_)
268 {550 {
@@ -271,7 +553,7 @@
271 }553 }
272}554}
273555
274nux::Size SwitcherView::SpreadSize()556nux::Size NuxView::SpreadSize()
275{557{
276 nux::Geometry const& base = GetGeometry();558 nux::Geometry const& base = GetGeometry();
277 nux::Size result(base.width - border_size * 2, base.height - border_size * 2);559 nux::Size result(base.width - border_size * 2, base.height - border_size * 2);
@@ -282,7 +564,7 @@
282 return result;564 return result;
283}565}
284566
285void SwitcherView::GetFlatIconPositions (int n_flat_icons,567void NuxView::GetFlatIconPositions (int n_flat_icons,
286 int size,568 int size,
287 int selection,569 int selection,
288 int &first_flat,570 int &first_flat,
@@ -356,7 +638,7 @@
356 }638 }
357}639}
358640
359std::list<RenderArg> SwitcherView::RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current)641std::list<RenderArg> NuxView::RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current)
360{642{
361 std::list<RenderArg> results;643 std::list<RenderArg> results;
362 nux::Geometry const& base = GetGeometry();644 nux::Geometry const& base = GetGeometry();
@@ -506,7 +788,7 @@
506 return results;788 return results;
507}789}
508790
509void SwitcherView::PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw)791void NuxView::PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
510{792{
511 clock_gettime(CLOCK_MONOTONIC, &current_);793 clock_gettime(CLOCK_MONOTONIC, &current_);
512794
@@ -523,12 +805,22 @@
523 icon_renderer_->PreprocessIcons(last_args_, GetGeometry());805 icon_renderer_->PreprocessIcons(last_args_, GetGeometry());
524}806}
525807
526nux::Geometry SwitcherView::GetBackgroundGeometry()808nux::Geometry NuxView::GetBackgroundGeometry()
527{809{
528 return last_background_;810 return last_background_;
529}811}
530812
531void SwitcherView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry internal_clip)813void NuxView::QueueDraw()
814{
815 ui::UnityWindowView::QueueDraw();
816}
817
818nux::Geometry NuxView::GetAbsoluteGeometry() const
819{
820 return ui::UnityWindowView::GetAbsoluteGeometry();
821}
822
823void NuxView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry internal_clip)
532{824{
533 nux::Geometry base = GetGeometry();825 nux::Geometry base = GetGeometry();
534826
@@ -600,7 +892,7 @@
600 animation_draw_ = false;892 animation_draw_ = false;
601}893}
602894
603int SwitcherView::IconIndexAt(int x, int y)895int NuxView::IconIndexAt(int x, int y)
604{896{
605 int half_size = icon_size.Get() / 2;897 int half_size = icon_size.Get() / 2;
606 int icon_index = -1;898 int icon_index = -1;
@@ -633,5 +925,88 @@
633 return icon_index;925 return icon_index;
634}926}
635927
928NuxView::MouseEventConnections
929NuxView::ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
930 const MouseButtonCallback &mouse_up_callback,
931 const MouseDragCallback &mouse_drag_callback)
932{
933 return NuxView::MouseEventConnections
934 (mouse_down.connect (mouse_down_callback),
935 mouse_up.connect (mouse_up_callback),
936 mouse_drag.connect (mouse_drag_callback));
937}
938
939}
940
941// Property setters
942void NuxView::SetMonitor(unsigned int monitor_id)
943{
944 monitor = monitor_id;
945}
946
947void NuxView::SetBorderSize(unsigned int size)
948{
949 border_size = size;
950}
951
952void NuxView::SetFlatSpacing(int spacing)
953{
954 flat_spacing = spacing;
955}
956
957void NuxView::SetTextSize(unsigned int size)
958{
959 text_size = size;
960}
961
962void NuxView::SetIconSize(unsigned int size)
963{
964 icon_size = size;
965}
966
967void NuxView::SetTileSize(unsigned int size)
968{
969 tile_size = size;
970}
971
972void NuxView::SetAnimationLength(unsigned int length)
973{
974 animation_length = length;
975}
976
977void NuxView::SetRenderBoxes(bool render)
978{
979 render_boxes = render;
980}
981
982// Property getters
983unsigned int NuxView::GetBorderSize()
984{
985 return border_size;
986}
987
988unsigned int NuxView::GetFlatSpacing()
989{
990 return flat_spacing;
991}
992
993unsigned int NuxView::GetTextSize()
994{
995 return text_size;
996}
997
998unsigned int NuxView::GetIconSize()
999{
1000 return icon_size;
1001}
1002
1003unsigned int NuxView::GetTileSize()
1004{
1005 return tile_size;
1006}
1007
1008unsigned int NuxView::GetAnimationLength()
1009{
1010 return animation_length;
636}1011}
637}1012}
6381013
=== modified file 'launcher/SwitcherView.h'
--- launcher/SwitcherView.h 2012-12-14 12:14:34 +0000
+++ launcher/SwitcherView.h 2012-12-20 16:52:21 +0000
@@ -20,6 +20,8 @@
20#ifndef SWITCHERVIEW_H20#ifndef SWITCHERVIEW_H
21#define SWITCHERVIEW_H21#define SWITCHERVIEW_H
2222
23#include <tuple>
24
23#include "SwitcherModel.h"25#include "SwitcherModel.h"
24#include "unity-shared/AbstractIconRenderer.h"26#include "unity-shared/AbstractIconRenderer.h"
25#include "unity-shared/StaticCairoText.h"27#include "unity-shared/StaticCairoText.h"
@@ -41,73 +43,204 @@
41}43}
42namespace switcher44namespace switcher
43{45{
4446class View
45class SwitcherView : public ui::UnityWindowView47{
46{48 public:
47 NUX_DECLARE_OBJECT_TYPE(SwitcherView, ui::UnityWindowView);49
48public:50 typedef sigc::slot<void, int, int, int, int> MouseButtonCallback;
49 typedef nux::ObjectPtr<SwitcherView> Ptr;51 typedef sigc::slot <void, int, int, int, int, unsigned int, unsigned int> MouseDragCallback;
5052
51 SwitcherView();53 typedef std::tuple <sigc::connection,
54 sigc::connection,
55 sigc::connection> MouseEventConnections;
56
57 class Impl;
58 typedef std::unique_ptr<Impl> ImplPtr;
59 typedef std::shared_ptr<View> Ptr;
60 typedef std::function<ImplPtr()> ViewFactoryFunc;
61
62 View(ViewFactoryFunc const&);
63
64 ui::LayoutWindow::Vector ExternalTargets();
65
66 void SetModel(SwitcherModel::Ptr model);
67 SwitcherModel::Ptr GetModel();
68
69 MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
70 const MouseButtonCallback &mouse_up_callback,
71 const MouseDragCallback &mouse_drag_callback);
72 void QueueDraw();
73 nux::Geometry GetAbsoluteGeometry() const;
74
75 // Returns the index of the icon at the given position, in window coordinates.
76 // If there's no icon there, -1 is returned.
77 int IconIndexAt(int x, int y);
78
79 // Property setters
80 void SetBackgroundColor(nux::Color const& color);
81 void SetMonitor(unsigned int monitor);
82 void SetBorderSize(unsigned int);
83 void SetFlatSpacing(int);
84 void SetTextSize(unsigned int);
85 void SetIconSize(unsigned int);
86 void SetTileSize(unsigned int);
87 void SetAnimationLength(unsigned int);
88 void SetRenderBoxes(bool);
89
90 // Property getters
91 unsigned int GetBorderSize();
92 unsigned int GetFlatSpacing();
93 unsigned int GetTextSize();
94 unsigned int GetIconSize();
95 unsigned int GetTileSize();
96 unsigned int GetAnimationLength();
97
98 void SetupBackground(bool enabled = true);
99
100 private:
101 std::unique_ptr<Impl> impl_;
102};
103
104class View::Impl
105{
106public:
107
108 typedef switcher::View::MouseButtonCallback MouseButtonCallback;
109 typedef switcher::View::MouseDragCallback MouseDragCallback;
110 typedef switcher::View::MouseEventConnections MouseEventConnections;
111
112 Impl();
113
114 virtual ~Impl() {};
115
116 virtual ui::LayoutWindow::Vector ExternalTargets() = 0;
117
118 virtual void SetModel(SwitcherModel::Ptr model) = 0;
119 virtual SwitcherModel::Ptr GetModel() = 0;
120
121 virtual MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
122 const MouseButtonCallback &mouse_up_callback,
123 const MouseDragCallback &mouse_drag_callback) = 0;
124 virtual void QueueDraw() = 0;
125 virtual nux::Geometry GetAbsoluteGeometry() const = 0;
126
127 // Returns the index of the icon at the given position, in window coordinates.
128 // If there's no icon there, -1 is returned.
129 virtual int IconIndexAt(int x, int y) = 0;
130
131 // Property setters
132 virtual void SetBackgroundColor(nux::Color const& color) = 0;
133 virtual void SetMonitor(unsigned int monitor) = 0;
134 virtual void SetBorderSize(unsigned int) = 0;
135 virtual void SetFlatSpacing(int) = 0;
136 virtual void SetTextSize(unsigned int) = 0;
137 virtual void SetIconSize(unsigned int) = 0;
138 virtual void SetTileSize(unsigned int) = 0;
139 virtual void SetAnimationLength(unsigned int) = 0;
140 virtual void SetRenderBoxes(bool) = 0;
141
142 // Property getters
143 virtual unsigned int GetBorderSize() = 0;
144 virtual unsigned int GetFlatSpacing() = 0;
145 virtual unsigned int GetTextSize() = 0;
146 virtual unsigned int GetIconSize() = 0;
147 virtual unsigned int GetTileSize() = 0;
148 virtual unsigned int GetAnimationLength() = 0;
149 virtual void SetupBackground(bool enabled) = 0;
150};
151
152class NuxView : public ui::UnityWindowView,
153 public unity::switcher::View::Impl
154{
155 NUX_DECLARE_OBJECT_TYPE(NuxView, ui::UnityWindowView);
156public:
157
158 NuxView();
52159
53 ui::LayoutWindow::Vector ExternalTargets();160 ui::LayoutWindow::Vector ExternalTargets();
54161
55 void SetModel(SwitcherModel::Ptr model);162 void SetModel(SwitcherModel::Ptr model);
56 SwitcherModel::Ptr GetModel();163 SwitcherModel::Ptr GetModel();
57164
58 nux::Property<bool> render_boxes;
59 nux::Property<int> border_size;
60 nux::Property<int> flat_spacing;
61 nux::Property<int> icon_size;
62 nux::Property<int> minimum_spacing;
63 nux::Property<int> tile_size;
64 nux::Property<int> vertical_size;
65 nux::Property<int> text_size;
66 nux::Property<int> animation_length;
67 nux::Property<int> monitor;
68 nux::Property<double> spread_size;
69
70 // Returns the index of the icon at the given position, in window coordinates.165 // Returns the index of the icon at the given position, in window coordinates.
71 // If there's no icon there, -1 is returned.166 // If there's no icon there, -1 is returned.
72 int IconIndexAt(int x, int y);167 int IconIndexAt(int x, int y);
73168
169 MouseEventConnections ConnectToMouseEvents(MouseButtonCallback const& mouse_down_callback,
170 MouseButtonCallback const& mouse_up_callback,
171 MouseDragCallback const& mouse_drag_callback);
172
74protected:173protected:
75 // Introspectable methods174 // Introspectable methods
175 void SetupBackground(bool enabled);
76 std::string GetName() const;176 std::string GetName() const;
77 void AddProperties(GVariantBuilder* builder);177 void AddProperties(GVariantBuilder* builder);
78178
79 void PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw);179 void PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
80 void DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry clip);180 void DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry clip);
181 void QueueDraw();
182 nux::Geometry GetAbsoluteGeometry() const;
81 nux::Geometry GetBackgroundGeometry();183 nux::Geometry GetBackgroundGeometry();
82184
83 ui::RenderArg InterpolateRenderArgs(ui::RenderArg const& start, ui::RenderArg const& end, float progress);185 ui::RenderArg InterpolateRenderArgs(ui::RenderArg const& start, ui::RenderArg const& end, float progress);
84 nux::Geometry InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress);186 nux::Geometry InterpolateBackground(nux::Geometry const& start, nux::Geometry const& end, float progress);
85187
86 std::list<ui::RenderArg> RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current);188 std::list<ui::RenderArg> RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current);
87189
88 ui::RenderArg CreateBaseArgForIcon(launcher::AbstractLauncherIcon::Ptr const& icon);190 ui::RenderArg CreateBaseArgForIcon(launcher::AbstractLauncherIcon::Ptr const& icon);
89private:191private:
90 void OnSelectionChanged(launcher::AbstractLauncherIcon::Ptr const& selection);192 void OnSelectionChanged(launcher::AbstractLauncherIcon::Ptr const& selection);
91 void OnDetailSelectionChanged (bool detail);193 void OnDetailSelectionChanged(bool detail);
92 void OnDetailSelectionIndexChanged (unsigned int index);194 void OnDetailSelectionIndexChanged(unsigned int index);
93195
94 void OnIconSizeChanged (int size);196 void OnIconSizeChanged(int size);
95 void OnTileSizeChanged (int size);197 void OnTileSizeChanged(int size);
96198
97 nux::Geometry UpdateRenderTargets (nux::Point const& center, timespec const& current);199 nux::Geometry UpdateRenderTargets(nux::Point const& center, timespec const& current);
98 void OffsetRenderTargets (int x, int y);200 void OffsetRenderTargets(int x, int y);
99201
100 nux::Size SpreadSize ();202 nux::Size SpreadSize();
101203
102 void GetFlatIconPositions (int n_flat_icons, 204 void GetFlatIconPositions(int n_flat_icons,
103 int size, 205 int size,
104 int selection, 206 int selection,
105 int &first_flat, 207 int &first_flat,
106 int &last_flat, 208 int &last_flat,
107 int &half_fold_left, 209 int &half_fold_left,
108 int &half_fold_right);210 int &half_fold_right);
109211
110 void SaveLast ();212 void SaveLast();
213
214 // Property setters
215 void SetBackgroundColor(nux::Color const& color);
216 void SetMonitor(unsigned int monitor);
217 void SetBorderSize(unsigned int);
218 void SetFlatSpacing(int);
219 void SetTextSize(unsigned int);
220 void SetIconSize(unsigned int);
221 void SetTileSize(unsigned int);
222 void SetAnimationLength(unsigned int);
223 void SetRenderBoxes(bool);
224
225 // Property getters
226 unsigned int GetBorderSize();
227 unsigned int GetFlatSpacing();
228 unsigned int GetTextSize();
229 unsigned int GetIconSize();
230 unsigned int GetTileSize();
231 unsigned int GetAnimationLength();
232
233 nux::Property<bool> render_boxes;
234 nux::Property<int> border_size;
235 nux::Property<int> flat_spacing;
236 nux::Property<int> icon_size;
237 nux::Property<int> minimum_spacing;
238 nux::Property<int> tile_size;
239 nux::Property<int> vertical_size;
240 nux::Property<int> text_size;
241 nux::Property<int> animation_length;
242 nux::Property<int> monitor;
243 nux::Property<double> spread_size;
111244
112 SwitcherModel::Ptr model_;245 SwitcherModel::Ptr model_;
113 ui::LayoutSystem layout_system_;246 ui::LayoutSystem layout_system_;
@@ -132,6 +265,53 @@
132 glib::Source::UniquePtr redraw_idle_;265 glib::Source::UniquePtr redraw_idle_;
133};266};
134267
268class NuxViewWrapper : public unity::switcher::View::Impl
269{
270 public:
271
272 NuxViewWrapper(nux::ObjectPtr<NuxView> const& nuxView);
273
274 ui::LayoutWindow::Vector ExternalTargets();
275
276 void SetModel(SwitcherModel::Ptr model);
277 SwitcherModel::Ptr GetModel();
278
279 MouseEventConnections ConnectToMouseEvents(const MouseButtonCallback &mouse_down_callback,
280 const MouseButtonCallback &mouse_up_callback,
281 const MouseDragCallback &mouse_drag_callback);
282 void QueueDraw();
283 nux::Geometry GetAbsoluteGeometry() const;
284
285 // Returns the index of the icon at the given position, in window coordinates.
286 // If there's no icon there, -1 is returned.
287 int IconIndexAt(int x, int y);
288
289 // Property setters
290 void SetBackgroundColor(nux::Color const& color);
291 void SetMonitor(unsigned int monitor);
292 void SetBorderSize(unsigned int);
293 void SetFlatSpacing(int);
294 void SetTextSize(unsigned int);
295 void SetIconSize(unsigned int);
296 void SetTileSize(unsigned int);
297 void SetAnimationLength(unsigned int);
298 void SetRenderBoxes(bool);
299
300 // Property getters
301 unsigned int GetBorderSize();
302 unsigned int GetFlatSpacing();
303 unsigned int GetTextSize();
304 unsigned int GetIconSize();
305 unsigned int GetTileSize();
306 unsigned int GetAnimationLength();
307
308 void SetupBackground(bool enabled = true);
309
310 nux::Area * GetTopLevelViewWindow();
311 private:
312 nux::ObjectPtr<nux::Object> reference_;
313 unity::switcher::View::Impl *impl_;
314};
135}315}
136}316}
137317
138318
=== modified file 'plugins/unityshell/src/GesturalWindowSwitcher.cpp'
--- plugins/unityshell/src/GesturalWindowSwitcher.cpp 2012-12-20 16:52:21 +0000
+++ plugins/unityshell/src/GesturalWindowSwitcher.cpp 2012-12-20 16:52:21 +0000
@@ -335,7 +335,7 @@
335335
336 state = State::RecognizingMouseClickOrDrag;336 state = State::RecognizingMouseClickOrDrag;
337337
338 unity::switcher::SwitcherView *view = switcher_controller->GetView();338 unity::switcher::View *view = switcher_controller->GetView();
339339
340 index_icon_hit = view->IconIndexAt(x, y);340 index_icon_hit = view->IconIndexAt(x, y);
341 accumulated_horizontal_drag = 0.0f;341 accumulated_horizontal_drag = 0.0f;
@@ -413,17 +413,17 @@
413413
414void GesturalWindowSwitcherPrivate::ConnectToSwitcherViewMouseEvents()414void GesturalWindowSwitcherPrivate::ConnectToSwitcherViewMouseEvents()
415{415{
416 unity::switcher::SwitcherView *switcher_view = switcher_controller->GetView();416 unity::switcher::View *switcher_view = switcher_controller->GetView();
417 g_assert(switcher_view);417 g_assert(switcher_view);
418418
419 mouse_down_connection = switcher_view->mouse_down.connect(419 auto connections =
420 sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDown));420 switcher_view->ConnectToMouseEvents(sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDown),
421421 sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseUp),
422 mouse_up_connection = switcher_view->mouse_up.connect(
423 sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseUp));
424
425 mouse_drag_connection = switcher_view->mouse_drag.connect(
426 sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDrag));422 sigc::mem_fun(this, &GesturalWindowSwitcherPrivate::ProcessSwitcherViewMouseDrag));
423
424 std::tie (mouse_down_connection,
425 mouse_up_connection,
426 mouse_drag_connection) = connections;
427}427}
428428
429///////////////////////////////////////////429///////////////////////////////////////////
430430
=== modified file 'plugins/unityshell/src/unity-switcher-accessible.cpp'
--- plugins/unityshell/src/unity-switcher-accessible.cpp 2012-10-11 01:44:15 +0000
+++ plugins/unityshell/src/unity-switcher-accessible.cpp 2012-12-20 16:52:21 +0000
@@ -139,7 +139,7 @@
139{139{
140 AtkObject* accessible = NULL;140 AtkObject* accessible = NULL;
141141
142 g_return_val_if_fail(dynamic_cast<SwitcherView*>(object), NULL);142 g_return_val_if_fail(dynamic_cast<NuxView*>(object), NULL);
143143
144 accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SWITCHER_ACCESSIBLE, NULL));144 accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_SWITCHER_ACCESSIBLE, NULL));
145145
@@ -154,7 +154,7 @@
154unity_switcher_accessible_initialize(AtkObject* accessible,154unity_switcher_accessible_initialize(AtkObject* accessible,
155 gpointer data)155 gpointer data)
156{156{
157 SwitcherView* switcher = NULL;157 NuxView* switcher = NULL;
158 nux::Object* nux_object = NULL;158 nux::Object* nux_object = NULL;
159 UnitySwitcherAccessible* self = NULL;159 UnitySwitcherAccessible* self = NULL;
160 SwitcherModel::Ptr model;160 SwitcherModel::Ptr model;
@@ -165,7 +165,7 @@
165165
166 self = UNITY_SWITCHER_ACCESSIBLE(accessible);166 self = UNITY_SWITCHER_ACCESSIBLE(accessible);
167 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));167 nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
168 switcher = dynamic_cast<SwitcherView*>(nux_object);168 switcher = dynamic_cast<NuxView*>(nux_object);
169 if (switcher == NULL)169 if (switcher == NULL)
170 return;170 return;
171171
@@ -276,7 +276,7 @@
276unity_switcher_accessible_ref_selection(AtkSelection* selection,276unity_switcher_accessible_ref_selection(AtkSelection* selection,
277 gint i)277 gint i)
278{278{
279 SwitcherView* switcher = NULL;279 NuxView* switcher = NULL;
280 SwitcherModel::Ptr switcher_model;280 SwitcherModel::Ptr switcher_model;
281 nux::Object* nux_object = NULL;281 nux::Object* nux_object = NULL;
282 gint selected_index = 0;282 gint selected_index = 0;
@@ -292,7 +292,7 @@
292 if (!nux_object) /* state is defunct */292 if (!nux_object) /* state is defunct */
293 return 0;293 return 0;
294294
295 switcher = dynamic_cast<SwitcherView*>(nux_object);295 switcher = dynamic_cast<NuxView*>(nux_object);
296296
297 switcher_model = switcher->GetModel();297 switcher_model = switcher->GetModel();
298 selected_index = switcher_model->SelectionIndex();298 selected_index = switcher_model->SelectionIndex();
@@ -309,7 +309,7 @@
309static gint309static gint
310unity_switcher_accessible_get_selection_count(AtkSelection* selection)310unity_switcher_accessible_get_selection_count(AtkSelection* selection)
311{311{
312 SwitcherView* switcher = NULL;312 NuxView* switcher = NULL;
313 SwitcherModel::Ptr switcher_model;313 SwitcherModel::Ptr switcher_model;
314 nux::Object* nux_object = NULL;314 nux::Object* nux_object = NULL;
315315
@@ -319,7 +319,7 @@
319 if (!nux_object) /* state is defunct */319 if (!nux_object) /* state is defunct */
320 return 0;320 return 0;
321321
322 switcher = dynamic_cast<SwitcherView*>(nux_object);322 switcher = dynamic_cast<NuxView*>(nux_object);
323 switcher_model = switcher->GetModel();323 switcher_model = switcher->GetModel();
324324
325 if (!switcher_model->Selection())325 if (!switcher_model->Selection())
@@ -332,7 +332,7 @@
332unity_switcher_accessible_is_child_selected(AtkSelection* selection,332unity_switcher_accessible_is_child_selected(AtkSelection* selection,
333 gint i)333 gint i)
334{334{
335 SwitcherView* switcher = NULL;335 NuxView* switcher = NULL;
336 SwitcherModel::Ptr switcher_model;336 SwitcherModel::Ptr switcher_model;
337 SwitcherModel::iterator it;337 SwitcherModel::iterator it;
338 nux::Object* nux_object = NULL;338 nux::Object* nux_object = NULL;
@@ -344,7 +344,7 @@
344 if (!nux_object) /* state is defunct */344 if (!nux_object) /* state is defunct */
345 return 0;345 return 0;
346346
347 switcher = dynamic_cast<SwitcherView*>(nux_object);347 switcher = dynamic_cast<NuxView*>(nux_object);
348 switcher_model = switcher->GetModel();348 switcher_model = switcher->GetModel();
349 selected_index = switcher_model->SelectionIndex();349 selected_index = switcher_model->SelectionIndex();
350350
@@ -385,7 +385,7 @@
385{385{
386 gint index = 0;386 gint index = 0;
387 nux::Object* nux_object = NULL;387 nux::Object* nux_object = NULL;
388 SwitcherView* switcher = NULL;388 NuxView* switcher = NULL;
389 SwitcherModel::iterator it;389 SwitcherModel::iterator it;
390 AtkObject* child_accessible = NULL;390 AtkObject* child_accessible = NULL;
391391
@@ -393,7 +393,7 @@
393 if (!nux_object) /* state is defunct */393 if (!nux_object) /* state is defunct */
394 return;394 return;
395395
396 switcher = dynamic_cast<SwitcherView*>(nux_object);396 switcher = dynamic_cast<NuxView*>(nux_object);
397 SwitcherModel::Ptr const& switcher_model = switcher->GetModel();397 SwitcherModel::Ptr const& switcher_model = switcher->GetModel();
398398
399 if (!switcher_model)399 if (!switcher_model)
400400
=== modified file 'plugins/unityshell/src/unitya11y.cpp'
--- plugins/unityshell/src/unitya11y.cpp 2012-12-14 12:14:34 +0000
+++ plugins/unityshell/src/unitya11y.cpp 2012-12-20 16:52:21 +0000
@@ -183,7 +183,7 @@
183 if (object->Type().IsDerivedFromType(unity::SearchBar::StaticObjectType))183 if (object->Type().IsDerivedFromType(unity::SearchBar::StaticObjectType))
184 return unity_search_bar_accessible_new(object);184 return unity_search_bar_accessible_new(object);
185185
186 if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType))186 if (object->Type().IsDerivedFromType(unity::switcher::NuxView::StaticObjectType))
187 return unity_switcher_accessible_new(object);187 return unity_switcher_accessible_new(object);
188188
189 /* NUX classes */189 /* NUX classes */
190190
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2012-12-20 16:52:21 +0000
+++ plugins/unityshell/src/unityshell.cpp 2012-12-20 16:52:21 +0000
@@ -1438,7 +1438,7 @@
14381438
1439 if (switcher_controller_ && switcher_controller_->Visible())1439 if (switcher_controller_ && switcher_controller_->Visible())
1440 {1440 {
1441 unity::switcher::SwitcherView* view = switcher_controller_->GetView();1441 unity::switcher::View* view = switcher_controller_->GetView();
14421442
1443 if (G_LIKELY(view))1443 if (G_LIKELY(view))
1444 {1444 {
14451445
=== modified file 'tests/MockSwitcherController.h'
--- tests/MockSwitcherController.h 2012-12-20 16:52:21 +0000
+++ tests/MockSwitcherController.h 2012-12-20 16:52:21 +0000
@@ -43,7 +43,7 @@
43 MOCK_METHOD0(Next, void());43 MOCK_METHOD0(Next, void());
44 MOCK_METHOD0(Prev, void());44 MOCK_METHOD0(Prev, void());
45 MOCK_METHOD1(Select, void(int));45 MOCK_METHOD1(Select, void(int));
46 MOCK_METHOD0(GetView, unity::switcher::SwitcherView * ());46 MOCK_METHOD0(GetView, unity::switcher::View * ());
47 MOCK_CONST_METHOD1(CanShowSwitcher, bool(const std::vector<launcher::AbstractLauncherIcon::Ptr> &));47 MOCK_CONST_METHOD1(CanShowSwitcher, bool(const std::vector<launcher::AbstractLauncherIcon::Ptr> &));
48 MOCK_METHOD0(NextDetail, void());48 MOCK_METHOD0(NextDetail, void());
49 MOCK_METHOD0(PrevDetail, void());49 MOCK_METHOD0(PrevDetail, void());
5050
=== modified file 'tests/StubSwitcherController.h'
--- tests/StubSwitcherController.h 2012-12-20 16:52:21 +0000
+++ tests/StubSwitcherController.h 2012-12-20 16:52:21 +0000
@@ -59,12 +59,12 @@
59 Reset ();59 Reset ();
60 };60 };
6161
62 void SetView (SwitcherView *view)62 void SetView (View *view)
63 {63 {
64 mock_view_ = view;64 mock_view_ = view;
65 }65 }
6666
67 SwitcherView * GetView ()67 View * GetView ()
68 {68 {
69 return mock_view_;69 return mock_view_;
70 }70 }
@@ -147,7 +147,7 @@
147 int index_selected_;147 int index_selected_;
148148
149 private:149 private:
150 SwitcherView *mock_view_;150 View *mock_view_;
151};151};
152}152}
153}153}
154154
=== modified file 'tests/test-gestures/SwitcherControllerMock.h'
--- tests/test-gestures/SwitcherControllerMock.h 2012-12-20 16:52:21 +0000
+++ tests/test-gestures/SwitcherControllerMock.h 2012-12-20 16:52:21 +0000
@@ -24,13 +24,42 @@
24namespace unity {24namespace unity {
25namespace switcher {25namespace switcher {
2626
27class SwitcherViewMock : public nux::ViewMock27class ViewMock
28{
29 public:
30
31 typedef sigc::slot<void, int, int, int, int> MouseButtonCallback;
32 typedef sigc::slot <void, int, int, int, int, unsigned int, unsigned int> MouseDragCallback;
33
34 typedef std::tuple <sigc::connection,
35 sigc::connection,
36 sigc::connection> MouseEventConnections;
37
38 virtual int IconIndexAt(int x, int y) = 0;
39
40 virtual MouseEventConnections ConnectToMouseEvents (const MouseButtonCallback &mouse_down_callback,
41 const MouseButtonCallback &mouse_up_callback,
42 const MouseDragCallback &mouse_drag_callback) = 0;
43
44
45};
46
47class NuxViewMock : public nux::ViewMock, public switcher::ViewMock
28{48{
29public:49public:
30 int IconIndexAt(int x, int y)50 int IconIndexAt(int x, int y)
31 {51 {
32 return x*y;52 return x*y;
33 }53 }
54
55 MouseEventConnections ConnectToMouseEvents (const MouseButtonCallback &mouse_down_callback,
56 const MouseButtonCallback &mouse_up_callback,
57 const MouseDragCallback &mouse_drag_callback)
58 {
59 return MouseEventConnections (mouse_down.connect (mouse_down_callback),
60 mouse_up.connect (mouse_up_callback),
61 mouse_drag.connect (mouse_drag_callback));
62 }
34};63};
3564
36class ControllerMock65class ControllerMock
@@ -78,7 +107,7 @@
78 is_visible_ = false;107 is_visible_ = false;
79 }108 }
80109
81 SwitcherViewMock *GetView()110 ViewMock *GetView()
82 {111 {
83 return &view_;112 return &view_;
84 }113 }
@@ -89,7 +118,7 @@
89 }118 }
90119
91 bool is_visible_;120 bool is_visible_;
92 SwitcherViewMock view_;121 NuxViewMock view_;
93 int prev_count_;122 int prev_count_;
94 int next_count_;123 int next_count_;
95 int index_selected_;124 int index_selected_;
96125
=== modified file 'tests/test-gestures/sed_script_switcher'
--- tests/test-gestures/sed_script_switcher 2012-07-27 20:24:01 +0000
+++ tests/test-gestures/sed_script_switcher 2012-12-20 16:52:21 +0000
@@ -22,4 +22,5 @@
22s|\<SwitcherController\>|SwitcherControllerMock|g22s|\<SwitcherController\>|SwitcherControllerMock|g
23s|\<switcher\:\:Controller\>|switcher\:\:ControllerMock|g23s|\<switcher\:\:Controller\>|switcher\:\:ControllerMock|g
24s|\<launcher\:\:Controller\>|launcher\:\:ControllerMock|g24s|\<launcher\:\:Controller\>|launcher\:\:ControllerMock|g
25s|\<SwitcherView\>|SwitcherViewMock|g25s|\<switcher\:\:View\>|switcher\:\:ViewMock|g
26s|\<switcher\:\:NuxView\>|switcher\:\:NuxViewMock|g
2627
=== modified file 'tests/test-gestures/test_gestural_window_switcher.cpp'
--- tests/test-gestures/test_gestural_window_switcher.cpp 2012-08-14 12:48:21 +0000
+++ tests/test-gestures/test_gestural_window_switcher.cpp 2012-12-20 16:52:21 +0000
@@ -290,7 +290,7 @@
290290
291TEST_F(GesturalWindowSwitcherTest, MouseDragAfterTapAndHoldSelectsNextWindow)291TEST_F(GesturalWindowSwitcherTest, MouseDragAfterTapAndHoldSelectsNextWindow)
292{292{
293 unity::switcher::SwitcherViewMock &switcher_view =293 unity::switcher::NuxViewMock &switcher_view =
294 unity_screen->switcher_controller()->view_;294 unity_screen->switcher_controller()->view_;
295 int drag_delta = GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION * 1.5f;295 int drag_delta = GesturalWindowSwitcher::DRAG_DELTA_FOR_CHANGING_SELECTION * 1.5f;
296296