Merge lp:~townsend/unity/unity.cleanup-refactor-preview into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3007
Proposed branch: lp:~townsend/unity/unity.cleanup-refactor-preview
Merge into: lp:unity
Diff against target: 350 lines (+4/-126)
8 files modified
dash/previews/ApplicationPreview.cpp (+0/-23)
dash/previews/GenericPreview.cpp (+0/-23)
dash/previews/MoviePreview.cpp (+2/-25)
dash/previews/MoviePreview.h (+1/-1)
dash/previews/MusicPreview.cpp (+0/-23)
dash/previews/Preview.cpp (+0/-5)
dash/previews/Preview.h (+1/-3)
dash/previews/SocialPreview.cpp (+0/-23)
To merge this branch: bzr merge lp:~townsend/unity/unity.cleanup-refactor-preview
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+141124@code.launchpad.net

Commit message

Per Nick Dedekind's comments on revno. 3006:
* Make SetupViews() into a pure virtual function.
* Get rid of SetupBackground(), details_bg_layer_, and GetShadowBackgroundEnabled and associated code. This is no longer used, so it's not needed.

Description of the change

Nick Dedekind reviewed my MP that has already been merged as revno. 3006. He had a few comments and after discussing these with him, I made the following changes:

- Make SetupViews() into a pure virtual function since what we really want here is to force any derived previews to define SetupViews().
- Get rid of SetupBackground(), details_bg_layer_, and GetShadowBackgroundEnabled and associated code. This is no longer used, so it's not needed.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Looks good to me :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/ApplicationPreview.cpp'
2--- dash/previews/ApplicationPreview.cpp 2012-12-20 18:51:09 +0000
3+++ dash/previews/ApplicationPreview.cpp 2012-12-21 20:03:25 +0000
4@@ -63,7 +63,6 @@
5 ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model)
6 : Preview(preview_model)
7 {
8- SetupBackground();
9 SetupViews();
10 }
11
12@@ -75,23 +74,9 @@
13 {
14 nux::Geometry const& base = GetGeometry();
15
16- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
17-
18 gfx_engine.PushClippingRectangle(base);
19 nux::GetPainter().PaintBackground(gfx_engine, base);
20
21- if (enable_bg_shadows && full_data_layout_)
22- {
23- unsigned int alpha, src, dest = 0;
24- gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
25- gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
26-
27- details_bg_layer_->SetGeometry(full_data_layout_->GetGeometry());
28- nux::GetPainter().RenderSinglePaintLayer(gfx_engine, full_data_layout_->GetGeometry(), details_bg_layer_.get());
29-
30- gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
31- }
32-
33 gfx_engine.PopClippingRectangle();
34 }
35
36@@ -100,11 +85,6 @@
37 nux::Geometry const& base = GetGeometry();
38 gfx_engine.PushClippingRectangle(base);
39
40- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
41-
42- if (enable_bg_shadows && !IsFullRedraw())
43- nux::GetPainter().PushLayer(gfx_engine, details_bg_layer_->GetGeometry(), details_bg_layer_.get());
44-
45 unsigned int alpha, src, dest = 0;
46 gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
47 gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
48@@ -114,9 +94,6 @@
49
50 gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
51
52- if (enable_bg_shadows && !IsFullRedraw())
53- nux::GetPainter().PopBackground();
54-
55 gfx_engine.PopClippingRectangle();
56 }
57
58
59=== modified file 'dash/previews/GenericPreview.cpp'
60--- dash/previews/GenericPreview.cpp 2012-12-20 18:51:09 +0000
61+++ dash/previews/GenericPreview.cpp 2012-12-21 20:03:25 +0000
62@@ -57,7 +57,6 @@
63 GenericPreview::GenericPreview(dash::Preview::Ptr preview_model)
64 : Preview(preview_model)
65 {
66- SetupBackground();
67 SetupViews();
68 }
69
70@@ -69,23 +68,9 @@
71 {
72 nux::Geometry const& base = GetGeometry();
73
74- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
75-
76 gfx_engine.PushClippingRectangle(base);
77 nux::GetPainter().PaintBackground(gfx_engine, base);
78
79- if (enable_bg_shadows && full_data_layout_)
80- {
81- unsigned int alpha, src, dest = 0;
82- gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
83- gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
84-
85- details_bg_layer_->SetGeometry(full_data_layout_->GetGeometry());
86- nux::GetPainter().RenderSinglePaintLayer(gfx_engine, full_data_layout_->GetGeometry(), details_bg_layer_.get());
87-
88- gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
89- }
90-
91 gfx_engine.PopClippingRectangle();
92 }
93
94@@ -94,11 +79,6 @@
95 nux::Geometry const& base = GetGeometry();
96 gfx_engine.PushClippingRectangle(base);
97
98- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
99-
100- if (enable_bg_shadows && !IsFullRedraw())
101- nux::GetPainter().PushLayer(gfx_engine, details_bg_layer_->GetGeometry(), details_bg_layer_.get());
102-
103 unsigned int alpha, src, dest = 0;
104 gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
105 gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
106@@ -108,9 +88,6 @@
107
108 gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
109
110- if (enable_bg_shadows && !IsFullRedraw())
111- nux::GetPainter().PopBackground();
112-
113 gfx_engine.PopClippingRectangle();
114 }
115
116
117=== modified file 'dash/previews/MoviePreview.cpp'
118--- dash/previews/MoviePreview.cpp 2012-12-20 18:51:09 +0000
119+++ dash/previews/MoviePreview.cpp 2012-12-21 20:03:25 +0000
120@@ -58,8 +58,7 @@
121 MoviePreview::MoviePreview(dash::Preview::Ptr preview_model)
122 : Preview(preview_model)
123 {
124- SetupBackground();
125- SetupView();
126+ SetupViews();
127 }
128
129 MoviePreview::~MoviePreview()
130@@ -80,23 +79,9 @@
131 {
132 nux::Geometry const& base = GetGeometry();
133
134- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
135-
136 gfx_engine.PushClippingRectangle(base);
137 nux::GetPainter().PaintBackground(gfx_engine, base);
138
139- if (enable_bg_shadows && full_data_layout_)
140- {
141- unsigned int alpha, src, dest = 0;
142- gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
143- gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
144-
145- details_bg_layer_->SetGeometry(full_data_layout_->GetGeometry());
146- nux::GetPainter().RenderSinglePaintLayer(gfx_engine, full_data_layout_->GetGeometry(), details_bg_layer_.get());
147-
148- gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
149- }
150-
151 gfx_engine.PopClippingRectangle();
152 }
153
154@@ -105,11 +90,6 @@
155 nux::Geometry const& base = GetGeometry();
156 gfx_engine.PushClippingRectangle(base);
157
158- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
159-
160- if (enable_bg_shadows && !IsFullRedraw())
161- nux::GetPainter().PushLayer(gfx_engine, details_bg_layer_->GetGeometry(), details_bg_layer_.get());
162-
163 unsigned int alpha, src, dest = 0;
164 gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
165 gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
166@@ -119,9 +99,6 @@
167
168 gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
169
170- if (enable_bg_shadows && !IsFullRedraw())
171- nux::GetPainter().PopBackground();
172-
173 gfx_engine.PopClippingRectangle();
174 }
175
176@@ -133,7 +110,7 @@
177 {
178 }
179
180-void MoviePreview::SetupView()
181+void MoviePreview::SetupViews()
182 {
183 dash::MoviePreview* movie_preview_model = dynamic_cast<dash::MoviePreview*>(preview_model_.get());
184 if (!movie_preview_model)
185
186=== modified file 'dash/previews/MoviePreview.h'
187--- dash/previews/MoviePreview.h 2012-12-20 18:51:09 +0000
188+++ dash/previews/MoviePreview.h 2012-12-21 20:03:25 +0000
189@@ -54,7 +54,7 @@
190 virtual void OnNavigateOut();
191 virtual void OnNavigateInComplete();
192
193- virtual void SetupView();
194+ virtual void SetupViews();
195
196 protected:
197 nux::ObjectPtr<PreviewRatingsWidget> rating_;
198
199=== modified file 'dash/previews/MusicPreview.cpp'
200--- dash/previews/MusicPreview.cpp 2012-12-20 18:51:09 +0000
201+++ dash/previews/MusicPreview.cpp 2012-12-21 20:03:25 +0000
202@@ -47,7 +47,6 @@
203 MusicPreview::MusicPreview(dash::Preview::Ptr preview_model)
204 : Preview(preview_model)
205 {
206- SetupBackground();
207 SetupViews();
208 }
209
210@@ -59,23 +58,9 @@
211 {
212 nux::Geometry const& base = GetGeometry();
213
214- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
215-
216 gfx_engine.PushClippingRectangle(base);
217 nux::GetPainter().PaintBackground(gfx_engine, base);
218
219- if (enable_bg_shadows && full_data_layout_)
220- {
221- unsigned int alpha, src, dest = 0;
222- gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
223- gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
224-
225- details_bg_layer_->SetGeometry(full_data_layout_->GetGeometry());
226- nux::GetPainter().RenderSinglePaintLayer(gfx_engine, full_data_layout_->GetGeometry(), details_bg_layer_.get());
227-
228- gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
229- }
230-
231 gfx_engine.PopClippingRectangle();
232 }
233
234@@ -84,11 +69,6 @@
235 nux::Geometry const& base = GetGeometry();
236 gfx_engine.PushClippingRectangle(base);
237
238- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
239-
240- if (enable_bg_shadows && !IsFullRedraw())
241- nux::GetPainter().PushLayer(gfx_engine, details_bg_layer_->GetGeometry(), details_bg_layer_.get());
242-
243 unsigned int alpha, src, dest = 0;
244 gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
245 gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
246@@ -98,9 +78,6 @@
247
248 gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
249
250- if (enable_bg_shadows && !IsFullRedraw())
251- nux::GetPainter().PopBackground();
252-
253 gfx_engine.PopClippingRectangle();
254 }
255
256
257=== modified file 'dash/previews/Preview.cpp'
258--- dash/previews/Preview.cpp 2012-12-20 18:51:09 +0000
259+++ dash/previews/Preview.cpp 2012-12-21 20:03:25 +0000
260@@ -368,11 +368,6 @@
261 nux::GetWindowCompositor().SetKeyFocusArea(default_focus);
262 }
263
264-void Preview::SetupBackground()
265-{
266- details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer());
267-}
268-
269 }
270 }
271 }
272
273=== modified file 'dash/previews/Preview.h'
274--- dash/previews/Preview.h 2012-12-20 18:51:09 +0000
275+++ dash/previews/Preview.h 2012-12-21 20:03:25 +0000
276@@ -86,8 +86,7 @@
277
278 virtual bool AcceptKeyNavFocus() { return false; }
279
280- virtual void SetupViews() {}
281- void SetupBackground();
282+ virtual void SetupViews() = 0;
283
284 nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
285 nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
286@@ -108,7 +107,6 @@
287 PreviewInfoHintWidget::Ptr preview_info_hints_;
288
289 typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr;
290- LayerPtr details_bg_layer_;
291
292 friend class PreviewContent;
293 };
294
295=== modified file 'dash/previews/SocialPreview.cpp'
296--- dash/previews/SocialPreview.cpp 2012-12-20 18:51:09 +0000
297+++ dash/previews/SocialPreview.cpp 2012-12-21 20:03:25 +0000
298@@ -64,7 +64,6 @@
299 SocialPreview::SocialPreview(dash::Preview::Ptr preview_model)
300 : Preview(preview_model)
301 {
302- SetupBackground();
303 SetupViews();
304 }
305
306@@ -76,23 +75,9 @@
307 {
308 nux::Geometry const& base = GetGeometry();
309
310- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
311-
312 gfx_engine.PushClippingRectangle(base);
313 nux::GetPainter().PaintBackground(gfx_engine, base);
314
315- if (enable_bg_shadows && full_data_layout_)
316- {
317- unsigned int alpha, src, dest = 0;
318- gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
319- gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
320-
321- details_bg_layer_->SetGeometry(full_data_layout_->GetGeometry());
322- nux::GetPainter().RenderSinglePaintLayer(gfx_engine, full_data_layout_->GetGeometry(), details_bg_layer_.get());
323-
324- gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
325- }
326-
327 gfx_engine.PopClippingRectangle();
328 }
329
330@@ -101,11 +86,6 @@
331 nux::Geometry const& base = GetGeometry();
332 gfx_engine.PushClippingRectangle(base);
333
334- bool enable_bg_shadows = dash::previews::Style::Instance().GetShadowBackgroundEnabled();
335-
336- if (enable_bg_shadows && !IsFullRedraw())
337- nux::GetPainter().PushLayer(gfx_engine, details_bg_layer_->GetGeometry(), details_bg_layer_.get());
338-
339 unsigned int alpha, src, dest = 0;
340 gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
341 gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
342@@ -115,9 +95,6 @@
343
344 gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
345
346- if (enable_bg_shadows && !IsFullRedraw())
347- nux::GetPainter().PopBackground();
348-
349 gfx_engine.PopClippingRectangle();
350 }
351