Merge lp:~hikiko/unity/unity.scale-movie-preview 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: 3837
Proposed branch: lp:~hikiko/unity/unity.scale-movie-preview
Merge into: lp:unity
Prerequisite: lp:~hikiko/unity/unity.scale-error-preview
Diff against target: 216 lines (+74/-22)
2 files modified
dash/previews/MoviePreview.cpp (+68/-21)
dash/previews/MoviePreview.h (+6/-1)
To merge this branch: bzr merge lp:~hikiko/unity/unity.scale-movie-preview
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Unity Team Pending
Review via email: mp+223446@code.launchpad.net

Commit message

Scaled MoviePreview and widgets

Description of the change

Scaled MoviePreview and widgets

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Perfect.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dash/previews/MoviePreview.cpp'
--- dash/previews/MoviePreview.cpp 2014-06-17 18:25:21 +0000
+++ dash/previews/MoviePreview.cpp 2014-06-17 18:25:21 +0000
@@ -41,6 +41,13 @@
41{41{
42namespace previews42namespace previews
43{43{
44
45namespace
46{
47 const RawPixel CHILDREN_SPACE = 16_em;
48 const RawPixel PREVIEW_INFO_CHILDREN_SPACE = 12_em;
49}
50
44DECLARE_LOGGER(logger, "unity.dash.preview.movie");51DECLARE_LOGGER(logger, "unity.dash.preview.movie");
4552
46class DetailsScrollView : public nux::ScrollView53class DetailsScrollView : public nux::ScrollView
@@ -123,8 +130,8 @@
123130
124 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); };131 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); };
125132
126 nux::HLayout* image_data_layout = new nux::HLayout();133 image_data_layout_ = new nux::HLayout();
127 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());134 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
128135
129 /////////////////////136 /////////////////////
130 // Image137 // Image
@@ -136,8 +143,8 @@
136 /////////////////////143 /////////////////////
137 // Data Panel144 // Data Panel
138 full_data_layout_ = new nux::VLayout();145 full_data_layout_ = new nux::VLayout();
139 full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());146 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
140 full_data_layout_->SetSpaceBetweenChildren(16);147 full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
141148
142 /////////////////////149 /////////////////////
143 // Data150 // Data
@@ -148,6 +155,7 @@
148 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);155 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
149 AddChild(title_.GetPointer());156 AddChild(title_.GetPointer());
150 title_->SetLines(-1);157 title_->SetLines(-1);
158 title_->SetScale(scale);
151 title_->SetFont(style.title_font().c_str());159 title_->SetFont(style.title_font().c_str());
152 title_->mouse_click.connect(on_mouse_down);160 title_->mouse_click.connect(on_mouse_down);
153 app_data_layout->AddView(title_.GetPointer(), 1);161 app_data_layout->AddView(title_.GetPointer(), 1);
@@ -157,6 +165,7 @@
157 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);165 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
158 AddChild(subtitle_.GetPointer());166 AddChild(subtitle_.GetPointer());
159 subtitle_->SetLines(-1);167 subtitle_->SetLines(-1);
168 subtitle_->SetScale(scale);
160 subtitle_->SetFont(style.subtitle_size_font().c_str());169 subtitle_->SetFont(style.subtitle_size_font().c_str());
161 subtitle_->mouse_click.connect(on_mouse_down);170 subtitle_->mouse_click.connect(on_mouse_down);
162 app_data_layout->AddView(subtitle_.GetPointer(), 1);171 app_data_layout->AddView(subtitle_.GetPointer(), 1);
@@ -166,8 +175,8 @@
166 if (movie_preview_model->rating >= 0) {175 if (movie_preview_model->rating >= 0) {
167 rating_ = new PreviewRatingsWidget();176 rating_ = new PreviewRatingsWidget();
168 AddChild(rating_.GetPointer());177 AddChild(rating_.GetPointer());
169 rating_->SetMaximumHeight(style.GetRatingWidgetHeight());178 rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
170 rating_->SetMinimumHeight(style.GetRatingWidgetHeight());179 rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
171 rating_->SetRating(movie_preview_model->rating);180 rating_->SetRating(movie_preview_model->rating);
172 rating_->SetReviews(movie_preview_model->num_ratings);181 rating_->SetReviews(movie_preview_model->num_ratings);
173 rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });182 rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
@@ -179,16 +188,17 @@
179 preview_info->EnableHorizontalScrollBar(false);188 preview_info->EnableHorizontalScrollBar(false);
180 preview_info->mouse_click.connect(on_mouse_down);189 preview_info->mouse_click.connect(on_mouse_down);
181190
182 nux::VLayout* preview_info_layout = new nux::VLayout();191 preview_info_layout_ = new nux::VLayout();
183 preview_info_layout->SetSpaceBetweenChildren(12);192 preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE.CP(scale));
184 preview_info->SetLayout(preview_info_layout);193 preview_info->SetLayout(preview_info_layout_);
185194
186 if (!preview_model_->GetInfoHints().empty())195 if (!preview_model_->GetInfoHints().empty())
187 {196 {
188 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());197 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
198 preview_info_hints_->scale = scale();
189 AddChild(preview_info_hints_.GetPointer());199 AddChild(preview_info_hints_.GetPointer());
190 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });200 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
191 preview_info_layout->AddView(preview_info_hints_.GetPointer(), 0);201 preview_info_layout_->AddView(preview_info_hints_.GetPointer(), 0);
192 }202 }
193203
194 if (!preview_model_->description.Get().empty())204 if (!preview_model_->description.Get().empty())
@@ -196,34 +206,35 @@
196 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!206 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
197 AddChild(description_.GetPointer());207 AddChild(description_.GetPointer());
198 description_->SetFont(style.description_font().c_str());208 description_->SetFont(style.description_font().c_str());
209 description_->SetScale(scale);
199 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);210 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);
200 description_->SetLines(-style.GetDescriptionLineCount());211 description_->SetLines(-style.GetDescriptionLineCount());
201 description_->SetLineSpacing(style.GetDescriptionLineSpacing());212 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
202 description_->mouse_click.connect(on_mouse_down);213 description_->mouse_click.connect(on_mouse_down);
203 preview_info_layout->AddView(description_.GetPointer());214 preview_info_layout_->AddView(description_.GetPointer());
204 }215 }
205 /////////////////////216 /////////////////////
206217
207 /////////////////////218 /////////////////////
208 // Actions219 // Actions
209 action_buttons_.clear();220 action_buttons_.clear();
210 nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);221 actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
211 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());222 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
212 ///////////////////223 ///////////////////
213224
214 full_data_layout_->AddLayout(app_data_layout, 0);225 full_data_layout_->AddLayout(app_data_layout, 0);
215 if (rating_ != NULL)226 if (rating_ != NULL)
216 full_data_layout_->AddView(rating_.GetPointer(), 0);227 full_data_layout_->AddView(rating_.GetPointer(), 0);
217 full_data_layout_->AddView(preview_info, 1);228 full_data_layout_->AddView(preview_info, 1);
218 full_data_layout_->AddView(actions_layout, 0);229 full_data_layout_->AddView(actions_layout_, 0);
219 /////////////////////230 /////////////////////
220 231
221 image_data_layout->AddView(image_.GetPointer(), 0);232 image_data_layout_->AddView(image_.GetPointer(), 0);
222 image_data_layout->AddLayout(full_data_layout_, 1);233 image_data_layout_->AddLayout(full_data_layout_, 1);
223234
224 mouse_click.connect(on_mouse_down);235 mouse_click.connect(on_mouse_down);
225236
226 SetLayout(image_data_layout);237 SetLayout(image_data_layout_);
227}238}
228239
229240
@@ -235,11 +246,13 @@
235246
236 nux::Geometry geo_art(geo.x, geo.y, style.GetVideoImageAspectRatio() * geo.height, geo.height);247 nux::Geometry geo_art(geo.x, geo.y, style.GetVideoImageAspectRatio() * geo.height, geo.height);
237248
238 if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())249 int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
239 geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());250 if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
251 geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
252
240 image_->SetMinMaxSize(geo_art.width, geo_art.height);253 image_->SetMinMaxSize(geo_art.width, geo_art.height);
241254
242 int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());255 int details_width = std::max(0, geo.width - geo_art.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale));
243256
244 if (title_) { title_->SetMaximumWidth(details_width); }257 if (title_) { title_->SetMaximumWidth(details_width); }
245 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }258 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
@@ -247,12 +260,46 @@
247260
248 for (nux::AbstractButton* button : action_buttons_)261 for (nux::AbstractButton* button : action_buttons_)
249 {262 {
250 button->SetMinMaxSize(CLAMP(RawPixel((details_width - style.GetSpaceBetweenActions()) / 2), 0_em, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());263 button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale));
251 }264 }
252265
253 Preview::PreLayoutManagement();266 Preview::PreLayoutManagement();
254}267}
255268
269void MoviePreview::UpdateScale(double scale)
270{
271 Preview::UpdateScale(scale);
272
273 if (image_)
274 image_->scale = scale;
275
276 if (preview_info_hints_)
277 preview_info_hints_->scale = scale;
278
279 previews::Style& style = dash::previews::Style::Instance();
280
281 if (full_data_layout_)
282 {
283 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
284 full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
285 }
286
287 if (image_data_layout_)
288 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
289
290 if (rating_)
291 {
292 rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
293 rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
294 }
295
296 if (preview_info_layout_)
297 preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE);
298
299 if (actions_layout_)
300 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
301}
302
256} // namespace previews303} // namespace previews
257} // namespace dash304} // namespace dash
258} // namespace unity305} // namespace unity
259306
=== modified file 'dash/previews/MoviePreview.h'
--- dash/previews/MoviePreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/MoviePreview.h 2014-06-17 18:25:21 +0000
@@ -55,9 +55,14 @@
55 virtual void OnNavigateInComplete();55 virtual void OnNavigateInComplete();
5656
57 virtual void SetupViews();57 virtual void SetupViews();
58 58 virtual void UpdateScale(double scale);
59
59protected:60protected:
60 nux::ObjectPtr<PreviewRatingsWidget> rating_;61 nux::ObjectPtr<PreviewRatingsWidget> rating_;
62
63 nux::HLayout* image_data_layout_;
64 nux::VLayout* preview_info_layout_;
65 nux::Layout* actions_layout_;
61};66};
6267
63}68}