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

Unified Diff: chrome/browser/ui/views/payments/editor_view_controller.cc

Issue 2871873003: [Payments] Fix up field widths in desktop editors. (Closed)
Patch Set: using extra width 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/editor_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/editor_view_controller.cc b/chrome/browser/ui/views/payments/editor_view_controller.cc
index fa3ab44d70d1f4f7a61a4486a79ad16f0829fdcd..b700eeb6cbfe261747047fe78a848d3ad2649e29 100644
--- a/chrome/browser/ui/views/payments/editor_view_controller.cc
+++ b/chrome/browser/ui/views/payments/editor_view_controller.cc
@@ -190,16 +190,36 @@ std::unique_ptr<views::View> EditorViewController::CreateEditorView() {
editor_layout->SetInsets(0, payments::kPaymentRequestRowHorizontalInsets, 0,
payments::kPaymentRequestRowHorizontalInsets);
- views::ColumnSet* columns = editor_layout->AddColumnSet(0);
- columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0,
- views::GridLayout::USE_PREF, 0, 0);
-
+ // Column set for short fields.
+ constexpr int kLabelWidth = 140;
+ views::ColumnSet* columns_short = editor_layout->AddColumnSet(0);
+ columns_short->AddColumn(views::GridLayout::LEADING,
+ views::GridLayout::CENTER, 0,
+ views::GridLayout::FIXED, kLabelWidth, 0);
// This is the horizontal padding between the label and the input field.
constexpr int kLabelInputFieldHorizontalPadding = 16;
- columns->AddPaddingColumn(0, kLabelInputFieldHorizontalPadding);
-
- columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0,
- views::GridLayout::USE_PREF, 0, 0);
+ columns_short->AddPaddingColumn(0, kLabelInputFieldHorizontalPadding);
+ // It's possible for the dialog to get wider than the minimum, in which case
+ // we use the extra whitespace for the field width.
+ constexpr int kShortInputFieldFixedWidth = 176;
+ int short_input_width =
anthonyvd 2017/05/10 15:03:56 Ok so one last thing to simplify this code. Curren
+ kShortInputFieldFixedWidth + (GetActualDialogWidth() - kDialogMinWidth);
+ columns_short->AddColumn(views::GridLayout::LEADING,
+ views::GridLayout::CENTER, 0,
+ views::GridLayout::FIXED, short_input_width, 0);
+
+ // Column set for long fields.
+ views::ColumnSet* columns_long = editor_layout->AddColumnSet(1);
+ columns_long->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
+ 0, views::GridLayout::FIXED, kLabelWidth, 0);
+ columns_long->AddPaddingColumn(0, kLabelInputFieldHorizontalPadding);
+ // It's possible for the dialog to get wider than the minimum, in which case
+ // we use the extra whitespace for the field width.
+ constexpr int kLongInputFieldFixedWidth = 272;
+ int long_input_width =
+ kLongInputFieldFixedWidth + (GetActualDialogWidth() - kDialogMinWidth);
+ columns_long->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
+ 0, views::GridLayout::FIXED, long_input_width, 0);
// The LayoutManager needs to be set before input fields are created, so we
// keep a handle to it before we release it to the view.
@@ -220,9 +240,12 @@ std::unique_ptr<views::View> EditorViewController::CreateEditorView() {
// +----------------------------------------------------------+
void EditorViewController::CreateInputField(views::GridLayout* layout,
const EditorField& field) {
+ int column_set =
+ field.length_hint == EditorField::LengthHint::HINT_SHORT ? 0 : 1;
+
// This is the top padding for every row.
constexpr int kInputRowSpacing = 6;
- layout->StartRowWithPadding(0, 0, 0, kInputRowSpacing);
+ layout->StartRowWithPadding(0, column_set, 0, kInputRowSpacing);
std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(
field.required ? field.label + base::ASCIIToUTF16("*") : field.label);
@@ -270,7 +293,7 @@ void EditorViewController::CreateInputField(views::GridLayout* layout,
NOTREACHED();
}
- layout->StartRow(0, 0);
+ layout->StartRow(0, column_set);
layout->SkipColumns(1);
std::unique_ptr<views::View> error_label_view =
base::MakeUnique<views::View>();

Powered by Google App Engine
This is Rietveld 408576698