Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: ui/app_list/views/search_result_page_view.cc

Issue 2339523004: Remove old (dead) app list code. (Closed)
Patch Set: Address nonbistytftatl review. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 views::Background::CreateSolidBackground(kCardBackgroundColor)); 44 views::Background::CreateSolidBackground(kCardBackgroundColor));
45 AddChildView(content_view); 45 AddChildView(content_view);
46 } 46 }
47 47
48 ~SearchCardView() override {} 48 ~SearchCardView() override {}
49 }; 49 };
50 50
51 } // namespace 51 } // namespace
52 52
53 SearchResultPageView::SearchResultPageView() : selected_index_(0) { 53 SearchResultPageView::SearchResultPageView() : selected_index_(0) {
54 if (switches::IsExperimentalAppListEnabled()) { 54 gfx::ShadowValue shadow = GetShadowForZHeight(kSearchResultZHeight);
55 gfx::ShadowValue shadow = GetShadowForZHeight(kSearchResultZHeight); 55 std::unique_ptr<views::Border> border(new views::ShadowBorder(shadow));
56 std::unique_ptr<views::Border> border(new views::ShadowBorder(shadow));
57 56
58 gfx::Insets insets = gfx::Insets(kTopPadding, kExperimentalSearchBoxPadding, 57 gfx::Insets insets =
59 0, kExperimentalSearchBoxPadding); 58 gfx::Insets(kTopPadding, kSearchBoxPadding, 0, kSearchBoxPadding);
60 insets += -border->GetInsets(); 59 insets += -border->GetInsets();
61 60
62 views::BoxLayout* layout = 61 views::BoxLayout* layout =
63 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, kGroupSpacing); 62 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, kGroupSpacing);
64 layout->set_inside_border_insets(insets); 63 layout->set_inside_border_insets(insets);
65 64
66 SetLayoutManager(layout); 65 SetLayoutManager(layout);
67 } else {
68 SetLayoutManager(new views::FillLayout);
69 }
70 } 66 }
71 67
72 SearchResultPageView::~SearchResultPageView() { 68 SearchResultPageView::~SearchResultPageView() {
73 } 69 }
74 70
75 void SearchResultPageView::SetSelection(bool select) { 71 void SearchResultPageView::SetSelection(bool select) {
76 if (select) 72 if (select)
77 SetSelectedIndex(0, false); 73 SetSelectedIndex(0, false);
78 else 74 else
79 ClearSelectedIndex(); 75 ClearSelectedIndex();
80 } 76 }
81 77
82 void SearchResultPageView::AddSearchResultContainerView( 78 void SearchResultPageView::AddSearchResultContainerView(
83 AppListModel::SearchResults* results_model, 79 AppListModel::SearchResults* results_model,
84 SearchResultContainerView* result_container) { 80 SearchResultContainerView* result_container) {
85 views::View* view_to_add = result_container; 81 AddChildView(new SearchCardView(result_container));
86 if (switches::IsExperimentalAppListEnabled())
87 view_to_add = new SearchCardView(result_container);
88
89 AddChildView(view_to_add);
90 result_container_views_.push_back(result_container); 82 result_container_views_.push_back(result_container);
91 result_container->SetResults(results_model); 83 result_container->SetResults(results_model);
92 result_container->set_delegate(this); 84 result_container->set_delegate(this);
93 } 85 }
94 86
95 bool SearchResultPageView::OnKeyPressed(const ui::KeyEvent& event) { 87 bool SearchResultPageView::OnKeyPressed(const ui::KeyEvent& event) {
96 if (HasSelection() && 88 if (HasSelection() &&
97 result_container_views_.at(selected_index_)->OnKeyPressed(event)) { 89 result_container_views_.at(selected_index_)->OnKeyPressed(event)) {
98 return true; 90 return true;
99 } 91 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 SearchResultContainerView* old_selection = 160 SearchResultContainerView* old_selection =
169 HasSelection() ? result_container_views_[selected_index_] : nullptr; 161 HasSelection() ? result_container_views_[selected_index_] : nullptr;
170 162
171 // Truncate the currently selected container's selection if necessary. If 163 // Truncate the currently selected container's selection if necessary. If
172 // there are no results, the selection will be cleared below. 164 // there are no results, the selection will be cleared below.
173 if (old_selection && old_selection->num_results() > 0 && 165 if (old_selection && old_selection->num_results() > 0 &&
174 old_selection->selected_index() >= old_selection->num_results()) { 166 old_selection->selected_index() >= old_selection->num_results()) {
175 old_selection->SetSelectedIndex(old_selection->num_results() - 1); 167 old_selection->SetSelectedIndex(old_selection->num_results() - 1);
176 } 168 }
177 169
178 if (switches::IsExperimentalAppListEnabled()) { 170 // Sort the result container views by their score.
179 // Sort the result container views by their score. 171 std::sort(result_container_views_.begin(), result_container_views_.end(),
180 std::sort(result_container_views_.begin(), result_container_views_.end(), 172 [](const SearchResultContainerView* a,
181 [](const SearchResultContainerView* a, 173 const SearchResultContainerView* b) -> bool {
182 const SearchResultContainerView* b) -> bool { 174 return a->container_score() > b->container_score();
183 return a->container_score() > b->container_score(); 175 });
184 });
185 176
186 int result_y_index = 0; 177 int result_y_index = 0;
187 for (size_t i = 0; i < result_container_views_.size(); ++i) { 178 for (size_t i = 0; i < result_container_views_.size(); ++i) {
188 SearchResultContainerView* view = result_container_views_[i]; 179 SearchResultContainerView* view = result_container_views_[i];
189 ReorderChildView(view->parent(), i); 180 ReorderChildView(view->parent(), i);
190 181
191 view->NotifyFirstResultYIndex(result_y_index); 182 view->NotifyFirstResultYIndex(result_y_index);
192 183
193 result_y_index += view->GetYSize(); 184 result_y_index += view->GetYSize();
194 }
195 } 185 }
196 186
197 Layout(); 187 Layout();
198 188
199 SearchResultContainerView* new_selection = nullptr; 189 SearchResultContainerView* new_selection = nullptr;
200 if (HasSelection() && 190 if (HasSelection() &&
201 result_container_views_[selected_index_]->num_results() > 0) { 191 result_container_views_[selected_index_]->num_results() > 0) {
202 new_selection = result_container_views_[selected_index_]; 192 new_selection = result_container_views_[selected_index_];
203 } 193 }
204 194
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 227
238 gfx::Rect onscreen_bounds( 228 gfx::Rect onscreen_bounds(
239 GetPageBoundsForState(AppListModel::STATE_SEARCH_RESULTS)); 229 GetPageBoundsForState(AppListModel::STATE_SEARCH_RESULTS));
240 onscreen_bounds -= bounds().OffsetFromOrigin(); 230 onscreen_bounds -= bounds().OffsetFromOrigin();
241 gfx::Path path; 231 gfx::Path path;
242 path.addRect(gfx::RectToSkRect(onscreen_bounds)); 232 path.addRect(gfx::RectToSkRect(onscreen_bounds));
243 set_clip_path(path); 233 set_clip_path(path);
244 } 234 }
245 235
246 int SearchResultPageView::GetSearchBoxZHeight() const { 236 int SearchResultPageView::GetSearchBoxZHeight() const {
247 return switches::IsExperimentalAppListEnabled() 237 return kSearchResultZHeight;
248 ? kSearchResultZHeight
249 : AppListPage::GetSearchBoxZHeight();
250 } 238 }
251 239
252 void SearchResultPageView::OnHidden() { 240 void SearchResultPageView::OnHidden() {
253 ClearSelectedIndex(); 241 ClearSelectedIndex();
254 } 242 }
255 243
256 } // namespace app_list 244 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698