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/app_list_constants.h" | 7 #include "ui/app_list/app_list_constants.h" |
8 #include "ui/app_list/views/contents_view.h" | 8 #include "ui/app_list/views/contents_view.h" |
9 #include "ui/views/background.h" | 9 #include "ui/views/background.h" |
10 #include "ui/views/controls/button/custom_button.h" | 10 #include "ui/views/controls/button/custom_button.h" |
11 #include "ui/views/controls/button/image_button.h" | 11 #include "ui/views/controls/button/image_button.h" |
12 #include "ui/views/layout/box_layout.h" | 12 #include "ui/views/layout/box_layout.h" |
13 #include "ui/views/layout/fill_layout.h" | 13 #include "ui/views/layout/fill_layout.h" |
14 | 14 |
15 namespace app_list { | 15 namespace app_list { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int kButtonImageSize = 32; | |
20 const int kButtonSpacing = 4; | 19 const int kButtonSpacing = 4; |
21 const int kMinimumHeight = 39; | 20 const int kMinimumHeight = 39; |
22 | 21 |
23 class ContentsPageIndicatorView : public views::View { | 22 class ContentsPageIndicatorView : public views::View { |
24 public: | 23 public: |
25 ContentsPageIndicatorView() {}; | 24 ContentsPageIndicatorView() {}; |
26 virtual ~ContentsPageIndicatorView() {}; | 25 virtual ~ContentsPageIndicatorView() {}; |
27 | 26 |
28 // Overridden from views::View: | 27 // Overridden from views::View: |
29 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 28 virtual gfx::Size GetPreferredSize() const OVERRIDE { |
(...skipping 12 matching lines...) Expand all Loading... |
42 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing); | 41 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing); |
43 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 42 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
44 layout->set_minimum_cross_axis_size(kMinimumHeight); | 43 layout->set_minimum_cross_axis_size(kMinimumHeight); |
45 SetLayoutManager(layout); | 44 SetLayoutManager(layout); |
46 } | 45 } |
47 | 46 |
48 ContentsSwitcherView::~ContentsSwitcherView() {} | 47 ContentsSwitcherView::~ContentsSwitcherView() {} |
49 | 48 |
50 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int page_index) { | 49 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int page_index) { |
51 views::ImageButton* button = new views::ImageButton(this); | 50 views::ImageButton* button = new views::ImageButton(this); |
52 button->SetPreferredSize(gfx::Size(kButtonImageSize, kButtonImageSize)); | 51 button->SetImage( |
53 if (resource_id) { | 52 views::CustomButton::STATE_NORMAL, |
54 button->SetImage( | 53 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); |
55 views::CustomButton::STATE_NORMAL, | |
56 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); | |
57 } | |
58 button->set_tag(page_index); | 54 button->set_tag(page_index); |
59 | 55 |
60 // Add an indicator for the current launcher page. | 56 // Add an indicator for the current launcher page. |
61 app_list::ContentsPageIndicatorView* indicator = | 57 app_list::ContentsPageIndicatorView* indicator = |
62 new app_list::ContentsPageIndicatorView(); | 58 new app_list::ContentsPageIndicatorView(); |
63 indicator->set_background( | 59 indicator->set_background( |
64 views::Background::CreateSolidBackground(app_list::kPagerSelectedColor)); | 60 views::Background::CreateSolidBackground(app_list::kPagerSelectedColor)); |
65 indicator->SetVisible(false); | 61 indicator->SetVisible(false); |
66 page_active_indicators_[page_index] = indicator; | 62 page_active_indicators_[page_index] = indicator; |
67 | 63 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (pm.IsRevertingCurrentTransition()) { | 111 if (pm.IsRevertingCurrentTransition()) { |
116 // Swap the direction if the transition is reversed. | 112 // Swap the direction if the transition is reversed. |
117 old_selected = pm.transition().target_page; | 113 old_selected = pm.transition().target_page; |
118 new_selected = pm.selected_page(); | 114 new_selected = pm.selected_page(); |
119 } | 115 } |
120 | 116 |
121 SelectedPageChanged(old_selected, new_selected); | 117 SelectedPageChanged(old_selected, new_selected); |
122 } | 118 } |
123 | 119 |
124 } // namespace app_list | 120 } // namespace app_list |
OLD | NEW |