Merge lp:~hikiko/unity/unity.scale-social-preview into lp:unity
- unity.scale-social-preview
- Merge into trunk
Proposed by
Eleni Maria Stea
Status: | Merged |
---|---|
Merged at revision: | 3839 |
Proposed branch: | lp:~hikiko/unity/unity.scale-social-preview |
Merge into: | lp:unity |
Prerequisite: | lp:~hikiko/unity/unity.scale-payment-musicpayment |
Diff against target: |
599 lines (+208/-88) 6 files modified
dash/previews/SocialPreview.cpp (+96/-36) dash/previews/SocialPreview.h (+9/-0) dash/previews/SocialPreviewComments.cpp (+66/-41) dash/previews/SocialPreviewComments.h (+11/-0) dash/previews/SocialPreviewContent.cpp (+22/-11) dash/previews/SocialPreviewContent.h (+4/-0) |
To merge this branch: | bzr merge lp:~hikiko/unity/unity.scale-social-preview |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Needs Fixing | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Unity Team | Pending | ||
Review via email: mp+224020@code.launchpad.net |
Commit message
scaled social preview, social preview comments, social preview content and components
Description of the change
scaled social preview, social preview comments, social preview content and components
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
There are various things that needs fixing here, I've mostly fixed them in lp:~3v1n0/unity/previews-scaling-improved which you should merge in lp:~hikiko/unity/unity.scale-track
I fixed the comment scaling, made the action buttons and other cairo textures (such as the bubble) to be properly scaled (not just resized), various crashes...
But there's still one mayor issue: the social avatar picture and the button icons are not shown in the actual dash (while they correctly work in the standalone version).
review:
Needs Fixing
Revision history for this message
Eleni Maria Stea (hikiko) wrote : | # |
thank you for fixing it Marco :) I'll merge your branch to mine
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'dash/previews/SocialPreview.cpp' |
2 | --- dash/previews/SocialPreview.cpp 2014-06-21 11:58:37 +0000 |
3 | +++ dash/previews/SocialPreview.cpp 2014-06-21 11:58:37 +0000 |
4 | @@ -49,6 +49,13 @@ |
5 | { |
6 | DECLARE_LOGGER(logger, "unity.dash.preview.social"); |
7 | |
8 | +namespace |
9 | +{ |
10 | + const RawPixel CHILDREN_SPACE = 16_em; |
11 | + const RawPixel ICON_CHILDREN_SPACE = 3_em; |
12 | + const RawPixel SOCIAL_INFO_CHILDREN_SPACE = 12_em; |
13 | +} |
14 | + |
15 | class DetailsScrollView : public nux::ScrollView |
16 | { |
17 | public: |
18 | @@ -64,8 +71,16 @@ |
19 | |
20 | SocialPreview::SocialPreview(dash::Preview::Ptr preview_model) |
21 | : Preview(preview_model) |
22 | +, image_data_layout_(nullptr) |
23 | +, main_social_info_(nullptr) |
24 | +, social_content_layout_(nullptr) |
25 | +, social_data_layout_(nullptr) |
26 | +, social_info_layout_(nullptr) |
27 | +, icon_layout_(nullptr) |
28 | +, actions_layout_(nullptr) |
29 | { |
30 | SetupViews(); |
31 | + UpdateScale(scale); |
32 | } |
33 | |
34 | SocialPreview::~SocialPreview() |
35 | @@ -122,23 +137,22 @@ |
36 | |
37 | auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); }; |
38 | |
39 | - nux::HLayout* image_data_layout = new nux::HLayout(); |
40 | - image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); |
41 | + image_data_layout_ = new nux::HLayout(); |
42 | + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); |
43 | |
44 | - nux::VLayout* social_content_layout = new nux::VLayout(); |
45 | - social_content_layout->SetSpaceBetweenChildren(16); |
46 | - |
47 | + nux::VLayout* social_content_layout_ = new nux::VLayout(); |
48 | + social_content_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); |
49 | |
50 | if (social_preview_model->description.Get().length() > 0) |
51 | { |
52 | content_ = new SocialPreviewContent(social_preview_model->description, NUX_TRACKER_LOCATION); |
53 | content_->request_close().connect([this]() { preview_container_->request_close.emit(); }); |
54 | - social_content_layout->AddView(content_.GetPointer(), 1); |
55 | + social_content_layout_->AddView(content_.GetPointer(), 1); |
56 | } else { |
57 | image_ = new CoverArt(); |
58 | AddChild(image_.GetPointer()); |
59 | UpdateCoverArtImage(image_.GetPointer()); |
60 | - social_content_layout->AddView(image_.GetPointer(), 1); |
61 | + social_content_layout_->AddView(image_.GetPointer(), 1); |
62 | } |
63 | |
64 | ///////////////////// |
65 | @@ -146,34 +160,35 @@ |
66 | ///////////////////// |
67 | // Social Data Panel |
68 | full_data_layout_ = new nux::VLayout(); |
69 | - full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin()); |
70 | - full_data_layout_->SetSpaceBetweenChildren(16); |
71 | + full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale)); |
72 | + full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); |
73 | |
74 | ///////////////////// |
75 | // Main Social Info |
76 | - nux::HLayout* main_social_info = new nux::HLayout(); |
77 | - main_social_info->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails()); |
78 | + main_social_info_ = new nux::HLayout(); |
79 | + main_social_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale)); |
80 | |
81 | ///////////////////// |
82 | // Icon Layout |
83 | - nux::VLayout* icon_layout = new nux::VLayout(); |
84 | - icon_layout->SetSpaceBetweenChildren(3); |
85 | - avatar_ = new IconTexture(social_preview_model->avatar.Get().RawPtr() ? g_icon_to_string(social_preview_model->avatar.Get().RawPtr()) : "", MIN(style.GetAvatarAreaWidth(), style.GetAvatarAreaHeight())); |
86 | + icon_layout_ = new nux::VLayout(); |
87 | + icon_layout_->SetSpaceBetweenChildren(ICON_CHILDREN_SPACE.CP(scale)); |
88 | + avatar_ = new IconTexture(social_preview_model->avatar.Get().RawPtr() ? g_icon_to_string(social_preview_model->avatar.Get().RawPtr()) : "", MIN(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale))); |
89 | AddChild(avatar_.GetPointer()); |
90 | - avatar_->SetMinMaxSize(style.GetAvatarAreaWidth(), style.GetAvatarAreaHeight()); |
91 | + avatar_->SetMinMaxSize(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale)); |
92 | avatar_->mouse_click.connect(on_mouse_down); |
93 | - icon_layout->AddView(avatar_.GetPointer(), 0); |
94 | + icon_layout_->AddView(avatar_.GetPointer(), 0); |
95 | |
96 | ///////////////////// |
97 | |
98 | ///////////////////// |
99 | // Data |
100 | - nux::VLayout* social_data_layout = new nux::VLayout(); |
101 | - social_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle()); |
102 | + social_data_layout_ = new nux::VLayout(); |
103 | + social_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); |
104 | |
105 | title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION); |
106 | AddChild(title_.GetPointer()); |
107 | title_->SetLines(-1); |
108 | + title_->SetScale(scale); |
109 | title_->SetFont(style.title_font().c_str()); |
110 | title_->mouse_click.connect(on_mouse_down); |
111 | |
112 | @@ -181,17 +196,18 @@ |
113 | AddChild(subtitle_.GetPointer()); |
114 | subtitle_->SetFont(style.content_font().c_str()); |
115 | subtitle_->SetLines(-1); |
116 | + subtitle_->SetScale(scale); |
117 | subtitle_->mouse_click.connect(on_mouse_down); |
118 | |
119 | - social_data_layout->AddView(title_.GetPointer(), 0); |
120 | - social_data_layout->AddView(subtitle_.GetPointer(), 0); |
121 | - social_data_layout->AddSpace(0, 1); |
122 | + social_data_layout_->AddView(title_.GetPointer(), 0); |
123 | + social_data_layout_->AddView(subtitle_.GetPointer(), 0); |
124 | + social_data_layout_->AddSpace(0, 1); |
125 | |
126 | // buffer space |
127 | ///////////////////// |
128 | |
129 | - main_social_info->AddLayout(icon_layout, 0); |
130 | - main_social_info->AddLayout(social_data_layout, 1); |
131 | + main_social_info_->AddLayout(icon_layout_, 0); |
132 | + main_social_info_->AddLayout(social_data_layout_, 1); |
133 | ///////////////////// |
134 | |
135 | ///////////////////// |
136 | @@ -200,16 +216,16 @@ |
137 | social_info->EnableHorizontalScrollBar(false); |
138 | social_info->mouse_click.connect(on_mouse_down); |
139 | |
140 | - nux::VLayout* social_info_layout = new nux::VLayout(); |
141 | - social_info_layout->SetSpaceBetweenChildren(12); |
142 | - social_info->SetLayout(social_info_layout); |
143 | + social_info_layout_ = new nux::VLayout(); |
144 | + social_info_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); |
145 | + social_info->SetLayout(social_info_layout_); |
146 | |
147 | if (!preview_model_->GetInfoHints().empty()) |
148 | { |
149 | preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetAvatarAreaWidth()); |
150 | AddChild(preview_info_hints_.GetPointer()); |
151 | preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); }); |
152 | - social_info_layout->AddView(preview_info_hints_.GetPointer(), 0); |
153 | + social_info_layout_->AddView(preview_info_hints_.GetPointer(), 0); |
154 | } |
155 | ///////////////////// |
156 | // Comments/Replies |
157 | @@ -232,29 +248,29 @@ |
158 | AddChild(comments_.GetPointer()); |
159 | comments_->request_close().connect([this]() { preview_container_->request_close.emit(); }); |
160 | comments_layout->AddView(comments_.GetPointer()); |
161 | - social_info_layout->AddView(comments_layout, 0); |
162 | + social_info_layout_->AddView(comments_layout, 0); |
163 | } |
164 | |
165 | ///////////////////// |
166 | // Actions |
167 | action_buttons_.clear(); |
168 | - nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); |
169 | - actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); |
170 | + actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); |
171 | + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); |
172 | /////////////////// |
173 | |
174 | - full_data_layout_->AddLayout(main_social_info, 0, nux::MINOR_POSITION_START); |
175 | + full_data_layout_->AddLayout(main_social_info_, 0, nux::MINOR_POSITION_START); |
176 | full_data_layout_->AddView(social_info, 1, nux::MINOR_POSITION_START); |
177 | //full_data_layout_->AddView(comments_.GetPointer(), 1, nux::MINOR_POSITION_START); |
178 | |
179 | - full_data_layout_->AddLayout(actions_layout, 0); |
180 | + full_data_layout_->AddLayout(actions_layout_, 0); |
181 | ///////////////////// |
182 | - |
183 | - image_data_layout->AddView(social_content_layout, 0); |
184 | - image_data_layout->AddLayout(full_data_layout_, 1); |
185 | + |
186 | + image_data_layout_->AddView(social_content_layout_, 0); |
187 | + image_data_layout_->AddLayout(full_data_layout_, 1); |
188 | |
189 | mouse_click.connect(on_mouse_down); |
190 | |
191 | - SetLayout(image_data_layout); |
192 | + SetLayout(image_data_layout_); |
193 | } |
194 | |
195 | void SocialPreview::PreLayoutManagement() |
196 | @@ -286,6 +302,50 @@ |
197 | Preview::PreLayoutManagement(); |
198 | } |
199 | |
200 | +void SocialPreview::UpdateScale(double scale) |
201 | +{ |
202 | + Preview::UpdateScale(scale); |
203 | + |
204 | + if (preview_info_hints_) |
205 | + preview_info_hints_->scale = scale; |
206 | + |
207 | + previews::Style& style = dash::previews::Style::Instance(); |
208 | + |
209 | + if (avatar_) |
210 | + { |
211 | + avatar_->SetMinMaxSize(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale)); |
212 | + avatar_->SetSize(MIN(style.GetAvatarAreaWidth().CP(scale), style.GetAvatarAreaHeight().CP(scale))); |
213 | + avatar_->ReLoadIcon(); |
214 | + } |
215 | + |
216 | + if (image_data_layout_) |
217 | + image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale)); |
218 | + |
219 | + if (social_content_layout_) |
220 | + social_content_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); |
221 | + |
222 | + if (main_social_info_) |
223 | + main_social_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale)); |
224 | + |
225 | + if (icon_layout_) |
226 | + icon_layout_->SetSpaceBetweenChildren(ICON_CHILDREN_SPACE.CP(scale)); |
227 | + |
228 | + if (social_data_layout_) |
229 | + social_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale)); |
230 | + |
231 | + if (social_info_layout_) |
232 | + social_info_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); |
233 | + |
234 | + if (actions_layout_) |
235 | + actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); |
236 | + |
237 | + if (content_) |
238 | + content_->scale = scale; |
239 | + |
240 | + if (comments_) |
241 | + comments_->scale = scale; |
242 | +} |
243 | + |
244 | } // namespace previews |
245 | } // namespace dash |
246 | } // namepsace unity |
247 | |
248 | === modified file 'dash/previews/SocialPreview.h' |
249 | --- dash/previews/SocialPreview.h 2013-09-19 16:44:03 +0000 |
250 | +++ dash/previews/SocialPreview.h 2014-06-21 11:58:37 +0000 |
251 | @@ -56,11 +56,20 @@ |
252 | virtual void PreLayoutManagement(); |
253 | |
254 | virtual void SetupViews(); |
255 | + virtual void UpdateScale(double scale) override; |
256 | |
257 | protected: |
258 | nux::VLayout* sender_layout_; |
259 | nux::VLayout* title_layout_; |
260 | |
261 | + nux::HLayout* image_data_layout_; |
262 | + nux::HLayout* main_social_info_; |
263 | + nux::VLayout* social_content_layout_; |
264 | + nux::VLayout* social_data_layout_; |
265 | + nux::VLayout* social_info_layout_; |
266 | + nux::VLayout* icon_layout_; |
267 | + nux::Layout* actions_layout_; |
268 | + |
269 | nux::ObjectPtr<IconTexture> avatar_; |
270 | nux::ObjectPtr<SocialPreviewContent> content_; |
271 | nux::ObjectPtr<SocialPreviewComments> comments_; |
272 | |
273 | === modified file 'dash/previews/SocialPreviewComments.cpp' |
274 | --- dash/previews/SocialPreviewComments.cpp 2013-11-19 18:48:35 +0000 |
275 | +++ dash/previews/SocialPreviewComments.cpp 2014-06-21 11:58:37 +0000 |
276 | @@ -40,16 +40,25 @@ |
277 | |
278 | namespace |
279 | { |
280 | -const int layout_spacing = 12; |
281 | +const RawPixel LAYOUT_SPACING = 12_em; |
282 | +const RawPixel CHILDREN_SPACE = 6_em; |
283 | } |
284 | |
285 | NUX_IMPLEMENT_OBJECT_TYPE(SocialPreviewComments); |
286 | |
287 | SocialPreviewComments::SocialPreviewComments(dash::Preview::Ptr preview_model, NUX_FILE_LINE_DECL) |
288 | : View(NUX_FILE_LINE_PARAM) |
289 | +, scale(1.0) |
290 | , preview_model_(preview_model) |
291 | +, layout_(nullptr) |
292 | +, name_layout_(nullptr) |
293 | +, comment_name_(nullptr) |
294 | +, comment_time_(nullptr) |
295 | +, comment_value_(nullptr) |
296 | { |
297 | SetupViews(); |
298 | + UpdateScale(scale); |
299 | + scale.changed.connect(sigc::mem_fun(this, &SocialPreviewComments::UpdateScale)); |
300 | } |
301 | |
302 | SocialPreviewComments::~SocialPreviewComments() |
303 | @@ -87,13 +96,13 @@ |
304 | int comment_width = 0; |
305 | for (Comment const& comment : comments_) |
306 | { |
307 | - int width = style.GetDetailsPanelMinimumWidth(); |
308 | + int width = style.GetDetailsPanelMinimumWidth().CP(scale); |
309 | if (comment.first) |
310 | { |
311 | width = comment.first->GetTextExtents().width; |
312 | |
313 | - if (width < style.GetDetailsPanelMinimumWidth()) |
314 | - width = style.GetDetailsPanelMinimumWidth(); |
315 | + if (width < style.GetDetailsPanelMinimumWidth().CP(scale)) |
316 | + width = style.GetDetailsPanelMinimumWidth().CP(scale); |
317 | } |
318 | |
319 | if (comment_width < width) |
320 | @@ -102,7 +111,7 @@ |
321 | } |
322 | } |
323 | |
324 | - int comment_value_width = MAX(0, geo.width - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin()); |
325 | + int comment_value_width = MAX(0, geo.width - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale)); |
326 | |
327 | for (Comment const& comment : comments_) |
328 | { |
329 | @@ -122,7 +131,6 @@ |
330 | { |
331 | dash::SocialPreview* social_preview_model = dynamic_cast<dash::SocialPreview*>(preview_model_.get()); |
332 | |
333 | - |
334 | RemoveLayout(); |
335 | comments_.clear(); |
336 | |
337 | @@ -130,59 +138,58 @@ |
338 | |
339 | auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); }; |
340 | |
341 | - nux::VLayout* layout = new nux::VLayout(); |
342 | - layout->SetSpaceBetweenChildren(6); |
343 | + layout_ = new nux::VLayout(); |
344 | + layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); |
345 | |
346 | for (dash::SocialPreview::CommentPtr comment : social_preview_model->GetComments()) |
347 | { |
348 | - |
349 | - nux::HLayout* name_layout = new nux::HLayout(); |
350 | - name_layout->SetSpaceBetweenChildren(layout_spacing); |
351 | - |
352 | - StaticCairoTextPtr comment_name; |
353 | + name_layout_ = new nux::HLayout(); |
354 | + name_layout_->SetSpaceBetweenChildren(LAYOUT_SPACING.CP(scale)); |
355 | + |
356 | if (!comment->display_name.empty()) |
357 | { |
358 | - comment_name = new StaticCairoText(comment->display_name, true, NUX_TRACKER_LOCATION); |
359 | - comment_name->SetFont(style.info_hint_bold_font()); |
360 | - comment_name->SetLines(-1); |
361 | - comment_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); |
362 | - comment_name->mouse_click.connect(on_mouse_down); |
363 | - name_layout->AddView(comment_name.GetPointer(), 0, nux::MINOR_POSITION_START); |
364 | + comment_name_ = new StaticCairoText(comment->display_name, true, NUX_TRACKER_LOCATION); |
365 | + comment_name_->SetFont(style.info_hint_bold_font()); |
366 | + comment_name_->SetLines(-1); |
367 | + comment_name_->SetScale(scale); |
368 | + comment_name_->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); |
369 | + comment_name_->mouse_click.connect(on_mouse_down); |
370 | + name_layout_->AddView(comment_name_.GetPointer(), 0, nux::MINOR_POSITION_START); |
371 | } |
372 | |
373 | - StaticCairoTextPtr comment_time; |
374 | if (!comment->time.empty()) |
375 | { |
376 | - comment_time = new StaticCairoText(comment->time, true, NUX_TRACKER_LOCATION); |
377 | - comment_time->SetFont(style.info_hint_font()); |
378 | - comment_time->SetLines(-1); |
379 | - comment_time->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); |
380 | - comment_time->mouse_click.connect(on_mouse_down); |
381 | - name_layout->AddView(comment_time.GetPointer(), 0, nux::MINOR_POSITION_START); |
382 | + comment_time_ = new StaticCairoText(comment->time, true, NUX_TRACKER_LOCATION); |
383 | + comment_time_->SetFont(style.info_hint_font()); |
384 | + comment_time_->SetLines(-1); |
385 | + comment_time_->SetScale(scale); |
386 | + comment_time_->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT); |
387 | + comment_time_->mouse_click.connect(on_mouse_down); |
388 | + name_layout_->AddView(comment_time_.GetPointer(), 0, nux::MINOR_POSITION_START); |
389 | } |
390 | |
391 | |
392 | nux::HLayout* comment_layout = new nux::HLayout(); |
393 | - comment_layout->SetSpaceBetweenChildren(layout_spacing); |
394 | - |
395 | - StaticCairoTextPtr comment_value(new StaticCairoText(comment->content, false, NUX_TRACKER_LOCATION)); |
396 | - |
397 | - comment_value->SetFont(style.info_hint_font()); |
398 | - comment_value->SetLines(-7); |
399 | - comment_value->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); |
400 | - comment_value->mouse_click.connect(on_mouse_down); |
401 | - comment_layout->AddView(comment_value.GetPointer(), 1, nux::MINOR_POSITION_START); |
402 | - |
403 | - Comment comment_views(comment_name, comment_value); |
404 | + comment_layout->SetSpaceBetweenChildren(LAYOUT_SPACING); |
405 | + |
406 | + comment_value_ = new StaticCairoText(comment->content, false, NUX_TRACKER_LOCATION); |
407 | + |
408 | + comment_value_->SetFont(style.info_hint_font()); |
409 | + comment_value_->SetLines(-7); |
410 | + comment_value_->SetScale(scale); |
411 | + comment_value_->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT); |
412 | + comment_value_->mouse_click.connect(on_mouse_down); |
413 | + comment_layout->AddView(comment_value_.GetPointer(), 1, nux::MINOR_POSITION_START); |
414 | + |
415 | + Comment comment_views(comment_name_, comment_value_); |
416 | comments_.push_back(comment_views); |
417 | |
418 | - layout->AddLayout(name_layout, 0); |
419 | - layout->AddLayout(comment_layout, 1); |
420 | + layout_->AddLayout(name_layout_, 0); |
421 | + layout_->AddLayout(comment_layout, 1); |
422 | } |
423 | mouse_click.connect(on_mouse_down); |
424 | |
425 | - SetLayout(layout); |
426 | - |
427 | + SetLayout(layout_); |
428 | } |
429 | |
430 | std::string SocialPreviewComments::GetName() const |
431 | @@ -195,6 +202,24 @@ |
432 | introspection.add(GetAbsoluteGeometry()); |
433 | } |
434 | |
435 | +void SocialPreviewComments::UpdateScale(double scale) |
436 | +{ |
437 | + if (comment_name_) |
438 | + comment_name_->SetScale(scale); |
439 | + |
440 | + if (comment_time_) |
441 | + comment_time_->SetScale(scale); |
442 | + |
443 | + if (comment_value_) |
444 | + comment_value_->SetScale(scale); |
445 | + |
446 | + if (layout_) |
447 | + layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale)); |
448 | + |
449 | + if (name_layout_) |
450 | + name_layout_->SetSpaceBetweenChildren(LAYOUT_SPACING.CP(scale)); |
451 | +} |
452 | + |
453 | } |
454 | } |
455 | } |
456 | |
457 | === modified file 'dash/previews/SocialPreviewComments.h' |
458 | --- dash/previews/SocialPreviewComments.h 2013-09-19 16:44:03 +0000 |
459 | +++ dash/previews/SocialPreviewComments.h 2014-06-21 11:58:37 +0000 |
460 | @@ -50,6 +50,8 @@ |
461 | |
462 | sigc::signal<void> request_close() const { return preview_container_.request_close; } |
463 | |
464 | + nux::Property<double> scale; |
465 | + |
466 | protected: |
467 | |
468 | typedef nux::ObjectPtr<StaticCairoText> StaticCairoTextPtr; |
469 | @@ -70,10 +72,19 @@ |
470 | virtual void AddProperties(debug::IntrospectionData&); |
471 | |
472 | private: |
473 | + void UpdateScale(double scale); |
474 | |
475 | typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr; |
476 | |
477 | PreviewContainer preview_container_; |
478 | + |
479 | + nux::VLayout* layout_; |
480 | + nux::HLayout* name_layout_; |
481 | + |
482 | + StaticCairoTextPtr comment_name_; |
483 | + StaticCairoTextPtr comment_time_; |
484 | + StaticCairoTextPtr comment_value_; |
485 | + |
486 | }; |
487 | |
488 | } |
489 | |
490 | === modified file 'dash/previews/SocialPreviewContent.cpp' |
491 | --- dash/previews/SocialPreviewContent.cpp 2013-11-19 18:48:35 +0000 |
492 | +++ dash/previews/SocialPreviewContent.cpp 2014-06-21 11:58:37 +0000 |
493 | @@ -38,16 +38,17 @@ |
494 | |
495 | namespace |
496 | { |
497 | -const int BUBBLE_WIDTH = 300; |
498 | -const int BUBBLE_HEIGHT = 250; |
499 | -const int TAIL_HEIGHT = 50; |
500 | -const int TAIL_POS_FROM_RIGHT = 60; |
501 | +const RawPixel BUBBLE_WIDTH = 300_em; |
502 | +const RawPixel BUBBLE_HEIGHT = 250_em; |
503 | +const RawPixel TAIL_HEIGHT = 50_em; |
504 | +const RawPixel TAIL_POS_FROM_RIGHT = 60_em; |
505 | +const RawPixel TEXT_LINE_SPACING = 5_em; |
506 | } |
507 | |
508 | -inline nux::Geometry GetBubbleGeometry(nux::Geometry const& geo) |
509 | +inline nux::Geometry GetBubbleGeometry(nux::Geometry const& geo, double scale) |
510 | { |
511 | - int width = MIN(BUBBLE_WIDTH, geo.width); |
512 | - int height = MIN(BUBBLE_HEIGHT + TAIL_HEIGHT, geo.height); |
513 | + int width = MIN(BUBBLE_WIDTH.CP(scale), geo.width); |
514 | + int height = MIN(BUBBLE_HEIGHT.CP(scale) + TAIL_HEIGHT.CP(scale), geo.height); |
515 | |
516 | return nux::Geometry(geo.x + (geo.width - width)/2, geo.y + (geo.height - height)/2, width, height); |
517 | } |
518 | @@ -56,10 +57,13 @@ |
519 | |
520 | SocialPreviewContent::SocialPreviewContent(std::string const& text, NUX_FILE_LINE_DECL) |
521 | : View(NUX_FILE_LINE_PARAM) |
522 | +, scale(1.0) |
523 | { |
524 | SetupViews(); |
525 | if (text.length() > 0) |
526 | SetText(text); |
527 | + UpdateScale(scale); |
528 | + scale.changed.connect(sigc::mem_fun(this, &SocialPreviewContent::UpdateScale)); |
529 | } |
530 | |
531 | SocialPreviewContent::~SocialPreviewContent() |
532 | @@ -94,7 +98,7 @@ |
533 | |
534 | nux::ObjectPtr<nux::IOpenGLBaseTexture> tex = cr_bubble_->GetTexture()->GetDeviceTexture(); |
535 | |
536 | - nux::Geometry geo_bubble(GetBubbleGeometry(geo)); |
537 | + nux::Geometry geo_bubble(GetBubbleGeometry(geo, scale)); |
538 | |
539 | gfx_engine.QRP_1Tex(geo_bubble.x, |
540 | geo_bubble.y, |
541 | @@ -134,8 +138,9 @@ |
542 | |
543 | text_ = new StaticCairoText("", false, NUX_TRACKER_LOCATION); |
544 | text_->SetLines(-8); |
545 | + text_->SetScale(scale); |
546 | text_->SetFont(style.content_font()); |
547 | - text_->SetLineSpacing(5); |
548 | + text_->SetLineSpacing(TEXT_LINE_SPACING.CP(scale)); |
549 | text_->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_MIDDLE); |
550 | text_->mouse_click.connect(on_mouse_down); |
551 | |
552 | @@ -153,10 +158,10 @@ |
553 | { |
554 | nux::Geometry const& geo = GetGeometry(); |
555 | |
556 | - nux::Geometry geo_cr(GetBubbleGeometry(geo)); |
557 | + nux::Geometry geo_cr(GetBubbleGeometry(geo, scale)); |
558 | |
559 | int max_width = std::max(0, (int)(geo_cr.width - 2*(geo_cr.width*0.1))); |
560 | - int max_height = std::max(0, (int)((geo_cr.height - TAIL_HEIGHT) - 2*((geo_cr.height - TAIL_HEIGHT)*0.1))); |
561 | + int max_height = std::max(0, (int)((geo_cr.height - TAIL_HEIGHT.CP(scale)) - 2*((geo_cr.height - TAIL_HEIGHT.CP(scale))*0.1))); |
562 | |
563 | // this will update the texture with the actual size of the text. |
564 | text_->SetMaximumHeight(max_height); |
565 | @@ -314,6 +319,12 @@ |
566 | introspection.add(GetAbsoluteGeometry()); |
567 | } |
568 | |
569 | +void SocialPreviewContent::UpdateScale(double scale) |
570 | +{ |
571 | + if (text_) |
572 | + text_->SetScale(scale); |
573 | +} |
574 | + |
575 | } |
576 | } |
577 | } |
578 | |
579 | === modified file 'dash/previews/SocialPreviewContent.h' |
580 | --- dash/previews/SocialPreviewContent.h 2013-09-19 16:44:03 +0000 |
581 | +++ dash/previews/SocialPreviewContent.h 2014-06-21 11:58:37 +0000 |
582 | @@ -52,6 +52,8 @@ |
583 | |
584 | sigc::signal<void> request_close() const { return preview_container_.request_close; } |
585 | |
586 | + nux::Property<double> scale; |
587 | + |
588 | protected: |
589 | virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw); |
590 | virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw); |
591 | @@ -76,6 +78,8 @@ |
592 | virtual void AddProperties(debug::IntrospectionData&); |
593 | |
594 | private: |
595 | + void UpdateScale(double scale); |
596 | + |
597 | nux::ObjectPtr<StaticCairoText> text_; |
598 | |
599 | typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr; |
FAILED: Continuous integration, rev:3834 jenkins. qa.ubuntu. com/job/ unity-ci/ 985/ jenkins. qa.ubuntu. com/job/ unity-utopic- amd64-ci/ 72/console jenkins. qa.ubuntu. com/job/ unity-utopic- armhf-ci/ 72/console jenkins. qa.ubuntu. com/job/ unity-utopic- i386-ci/ 72/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/985/ rebuild
http://