Merge lp:~hikiko/unity/unity.scale-music-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: 3839
Proposed branch: lp:~hikiko/unity/unity.scale-music-preview
Merge into: lp:unity
Prerequisite: lp:~hikiko/unity/unity.scale-movie-preview
Diff against target: 292 lines (+88/-34)
3 files modified
dash/previews/MusicPreview.cpp (+81/-32)
dash/previews/MusicPreview.h (+4/-0)
dash/previews/PreviewContainer.cpp (+3/-2)
To merge this branch: bzr merge lp:~hikiko/unity/unity.scale-music-preview
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+223519@code.launchpad.net

Commit message

Scaled MusicPreview and widgets

Description of the change

scaled the MusicPreview and widgets

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
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 :

It would be nice if you might fix the comment above in this branch.

review: Needs Fixing
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

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/MusicPreview.cpp'
2--- dash/previews/MusicPreview.cpp 2014-07-06 21:18:53 +0000
3+++ dash/previews/MusicPreview.cpp 2014-07-06 21:18:53 +0000
4@@ -42,14 +42,27 @@
5 {
6 namespace previews
7 {
8+
9+namespace
10+{
11+ const RawPixel CHILDREN_SPACE = 16_em;
12+ const RawPixel ICON_LEFT_RIGHT_PADDING = 10_em;
13+ const RawPixel WARNING_MIN_HEIGHT = 50_em;
14+ const RawPixel WARNING_MAX_WIDTH = 300_em;
15+}
16+
17 DECLARE_LOGGER(logger, "unity.dash.preview.music");
18
19 NUX_IMPLEMENT_OBJECT_TYPE(MusicPreview);
20
21 MusicPreview::MusicPreview(dash::Preview::Ptr preview_model)
22 : Preview(preview_model)
23+, actions_layout_(nullptr)
24+, image_data_layout_(nullptr)
25+, icon_layout_(nullptr)
26 {
27 SetupViews();
28+ UpdateScale(scale);
29 }
30
31 MusicPreview::~MusicPreview()
32@@ -130,13 +143,13 @@
33
34 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); };
35
36- nux::HLayout* image_data_layout = new nux::HLayout();
37- image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
38+ image_data_layout_ = new nux::HLayout();
39+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
40
41 /////////////////////
42 // Image
43 image_ = new CoverArt();
44-
45+ image_->scale = scale();
46 AddChild(image_.GetPointer());
47 UpdateCoverArtImage(image_.GetPointer());
48 /////////////////////
49@@ -144,8 +157,8 @@
50 /////////////////////
51 // App Data Panel
52 full_data_layout_ = new nux::VLayout();
53- full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());
54- full_data_layout_->SetSpaceBetweenChildren(16);
55+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
56+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
57
58 /////////////////////
59 // Music Info
60@@ -156,6 +169,7 @@
61 AddChild(title_.GetPointer());
62 title_->SetFont(style.title_font().c_str());
63 title_->SetLines(-1);
64+ title_->SetScale(scale);
65 title_->mouse_click.connect(on_mouse_down);
66 album_data_layout->AddView(title_.GetPointer(), 1);
67
68@@ -165,6 +179,7 @@
69 AddChild(subtitle_.GetPointer());
70 subtitle_->SetFont(style.subtitle_size_font().c_str());
71 subtitle_->SetLines(-1);
72+ subtitle_->SetScale(scale);
73 subtitle_->mouse_click.connect(on_mouse_down);
74 album_data_layout->AddView(subtitle_.GetPointer(), 1);
75 }
76@@ -187,7 +202,7 @@
77 /////////////////////
78 // Hints && Actions
79 nux::VLayout* hints_layout = NULL;
80- nux::Layout* actions_layout = NULL;
81+ actions_layout_ = NULL;
82 bool has_u1_creds = HasUbuntuOneCredentials();
83
84 if (has_u1_creds)
85@@ -197,55 +212,57 @@
86 hints_layout = new nux::VLayout();
87 hints_layout->SetSpaceBetweenChildren(0);
88 hints_layout->AddSpace(0, 1);
89- preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
90+ preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale));
91+ preview_info_hints_->scale = scale();
92 AddChild(preview_info_hints_.GetPointer());
93 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
94 hints_layout->AddView(preview_info_hints_.GetPointer(), 0);
95
96 // If there are actions, we use a vertical layout
97 action_buttons_.clear();
98- actions_layout = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_);
99- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
100+ actions_layout_ = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_);
101+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
102 }
103 else // otherwise we add a grid layout.
104 {
105 action_buttons_.clear();
106- actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
107+ actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
108 if (action_buttons_.size() < 2)
109 hint_actions_layout->AddSpace(0, 1);
110- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
111+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
112 }
113 }
114 else
115 {
116 // let the user know he needs to connect
117 previews::Style& style = dash::previews::Style::Instance();
118- actions_layout = new nux::HLayout();
119- nux::VLayout* icon_layout = new nux::VLayout();
120- icon_layout->SetLeftAndRightPadding(10);
121+ nux::HLayout* actions_layout = new nux::HLayout();
122+ icon_layout_ = new nux::VLayout();
123+ icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING);
124
125 warning_texture_ = new IconTexture(style.GetWarningIcon());
126- icon_layout->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START,
127+ icon_layout_->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START,
128 nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);
129- actions_layout->AddLayout(icon_layout, 0, nux::MINOR_POSITION_CENTER);
130+ actions_layout->AddLayout(icon_layout_, 0, nux::MINOR_POSITION_CENTER);
131
132 warning_msg_ = new StaticCairoText(
133 no_credentials_message_, true,
134 NUX_TRACKER_LOCATION);
135- AddChild(warning_msg_.GetPointer());
136+ AddChild(warning_msg_.GetPointer());
137 warning_msg_->SetFont(style.u1_warning_font().c_str());
138 warning_msg_->SetLines(-2);
139- warning_msg_->SetMinimumHeight(50);
140- warning_msg_->SetMaximumWidth(300);
141+ warning_msg_->SetScale(scale);
142+ warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale));
143+ warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale));
144
145 actions_layout->AddView(warning_msg_.GetPointer(), 0, nux::MINOR_POSITION_CENTER);
146
147 }
148-
149+
150 /////////////////////
151
152 if (hints_layout) hint_actions_layout->AddView(hints_layout, 1);
153- hint_actions_layout->AddView(actions_layout, 0);
154+ hint_actions_layout->AddView(actions_layout_, 0);
155
156 full_data_layout_->AddLayout(album_data_layout, 0);
157 if (tracks_)
158@@ -254,13 +271,13 @@
159 }
160 full_data_layout_->AddLayout(hint_actions_layout, 0);
161 /////////////////////
162-
163- image_data_layout->AddView(image_.GetPointer(), 0);
164- image_data_layout->AddLayout(full_data_layout_, 1);
165+
166+ image_data_layout_->AddView(image_.GetPointer(), 0);
167+ image_data_layout_->AddLayout(full_data_layout_, 1);
168
169 mouse_click.connect(on_mouse_down);
170
171- SetLayout(image_data_layout);
172+ SetLayout(image_data_layout_);
173 }
174
175 void MusicPreview::PreLayoutManagement()
176@@ -272,23 +289,23 @@
177
178 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
179
180- if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
181- geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
182+ int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
183+ if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
184+ geo_art.width = MAX(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
185 image_->SetMinMaxSize(geo_art.width, geo_art.height);
186
187- int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
188+ int details_width = MAX(0, content_width - geo_art.width);
189
190 if (title_) { title_->SetMaximumWidth(details_width); }
191 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
192
193 for (nux::AbstractButton* button : action_buttons_)
194 {
195- int action_width = CLAMP(RawPixel((details_width - style.GetSpaceBetweenActions()) /
196- 2), 0_em, style.GetActionButtonMaximumWidth());
197+ int action_width = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale));
198 // do not use SetMinMax because width has to be able to grow
199 button->SetMinimumWidth(action_width);
200- button->SetMinimumHeight(style.GetActionButtonHeight());
201- button->SetMaximumHeight(style.GetActionButtonHeight());
202+ button->SetMinimumHeight(style.GetActionButtonHeight().CP(scale));
203+ button->SetMaximumHeight(style.GetActionButtonHeight().CP(scale));
204 }
205
206 Preview::PreLayoutManagement();
207@@ -300,6 +317,38 @@
208 player.Stop();
209 }
210
211+void MusicPreview::UpdateScale(double scale)
212+{
213+ Preview::UpdateScale(scale);
214+
215+ if (preview_info_hints_)
216+ preview_info_hints_->scale = scale;
217+
218+ if (warning_msg_)
219+ {
220+ warning_msg_->SetScale(scale);
221+ warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale));
222+ warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale));
223+ }
224+
225+ previews::Style& style = dash::previews::Style::Instance();
226+
227+ if (image_data_layout_)
228+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
229+
230+ if (full_data_layout_)
231+ {
232+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
233+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
234+ }
235+
236+ if (actions_layout_)
237+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
238+
239+ if (icon_layout_)
240+ icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale));
241+}
242+
243 } // namespace previews
244 } // namespace dash
245 } // namespace unity
246
247=== modified file 'dash/previews/MusicPreview.h'
248--- dash/previews/MusicPreview.h 2013-09-19 16:44:03 +0000
249+++ dash/previews/MusicPreview.h 2014-07-06 21:18:53 +0000
250@@ -53,6 +53,7 @@
251 virtual void PreLayoutManagement();
252
253 virtual void SetupViews();
254+ virtual void UpdateScale(double scale);
255
256 virtual void OnNavigateOut();
257
258@@ -64,6 +65,9 @@
259 nux::ObjectPtr<IconTexture> warning_texture_;
260 std::string no_credentials_message_;
261
262+ nux::Layout* actions_layout_;
263+ nux::HLayout* image_data_layout_;
264+ nux::VLayout* icon_layout_;
265 };
266
267 }
268
269=== modified file 'dash/previews/PreviewContainer.cpp'
270--- dash/previews/PreviewContainer.cpp 2014-07-06 21:18:53 +0000
271+++ dash/previews/PreviewContainer.cpp 2014-07-06 21:18:53 +0000
272@@ -440,9 +440,9 @@
273 if (preview_view)
274 {
275 preview_view->request_close().connect([this]() { request_close.emit(); });
276+ preview_layout_->PushPreview(preview_view, direction);
277 }
278
279- preview_layout_->PushPreview(preview_view, direction);
280 }
281
282 void PreviewContainer::DisableNavButton(Navigation button)
283@@ -618,7 +618,8 @@
284 timespec current;
285 clock_gettime(CLOCK_MONOTONIC, &current);
286 float progress = GetSwipeAnimationProgress(current);
287- preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out.
288+ if (preview_layout_)
289+ preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out.
290 last_progress_time_ = current;
291
292 QueueDraw();