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
1=== modified file 'dash/previews/MoviePreview.cpp'
2--- dash/previews/MoviePreview.cpp 2014-06-17 18:25:21 +0000
3+++ dash/previews/MoviePreview.cpp 2014-06-17 18:25:21 +0000
4@@ -41,6 +41,13 @@
5 {
6 namespace previews
7 {
8+
9+namespace
10+{
11+ const RawPixel CHILDREN_SPACE = 16_em;
12+ const RawPixel PREVIEW_INFO_CHILDREN_SPACE = 12_em;
13+}
14+
15 DECLARE_LOGGER(logger, "unity.dash.preview.movie");
16
17 class DetailsScrollView : public nux::ScrollView
18@@ -123,8 +130,8 @@
19
20 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); };
21
22- nux::HLayout* image_data_layout = new nux::HLayout();
23- image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
24+ image_data_layout_ = new nux::HLayout();
25+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
26
27 /////////////////////
28 // Image
29@@ -136,8 +143,8 @@
30 /////////////////////
31 // Data Panel
32 full_data_layout_ = new nux::VLayout();
33- full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());
34- full_data_layout_->SetSpaceBetweenChildren(16);
35+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
36+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
37
38 /////////////////////
39 // Data
40@@ -148,6 +155,7 @@
41 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
42 AddChild(title_.GetPointer());
43 title_->SetLines(-1);
44+ title_->SetScale(scale);
45 title_->SetFont(style.title_font().c_str());
46 title_->mouse_click.connect(on_mouse_down);
47 app_data_layout->AddView(title_.GetPointer(), 1);
48@@ -157,6 +165,7 @@
49 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
50 AddChild(subtitle_.GetPointer());
51 subtitle_->SetLines(-1);
52+ subtitle_->SetScale(scale);
53 subtitle_->SetFont(style.subtitle_size_font().c_str());
54 subtitle_->mouse_click.connect(on_mouse_down);
55 app_data_layout->AddView(subtitle_.GetPointer(), 1);
56@@ -166,8 +175,8 @@
57 if (movie_preview_model->rating >= 0) {
58 rating_ = new PreviewRatingsWidget();
59 AddChild(rating_.GetPointer());
60- rating_->SetMaximumHeight(style.GetRatingWidgetHeight());
61- rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
62+ rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
63+ rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
64 rating_->SetRating(movie_preview_model->rating);
65 rating_->SetReviews(movie_preview_model->num_ratings);
66 rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
67@@ -179,16 +188,17 @@
68 preview_info->EnableHorizontalScrollBar(false);
69 preview_info->mouse_click.connect(on_mouse_down);
70
71- nux::VLayout* preview_info_layout = new nux::VLayout();
72- preview_info_layout->SetSpaceBetweenChildren(12);
73- preview_info->SetLayout(preview_info_layout);
74+ preview_info_layout_ = new nux::VLayout();
75+ preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE.CP(scale));
76+ preview_info->SetLayout(preview_info_layout_);
77
78 if (!preview_model_->GetInfoHints().empty())
79 {
80 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
81+ preview_info_hints_->scale = scale();
82 AddChild(preview_info_hints_.GetPointer());
83 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
84- preview_info_layout->AddView(preview_info_hints_.GetPointer(), 0);
85+ preview_info_layout_->AddView(preview_info_hints_.GetPointer(), 0);
86 }
87
88 if (!preview_model_->description.Get().empty())
89@@ -196,34 +206,35 @@
90 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
91 AddChild(description_.GetPointer());
92 description_->SetFont(style.description_font().c_str());
93+ description_->SetScale(scale);
94 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);
95 description_->SetLines(-style.GetDescriptionLineCount());
96 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
97 description_->mouse_click.connect(on_mouse_down);
98- preview_info_layout->AddView(description_.GetPointer());
99+ preview_info_layout_->AddView(description_.GetPointer());
100 }
101 /////////////////////
102
103 /////////////////////
104 // Actions
105 action_buttons_.clear();
106- nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
107- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
108+ actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
109+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
110 ///////////////////
111
112 full_data_layout_->AddLayout(app_data_layout, 0);
113 if (rating_ != NULL)
114 full_data_layout_->AddView(rating_.GetPointer(), 0);
115 full_data_layout_->AddView(preview_info, 1);
116- full_data_layout_->AddView(actions_layout, 0);
117+ full_data_layout_->AddView(actions_layout_, 0);
118 /////////////////////
119
120- image_data_layout->AddView(image_.GetPointer(), 0);
121- image_data_layout->AddLayout(full_data_layout_, 1);
122+ image_data_layout_->AddView(image_.GetPointer(), 0);
123+ image_data_layout_->AddLayout(full_data_layout_, 1);
124
125 mouse_click.connect(on_mouse_down);
126
127- SetLayout(image_data_layout);
128+ SetLayout(image_data_layout_);
129 }
130
131
132@@ -235,11 +246,13 @@
133
134 nux::Geometry geo_art(geo.x, geo.y, style.GetVideoImageAspectRatio() * geo.height, geo.height);
135
136- if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
137- geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
138+ int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
139+ if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
140+ geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
141+
142 image_->SetMinMaxSize(geo_art.width, geo_art.height);
143
144- int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
145+ int details_width = std::max(0, geo.width - geo_art.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale));
146
147 if (title_) { title_->SetMaximumWidth(details_width); }
148 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
149@@ -247,12 +260,46 @@
150
151 for (nux::AbstractButton* button : action_buttons_)
152 {
153- button->SetMinMaxSize(CLAMP(RawPixel((details_width - style.GetSpaceBetweenActions()) / 2), 0_em, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
154+ button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale));
155 }
156
157 Preview::PreLayoutManagement();
158 }
159
160+void MoviePreview::UpdateScale(double scale)
161+{
162+ Preview::UpdateScale(scale);
163+
164+ if (image_)
165+ image_->scale = scale;
166+
167+ if (preview_info_hints_)
168+ preview_info_hints_->scale = scale;
169+
170+ previews::Style& style = dash::previews::Style::Instance();
171+
172+ if (full_data_layout_)
173+ {
174+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
175+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
176+ }
177+
178+ if (image_data_layout_)
179+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
180+
181+ if (rating_)
182+ {
183+ rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
184+ rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
185+ }
186+
187+ if (preview_info_layout_)
188+ preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE);
189+
190+ if (actions_layout_)
191+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
192+}
193+
194 } // namespace previews
195 } // namespace dash
196 } // namespace unity
197
198=== modified file 'dash/previews/MoviePreview.h'
199--- dash/previews/MoviePreview.h 2013-09-19 16:44:03 +0000
200+++ dash/previews/MoviePreview.h 2014-06-17 18:25:21 +0000
201@@ -55,9 +55,14 @@
202 virtual void OnNavigateInComplete();
203
204 virtual void SetupViews();
205-
206+ virtual void UpdateScale(double scale);
207+
208 protected:
209 nux::ObjectPtr<PreviewRatingsWidget> rating_;
210+
211+ nux::HLayout* image_data_layout_;
212+ nux::VLayout* preview_info_layout_;
213+ nux::Layout* actions_layout_;
214 };
215
216 }