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

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

Issue 2692923011: [Payments] Adjust the UI fit the mocks better (Closed)
Patch Set: adds ascii art Created 3 years, 10 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/payment_request_sheet_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
6 6
7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
9 #include "components/strings/grit/components_strings.h" 9 #include "components/strings/grit/components_strings.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/views/background.h" 11 #include "ui/views/background.h"
12 #include "ui/views/controls/button/md_text_button.h" 12 #include "ui/views/controls/button/md_text_button.h"
13 #include "ui/views/layout/box_layout.h" 13 #include "ui/views/layout/box_layout.h"
14 #include "ui/views/layout/grid_layout.h" 14 #include "ui/views/layout/grid_layout.h"
15 15
16
17 namespace payments { 16 namespace payments {
18 17
19 PaymentRequestSheetController::PaymentRequestSheetController( 18 PaymentRequestSheetController::PaymentRequestSheetController(
20 PaymentRequest* request, PaymentRequestDialogView* dialog) 19 PaymentRequest* request, PaymentRequestDialogView* dialog)
21 : request_(request), dialog_(dialog) { 20 : request_(request), dialog_(dialog) {
22 } 21 }
23 22
24 std::unique_ptr<views::Button> 23 std::unique_ptr<views::Button>
25 PaymentRequestSheetController::CreatePrimaryButton() { 24 PaymentRequestSheetController::CreatePrimaryButton() {
26 return nullptr; 25 return nullptr;
(...skipping 20 matching lines...) Expand all
47 std::unique_ptr<views::View> view = base::MakeUnique<views::View>(); 46 std::unique_ptr<views::View> view = base::MakeUnique<views::View>();
48 view->set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); 47 view->set_background(views::Background::CreateSolidBackground(SK_ColorWHITE));
49 48
50 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a 49 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a
51 // layer) won't do proper clipping. 50 // layer) won't do proper clipping.
52 view->SetPaintToLayer(); 51 view->SetPaintToLayer();
53 52
54 views::GridLayout* layout = new views::GridLayout(view.get()); 53 views::GridLayout* layout = new views::GridLayout(view.get());
55 view->SetLayoutManager(layout); 54 view->SetLayoutManager(layout);
56 55
57 constexpr int kTopInsetSize = 9; 56 // Note: each view is responsible for its own padding (insets).
58 constexpr int kBottomInsetSize = 18;
59 layout->SetInsets(kTopInsetSize, 0, kBottomInsetSize, 0);
60 views::ColumnSet* columns = layout->AddColumnSet(0); 57 views::ColumnSet* columns = layout->AddColumnSet(0);
61 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 58 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
62 1, views::GridLayout::USE_PREF, 0, 0); 59 1, views::GridLayout::USE_PREF, 0, 0);
63 60
64 layout->StartRow(0, 0); 61 layout->StartRow(0, 0);
65 // |header_view| will be deleted when |view| is. 62 // |header_view| will be deleted when |view| is.
66 layout->AddView(header_view.release()); 63 layout->AddView(header_view.release());
67 64
68 layout->StartRow(0, 0); 65 layout->StartRow(0, 0);
69 // |content_view| will be deleted when |view| is. 66 // |content_view| will be deleted when |view| is.
(...skipping 12 matching lines...) Expand all
82 views::GridLayout* layout = new views::GridLayout(container.get()); 79 views::GridLayout* layout = new views::GridLayout(container.get());
83 container->SetLayoutManager(layout); 80 container->SetLayoutManager(layout);
84 81
85 views::ColumnSet* columns = layout->AddColumnSet(0); 82 views::ColumnSet* columns = layout->AddColumnSet(0);
86 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 83 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
87 0, views::GridLayout::USE_PREF, 0, 0); 84 0, views::GridLayout::USE_PREF, 0, 0);
88 columns->AddPaddingColumn(1, 0); 85 columns->AddPaddingColumn(1, 0);
89 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 86 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
90 0, views::GridLayout::USE_PREF, 0, 0); 87 0, views::GridLayout::USE_PREF, 0, 0);
91 88
89 // The horizontal distance between the right/left edges of the dialog and the
90 // elements.
91 constexpr int kFooterHorizontalInset = 16;
92 // The vertical distance between footer elements and the top/bottom border
93 // (the bottom border is the edge of the dialog).
94 constexpr int kFooterVerticalInset = 16;
95 layout->SetInsets(kFooterVerticalInset, kFooterHorizontalInset,
96 kFooterVerticalInset, kFooterHorizontalInset);
97
92 layout->StartRow(0, 0); 98 layout->StartRow(0, 0);
93 std::unique_ptr<views::View> leading_buttons_container =
94 base::MakeUnique<views::View>();
95 99
96 // TODO(anthonyvd): Add the other buttons that can eventually go into this 100 layout->AddView(CreateLeadingFooterView().release());
97 // footer.
98
99 layout->AddView(leading_buttons_container.release());
100 101
101 std::unique_ptr<views::View> trailing_buttons_container = 102 std::unique_ptr<views::View> trailing_buttons_container =
102 base::MakeUnique<views::View>(); 103 base::MakeUnique<views::View>();
103 104
104 constexpr int kButtonSpacing = 10; 105 constexpr int kButtonSpacing = 10;
105 trailing_buttons_container->SetLayoutManager(new views::BoxLayout( 106 trailing_buttons_container->SetLayoutManager(new views::BoxLayout(
106 views::BoxLayout::kHorizontal, 107 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing));
107 kPaymentRequestRowHorizontalInsets,
108 kPaymentRequestRowVerticalInsets,
109 kButtonSpacing));
110 108
111 std::unique_ptr<views::Button> primary_button = CreatePrimaryButton(); 109 std::unique_ptr<views::Button> primary_button = CreatePrimaryButton();
112 if (primary_button) 110 if (primary_button)
113 trailing_buttons_container->AddChildView(primary_button.release()); 111 trailing_buttons_container->AddChildView(primary_button.release());
114 112
115 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 113 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
116 this, l10n_util::GetStringUTF16(IDS_CANCEL)); 114 this, l10n_util::GetStringUTF16(IDS_CANCEL));
117 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG)); 115 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG));
118 trailing_buttons_container->AddChildView(button); 116 trailing_buttons_container->AddChildView(button);
119 117
120 layout->AddView(trailing_buttons_container.release()); 118 layout->AddView(trailing_buttons_container.release());
121 119
122 return container; 120 return container;
123 } 121 }
124 122
123 std::unique_ptr<views::View>
124 PaymentRequestSheetController::CreateLeadingFooterView() {
125 return base::MakeUnique<views::View>();
126 }
127
125 } // namespace payments 128 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698