Merge lp:~hikiko/unity/unity.scale-application-components into lp:unity

Proposed by Eleni Maria Stea
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3834
Proposed branch: lp:~hikiko/unity/unity.scale-application-components
Merge into: lp:unity
Prerequisite: lp:~hikiko/unity/unity.preview-container-components
Diff against target: 455 lines (+162/-51)
6 files modified
dash/previews/ApplicationPreview.cpp (+106/-41)
dash/previews/ApplicationPreview.h (+8/-0)
dash/previews/PreviewRatingsWidget.cpp (+37/-6)
dash/previews/PreviewRatingsWidget.h (+6/-0)
unity-shared/RatingsButton.cpp (+2/-2)
unity-shared/RatingsButton.h (+3/-2)
To merge this branch: bzr merge lp:~hikiko/unity/unity.scale-application-components
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Unity Team Pending
Review via email: mp+223208@code.launchpad.net

Commit message

Scaled the ApplicationPreview and the containing widgets and components.

Description of the change

Scaled the ApplicationPreview and the containing widgets 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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Needs Fixing
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

fixed the PreLayoutManagement

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, problematic code has been fixed here.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dash/previews/ApplicationPreview.cpp'
--- dash/previews/ApplicationPreview.cpp 2014-06-17 18:22:57 +0000
+++ dash/previews/ApplicationPreview.cpp 2014-06-17 18:22:57 +0000
@@ -46,6 +46,16 @@
46{46{
47namespace previews47namespace previews
48{48{
49
50namespace
51{
52 const RawPixel ICON_SPACE_CHILDREN = 3_em;
53 const RawPixel DATA_SPACE_CHILDREN = 16_em;
54 const RawPixel INFO_SPACE_CHILDREN = 12_em;
55 const RawPixel COPYRIGHT_SPACE_CHILDREN = 8_em;
56 const RawPixel ICON_SIZE = 72_em;
57}
58
49DECLARE_LOGGER(logger, "unity.dash.preview.application");59DECLARE_LOGGER(logger, "unity.dash.preview.application");
5060
51class DetailsScrollView : public nux::ScrollView61class DetailsScrollView : public nux::ScrollView
@@ -121,8 +131,8 @@
121131
122 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); };132 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); };
123133
124 nux::HLayout* image_data_layout = new nux::HLayout();134 image_data_layout_ = new nux::HLayout();
125 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());135 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
126136
127 /////////////////////137 /////////////////////
128 // Image138 // Image
@@ -134,34 +144,34 @@
134 /////////////////////144 /////////////////////
135 // App Data Panel145 // App Data Panel
136 full_data_layout_ = new nux::VLayout();146 full_data_layout_ = new nux::VLayout();
137 full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());147 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
138 full_data_layout_->SetSpaceBetweenChildren(16);148 full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN);
139149
140 /////////////////////150 /////////////////////
141 // Main App Info151 // Main App Info
142 nux::HLayout* main_app_info = new nux::HLayout();152 main_app_info_ = new nux::HLayout();
143 main_app_info->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails());153 main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale));
144154
145 /////////////////////155 /////////////////////
146 // Icon Layout156 // Icon Layout
147 nux::VLayout* icon_layout = new nux::VLayout();157 icon_layout_ = new nux::VLayout();
148 icon_layout->SetSpaceBetweenChildren(3);158 icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale));
149 app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", 72);159 app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", ICON_SIZE.CP(scale));
150 AddChild(app_icon_.GetPointer());160 AddChild(app_icon_.GetPointer());
151 app_icon_->SetMinimumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());161 app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
152 app_icon_->SetMaximumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());162 app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
153 app_icon_->mouse_click.connect(on_mouse_down);163 app_icon_->mouse_click.connect(on_mouse_down);
154 icon_layout->AddView(app_icon_.GetPointer(), 0);164 icon_layout_->AddView(app_icon_.GetPointer(), 0);
155165
156 if (app_preview_model->rating >= 0) {166 if (app_preview_model->rating >= 0) {
157 app_rating_ = new PreviewRatingsWidget();167 app_rating_ = new PreviewRatingsWidget();
158 AddChild(app_rating_.GetPointer());168 AddChild(app_rating_.GetPointer());
159 app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight());169 app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
160 app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight());170 app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
161 app_rating_->SetRating(app_preview_model->rating);171 app_rating_->SetRating(app_preview_model->rating);
162 app_rating_->SetReviews(app_preview_model->num_ratings);172 app_rating_->SetReviews(app_preview_model->num_ratings);
163 app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });173 app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
164 icon_layout->AddView(app_rating_.GetPointer(), 0);174 icon_layout_->AddView(app_rating_.GetPointer(), 0);
165 }175 }
166176
167 /////////////////////177 /////////////////////
@@ -169,11 +179,11 @@
169 /////////////////////179 /////////////////////
170 // Data180 // Data
171181
172 nux::VLayout* app_data_layout = new nux::VLayout();182 app_data_layout_ = new nux::VLayout();
173 app_data_layout->SetSpaceBetweenChildren(16);183 app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
174184
175 title_subtitle_layout_ = new nux::VLayout();185 title_subtitle_layout_ = new nux::VLayout();
176 title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());186 title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
177187
178 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);188 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
179 AddChild(title_.GetPointer());189 AddChild(title_.GetPointer());
@@ -192,8 +202,8 @@
192 title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);202 title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);
193 }203 }
194204
195 nux::VLayout* app_updated_copywrite_layout = new nux::VLayout();205 app_updated_copywrite_layout_ = new nux::VLayout();
196 app_updated_copywrite_layout->SetSpaceBetweenChildren(8);206 app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale));
197207
198 if (!app_preview_model->license.Get().empty())208 if (!app_preview_model->license.Get().empty())
199 {209 {
@@ -202,7 +212,7 @@
202 license_->SetFont(style.app_license_font().c_str());212 license_->SetFont(style.app_license_font().c_str());
203 license_->SetLines(-1);213 license_->SetLines(-1);
204 license_->mouse_click.connect(on_mouse_down);214 license_->mouse_click.connect(on_mouse_down);
205 app_updated_copywrite_layout->AddView(license_.GetPointer(), 1);215 app_updated_copywrite_layout_->AddView(license_.GetPointer(), 1);
206 }216 }
207217
208 if (!app_preview_model->last_update.Get().empty())218 if (!app_preview_model->last_update.Get().empty())
@@ -214,7 +224,7 @@
214 AddChild(last_update_.GetPointer());224 AddChild(last_update_.GetPointer());
215 last_update_->SetFont(style.app_last_update_font().c_str());225 last_update_->SetFont(style.app_last_update_font().c_str());
216 last_update_->mouse_click.connect(on_mouse_down);226 last_update_->mouse_click.connect(on_mouse_down);
217 app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1);227 app_updated_copywrite_layout_->AddView(last_update_.GetPointer(), 1);
218 }228 }
219229
220 if (!app_preview_model->copyright.Get().empty())230 if (!app_preview_model->copyright.Get().empty())
@@ -224,17 +234,17 @@
224 copywrite_->SetFont(style.app_copywrite_font().c_str());234 copywrite_->SetFont(style.app_copywrite_font().c_str());
225 copywrite_->SetLines(-1);235 copywrite_->SetLines(-1);
226 copywrite_->mouse_click.connect(on_mouse_down);236 copywrite_->mouse_click.connect(on_mouse_down);
227 app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1);237 app_updated_copywrite_layout_->AddView(copywrite_.GetPointer(), 1);
228 }238 }
229239
230 app_data_layout->AddLayout(title_subtitle_layout_);240 app_data_layout_->AddLayout(title_subtitle_layout_);
231 app_data_layout->AddLayout(app_updated_copywrite_layout);241 app_data_layout_->AddLayout(app_updated_copywrite_layout_);
232242
233 // buffer space243 // buffer space
234 /////////////////////244 /////////////////////
235245
236 main_app_info->AddLayout(icon_layout, 0);246 main_app_info_->AddLayout(icon_layout_, 0);
237 main_app_info->AddLayout(app_data_layout, 1);247 main_app_info_->AddLayout(app_data_layout_, 1);
238 /////////////////////248 /////////////////////
239249
240 /////////////////////250 /////////////////////
@@ -243,9 +253,9 @@
243 app_info->EnableHorizontalScrollBar(false);253 app_info->EnableHorizontalScrollBar(false);
244 app_info->mouse_click.connect(on_mouse_down);254 app_info->mouse_click.connect(on_mouse_down);
245255
246 nux::VLayout* app_info_layout = new nux::VLayout();256 app_info_layout_ = new nux::VLayout();
247 app_info_layout->SetSpaceBetweenChildren(12);257 app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN);
248 app_info->SetLayout(app_info_layout);258 app_info->SetLayout(app_info_layout_);
249259
250 if (!preview_model_->description.Get().empty())260 if (!preview_model_->description.Get().empty())
251 {261 {
@@ -256,7 +266,7 @@
256 description_->SetLines(-style.GetDescriptionLineCount());266 description_->SetLines(-style.GetDescriptionLineCount());
257 description_->SetLineSpacing(style.GetDescriptionLineSpacing());267 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
258 description_->mouse_click.connect(on_mouse_down);268 description_->mouse_click.connect(on_mouse_down);
259 app_info_layout->AddView(description_.GetPointer());269 app_info_layout_->AddView(description_.GetPointer());
260 }270 }
261271
262 if (!preview_model_->GetInfoHints().empty())272 if (!preview_model_->GetInfoHints().empty())
@@ -264,7 +274,7 @@
264 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());274 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
265 AddChild(preview_info_hints_.GetPointer());275 AddChild(preview_info_hints_.GetPointer());
266 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });276 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
267 app_info_layout->AddView(preview_info_hints_.GetPointer());277 app_info_layout_->AddView(preview_info_hints_.GetPointer());
268 }278 }
269 /////////////////////279 /////////////////////
270280
@@ -275,17 +285,17 @@
275 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());285 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
276 ///////////////////286 ///////////////////
277287
278 full_data_layout_->AddLayout(main_app_info, 0);288 full_data_layout_->AddLayout(main_app_info_, 0);
279 full_data_layout_->AddView(app_info, 1);289 full_data_layout_->AddView(app_info, 1);
280 full_data_layout_->AddLayout(actions_layout, 0);290 full_data_layout_->AddLayout(actions_layout, 0);
281 /////////////////////291 /////////////////////
282 292
283 image_data_layout->AddView(image_.GetPointer(), 0);293 image_data_layout_->AddView(image_.GetPointer(), 0);
284 image_data_layout->AddLayout(full_data_layout_, 1);294 image_data_layout_->AddLayout(full_data_layout_, 1);
285295
286 mouse_click.connect(on_mouse_down);296 mouse_click.connect(on_mouse_down);
287297
288 SetLayout(image_data_layout);298 SetLayout(image_data_layout_);
289}299}
290300
291void ApplicationPreview::PreLayoutManagement()301void ApplicationPreview::PreLayoutManagement()
@@ -296,12 +306,14 @@
296306
297 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);307 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
298308
299 if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())309 int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
300 geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());310 if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
311 geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
312
301 image_->SetMinMaxSize(geo_art.width, geo_art.height);313 image_->SetMinMaxSize(geo_art.width, geo_art.height);
302314
303 int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());315 int details_width = std::max(0, content_width - geo_art.width);
304 int top_app_info_max_width = MAX(0, details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails());316 int top_app_info_max_width = std::max(0, details_width - style.GetAppIconAreaWidth().CP(scale) - style.GetSpaceBetweenIconAndDetails().CP(scale));
305317
306 if (title_) { title_->SetMaximumWidth(top_app_info_max_width); }318 if (title_) { title_->SetMaximumWidth(top_app_info_max_width); }
307 if (subtitle_) { subtitle_->SetMaximumWidth(top_app_info_max_width); }319 if (subtitle_) { subtitle_->SetMaximumWidth(top_app_info_max_width); }
@@ -312,12 +324,65 @@
312324
313 for (nux::AbstractButton* button : action_buttons_)325 for (nux::AbstractButton* button : action_buttons_)
314 {326 {
315 button->SetMinMaxSize(CLAMP(RawPixel((details_width - style.GetSpaceBetweenActions()) / 2), 0_em, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());327 button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale));
316 }328 }
317329
318 Preview::PreLayoutManagement();330 Preview::PreLayoutManagement();
319}331}
320332
333void ApplicationPreview::UpdateScale(double scale)
334{
335 previews::Style& style = dash::previews::Style::Instance();
336
337 if (app_icon_)
338 {
339 app_icon_->SetSize(ICON_SIZE.CP(scale));
340 app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
341 app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
342 app_icon_->ReLoadIcon();
343 }
344
345 if (license_)
346 license_->SetScale(scale);
347 if (last_update_)
348 last_update_->SetScale(scale);
349 if (copywrite_)
350 copywrite_->SetScale(scale);
351
352 if (app_rating_)
353 {
354 app_rating_->scale = scale;
355 app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
356 app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
357 }
358
359 if (image_data_layout_)
360 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
361
362 if (full_data_layout_)
363 {
364 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
365 full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
366 }
367
368 if (main_app_info_)
369 main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale));
370
371 if (icon_layout_)
372 icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale));
373
374 if (app_data_layout_)
375 app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
376
377 if (app_info_layout_)
378 app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN.CP(scale));
379
380 if (app_updated_copywrite_layout_)
381 app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale));
382
383 Preview::UpdateScale(scale);
384}
385
321} // namespace previews386} // namespace previews
322} // namespace dash387} // namespace dash
323} // namepsace unity388} // namepsace unity
324389
=== modified file 'dash/previews/ApplicationPreview.h'
--- dash/previews/ApplicationPreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/ApplicationPreview.h 2014-06-17 18:22:57 +0000
@@ -54,9 +54,17 @@
54 virtual void PreLayoutManagement();54 virtual void PreLayoutManagement();
5555
56 virtual void SetupViews();56 virtual void SetupViews();
57 void UpdateScale(double scale) override;
5758
58protected:59protected:
59 nux::VLayout* title_subtitle_layout_;60 nux::VLayout* title_subtitle_layout_;
61 nux::HLayout* image_data_layout_;
62 nux::HLayout* main_app_info_;
63 nux::VLayout* icon_layout_;
64 nux::VLayout* app_data_layout_;
65 nux::VLayout* app_updated_copywrite_layout_;
66 nux::VLayout* app_info_layout_;
67 nux::Layout* actions_layout_;
6068
61 nux::ObjectPtr<IconTexture> app_icon_;69 nux::ObjectPtr<IconTexture> app_icon_;
62 nux::ObjectPtr<PreviewRatingsWidget> app_rating_;70 nux::ObjectPtr<PreviewRatingsWidget> app_rating_;
6371
=== modified file 'dash/previews/PreviewRatingsWidget.cpp'
--- dash/previews/PreviewRatingsWidget.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/PreviewRatingsWidget.cpp 2014-06-17 18:22:57 +0000
@@ -38,31 +38,42 @@
38namespace previews38namespace previews
39{39{
4040
41namespace
42{
43 const RawPixel CHILDREN_SPACE = 3_em;
44 const RawPixel RATINGS_SIZE = 18_em;
45 const RawPixel RATINGS_GAP = 2_em;
46}
47
41NUX_IMPLEMENT_OBJECT_TYPE(PreviewRatingsWidget);48NUX_IMPLEMENT_OBJECT_TYPE(PreviewRatingsWidget);
4249
43PreviewRatingsWidget::PreviewRatingsWidget(NUX_FILE_LINE_DECL)50PreviewRatingsWidget::PreviewRatingsWidget(NUX_FILE_LINE_DECL)
44 : View(NUX_FILE_LINE_PARAM)51 : View(NUX_FILE_LINE_PARAM)
52 , scale(1.0)
45{53{
46 nux::VLayout* layout = new nux::VLayout();54 layout_ = new nux::VLayout();
47 layout->SetSpaceBetweenChildren(3);55 layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
4856
49 previews::Style& style = previews::Style::Instance();57 previews::Style& style = previews::Style::Instance();
5058
51 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); };59 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); };
5260
53 ratings_ = new RatingsButton(18,2);61 ratings_ = new RatingsButton(RATINGS_SIZE.CP(scale), RATINGS_GAP.CP(scale));
54 ratings_->SetEditable(false);62 ratings_->SetEditable(false);
55 ratings_->mouse_click.connect(on_mouse_down);63 ratings_->mouse_click.connect(on_mouse_down);
56 layout->AddView(ratings_);64 layout_->AddView(ratings_);
57 65
58 reviews_ = new StaticCairoText("", NUX_TRACKER_LOCATION);66 reviews_ = new StaticCairoText("", NUX_TRACKER_LOCATION);
59 reviews_->SetFont(style.user_rating_font());67 reviews_->SetFont(style.user_rating_font());
68 reviews_->SetScale(scale);
60 reviews_->mouse_click.connect(on_mouse_down);69 reviews_->mouse_click.connect(on_mouse_down);
61 layout->AddView(reviews_);70 layout_->AddView(reviews_);
6271
63 mouse_click.connect(on_mouse_down);72 mouse_click.connect(on_mouse_down);
6473
65 SetLayout(layout);74 SetLayout(layout_);
75
76 scale.changed.connect(sigc::mem_fun(this, &PreviewRatingsWidget::UpdateScale));
66}77}
6778
68PreviewRatingsWidget::~PreviewRatingsWidget()79PreviewRatingsWidget::~PreviewRatingsWidget()
@@ -114,6 +125,26 @@
114 .add(GetAbsoluteGeometry());125 .add(GetAbsoluteGeometry());
115}126}
116127
128void PreviewRatingsWidget::UpdateScale(double scale)
129{
130 if (reviews_)
131 reviews_->SetScale(scale);
132
133 if (ratings_)
134 {
135 ratings_->star_gap_ = RATINGS_SIZE.CP(scale);
136 ratings_->star_gap_ = RATINGS_GAP.CP(scale);
137 }
138
139 preview_container_.scale = scale;
140
141 if (layout_)
142 layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
143
144 QueueRelayout();
145 QueueDraw();
146}
147
117} // namespace previews148} // namespace previews
118} // namespace dash149} // namespace dash
119} // namespace unity150} // namespace unity
120151
=== modified file 'dash/previews/PreviewRatingsWidget.h'
--- dash/previews/PreviewRatingsWidget.h 2013-09-19 16:44:03 +0000
+++ dash/previews/PreviewRatingsWidget.h 2014-06-17 18:22:57 +0000
@@ -52,6 +52,8 @@
5252
53 void SetReviews(int count);53 void SetReviews(int count);
5454
55 nux::Property<double> scale;
56
55 sigc::signal<void> request_close() const { return preview_container_.request_close; }57 sigc::signal<void> request_close() const { return preview_container_.request_close; }
5658
57protected:59protected:
@@ -65,9 +67,13 @@
65 void AddProperties(debug::IntrospectionData&);67 void AddProperties(debug::IntrospectionData&);
6668
67private:69private:
70 void UpdateScale(double scale);
71
68 RatingsButton* ratings_;72 RatingsButton* ratings_;
69 StaticCairoText* reviews_;73 StaticCairoText* reviews_;
7074
75 nux::VLayout* layout_;
76
71 PreviewContainer preview_container_;77 PreviewContainer preview_container_;
72};78};
7379
7480
=== modified file 'unity-shared/RatingsButton.cpp'
--- unity-shared/RatingsButton.cpp 2013-11-19 18:48:35 +0000
+++ unity-shared/RatingsButton.cpp 2014-06-17 18:22:57 +0000
@@ -36,11 +36,11 @@
36{36{
37RatingsButton::RatingsButton(int star_size, int star_gap, NUX_FILE_LINE_DECL)37RatingsButton::RatingsButton(int star_size, int star_gap, NUX_FILE_LINE_DECL)
38 : nux::ToggleButton(NUX_FILE_LINE_PARAM)38 : nux::ToggleButton(NUX_FILE_LINE_PARAM)
39 , star_size_(star_size)
40 , star_gap_(star_gap)
39 , editable_(true)41 , editable_(true)
40 , rating_(0.0)42 , rating_(0.0)
41 , focused_star_(-1)43 , focused_star_(-1)
42 , star_size_(star_size)
43 , star_gap_(star_gap)
44{44{
45 SetAcceptKeyNavFocusOnMouseDown(false);45 SetAcceptKeyNavFocusOnMouseDown(false);
46 SetAcceptKeyNavFocusOnMouseEnter(true);46 SetAcceptKeyNavFocusOnMouseEnter(true);
4747
=== modified file 'unity-shared/RatingsButton.h'
--- unity-shared/RatingsButton.h 2013-09-19 16:44:03 +0000
+++ unity-shared/RatingsButton.h 2014-06-17 18:22:57 +0000
@@ -41,6 +41,9 @@
41 virtual void SetRating(float rating);41 virtual void SetRating(float rating);
42 virtual float GetRating() const;42 virtual float GetRating() const;
4343
44 int star_size_;
45 int star_gap_;
46
44protected:47protected:
45 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);48 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
4649
@@ -67,8 +70,6 @@
67 bool editable_;70 bool editable_;
68 float rating_;71 float rating_;
69 int focused_star_;72 int focused_star_;
70 int star_size_;
71 int star_gap_;
72};73};
7374
74} // namespace unity75} // namespace unity