Merge lp:~hikiko/unity/unity.scale-generic-preview-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: 3835
Proposed branch: lp:~hikiko/unity/unity.scale-generic-preview-components
Merge into: lp:unity
Prerequisite: lp:~hikiko/unity/unity.scale-application-components
Diff against target: 218 lines (+78/-26)
2 files modified
dash/previews/GenericPreview.cpp (+71/-26)
dash/previews/GenericPreview.h (+7/-0)
To merge this branch: bzr merge lp:~hikiko/unity/unity.scale-generic-preview-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+223275@code.launchpad.net

Commit message

Scaled GenericPreview and its widgets.

Description of the change

Scaled GenericPreview and its widgets.

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) :
review: Needs Fixing
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
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
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, issues here have been fixed.

review: Approve

Preview Diff

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