Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/ui/views/payments/editor_view_controller.cc

Issue 2882463002: [Web Payments] UI tweaks to desktop editors (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/payments/editor_view_controller.h" 5 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 // An editor can optionally have a header view specific to it. 127 // An editor can optionally have a header view specific to it.
128 std::unique_ptr<views::View> header_view = CreateHeaderView(); 128 std::unique_ptr<views::View> header_view = CreateHeaderView();
129 if (header_view.get()) 129 if (header_view.get())
130 content_view->AddChildView(header_view.release()); 130 content_view->AddChildView(header_view.release());
131 131
132 // The heart of the editor dialog: all the input fields with their labels. 132 // The heart of the editor dialog: all the input fields with their labels.
133 content_view->AddChildView(CreateEditorView().release()); 133 content_view->AddChildView(CreateEditorView().release());
134 } 134 }
135 135
136 // Adds the "required fields" label in disabled text, to obtain this result. 136 base::string16 EditorViewController::GetSecondaryButtonLabel() {
137 // +---------------------------------------------------------+ 137 return l10n_util::GetStringUTF16(IDS_PAYMENTS_CANCEL_PAYMENT);
138 // | "* indicates required fields" | CANCEL | DONE |
139 // +---------------------------------------------------------+
140 std::unique_ptr<views::View> EditorViewController::CreateExtraFooterView() {
141 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
142
143 views::BoxLayout* layout =
144 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
145 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
146 layout->set_cross_axis_alignment(
147 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
148 content_view->SetLayoutManager(layout);
149
150 // Adds the "* indicates a required field" label in "disabled" grey text.
151 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(
152 l10n_util::GetStringUTF16(IDS_PAYMENTS_REQUIRED_FIELD_MESSAGE));
153 label->SetDisabledColor(label->GetNativeTheme()->GetSystemColor(
154 ui::NativeTheme::kColorId_LabelDisabledColor));
155 label->SetEnabled(false);
156 content_view->AddChildView(label.release());
157 return content_view;
158 } 138 }
159 139
160 void EditorViewController::UpdateEditorView() { 140 void EditorViewController::UpdateEditorView() {
161 UpdateContentView(); 141 UpdateContentView();
162 // TODO(crbug.com/704254): Find how to update the parent view bounds so that 142 // TODO(crbug.com/704254): Find how to update the parent view bounds so that
163 // the vertical scrollbar size gets updated. 143 // the vertical scrollbar size gets updated.
164 dialog()->EditorViewUpdated(); 144 dialog()->EditorViewUpdated();
165 } 145 }
166 146
167 void EditorViewController::ButtonPressed(views::Button* sender, 147 void EditorViewController::ButtonPressed(views::Button* sender,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, 197 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0,
218 views::GridLayout::USE_PREF, 0, 0); 198 views::GridLayout::USE_PREF, 0, 0);
219 199
220 // This is the horizontal padding between the label and the input field. 200 // This is the horizontal padding between the label and the input field.
221 constexpr int kLabelInputFieldHorizontalPadding = 16; 201 constexpr int kLabelInputFieldHorizontalPadding = 16;
222 columns->AddPaddingColumn(0, kLabelInputFieldHorizontalPadding); 202 columns->AddPaddingColumn(0, kLabelInputFieldHorizontalPadding);
223 203
224 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, 204 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0,
225 views::GridLayout::USE_PREF, 0, 0); 205 views::GridLayout::USE_PREF, 0, 0);
226 206
227 editor_view->SetLayoutManager(editor_layout.release());
228 std::vector<EditorField> fields = GetFieldDefinitions(); 207 std::vector<EditorField> fields = GetFieldDefinitions();
229 for (const auto& field : fields) { 208 for (const auto& field : fields) {
Mathieu 2017/05/11 18:15:14 no curlz
anthonyvd 2017/05/11 21:21:50 Done.
230 CreateInputField( 209 CreateInputField(editor_layout.get(), field);
231 static_cast<views::GridLayout*>(editor_view->GetLayoutManager()),
232 field);
233 } 210 }
234 211
212 // Adds the "* indicates a required field" label in "disabled" grey text.
213 std::unique_ptr<views::Label> required_field = base::MakeUnique<views::Label>(
214 l10n_util::GetStringUTF16(IDS_PAYMENTS_REQUIRED_FIELD_MESSAGE));
215 required_field->SetDisabledColor(
216 required_field->GetNativeTheme()->GetSystemColor(
217 ui::NativeTheme::kColorId_LabelDisabledColor));
218 required_field->SetEnabled(false);
219
220 views::ColumnSet* required_field_columns = editor_layout->AddColumnSet(1);
Mathieu 2017/05/11 18:15:14 I think you'll need a big rebase
anthonyvd 2017/05/11 21:21:50 Done.
221 required_field_columns->AddColumn(views::GridLayout::LEADING,
222 views::GridLayout::CENTER, 1,
223 views::GridLayout::USE_PREF, 0, 0);
224 editor_layout->StartRow(0, 1);
225 editor_layout->AddView(required_field.release());
226
227 editor_view->SetLayoutManager(editor_layout.release());
228
235 return editor_view; 229 return editor_view;
236 } 230 }
237 231
238 // Each input field is a 4-quadrant grid. 232 // Each input field is a 4-quadrant grid.
239 // +----------------------------------------------------------+ 233 // +----------------------------------------------------------+
240 // | Field Label | Input field (textfield/combobox) | 234 // | Field Label | Input field (textfield/combobox) |
241 // |_______________________|__________________________________| 235 // |_______________________|__________________________________|
242 // | (empty) | Error label | 236 // | (empty) | Error label |
243 // +----------------------------------------------------------+ 237 // +----------------------------------------------------------+
244 void EditorViewController::CreateInputField(views::GridLayout* layout, 238 void EditorViewController::CreateInputField(views::GridLayout* layout,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 base::MakeUnique<views::View>(); 293 base::MakeUnique<views::View>();
300 error_label_view->SetLayoutManager(new views::FillLayout); 294 error_label_view->SetLayoutManager(new views::FillLayout);
301 error_labels_[field] = error_label_view.get(); 295 error_labels_[field] = error_label_view.get();
302 layout->AddView(error_label_view.release()); 296 layout->AddView(error_label_view.release());
303 297
304 // Bottom padding for the row. 298 // Bottom padding for the row.
305 layout->AddPaddingRow(0, kInputRowSpacing); 299 layout->AddPaddingRow(0, kInputRowSpacing);
306 } 300 }
307 301
308 } // namespace payments 302 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/editor_view_controller.h ('k') | components/payments_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698