| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_views_util.h" | 5 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 namespace payments { | 82 namespace payments { |
| 83 | 83 |
| 84 std::unique_ptr<views::View> CreateSheetHeaderView( | 84 std::unique_ptr<views::View> CreateSheetHeaderView( |
| 85 bool show_back_arrow, | 85 bool show_back_arrow, |
| 86 const base::string16& title, | 86 const base::string16& title, |
| 87 views::VectorIconButtonDelegate* delegate) { | 87 views::VectorIconButtonDelegate* delegate) { |
| 88 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); | 88 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); |
| 89 views::GridLayout* layout = new views::GridLayout(container.get()); | 89 views::GridLayout* layout = new views::GridLayout(container.get()); |
| 90 container->SetLayoutManager(layout); | 90 container->SetLayoutManager(layout); |
| 91 layout->SetInsets(0, kPaymentRequestRowHorizontalInsets, | 91 |
| 92 0, kPaymentRequestRowHorizontalInsets); | 92 constexpr int kHeaderTopVerticalInset = 14; |
| 93 constexpr int kHeaderBottomVerticalInset = 8; |
| 94 constexpr int kHeaderHorizontalInset = 16; |
| 95 // Top, left, bottom, right. |
| 96 layout->SetInsets(kHeaderTopVerticalInset, kHeaderHorizontalInset, |
| 97 kHeaderBottomVerticalInset, kHeaderHorizontalInset); |
| 93 | 98 |
| 94 views::ColumnSet* columns = layout->AddColumnSet(0); | 99 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 95 // A column for the optional back arrow. | 100 // A column for the optional back arrow. |
| 96 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 101 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
| 97 0, views::GridLayout::USE_PREF, 0, 0); | 102 0, views::GridLayout::USE_PREF, 0, 0); |
| 103 |
| 104 constexpr int kPaddingBetweenArrowAndTitle = 16; |
| 105 if (show_back_arrow) |
| 106 columns->AddPaddingColumn(0, kPaddingBetweenArrowAndTitle); |
| 107 |
| 98 // A column for the title. | 108 // A column for the title. |
| 99 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 109 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 100 1, views::GridLayout::USE_PREF, 0, 0); | 110 1, views::GridLayout::USE_PREF, 0, 0); |
| 101 | 111 |
| 102 layout->StartRow(0, 0); | 112 layout->StartRow(0, 0); |
| 103 if (!show_back_arrow) { | 113 if (!show_back_arrow) { |
| 104 layout->SkipColumns(1); | 114 layout->SkipColumns(1); |
| 105 } else { | 115 } else { |
| 106 views::VectorIconButton* back_arrow = new views::VectorIconButton(delegate); | 116 views::VectorIconButton* back_arrow = new views::VectorIconButton(delegate); |
| 107 back_arrow->SetIcon(ui::kBackArrowIcon); | 117 back_arrow->SetIcon(ui::kBackArrowIcon); |
| 108 back_arrow->SetSize(back_arrow->GetPreferredSize()); | 118 constexpr int kBackArrowSize = 16; |
| 119 back_arrow->SetSize(gfx::Size(kBackArrowSize, kBackArrowSize)); |
| 109 back_arrow->set_tag(static_cast<int>( | 120 back_arrow->set_tag(static_cast<int>( |
| 110 PaymentRequestCommonTags::BACK_BUTTON_TAG)); | 121 PaymentRequestCommonTags::BACK_BUTTON_TAG)); |
| 111 layout->AddView(back_arrow); | 122 layout->AddView(back_arrow); |
| 112 } | 123 } |
| 113 | 124 |
| 114 views::Label* title_label = new views::Label(title); | 125 views::Label* title_label = new views::Label(title); |
| 115 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 126 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 127 title_label->SetFontList( |
| 128 title_label->GetDefaultFontList().DeriveWithSizeDelta(2)); |
| 116 layout->AddView(title_label); | 129 layout->AddView(title_label); |
| 117 | 130 |
| 118 return container; | 131 return container; |
| 119 } | 132 } |
| 120 | 133 |
| 121 std::unique_ptr<views::ImageView> CreateCardIconView( | 134 std::unique_ptr<views::ImageView> CreateCardIconView( |
| 122 const std::string& card_type) { | 135 const std::string& card_type) { |
| 123 std::unique_ptr<views::ImageView> card_icon_view = | 136 std::unique_ptr<views::ImageView> card_icon_view = |
| 124 base::MakeUnique<views::ImageView>(); | 137 base::MakeUnique<views::ImageView>(); |
| 125 card_icon_view->set_interactive(false); | 138 card_icon_view->set_interactive(false); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 217 |
| 205 // Creates a views::Border object that can paint the gray horizontal ruler used | 218 // Creates a views::Border object that can paint the gray horizontal ruler used |
| 206 // as a separator between items in the Payment Request dialog. | 219 // as a separator between items in the Payment Request dialog. |
| 207 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { | 220 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { |
| 208 return views::CreateBorderPainter( | 221 return views::CreateBorderPainter( |
| 209 base::MakeUnique<PaymentRequestRowBorderPainter>(), | 222 base::MakeUnique<PaymentRequestRowBorderPainter>(), |
| 210 gfx::Insets()); | 223 gfx::Insets()); |
| 211 } | 224 } |
| 212 | 225 |
| 213 } // namespace payments | 226 } // namespace payments |
| OLD | NEW |