Merge lp:~townsend/unity/unity.refactor-preview into lp:unity
- unity.refactor-preview
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3006 |
Proposed branch: | lp:~townsend/unity/unity.refactor-preview |
Merge into: | lp:unity |
Diff against target: |
567 lines (+36/-152) 12 files modified
dash/previews/ApplicationPreview.cpp (+0/-8) dash/previews/ApplicationPreview.h (+1/-21) dash/previews/GenericPreview.cpp (+0/-8) dash/previews/GenericPreview.h (+1/-24) dash/previews/MoviePreview.cpp (+0/-8) dash/previews/MoviePreview.h (+1/-22) dash/previews/MusicPreview.cpp (+0/-10) dash/previews/MusicPreview.h (+1/-22) dash/previews/Preview.cpp (+10/-0) dash/previews/Preview.h (+21/-1) dash/previews/SocialPreview.cpp (+0/-8) dash/previews/SocialPreview.h (+1/-20) |
To merge this branch: | bzr merge lp:~townsend/unity/unity.refactor-preview |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nick Dedekind (community) | Needs Fixing | ||
Brandon Schaefer (community) | Approve | ||
PS Jenkins bot | continuous-integration | Pending | |
Review via email: mp+140976@code.launchpad.net |
Commit message
Refactored the derived preview classes to put the common members into the base Preview class. This should help alleviate code redundancy, code readability, and make the creation of any future new derived preview classes easier.
Description of the change
= Issue =
The derived preview classes(
= Fix =
This moves the common members into the base Preview class. This should alleviate code redundancy, code readability, and make it easier to create any future new derived preview classes.
= Test =
This does not change any functionality, so the current tests should be sufficient.
Nick Dedekind (nick-dedekind) wrote : | # |
I think it's about time to get rid of the background layer. Now that previews are a bit more mature I think we can remove them from the code as they are not actually used.
Can you get rid of:
dash::Preview:
dash::Preview:
dash::preview:
The reason why I didn't do this before is that some of the previews don't (or will not) use some of those members you have moved into the common class. eg. socialpreview does not use CoverArt (movie preview will not in future), Social does not use info hints, music and social don't use description.
Also the Payment preview which will be coming through soon won't use most of these fields.
444 + virtual void SetupViews() {}
Don't need it to be there or virtual. It's only called from the constructor of the derived class, so there's no need for it in the base class, esspecially since it doesn't do anything. There's no redundancy issue here because it's always overridden.
Preview Diff
1 | === modified file 'dash/previews/ApplicationPreview.cpp' | |||
2 | --- dash/previews/ApplicationPreview.cpp 2012-12-14 12:14:34 +0000 | |||
3 | +++ dash/previews/ApplicationPreview.cpp 2012-12-20 19:09:20 +0000 | |||
4 | @@ -24,7 +24,6 @@ | |||
5 | 24 | #include "unity-shared/PreviewStyle.h" | 24 | #include "unity-shared/PreviewStyle.h" |
6 | 25 | #include "unity-shared/CoverArt.h" | 25 | #include "unity-shared/CoverArt.h" |
7 | 26 | #include "unity-shared/IconTexture.h" | 26 | #include "unity-shared/IconTexture.h" |
8 | 27 | #include "unity-shared/StaticCairoText.h" | ||
9 | 28 | #include "unity-shared/PlacesOverlayVScrollBar.h" | 27 | #include "unity-shared/PlacesOverlayVScrollBar.h" |
10 | 29 | #include <UnityCore/ApplicationPreview.h> | 28 | #include <UnityCore/ApplicationPreview.h> |
11 | 30 | #include <NuxCore/Logger.h> | 29 | #include <NuxCore/Logger.h> |
12 | @@ -38,7 +37,6 @@ | |||
13 | 38 | 37 | ||
14 | 39 | #include "ApplicationPreview.h" | 38 | #include "ApplicationPreview.h" |
15 | 40 | #include "ActionButton.h" | 39 | #include "ActionButton.h" |
16 | 41 | #include "PreviewInfoHintWidget.h" | ||
17 | 42 | #include "PreviewRatingsWidget.h" | 40 | #include "PreviewRatingsWidget.h" |
18 | 43 | 41 | ||
19 | 44 | namespace unity | 42 | namespace unity |
20 | @@ -64,7 +62,6 @@ | |||
21 | 64 | 62 | ||
22 | 65 | ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model) | 63 | ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model) |
23 | 66 | : Preview(preview_model) | 64 | : Preview(preview_model) |
24 | 67 | , full_data_layout_(nullptr) | ||
25 | 68 | { | 65 | { |
26 | 69 | SetupBackground(); | 66 | SetupBackground(); |
27 | 70 | SetupViews(); | 67 | SetupViews(); |
28 | @@ -133,11 +130,6 @@ | |||
29 | 133 | Preview::AddProperties(builder); | 130 | Preview::AddProperties(builder); |
30 | 134 | } | 131 | } |
31 | 135 | 132 | ||
32 | 136 | void ApplicationPreview::SetupBackground() | ||
33 | 137 | { | ||
34 | 138 | details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer()); | ||
35 | 139 | } | ||
36 | 140 | |||
37 | 141 | void ApplicationPreview::SetupViews() | 133 | void ApplicationPreview::SetupViews() |
38 | 142 | { | 134 | { |
39 | 143 | dash::ApplicationPreview* app_preview_model = dynamic_cast<dash::ApplicationPreview*>(preview_model_.get()); | 135 | dash::ApplicationPreview* app_preview_model = dynamic_cast<dash::ApplicationPreview*>(preview_model_.get()); |
40 | 144 | 136 | ||
41 | === modified file 'dash/previews/ApplicationPreview.h' | |||
42 | --- dash/previews/ApplicationPreview.h 2012-12-14 12:14:34 +0000 | |||
43 | +++ dash/previews/ApplicationPreview.h 2012-12-20 19:09:20 +0000 | |||
44 | @@ -24,14 +24,6 @@ | |||
45 | 24 | #define APPLICATIONPREVIEW_H | 24 | #define APPLICATIONPREVIEW_H |
46 | 25 | 25 | ||
47 | 26 | #include "Preview.h" | 26 | #include "Preview.h" |
48 | 27 | #include <Nux/Nux.h> | ||
49 | 28 | |||
50 | 29 | namespace nux | ||
51 | 30 | { | ||
52 | 31 | class AbstractPaintLayer; | ||
53 | 32 | class VLayout; | ||
54 | 33 | class StaticCairoText; | ||
55 | 34 | } | ||
56 | 35 | 27 | ||
57 | 36 | namespace unity | 28 | namespace unity |
58 | 37 | { | 29 | { |
59 | @@ -41,9 +33,7 @@ | |||
60 | 41 | { | 33 | { |
61 | 42 | namespace previews | 34 | namespace previews |
62 | 43 | { | 35 | { |
63 | 44 | class CoverArt; | ||
64 | 45 | class PreviewRatingsWidget; | 36 | class PreviewRatingsWidget; |
65 | 46 | class PreviewInfoHintWidget; | ||
66 | 47 | 37 | ||
67 | 48 | class ApplicationPreview : public Preview | 38 | class ApplicationPreview : public Preview |
68 | 49 | { | 39 | { |
69 | @@ -63,26 +53,16 @@ | |||
70 | 63 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | 53 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
71 | 64 | virtual void PreLayoutManagement(); | 54 | virtual void PreLayoutManagement(); |
72 | 65 | 55 | ||
75 | 66 | void SetupBackground(); | 56 | virtual void SetupViews(); |
74 | 67 | void SetupViews(); | ||
76 | 68 | 57 | ||
77 | 69 | protected: | 58 | protected: |
78 | 70 | nux::VLayout* full_data_layout_; | ||
79 | 71 | nux::VLayout* title_subtitle_layout_; | 59 | nux::VLayout* title_subtitle_layout_; |
80 | 72 | 60 | ||
81 | 73 | nux::ObjectPtr<CoverArt> image_; | ||
82 | 74 | nux::ObjectPtr<IconTexture> app_icon_; | 61 | nux::ObjectPtr<IconTexture> app_icon_; |
83 | 75 | nux::ObjectPtr<PreviewRatingsWidget> app_rating_; | 62 | nux::ObjectPtr<PreviewRatingsWidget> app_rating_; |
84 | 76 | nux::ObjectPtr<StaticCairoText> title_; | ||
85 | 77 | nux::ObjectPtr<StaticCairoText> subtitle_; | ||
86 | 78 | nux::ObjectPtr<StaticCairoText> license_; | 63 | nux::ObjectPtr<StaticCairoText> license_; |
87 | 79 | nux::ObjectPtr<StaticCairoText> last_update_; | 64 | nux::ObjectPtr<StaticCairoText> last_update_; |
88 | 80 | nux::ObjectPtr<StaticCairoText> copywrite_; | 65 | nux::ObjectPtr<StaticCairoText> copywrite_; |
89 | 81 | nux::ObjectPtr<StaticCairoText> description_; | ||
90 | 82 | nux::ObjectPtr<PreviewInfoHintWidget> preview_info_hints_; | ||
91 | 83 | |||
92 | 84 | typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr; | ||
93 | 85 | LayerPtr details_bg_layer_; | ||
94 | 86 | }; | 66 | }; |
95 | 87 | 67 | ||
96 | 88 | } | 68 | } |
97 | 89 | 69 | ||
98 | === modified file 'dash/previews/GenericPreview.cpp' | |||
99 | --- dash/previews/GenericPreview.cpp 2012-12-14 12:14:34 +0000 | |||
100 | +++ dash/previews/GenericPreview.cpp 2012-12-20 19:09:20 +0000 | |||
101 | @@ -23,7 +23,6 @@ | |||
102 | 23 | #include "unity-shared/IntrospectableWrappers.h" | 23 | #include "unity-shared/IntrospectableWrappers.h" |
103 | 24 | #include "unity-shared/PreviewStyle.h" | 24 | #include "unity-shared/PreviewStyle.h" |
104 | 25 | #include "unity-shared/CoverArt.h" | 25 | #include "unity-shared/CoverArt.h" |
105 | 26 | #include "unity-shared/StaticCairoText.h" | ||
106 | 27 | #include "unity-shared/PlacesOverlayVScrollBar.h" | 26 | #include "unity-shared/PlacesOverlayVScrollBar.h" |
107 | 28 | #include <NuxCore/Logger.h> | 27 | #include <NuxCore/Logger.h> |
108 | 29 | #include <Nux/HLayout.h> | 28 | #include <Nux/HLayout.h> |
109 | @@ -33,7 +32,6 @@ | |||
110 | 33 | #include <Nux/AbstractButton.h> | 32 | #include <Nux/AbstractButton.h> |
111 | 34 | 33 | ||
112 | 35 | #include "GenericPreview.h" | 34 | #include "GenericPreview.h" |
113 | 36 | #include "PreviewInfoHintWidget.h" | ||
114 | 37 | 35 | ||
115 | 38 | namespace unity | 36 | namespace unity |
116 | 39 | { | 37 | { |
117 | @@ -58,7 +56,6 @@ | |||
118 | 58 | 56 | ||
119 | 59 | GenericPreview::GenericPreview(dash::Preview::Ptr preview_model) | 57 | GenericPreview::GenericPreview(dash::Preview::Ptr preview_model) |
120 | 60 | : Preview(preview_model) | 58 | : Preview(preview_model) |
121 | 61 | , full_data_layout_(nullptr) | ||
122 | 62 | { | 59 | { |
123 | 63 | SetupBackground(); | 60 | SetupBackground(); |
124 | 64 | SetupViews(); | 61 | SetupViews(); |
125 | @@ -127,11 +124,6 @@ | |||
126 | 127 | Preview::AddProperties(builder); | 124 | Preview::AddProperties(builder); |
127 | 128 | } | 125 | } |
128 | 129 | 126 | ||
129 | 130 | void GenericPreview::SetupBackground() | ||
130 | 131 | { | ||
131 | 132 | details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer()); | ||
132 | 133 | } | ||
133 | 134 | |||
134 | 135 | void GenericPreview::SetupViews() | 127 | void GenericPreview::SetupViews() |
135 | 136 | { | 128 | { |
136 | 137 | if (!preview_model_) | 129 | if (!preview_model_) |
137 | 138 | 130 | ||
138 | === modified file 'dash/previews/GenericPreview.h' | |||
139 | --- dash/previews/GenericPreview.h 2012-12-14 12:14:34 +0000 | |||
140 | +++ dash/previews/GenericPreview.h 2012-12-20 19:09:20 +0000 | |||
141 | @@ -24,24 +24,14 @@ | |||
142 | 24 | #define GENERICPREVIEW_H | 24 | #define GENERICPREVIEW_H |
143 | 25 | 25 | ||
144 | 26 | #include "Preview.h" | 26 | #include "Preview.h" |
145 | 27 | #include <Nux/Nux.h> | ||
146 | 28 | #include <UnityCore/GenericPreview.h> | 27 | #include <UnityCore/GenericPreview.h> |
147 | 29 | 28 | ||
148 | 30 | namespace nux | ||
149 | 31 | { | ||
150 | 32 | class AbstractPaintLayer; | ||
151 | 33 | class StaticCairoText; | ||
152 | 34 | class VLayout; | ||
153 | 35 | } | ||
154 | 36 | |||
155 | 37 | namespace unity | 29 | namespace unity |
156 | 38 | { | 30 | { |
157 | 39 | namespace dash | 31 | namespace dash |
158 | 40 | { | 32 | { |
159 | 41 | namespace previews | 33 | namespace previews |
160 | 42 | { | 34 | { |
161 | 43 | class CoverArt; | ||
162 | 44 | class PreviewInfoHintWidget; | ||
163 | 45 | 35 | ||
164 | 46 | class GenericPreview : public Preview | 36 | class GenericPreview : public Preview |
165 | 47 | { | 37 | { |
166 | @@ -61,20 +51,7 @@ | |||
167 | 61 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | 51 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
168 | 62 | virtual void PreLayoutManagement(); | 52 | virtual void PreLayoutManagement(); |
169 | 63 | 53 | ||
184 | 64 | void SetupBackground(); | 54 | virtual void SetupViews(); |
171 | 65 | void SetupViews(); | ||
172 | 66 | |||
173 | 67 | protected: | ||
174 | 68 | nux::VLayout* full_data_layout_; | ||
175 | 69 | |||
176 | 70 | nux::ObjectPtr<CoverArt> image_; | ||
177 | 71 | nux::ObjectPtr<StaticCairoText> title_; | ||
178 | 72 | nux::ObjectPtr<StaticCairoText> subtitle_; | ||
179 | 73 | nux::ObjectPtr<StaticCairoText> description_; | ||
180 | 74 | nux::ObjectPtr<PreviewInfoHintWidget> preview_info_hints_; | ||
181 | 75 | |||
182 | 76 | typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr; | ||
183 | 77 | LayerPtr details_bg_layer_; | ||
185 | 78 | }; | 55 | }; |
186 | 79 | 56 | ||
187 | 80 | } | 57 | } |
188 | 81 | 58 | ||
189 | === modified file 'dash/previews/MoviePreview.cpp' | |||
190 | --- dash/previews/MoviePreview.cpp 2012-12-14 12:14:34 +0000 | |||
191 | +++ dash/previews/MoviePreview.cpp 2012-12-20 19:09:20 +0000 | |||
192 | @@ -23,7 +23,6 @@ | |||
193 | 23 | #include "unity-shared/IntrospectableWrappers.h" | 23 | #include "unity-shared/IntrospectableWrappers.h" |
194 | 24 | #include "unity-shared/PreviewStyle.h" | 24 | #include "unity-shared/PreviewStyle.h" |
195 | 25 | #include "unity-shared/CoverArt.h" | 25 | #include "unity-shared/CoverArt.h" |
196 | 26 | #include "unity-shared/StaticCairoText.h" | ||
197 | 27 | #include "unity-shared/PlacesOverlayVScrollBar.h" | 26 | #include "unity-shared/PlacesOverlayVScrollBar.h" |
198 | 28 | #include <UnityCore/MoviePreview.h> | 27 | #include <UnityCore/MoviePreview.h> |
199 | 29 | #include <NuxCore/Logger.h> | 28 | #include <NuxCore/Logger.h> |
200 | @@ -33,7 +32,6 @@ | |||
201 | 33 | #include <Nux/AbstractButton.h> | 32 | #include <Nux/AbstractButton.h> |
202 | 34 | 33 | ||
203 | 35 | #include "MoviePreview.h" | 34 | #include "MoviePreview.h" |
204 | 36 | #include "PreviewInfoHintWidget.h" | ||
205 | 37 | #include "PreviewRatingsWidget.h" | 35 | #include "PreviewRatingsWidget.h" |
206 | 38 | 36 | ||
207 | 39 | namespace unity | 37 | namespace unity |
208 | @@ -59,7 +57,6 @@ | |||
209 | 59 | 57 | ||
210 | 60 | MoviePreview::MoviePreview(dash::Preview::Ptr preview_model) | 58 | MoviePreview::MoviePreview(dash::Preview::Ptr preview_model) |
211 | 61 | : Preview(preview_model) | 59 | : Preview(preview_model) |
212 | 62 | , full_data_layout_(nullptr) | ||
213 | 63 | { | 60 | { |
214 | 64 | SetupBackground(); | 61 | SetupBackground(); |
215 | 65 | SetupView(); | 62 | SetupView(); |
216 | @@ -136,11 +133,6 @@ | |||
217 | 136 | { | 133 | { |
218 | 137 | } | 134 | } |
219 | 138 | 135 | ||
220 | 139 | void MoviePreview::SetupBackground() | ||
221 | 140 | { | ||
222 | 141 | details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer()); | ||
223 | 142 | } | ||
224 | 143 | |||
225 | 144 | void MoviePreview::SetupView() | 136 | void MoviePreview::SetupView() |
226 | 145 | { | 137 | { |
227 | 146 | dash::MoviePreview* movie_preview_model = dynamic_cast<dash::MoviePreview*>(preview_model_.get()); | 138 | dash::MoviePreview* movie_preview_model = dynamic_cast<dash::MoviePreview*>(preview_model_.get()); |
228 | 147 | 139 | ||
229 | === modified file 'dash/previews/MoviePreview.h' | |||
230 | --- dash/previews/MoviePreview.h 2012-12-14 12:14:34 +0000 | |||
231 | +++ dash/previews/MoviePreview.h 2012-12-20 19:09:20 +0000 | |||
232 | @@ -24,14 +24,6 @@ | |||
233 | 24 | #define MOVIEPREVIEW_H | 24 | #define MOVIEPREVIEW_H |
234 | 25 | 25 | ||
235 | 26 | #include "Preview.h" | 26 | #include "Preview.h" |
236 | 27 | #include <Nux/Nux.h> | ||
237 | 28 | |||
238 | 29 | namespace nux | ||
239 | 30 | { | ||
240 | 31 | class AbstractPaintLayer; | ||
241 | 32 | class StaticCairoText; | ||
242 | 33 | class VLayout; | ||
243 | 34 | } | ||
244 | 35 | 27 | ||
245 | 36 | namespace unity | 28 | namespace unity |
246 | 37 | { | 29 | { |
247 | @@ -39,9 +31,7 @@ | |||
248 | 39 | { | 31 | { |
249 | 40 | namespace previews | 32 | namespace previews |
250 | 41 | { | 33 | { |
251 | 42 | class CoverArt; | ||
252 | 43 | class PreviewRatingsWidget; | 34 | class PreviewRatingsWidget; |
253 | 44 | class PreviewInfoHintWidget; | ||
254 | 45 | 35 | ||
255 | 46 | class MoviePreview : public Preview | 36 | class MoviePreview : public Preview |
256 | 47 | { | 37 | { |
257 | @@ -64,21 +54,10 @@ | |||
258 | 64 | virtual void OnNavigateOut(); | 54 | virtual void OnNavigateOut(); |
259 | 65 | virtual void OnNavigateInComplete(); | 55 | virtual void OnNavigateInComplete(); |
260 | 66 | 56 | ||
263 | 67 | void SetupBackground(); | 57 | virtual void SetupView(); |
262 | 68 | void SetupView(); | ||
264 | 69 | 58 | ||
265 | 70 | protected: | 59 | protected: |
266 | 71 | nux::VLayout* full_data_layout_; | ||
267 | 72 | |||
268 | 73 | nux::ObjectPtr<CoverArt> image_; | ||
269 | 74 | nux::ObjectPtr<PreviewRatingsWidget> rating_; | 60 | nux::ObjectPtr<PreviewRatingsWidget> rating_; |
270 | 75 | nux::ObjectPtr<StaticCairoText> title_; | ||
271 | 76 | nux::ObjectPtr<StaticCairoText> subtitle_; | ||
272 | 77 | nux::ObjectPtr<StaticCairoText> description_; | ||
273 | 78 | nux::ObjectPtr<PreviewInfoHintWidget> preview_info_hints_; | ||
274 | 79 | |||
275 | 80 | typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr; | ||
276 | 81 | LayerPtr details_bg_layer_; | ||
277 | 82 | }; | 61 | }; |
278 | 83 | 62 | ||
279 | 84 | } | 63 | } |
280 | 85 | 64 | ||
281 | === modified file 'dash/previews/MusicPreview.cpp' | |||
282 | --- dash/previews/MusicPreview.cpp 2012-12-14 12:14:34 +0000 | |||
283 | +++ dash/previews/MusicPreview.cpp 2012-12-20 19:09:20 +0000 | |||
284 | @@ -24,7 +24,6 @@ | |||
285 | 24 | #include "unity-shared/PreviewStyle.h" | 24 | #include "unity-shared/PreviewStyle.h" |
286 | 25 | #include "unity-shared/CoverArt.h" | 25 | #include "unity-shared/CoverArt.h" |
287 | 26 | #include "unity-shared/IconTexture.h" | 26 | #include "unity-shared/IconTexture.h" |
288 | 27 | #include "unity-shared/StaticCairoText.h" | ||
289 | 28 | #include <UnityCore/MusicPreview.h> | 27 | #include <UnityCore/MusicPreview.h> |
290 | 29 | #include <NuxCore/Logger.h> | 28 | #include <NuxCore/Logger.h> |
291 | 30 | #include <Nux/HLayout.h> | 29 | #include <Nux/HLayout.h> |
292 | @@ -33,7 +32,6 @@ | |||
293 | 33 | 32 | ||
294 | 34 | #include "MusicPreview.h" | 33 | #include "MusicPreview.h" |
295 | 35 | #include "ActionButton.h" | 34 | #include "ActionButton.h" |
296 | 36 | #include "PreviewInfoHintWidget.h" | ||
297 | 37 | #include "Tracks.h" | 35 | #include "Tracks.h" |
298 | 38 | 36 | ||
299 | 39 | namespace unity | 37 | namespace unity |
300 | @@ -48,9 +46,6 @@ | |||
301 | 48 | 46 | ||
302 | 49 | MusicPreview::MusicPreview(dash::Preview::Ptr preview_model) | 47 | MusicPreview::MusicPreview(dash::Preview::Ptr preview_model) |
303 | 50 | : Preview(preview_model) | 48 | : Preview(preview_model) |
304 | 51 | , image_(nullptr) | ||
305 | 52 | , title_(nullptr) | ||
306 | 53 | , subtitle_(nullptr) | ||
307 | 54 | { | 49 | { |
308 | 55 | SetupBackground(); | 50 | SetupBackground(); |
309 | 56 | SetupViews(); | 51 | SetupViews(); |
310 | @@ -119,11 +114,6 @@ | |||
311 | 119 | Preview::AddProperties(builder); | 114 | Preview::AddProperties(builder); |
312 | 120 | } | 115 | } |
313 | 121 | 116 | ||
314 | 122 | void MusicPreview::SetupBackground() | ||
315 | 123 | { | ||
316 | 124 | details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer()); | ||
317 | 125 | } | ||
318 | 126 | |||
319 | 127 | void MusicPreview::SetupViews() | 117 | void MusicPreview::SetupViews() |
320 | 128 | { | 118 | { |
321 | 129 | dash::MusicPreview* music_preview_model = dynamic_cast<dash::MusicPreview*>(preview_model_.get()); | 119 | dash::MusicPreview* music_preview_model = dynamic_cast<dash::MusicPreview*>(preview_model_.get()); |
322 | 130 | 120 | ||
323 | === modified file 'dash/previews/MusicPreview.h' | |||
324 | --- dash/previews/MusicPreview.h 2012-12-14 12:14:34 +0000 | |||
325 | +++ dash/previews/MusicPreview.h 2012-12-20 19:09:20 +0000 | |||
326 | @@ -24,15 +24,6 @@ | |||
327 | 24 | #define MUSICPREVIEW_H | 24 | #define MUSICPREVIEW_H |
328 | 25 | 25 | ||
329 | 26 | #include "Preview.h" | 26 | #include "Preview.h" |
330 | 27 | #include <Nux/Nux.h> | ||
331 | 28 | #include <Nux/StaticText.h> | ||
332 | 29 | |||
333 | 30 | namespace nux | ||
334 | 31 | { | ||
335 | 32 | class AbstractPaintLayer; | ||
336 | 33 | class StaticCairoText; | ||
337 | 34 | class VLayout; | ||
338 | 35 | } | ||
339 | 36 | 27 | ||
340 | 37 | namespace unity | 28 | namespace unity |
341 | 38 | { | 29 | { |
342 | @@ -40,8 +31,6 @@ | |||
343 | 40 | { | 31 | { |
344 | 41 | namespace previews | 32 | namespace previews |
345 | 42 | { | 33 | { |
346 | 43 | class CoverArt; | ||
347 | 44 | class PreviewInfoHintWidget; | ||
348 | 45 | class Tracks; | 34 | class Tracks; |
349 | 46 | 35 | ||
350 | 47 | class MusicPreview : public Preview | 36 | class MusicPreview : public Preview |
351 | @@ -62,23 +51,13 @@ | |||
352 | 62 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | 51 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
353 | 63 | virtual void PreLayoutManagement(); | 52 | virtual void PreLayoutManagement(); |
354 | 64 | 53 | ||
357 | 65 | void SetupBackground(); | 54 | virtual void SetupViews(); |
356 | 66 | void SetupViews(); | ||
358 | 67 | 55 | ||
359 | 68 | void OnPlayTrack(std::string const& uri); | 56 | void OnPlayTrack(std::string const& uri); |
360 | 69 | void OnPauseTrack(std::string const& uri); | 57 | void OnPauseTrack(std::string const& uri); |
361 | 70 | 58 | ||
362 | 71 | protected: | 59 | protected: |
363 | 72 | nux::VLayout* full_data_layout_; | ||
364 | 73 | |||
365 | 74 | nux::ObjectPtr<CoverArt> image_; | ||
366 | 75 | nux::ObjectPtr<StaticCairoText> title_; | ||
367 | 76 | nux::ObjectPtr<StaticCairoText> subtitle_; | ||
368 | 77 | nux::ObjectPtr<Tracks> tracks_; | 60 | nux::ObjectPtr<Tracks> tracks_; |
369 | 78 | nux::ObjectPtr<PreviewInfoHintWidget> preview_info_hints_; | ||
370 | 79 | |||
371 | 80 | typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr; | ||
372 | 81 | LayerPtr details_bg_layer_; | ||
373 | 82 | }; | 61 | }; |
374 | 83 | 62 | ||
375 | 84 | } | 63 | } |
376 | 85 | 64 | ||
377 | === modified file 'dash/previews/Preview.cpp' | |||
378 | --- dash/previews/Preview.cpp 2012-11-08 09:12:24 +0000 | |||
379 | +++ dash/previews/Preview.cpp 2012-12-20 19:09:20 +0000 | |||
380 | @@ -33,6 +33,7 @@ | |||
381 | 33 | #include "MusicPreview.h" | 33 | #include "MusicPreview.h" |
382 | 34 | #include "MoviePreview.h" | 34 | #include "MoviePreview.h" |
383 | 35 | #include "SocialPreview.h" | 35 | #include "SocialPreview.h" |
384 | 36 | #include "PreviewInfoHintWidget.h" | ||
385 | 36 | 37 | ||
386 | 37 | namespace unity | 38 | namespace unity |
387 | 38 | { | 39 | { |
388 | @@ -219,6 +220,10 @@ | |||
389 | 219 | : View(NUX_TRACKER_LOCATION) | 220 | : View(NUX_TRACKER_LOCATION) |
390 | 220 | , preview_model_(preview_model) | 221 | , preview_model_(preview_model) |
391 | 221 | , tab_iterator_(new TabIterator()) | 222 | , tab_iterator_(new TabIterator()) |
392 | 223 | , full_data_layout_(nullptr) | ||
393 | 224 | , image_(nullptr) | ||
394 | 225 | , title_(nullptr) | ||
395 | 226 | , subtitle_(nullptr) | ||
396 | 222 | { | 227 | { |
397 | 223 | } | 228 | } |
398 | 224 | 229 | ||
399 | @@ -363,6 +368,11 @@ | |||
400 | 363 | nux::GetWindowCompositor().SetKeyFocusArea(default_focus); | 368 | nux::GetWindowCompositor().SetKeyFocusArea(default_focus); |
401 | 364 | } | 369 | } |
402 | 365 | 370 | ||
403 | 371 | void Preview::SetupBackground() | ||
404 | 372 | { | ||
405 | 373 | details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer()); | ||
406 | 374 | } | ||
407 | 375 | |||
408 | 366 | } | 376 | } |
409 | 367 | } | 377 | } |
410 | 368 | } | 378 | } |
411 | 369 | 379 | ||
412 | === modified file 'dash/previews/Preview.h' | |||
413 | --- dash/previews/Preview.h 2012-09-18 09:05:50 +0000 | |||
414 | +++ dash/previews/Preview.h 2012-12-20 19:09:20 +0000 | |||
415 | @@ -28,11 +28,16 @@ | |||
416 | 28 | #include <UnityCore/Preview.h> | 28 | #include <UnityCore/Preview.h> |
417 | 29 | #include "unity-shared/Introspectable.h" | 29 | #include "unity-shared/Introspectable.h" |
418 | 30 | #include "unity-shared/PreviewStyle.h" | 30 | #include "unity-shared/PreviewStyle.h" |
419 | 31 | #include "unity-shared/StaticCairoText.h" | ||
420 | 32 | #include "PreviewInfoHintWidget.h" | ||
421 | 31 | 33 | ||
422 | 32 | namespace nux | 34 | namespace nux |
423 | 33 | { | 35 | { |
424 | 34 | class AbstractButton; | 36 | class AbstractButton; |
425 | 37 | class AbstractPaintLayer; | ||
426 | 35 | class Layout; | 38 | class Layout; |
427 | 39 | class VLayout; | ||
428 | 40 | class StaticCairoText; | ||
429 | 36 | } | 41 | } |
430 | 37 | 42 | ||
431 | 38 | namespace unity | 43 | namespace unity |
432 | @@ -45,6 +50,7 @@ | |||
433 | 45 | { | 50 | { |
434 | 46 | class CoverArt; | 51 | class CoverArt; |
435 | 47 | class TabIterator; | 52 | class TabIterator; |
436 | 53 | class PreviewInfoHintWidget; | ||
437 | 48 | 54 | ||
438 | 49 | class Preview : public nux::View, public debug::Introspectable | 55 | class Preview : public nux::View, public debug::Introspectable |
439 | 50 | { | 56 | { |
440 | @@ -80,9 +86,12 @@ | |||
441 | 80 | 86 | ||
442 | 81 | virtual bool AcceptKeyNavFocus() { return false; } | 87 | virtual bool AcceptKeyNavFocus() { return false; } |
443 | 82 | 88 | ||
444 | 89 | virtual void SetupViews() {} | ||
445 | 90 | void SetupBackground(); | ||
446 | 91 | |||
447 | 83 | nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons); | 92 | nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons); |
448 | 84 | nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons); | 93 | nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons); |
450 | 85 | 94 | ||
451 | 86 | void UpdateCoverArtImage(CoverArt* cover_art); | 95 | void UpdateCoverArtImage(CoverArt* cover_art); |
452 | 87 | 96 | ||
453 | 88 | protected: | 97 | protected: |
454 | @@ -90,6 +99,17 @@ | |||
455 | 90 | std::list<nux::AbstractButton*> action_buttons_; | 99 | std::list<nux::AbstractButton*> action_buttons_; |
456 | 91 | TabIterator* tab_iterator_; | 100 | TabIterator* tab_iterator_; |
457 | 92 | 101 | ||
458 | 102 | nux::VLayout* full_data_layout_; | ||
459 | 103 | |||
460 | 104 | nux::ObjectPtr<CoverArt> image_; | ||
461 | 105 | nux::ObjectPtr<StaticCairoText> title_; | ||
462 | 106 | nux::ObjectPtr<StaticCairoText> subtitle_; | ||
463 | 107 | nux::ObjectPtr<StaticCairoText> description_; | ||
464 | 108 | PreviewInfoHintWidget::Ptr preview_info_hints_; | ||
465 | 109 | |||
466 | 110 | typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr; | ||
467 | 111 | LayerPtr details_bg_layer_; | ||
468 | 112 | |||
469 | 93 | friend class PreviewContent; | 113 | friend class PreviewContent; |
470 | 94 | }; | 114 | }; |
471 | 95 | 115 | ||
472 | 96 | 116 | ||
473 | === modified file 'dash/previews/SocialPreview.cpp' | |||
474 | --- dash/previews/SocialPreview.cpp 2012-12-17 21:30:27 +0000 | |||
475 | +++ dash/previews/SocialPreview.cpp 2012-12-20 19:09:20 +0000 | |||
476 | @@ -24,7 +24,6 @@ | |||
477 | 24 | #include "unity-shared/PreviewStyle.h" | 24 | #include "unity-shared/PreviewStyle.h" |
478 | 25 | #include "unity-shared/CoverArt.h" | 25 | #include "unity-shared/CoverArt.h" |
479 | 26 | #include "unity-shared/IconTexture.h" | 26 | #include "unity-shared/IconTexture.h" |
480 | 27 | #include "unity-shared/StaticCairoText.h" | ||
481 | 28 | #include "unity-shared/PlacesOverlayVScrollBar.h" | 27 | #include "unity-shared/PlacesOverlayVScrollBar.h" |
482 | 29 | #include <UnityCore/SocialPreview.h> | 28 | #include <UnityCore/SocialPreview.h> |
483 | 30 | #include <NuxCore/Logger.h> | 29 | #include <NuxCore/Logger.h> |
484 | @@ -40,7 +39,6 @@ | |||
485 | 40 | #include "SocialPreviewContent.h" | 39 | #include "SocialPreviewContent.h" |
486 | 41 | #include "SocialPreviewComments.h" | 40 | #include "SocialPreviewComments.h" |
487 | 42 | #include "ActionButton.h" | 41 | #include "ActionButton.h" |
488 | 43 | #include "PreviewInfoHintWidget.h" | ||
489 | 44 | 42 | ||
490 | 45 | namespace unity | 43 | namespace unity |
491 | 46 | { | 44 | { |
492 | @@ -65,7 +63,6 @@ | |||
493 | 65 | 63 | ||
494 | 66 | SocialPreview::SocialPreview(dash::Preview::Ptr preview_model) | 64 | SocialPreview::SocialPreview(dash::Preview::Ptr preview_model) |
495 | 67 | : Preview(preview_model) | 65 | : Preview(preview_model) |
496 | 68 | , full_data_layout_(nullptr) | ||
497 | 69 | { | 66 | { |
498 | 70 | SetupBackground(); | 67 | SetupBackground(); |
499 | 71 | SetupViews(); | 68 | SetupViews(); |
500 | @@ -134,11 +131,6 @@ | |||
501 | 134 | Preview::AddProperties(builder); | 131 | Preview::AddProperties(builder); |
502 | 135 | } | 132 | } |
503 | 136 | 133 | ||
504 | 137 | void SocialPreview::SetupBackground() | ||
505 | 138 | { | ||
506 | 139 | details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer()); | ||
507 | 140 | } | ||
508 | 141 | |||
509 | 142 | void SocialPreview::SetupViews() | 134 | void SocialPreview::SetupViews() |
510 | 143 | { | 135 | { |
511 | 144 | dash::SocialPreview* social_preview_model = dynamic_cast<dash::SocialPreview*>(preview_model_.get()); | 136 | dash::SocialPreview* social_preview_model = dynamic_cast<dash::SocialPreview*>(preview_model_.get()); |
512 | 145 | 137 | ||
513 | === modified file 'dash/previews/SocialPreview.h' | |||
514 | --- dash/previews/SocialPreview.h 2012-12-14 12:14:34 +0000 | |||
515 | +++ dash/previews/SocialPreview.h 2012-12-20 19:09:20 +0000 | |||
516 | @@ -24,14 +24,6 @@ | |||
517 | 24 | #define SOCIALPREVIEW_H | 24 | #define SOCIALPREVIEW_H |
518 | 25 | 25 | ||
519 | 26 | #include "Preview.h" | 26 | #include "Preview.h" |
520 | 27 | #include <Nux/Nux.h> | ||
521 | 28 | |||
522 | 29 | namespace nux | ||
523 | 30 | { | ||
524 | 31 | class AbstractPaintLayer; | ||
525 | 32 | class VLayout; | ||
526 | 33 | class StaticCairoText; | ||
527 | 34 | } | ||
528 | 35 | 27 | ||
529 | 36 | namespace unity | 28 | namespace unity |
530 | 37 | { | 29 | { |
531 | @@ -41,9 +33,7 @@ | |||
532 | 41 | { | 33 | { |
533 | 42 | namespace previews | 34 | namespace previews |
534 | 43 | { | 35 | { |
535 | 44 | class CoverArt; | ||
536 | 45 | class PreviewLikesWidget; | 36 | class PreviewLikesWidget; |
537 | 46 | class PreviewInfoHintWidget; | ||
538 | 47 | class SocialPreviewContent; | 37 | class SocialPreviewContent; |
539 | 48 | class SocialPreviewComments; | 38 | class SocialPreviewComments; |
540 | 49 | 39 | ||
541 | @@ -65,25 +55,16 @@ | |||
542 | 65 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | 55 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
543 | 66 | virtual void PreLayoutManagement(); | 56 | virtual void PreLayoutManagement(); |
544 | 67 | 57 | ||
547 | 68 | void SetupBackground(); | 58 | virtual void SetupViews(); |
546 | 69 | void SetupViews(); | ||
548 | 70 | 59 | ||
549 | 71 | protected: | 60 | protected: |
550 | 72 | nux::VLayout* full_data_layout_; | ||
551 | 73 | nux::VLayout* sender_layout_; | 61 | nux::VLayout* sender_layout_; |
552 | 74 | nux::VLayout* title_layout_; | 62 | nux::VLayout* title_layout_; |
553 | 75 | 63 | ||
554 | 76 | nux::ObjectPtr<IconTexture> avatar_; | 64 | nux::ObjectPtr<IconTexture> avatar_; |
555 | 77 | nux::ObjectPtr<CoverArt> image_; | ||
556 | 78 | nux::ObjectPtr<SocialPreviewContent> content_; | 65 | nux::ObjectPtr<SocialPreviewContent> content_; |
557 | 79 | nux::ObjectPtr<SocialPreviewComments> comments_; | 66 | nux::ObjectPtr<SocialPreviewComments> comments_; |
558 | 80 | nux::ObjectPtr<StaticCairoText> title_; | ||
559 | 81 | nux::ObjectPtr<StaticCairoText> subtitle_; | ||
560 | 82 | nux::ObjectPtr<StaticCairoText> comments_hint_; | 67 | nux::ObjectPtr<StaticCairoText> comments_hint_; |
561 | 83 | nux::ObjectPtr<PreviewInfoHintWidget> preview_info_hints_; | ||
562 | 84 | |||
563 | 85 | typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr; | ||
564 | 86 | LayerPtr details_bg_layer_; | ||
565 | 87 | }; | 68 | }; |
566 | 88 | 69 | ||
567 | 89 | } | 70 | } |
Awesome! Nice clean up, everything looks good, compiles, and things still work :).