OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/app_list/views/contents_switcher_view.h" | 5 #include "ui/app_list/views/contents_switcher_view.h" |
6 | 6 |
7 #include "ui/app_list/views/contents_view.h" | 7 #include "ui/app_list/views/contents_view.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/views/controls/button/custom_button.h" | 9 #include "ui/views/controls/button/custom_button.h" |
10 #include "ui/views/controls/button/image_button.h" | 10 #include "ui/views/controls/button/image_button.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing); | 25 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing); |
26 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 26 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
27 layout->set_minimum_cross_axis_size(kMinimumHeight); | 27 layout->set_minimum_cross_axis_size(kMinimumHeight); |
28 SetLayoutManager(layout); | 28 SetLayoutManager(layout); |
29 } | 29 } |
30 | 30 |
31 ContentsSwitcherView::~ContentsSwitcherView() {} | 31 ContentsSwitcherView::~ContentsSwitcherView() {} |
32 | 32 |
33 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int page_index) { | 33 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int page_index) { |
34 views::ImageButton* button = new views::ImageButton(this); | 34 views::ImageButton* button = new views::ImageButton(this); |
| 35 button->SetMinimumImageSize(gfx::Size(kMinimumHeight, kMinimumHeight)); |
| 36 button->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 37 views::ImageButton::ALIGN_MIDDLE); |
35 button->SetImage( | 38 button->SetImage( |
36 views::CustomButton::STATE_NORMAL, | 39 views::CustomButton::STATE_NORMAL, |
37 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); | 40 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); |
38 button->set_tag(page_index); | 41 button->set_tag(page_index); |
39 | 42 |
40 AddChildView(button); | 43 AddChildView(button); |
41 } | 44 } |
42 | 45 |
43 void ContentsSwitcherView::ButtonPressed(views::Button* sender, | 46 void ContentsSwitcherView::ButtonPressed(views::Button* sender, |
44 const ui::Event& event) { | 47 const ui::Event& event) { |
(...skipping 19 matching lines...) Expand all Loading... |
64 if (pm.IsRevertingCurrentTransition()) { | 67 if (pm.IsRevertingCurrentTransition()) { |
65 // Swap the direction if the transition is reversed. | 68 // Swap the direction if the transition is reversed. |
66 old_selected = pm.transition().target_page; | 69 old_selected = pm.transition().target_page; |
67 new_selected = pm.selected_page(); | 70 new_selected = pm.selected_page(); |
68 } | 71 } |
69 | 72 |
70 SelectedPageChanged(old_selected, new_selected); | 73 SelectedPageChanged(old_selected, new_selected); |
71 } | 74 } |
72 | 75 |
73 } // namespace app_list | 76 } // namespace app_list |
OLD | NEW |