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 "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
9 #include "ui/app_list/views/contents_view.h" | 9 #include "ui/app_list/views/contents_view.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/views/controls/button/custom_button.h" | 11 #include "ui/views/controls/button/custom_button.h" |
12 #include "ui/views/controls/button/image_button.h" | 12 #include "ui/views/controls/button/image_button.h" |
13 #include "ui/views/layout/box_layout.h" | 13 #include "ui/views/layout/box_layout.h" |
14 | 14 |
15 namespace app_list { | 15 namespace app_list { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int kPreferredHeight = 32; | 19 const int kPreferredHeight = 32; |
20 const int kButtonSpacing = 4; | 20 const int kButtonSpacing = 4; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 ContentsSwitcherView::ContentsSwitcherView(ContentsView* contents_view) | 24 ContentsSwitcherView::ContentsSwitcherView(ContentsView* contents_view) |
25 : contents_view_(contents_view), buttons_(new views::View) { | 25 : contents_view_(contents_view), buttons_(new views::View) { |
26 AddChildView(buttons_); | 26 AddChildView(buttons_); |
27 | 27 |
28 buttons_->SetLayoutManager(new views::BoxLayout( | 28 buttons_->SetLayoutManager(new views::BoxLayout( |
29 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); | 29 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); |
30 AddSwitcherButton(IDR_APP_LIST_SEARCH_ICON, | 30 AddSwitcherButton(IDR_APP_LIST_SEARCH_ICON, ContentsView::SHOW_START_PAGE); |
31 ContentsView::SHOW_SEARCH_RESULTS); | |
32 AddSwitcherButton(IDR_APP_LIST_APPS_ICON, ContentsView::SHOW_APPS); | 31 AddSwitcherButton(IDR_APP_LIST_APPS_ICON, ContentsView::SHOW_APPS); |
33 } | 32 } |
34 | 33 |
35 ContentsSwitcherView::~ContentsSwitcherView() {} | 34 ContentsSwitcherView::~ContentsSwitcherView() {} |
36 | 35 |
37 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int tag) { | 36 void ContentsSwitcherView::AddSwitcherButton(int resource_id, int tag) { |
38 views::ImageButton* button = new views::ImageButton(this); | 37 views::ImageButton* button = new views::ImageButton(this); |
39 button->SetImage( | 38 button->SetImage( |
40 views::CustomButton::STATE_NORMAL, | 39 views::CustomButton::STATE_NORMAL, |
41 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); | 40 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); |
(...skipping 17 matching lines...) Expand all Loading... |
59 buttons_->SetBoundsRect(gfx::IntersectRects(rect, buttons_bounds)); | 58 buttons_->SetBoundsRect(gfx::IntersectRects(rect, buttons_bounds)); |
60 } | 59 } |
61 | 60 |
62 void ContentsSwitcherView::ButtonPressed(views::Button* sender, | 61 void ContentsSwitcherView::ButtonPressed(views::Button* sender, |
63 const ui::Event& event) { | 62 const ui::Event& event) { |
64 contents_view_->SetShowState( | 63 contents_view_->SetShowState( |
65 static_cast<ContentsView::ShowState>(sender->tag())); | 64 static_cast<ContentsView::ShowState>(sender->tag())); |
66 } | 65 } |
67 | 66 |
68 } // namespace app_list | 67 } // namespace app_list |
OLD | NEW |