OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 CreateInputField(editor_layout.get(), field, &valid); | 300 CreateInputField(editor_layout.get(), field, &valid); |
301 if (!first_field) | 301 if (!first_field) |
302 first_field = focusable_field; | 302 first_field = focusable_field; |
303 if (!initial_focus_field_view_ && !valid) | 303 if (!initial_focus_field_view_ && !valid) |
304 initial_focus_field_view_ = focusable_field; | 304 initial_focus_field_view_ = focusable_field; |
305 } | 305 } |
306 | 306 |
307 if (!initial_focus_field_view_) | 307 if (!initial_focus_field_view_) |
308 initial_focus_field_view_ = first_field; | 308 initial_focus_field_view_ = first_field; |
309 | 309 |
310 // Adds the "* indicates a required field" label in "disabled" grey text. | |
311 std::unique_ptr<views::Label> required_field = base::MakeUnique<views::Label>( | |
312 l10n_util::GetStringUTF16(IDS_PAYMENTS_REQUIRED_FIELD_MESSAGE)); | |
313 required_field->SetDisabledColor( | |
314 required_field->GetNativeTheme()->GetSystemColor( | |
315 ui::NativeTheme::kColorId_LabelDisabledColor)); | |
316 required_field->SetEnabled(false); | |
317 | |
318 views::ColumnSet* required_field_columns = editor_layout->AddColumnSet(2); | 310 views::ColumnSet* required_field_columns = editor_layout->AddColumnSet(2); |
319 required_field_columns->AddColumn(views::GridLayout::LEADING, | 311 required_field_columns->AddColumn(views::GridLayout::LEADING, |
320 views::GridLayout::CENTER, 1, | 312 views::GridLayout::CENTER, 1, |
321 views::GridLayout::USE_PREF, 0, 0); | 313 views::GridLayout::USE_PREF, 0, 0); |
322 editor_layout->StartRow(0, 2); | 314 editor_layout->StartRow(0, 2); |
323 editor_layout->AddView(required_field.release()); | 315 // Adds the "* indicates a required field" label in "disabled" grey text. |
| 316 editor_layout->AddView( |
| 317 CreateHintLabel( |
| 318 l10n_util::GetStringUTF16(IDS_PAYMENTS_REQUIRED_FIELD_MESSAGE)) |
| 319 .release()); |
324 | 320 |
325 editor_view->SetLayoutManager(editor_layout.release()); | 321 editor_view->SetLayoutManager(editor_layout.release()); |
326 | 322 |
327 return editor_view; | 323 return editor_view; |
328 } | 324 } |
329 | 325 |
330 // Each input field is a 4-quadrant grid. | 326 // Each input field is a 4-quadrant grid. |
331 // +----------------------------------------------------------+ | 327 // +----------------------------------------------------------+ |
332 // | Field Label | Input field (textfield/combobox) | | 328 // | Field Label | Input field (textfield/combobox) | |
333 // |_______________________|__________________________________| | 329 // |_______________________|__________________________________| |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 CreateExtraViewForField(field.type); | 438 CreateExtraViewForField(field.type); |
443 if (!extra_view) | 439 if (!extra_view) |
444 continue; | 440 continue; |
445 widest_column_width = | 441 widest_column_width = |
446 std::max(extra_view->GetPreferredSize().width(), widest_column_width); | 442 std::max(extra_view->GetPreferredSize().width(), widest_column_width); |
447 } | 443 } |
448 return widest_column_width; | 444 return widest_column_width; |
449 } | 445 } |
450 | 446 |
451 } // namespace payments | 447 } // namespace payments |
OLD | NEW |