Merge lp:~hikiko/unity/unity.scale-error-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: 3836
Proposed branch: lp:~hikiko/unity/unity.scale-error-preview
Merge into: lp:unity
Prerequisite: lp:~hikiko/unity/unity.scale-generic-preview-components
Diff against target: 163 lines (+55/-14)
2 files modified
dash/previews/ErrorPreview.cpp (+53/-14)
dash/previews/ErrorPreview.h (+2/-0)
To merge this branch: bzr merge lp:~hikiko/unity/unity.scale-error-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+223293@code.launchpad.net

Commit message

scaled ErrorPreview

Description of the change

scaled ErrorPreview

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: 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 :

Cool

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/ErrorPreview.cpp'
2--- dash/previews/ErrorPreview.cpp 2013-09-19 16:44:03 +0000
3+++ dash/previews/ErrorPreview.cpp 2014-06-17 18:24:39 +0000
4@@ -50,6 +50,13 @@
5 {
6 nux::logging::Logger logger("unity.dash.previews.ErrorPreview");
7
8+const RawPixel TITLE_DATA_MAX_SIZE = 76_em;
9+const RawPixel TITLE_DATA_CHILDREN_SPACE = 10_em;
10+const RawPixel LINE_SPACING = 10_em;
11+const RawPixel TITLE_MAX_WIDTH = 480_em;
12+const RawPixel CHILDREN_SPACE = 5_em;
13+const RawPixel BUTTONS_DATA_SPACE = 20_em;
14+const RawPixel INTRO_SPACE = 110_em;
15 }
16
17 const std::string ErrorPreview::CANCEL_ACTION = "cancel";
18@@ -73,6 +80,9 @@
19 {
20 PaymentPreview::SetupBackground();
21 SetupViews();
22+
23+ UpdateScale(scale);
24+ scale.changed.connect(sigc::mem_fun(this, &ErrorPreview::UpdateScale));
25 }
26
27 ErrorPreview::~ErrorPreview()
28@@ -114,6 +124,7 @@
29 for (dash::Preview::ActionPtr action : preview_model_->GetActions())
30 {
31 nux::ObjectPtr<ActionButton> button = this->CreateButton(action);
32+ button->scale = scale();
33 button->activate.connect(sigc::mem_fun(this, &ErrorPreview::OnActionActivated));
34 buttons_map_.insert(std::make_pair(action->id, button));
35 }
36@@ -123,8 +134,8 @@
37 {
38 previews::Style& style = dash::previews::Style::Instance();
39 nux::VLayout* title_data_layout = new nux::VLayout();
40- title_data_layout->SetMaximumHeight(76);
41- title_data_layout->SetSpaceBetweenChildren(10);
42+ title_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale));
43+ title_data_layout->SetSpaceBetweenChildren(TITLE_DATA_CHILDREN_SPACE.CP(scale));
44
45 title_ = new StaticCairoText(
46 preview_model_->title.Get(), true,
47@@ -133,7 +144,7 @@
48 title_->SetFont(style.payment_title_font());
49 title_->SetLines(-1);
50 title_->SetFont(style.title_font());
51- title_->SetMaximumWidth(480);
52+ title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
53 title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
54 title_data_layout->AddView(title_.GetPointer(), 1);
55
56@@ -151,9 +162,9 @@
57 {
58 previews::Style& style = dash::previews::Style::Instance();
59 nux::VLayout *prize_data_layout = new nux::VLayout();
60- prize_data_layout->SetMaximumHeight(76);
61- prize_data_layout->SetSpaceBetweenChildren(5);
62- prize_data_layout->SetPadding(0, 10, 0, 0);
63+ prize_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale));
64+ prize_data_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
65+ prize_data_layout->SetPadding(0, TITLE_DATA_CHILDREN_SPACE.CP(scale), 0, 0);
66
67 purchase_prize_ = new StaticCairoText(
68 error_preview_model_->purchase_prize.Get(), true,
69@@ -188,16 +199,17 @@
70 nux::HLayout *intro_layout = new nux::HLayout();
71 nux::VLayout *icon_layout = new nux::VLayout();
72
73- icon_layout->SetPadding(78, 10, 90, 43);
74- intro_layout->SetPadding(75, 20, 0, 0);
75- intro_layout->SetSpaceBetweenChildren(5);
76+ icon_layout->SetPadding((78_em).CP(scale), (10_em).CP(scale), (90_em).CP(scale), (43_em).CP(scale));
77+ intro_layout->SetPadding((75_em).CP(scale), (20_em).CP(scale), 0, 0);
78+ intro_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
79
80 intro_ = new StaticCairoText(
81 error_preview_model_->header.Get(), true,
82 NUX_TRACKER_LOCATION);
83 intro_->SetFont(style.payment_intro_font().c_str());
84+ intro_->SetScale(scale);
85 intro_->SetLines(-3);
86- intro_->SetLineSpacing(10);
87+ intro_->SetLineSpacing(LINE_SPACING.CP(scale));
88 intro_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
89
90 intro_layout->AddView(intro_.GetPointer());//, 0, nux::MINOR_POSITION_CENTER);
91@@ -220,9 +232,9 @@
92 actions_buffer_h->AddSpace(0, 1);
93
94 nux::HLayout* buttons_data_layout = new TabIteratorHLayout(tab_iterator_);
95- buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());
96+ buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
97
98- buttons_data_layout->AddSpace(20, 1);
99+ buttons_data_layout->AddSpace(BUTTONS_DATA_SPACE.CP(scale), 1);
100 if(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer()){
101 ActionButton* button = (ActionButton*)buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer();
102 buttons_data_layout->AddView(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer(),
103@@ -249,11 +261,11 @@
104
105 previews::Style& style = dash::previews::Style::Instance();
106
107- int width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
108+ int width = std::max(0, geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale));
109
110 if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); }
111 if(header_layout_) { header_layout_->SetMaximumWidth(width); }
112- if(intro_) { intro_->SetMaximumWidth(width - 110); }
113+ if(intro_) { intro_->SetMaximumWidth(width - INTRO_SPACE.CP(scale)); }
114 if(footer_layout_) { footer_layout_->SetMaximumWidth(width); }
115
116 Preview::PreLayoutManagement();
117@@ -274,6 +286,33 @@
118 PaymentPreview::SetupViews();
119 }
120
121+void ErrorPreview::UpdateScale(double scale)
122+{
123+ if (intro_)
124+ intro_->SetScale(scale);
125+
126+ if (purchase_hint_)
127+ purchase_hint_->SetScale(scale);
128+ if (purchase_prize_)
129+ purchase_prize_->SetScale(scale);
130+ if (purchase_type_)
131+ purchase_type_->SetScale(scale);
132+
133+ if (warning_texture_)
134+ {
135+ previews::Style& style = dash::previews::Style::Instance();
136+ RawPixel width(style.GetWarningIcon()->GetWidth());
137+ RawPixel height(style.GetWarningIcon()->GetHeight());
138+
139+ warning_texture_->SetSize(std::max(width, height).CP(scale));
140+ warning_texture_->ReLoadIcon();
141+ }
142+
143+ if (title_)
144+ title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
145+
146+ Preview::UpdateScale(scale);
147+}
148
149 }
150 }
151
152=== modified file 'dash/previews/ErrorPreview.h'
153--- dash/previews/ErrorPreview.h 2013-09-19 16:44:03 +0000
154+++ dash/previews/ErrorPreview.h 2014-06-17 18:24:39 +0000
155@@ -94,6 +94,8 @@
156 void PreLayoutManagement();
157
158 virtual void SetupViews();
159+ virtual void UpdateScale(double scale);
160+
161 // content elements
162 nux::ObjectPtr<CoverArt> image_;
163 nux::ObjectPtr<StaticCairoText> intro_;