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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" | |
| 8 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/gfx/vector_icons/vector_icons.h" | |
| 9 #include "ui/views/background.h" | 11 #include "ui/views/background.h" |
| 12 #include "ui/views/bubble/bubble_frame_view.h" | |
| 13 #include "ui/views/controls/button/button.h" | |
| 14 #include "ui/views/controls/button/vector_icon_button.h" | |
| 10 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
| 11 #include "ui/views/layout/grid_layout.h" | 16 #include "ui/views/layout/grid_layout.h" |
| 12 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 13 | 18 |
| 19 namespace { | |
|
please use gerrit instead
2017/01/04 15:55:27
Here and elsewhere:
nit: Anonymous namespace usua
anthonyvd
2017/01/04 19:08:55
Wow I've been doing the opposite for 2 years. It l
please use gerrit instead
2017/01/04 19:17:11
Thank you. As long as we're consistent, I'm OK wit
| |
| 20 | |
| 21 constexpr int kTopInsetSize = 9; | |
| 22 constexpr int kBottomInsetSize = 18; | |
| 23 constexpr int kSideInsetSize = 14; | |
|
please use gerrit instead
2017/01/04 15:55:27
Here and elsewhere:
It's easier to read the code
anthonyvd
2017/01/04 19:08:55
Done.
| |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 14 namespace payments { | 27 namespace payments { |
| 15 | 28 |
| 29 std::unique_ptr<views::View> CreateSheetHeaderView( | |
| 30 bool show_back_arrow, | |
| 31 const base::string16& title, | |
| 32 views::VectorIconButtonDelegate* delegate) { | |
| 33 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); | |
| 34 views::GridLayout* layout = new views::GridLayout(container.get()); | |
| 35 container->SetLayoutManager(layout); | |
| 36 | |
| 37 views::ColumnSet* columns = layout->AddColumnSet(0); | |
| 38 // A column for the optional back arrow. | |
| 39 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | |
| 40 0, views::GridLayout::USE_PREF, 0, 0); | |
| 41 // A column for the title. | |
| 42 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | |
| 43 1, views::GridLayout::USE_PREF, 0, 0); | |
| 44 // A column for the close button. | |
| 45 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, | |
| 46 0, views::GridLayout::USE_PREF, 0, 0); | |
| 47 | |
| 48 layout->StartRow(0, 0); | |
| 49 if (!show_back_arrow) { | |
| 50 layout->SkipColumns(1); | |
| 51 } else { | |
| 52 views::VectorIconButton* back_arrow = new views::VectorIconButton(delegate); | |
| 53 back_arrow->SetIcon(gfx::VectorIconId::NAVIGATE_BACK); | |
| 54 back_arrow->SetSize(back_arrow->GetPreferredSize()); | |
| 55 back_arrow->set_tag(BACK_BUTTON_TAG); | |
| 56 layout->AddView(back_arrow); | |
| 57 } | |
| 58 | |
| 59 views::Label* title_label = new views::Label(title); | |
| 60 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 61 layout->AddView(title_label); | |
| 62 views::Button* close_button = | |
| 63 views::BubbleFrameView::CreateCloseButton(delegate); | |
| 64 close_button->set_tag(CLOSE_BUTTON_TAG); | |
| 65 layout->AddView(close_button); | |
| 66 | |
| 67 return container; | |
| 68 } | |
| 69 | |
| 70 | |
| 16 std::unique_ptr<views::View> CreatePaymentView( | 71 std::unique_ptr<views::View> CreatePaymentView( |
| 17 const base::string16& title, std::unique_ptr<views::View> content_view) { | 72 std::unique_ptr<views::View> header_view, |
| 73 std::unique_ptr<views::View> content_view) { | |
| 18 std::unique_ptr<views::View> view = base::MakeUnique<views::View>(); | 74 std::unique_ptr<views::View> view = base::MakeUnique<views::View>(); |
| 19 view->set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); | 75 view->set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); |
| 20 | 76 |
| 21 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a | 77 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a |
| 22 // layer) won't do proper clipping. | 78 // layer) won't do proper clipping. |
| 23 view->SetPaintToLayer(true); | 79 view->SetPaintToLayer(true); |
| 24 | 80 |
| 25 views::GridLayout* layout = new views::GridLayout(view.get()); | 81 views::GridLayout* layout = new views::GridLayout(view.get()); |
| 26 view->SetLayoutManager(layout); | 82 view->SetLayoutManager(layout); |
| 83 layout->SetInsets( | |
| 84 kTopInsetSize, kSideInsetSize, kBottomInsetSize, kSideInsetSize); | |
| 27 views::ColumnSet* columns = layout->AddColumnSet(0); | 85 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 28 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 86 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 29 1, views::GridLayout::USE_PREF, 0, 0); | 87 1, views::GridLayout::USE_PREF, 0, 0); |
| 30 | 88 |
| 31 layout->StartRow(0, 0); | 89 layout->StartRow(0, 0); |
| 32 layout->AddView(new views::Label(title)); | 90 // |header_view| will be deleted when |view| is. |
| 91 layout->AddView(header_view.release()); | |
| 33 | 92 |
| 34 layout->StartRow(0, 0); | 93 layout->StartRow(0, 0); |
| 35 // |content_view| will be deleted when |view| is. | 94 // |content_view| will be deleted when |view| is. |
| 36 layout->AddView(content_view.release()); | 95 layout->AddView(content_view.release()); |
| 37 | 96 |
| 38 return view; | 97 return view; |
| 39 } | 98 } |
| 40 | 99 |
| 41 } // namespace payments | 100 } // namespace payments |
| OLD | NEW |