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/search_result_page_view.h" | 5 #include "ui/app_list/views/search_result_page_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/app_list_switches.h" |
8 #include "ui/app_list/app_list_view_delegate.h" | 9 #include "ui/app_list/app_list_view_delegate.h" |
9 #include "ui/app_list/views/app_list_main_view.h" | 10 #include "ui/app_list/views/app_list_main_view.h" |
10 #include "ui/app_list/views/search_result_list_view.h" | 11 #include "ui/app_list/views/search_result_list_view.h" |
11 #include "ui/app_list/views/search_result_tile_item_list_view.h" | 12 #include "ui/app_list/views/search_result_tile_item_list_view.h" |
12 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
13 #include "ui/views/layout/box_layout.h" | 14 #include "ui/views/layout/box_layout.h" |
14 #include "ui/views/layout/fill_layout.h" | 15 #include "ui/views/layout/fill_layout.h" |
15 #include "ui/views/shadow_border.h" | 16 #include "ui/views/shadow_border.h" |
16 | 17 |
17 namespace app_list { | 18 namespace app_list { |
(...skipping 20 matching lines...) Expand all Loading... |
38 | 39 |
39 void ChildPreferredSizeChanged(views::View* child) override { | 40 void ChildPreferredSizeChanged(views::View* child) override { |
40 Layout(); | 41 Layout(); |
41 PreferredSizeChanged(); | 42 PreferredSizeChanged(); |
42 } | 43 } |
43 }; | 44 }; |
44 | 45 |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 SearchResultPageView::SearchResultPageView() : selected_index_(0) { | 48 SearchResultPageView::SearchResultPageView() : selected_index_(0) { |
48 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, | 49 if (switches::IsExperimentalAppListEnabled()) { |
49 kExperimentalWindowPadding, kTopPadding, | 50 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, |
50 kGroupSpacing)); | 51 kExperimentalWindowPadding, |
| 52 kTopPadding, kGroupSpacing)); |
| 53 } else { |
| 54 SetLayoutManager(new views::FillLayout); |
| 55 } |
51 } | 56 } |
52 | 57 |
53 SearchResultPageView::~SearchResultPageView() { | 58 SearchResultPageView::~SearchResultPageView() { |
54 } | 59 } |
55 | 60 |
56 void SearchResultPageView::AddSearchResultContainerView( | 61 void SearchResultPageView::AddSearchResultContainerView( |
57 AppListModel::SearchResults* results_model, | 62 AppListModel::SearchResults* results_model, |
58 SearchResultContainerView* result_container) { | 63 SearchResultContainerView* result_container) { |
59 AddChildView(new SearchCardView(result_container)); | 64 views::View* view_to_add = result_container; |
| 65 if (switches::IsExperimentalAppListEnabled()) |
| 66 view_to_add = new SearchCardView(result_container); |
| 67 |
| 68 AddChildView(view_to_add); |
60 result_container_views_.push_back(result_container); | 69 result_container_views_.push_back(result_container); |
61 result_container->SetResults(results_model); | 70 result_container->SetResults(results_model); |
62 } | 71 } |
63 | 72 |
64 bool SearchResultPageView::OnKeyPressed(const ui::KeyEvent& event) { | 73 bool SearchResultPageView::OnKeyPressed(const ui::KeyEvent& event) { |
65 if (result_container_views_.at(selected_index_)->OnKeyPressed(event)) | 74 if (result_container_views_.at(selected_index_)->OnKeyPressed(event)) |
66 return true; | 75 return true; |
67 | 76 |
68 int dir = 0; | 77 int dir = 0; |
69 switch (event.key_code()) { | 78 switch (event.key_code()) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return index >= 0 && index < static_cast<int>(result_container_views_.size()); | 119 return index >= 0 && index < static_cast<int>(result_container_views_.size()); |
111 } | 120 } |
112 | 121 |
113 void SearchResultPageView::ChildPreferredSizeChanged(views::View* child) { | 122 void SearchResultPageView::ChildPreferredSizeChanged(views::View* child) { |
114 DCHECK(!result_container_views_.empty()); | 123 DCHECK(!result_container_views_.empty()); |
115 Layout(); | 124 Layout(); |
116 SetSelectedIndex(0); | 125 SetSelectedIndex(0); |
117 } | 126 } |
118 | 127 |
119 } // namespace app_list | 128 } // namespace app_list |
OLD | NEW |