Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/font_list.h" | 23 #include "ui/gfx/font_list.h" |
| 24 #include "ui/gfx/geometry/insets.h" | 24 #include "ui/gfx/geometry/insets.h" |
| 25 #include "ui/gfx/geometry/point_f.h" | 25 #include "ui/gfx/geometry/point_f.h" |
| 26 #include "ui/gfx/paint_vector_icon.h" | 26 #include "ui/gfx/paint_vector_icon.h" |
| 27 #include "ui/vector_icons/vector_icons.h" | 27 #include "ui/vector_icons/vector_icons.h" |
| 28 #include "ui/views/border.h" | 28 #include "ui/views/border.h" |
| 29 #include "ui/views/bubble/bubble_frame_view.h" | 29 #include "ui/views/bubble/bubble_frame_view.h" |
| 30 #include "ui/views/controls/button/button.h" | 30 #include "ui/views/controls/button/button.h" |
| 31 #include "ui/views/controls/button/vector_icon_button.h" | 31 #include "ui/views/controls/button/image_button.h" |
| 32 #include "ui/views/controls/button/image_button_util.h" | |
| 32 #include "ui/views/controls/image_view.h" | 33 #include "ui/views/controls/image_view.h" |
| 33 #include "ui/views/controls/label.h" | 34 #include "ui/views/controls/label.h" |
| 34 #include "ui/views/controls/styled_label.h" | 35 #include "ui/views/controls/styled_label.h" |
| 35 #include "ui/views/layout/box_layout.h" | 36 #include "ui/views/layout/box_layout.h" |
| 36 #include "ui/views/layout/grid_layout.h" | 37 #include "ui/views/layout/grid_layout.h" |
| 37 #include "ui/views/painter.h" | 38 #include "ui/views/painter.h" |
| 38 #include "ui/views/view.h" | 39 #include "ui/views/view.h" |
| 39 | 40 |
| 40 namespace payments { | 41 namespace payments { |
| 41 | 42 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 | 117 |
| 117 private: | 118 private: |
| 118 DISALLOW_COPY_AND_ASSIGN(PaymentRequestRowBorderPainter); | 119 DISALLOW_COPY_AND_ASSIGN(PaymentRequestRowBorderPainter); |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 } // namespace | 122 } // namespace |
| 122 | 123 |
| 123 std::unique_ptr<views::View> CreateSheetHeaderView( | 124 std::unique_ptr<views::View> CreateSheetHeaderView( |
| 124 bool show_back_arrow, | 125 bool show_back_arrow, |
| 125 const base::string16& title, | 126 const base::string16& title, |
| 126 views::VectorIconButtonDelegate* delegate) { | 127 views::ButtonListener* listener) { |
| 127 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); | 128 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); |
| 128 views::GridLayout* layout = new views::GridLayout(container.get()); | 129 views::GridLayout* layout = new views::GridLayout(container.get()); |
| 129 container->SetLayoutManager(layout); | 130 container->SetLayoutManager(layout); |
| 130 | 131 |
| 131 constexpr int kHeaderTopVerticalInset = 14; | 132 constexpr int kHeaderTopVerticalInset = 14; |
| 132 constexpr int kHeaderBottomVerticalInset = 8; | 133 constexpr int kHeaderBottomVerticalInset = 8; |
| 133 constexpr int kHeaderHorizontalInset = 16; | 134 constexpr int kHeaderHorizontalInset = 16; |
| 134 // Top, left, bottom, right. | 135 // Top, left, bottom, right. |
| 135 layout->SetInsets(kHeaderTopVerticalInset, kHeaderHorizontalInset, | 136 layout->SetInsets(kHeaderTopVerticalInset, kHeaderHorizontalInset, |
| 136 kHeaderBottomVerticalInset, kHeaderHorizontalInset); | 137 kHeaderBottomVerticalInset, kHeaderHorizontalInset); |
| 137 | 138 |
| 138 views::ColumnSet* columns = layout->AddColumnSet(0); | 139 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 139 // A column for the optional back arrow. | 140 // A column for the optional back arrow. |
| 140 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 141 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
| 141 0, views::GridLayout::USE_PREF, 0, 0); | 142 0, views::GridLayout::USE_PREF, 0, 0); |
| 142 | 143 |
| 143 constexpr int kPaddingBetweenArrowAndTitle = 16; | 144 constexpr int kPaddingBetweenArrowAndTitle = 16; |
| 144 if (show_back_arrow) | 145 if (show_back_arrow) |
| 145 columns->AddPaddingColumn(0, kPaddingBetweenArrowAndTitle); | 146 columns->AddPaddingColumn(0, kPaddingBetweenArrowAndTitle); |
| 146 | 147 |
| 147 // A column for the title. | 148 // A column for the title. |
| 148 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 149 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 149 1, views::GridLayout::USE_PREF, 0, 0); | 150 1, views::GridLayout::USE_PREF, 0, 0); |
| 150 | 151 |
| 151 layout->StartRow(0, 0); | 152 layout->StartRow(0, 0); |
| 152 if (!show_back_arrow) { | 153 if (!show_back_arrow) { |
| 153 layout->SkipColumns(1); | 154 layout->SkipColumns(1); |
| 154 } else { | 155 } else { |
| 155 views::VectorIconButton* back_arrow = new views::VectorIconButton(delegate); | 156 views::ImageButton* back_arrow = |
| 156 back_arrow->SetIcon(ui::kBackArrowIcon); | 157 views::CreateImageButtonWithVectorIconStyling(listener); |
| 158 views::SetImageFromVectorIcon(back_arrow, ui::kBackArrowIcon, | |
| 159 SK_ColorBLACK); | |
|
Evan Stade
2017/03/17 13:54:44
nit: black is technically wrong here although in p
Bret
2017/03/17 23:41:41
It was using black before, by way of VectorIconBut
| |
| 157 constexpr int kBackArrowSize = 16; | 160 constexpr int kBackArrowSize = 16; |
| 158 back_arrow->SetSize(gfx::Size(kBackArrowSize, kBackArrowSize)); | 161 back_arrow->SetSize(gfx::Size(kBackArrowSize, kBackArrowSize)); |
| 159 back_arrow->set_tag(static_cast<int>( | 162 back_arrow->set_tag(static_cast<int>( |
| 160 PaymentRequestCommonTags::BACK_BUTTON_TAG)); | 163 PaymentRequestCommonTags::BACK_BUTTON_TAG)); |
| 161 layout->AddView(back_arrow); | 164 layout->AddView(back_arrow); |
| 162 } | 165 } |
| 163 | 166 |
| 164 views::Label* title_label = new views::Label(title); | 167 views::Label* title_label = new views::Label(title); |
| 165 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 168 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 166 title_label->SetFontList( | 169 title_label->SetFontList( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 if (shipping_option) { | 294 if (shipping_option) { |
| 292 container->AddChildView( | 295 container->AddChildView( |
| 293 new views::Label(base::ASCIIToUTF16(shipping_option->label))); | 296 new views::Label(base::ASCIIToUTF16(shipping_option->label))); |
| 294 container->AddChildView(new views::Label(formatted_amount)); | 297 container->AddChildView(new views::Label(formatted_amount)); |
| 295 } | 298 } |
| 296 | 299 |
| 297 return container; | 300 return container; |
| 298 } | 301 } |
| 299 | 302 |
| 300 } // namespace payments | 303 } // namespace payments |
| OLD | NEW |