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

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

Issue 896633005: Remove separate SearchResultListView from ContentsView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@separate_start_page_tile_container
Patch Set: Created 5 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_view.h" 5 #include "ui/app_list/views/contents_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/events/event.h" 24 #include "ui/events/event.h"
25 #include "ui/resources/grit/ui_resources.h" 25 #include "ui/resources/grit/ui_resources.h"
26 #include "ui/views/view_model.h" 26 #include "ui/views/view_model.h"
27 #include "ui/views/view_model_utils.h" 27 #include "ui/views/view_model_utils.h"
28 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
29 29
30 namespace app_list { 30 namespace app_list {
31 31
32 ContentsView::ContentsView(AppListMainView* app_list_main_view) 32 ContentsView::ContentsView(AppListMainView* app_list_main_view)
33 : apps_container_view_(nullptr), 33 : apps_container_view_(nullptr),
34 search_results_list_view_(nullptr),
35 search_results_page_view_(nullptr), 34 search_results_page_view_(nullptr),
36 start_page_view_(nullptr), 35 start_page_view_(nullptr),
37 custom_page_view_(nullptr), 36 custom_page_view_(nullptr),
38 app_list_main_view_(app_list_main_view), 37 app_list_main_view_(app_list_main_view),
39 view_model_(new views::ViewModel), 38 view_model_(new views::ViewModel),
40 page_before_search_(0) { 39 page_before_search_(0) {
41 pagination_model_.SetTransitionDurations(kPageTransitionDurationInMs, 40 pagination_model_.SetTransitionDurations(kPageTransitionDurationInMs,
42 kOverscrollPageTransitionDurationMs); 41 kOverscrollPageTransitionDurationMs);
43 pagination_model_.AddObserver(this); 42 pagination_model_.AddObserver(this);
44 } 43 }
(...skipping 21 matching lines...) Expand all
66 65
67 AddLauncherPage(*it, AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); 66 AddLauncherPage(*it, AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
68 } else { 67 } else {
69 AddLauncherPage(*it); 68 AddLauncherPage(*it);
70 } 69 }
71 } 70 }
72 71
73 // Start page. 72 // Start page.
74 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate); 73 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate);
75 AddLauncherPage(start_page_view_, AppListModel::STATE_START); 74 AddLauncherPage(start_page_view_, AppListModel::STATE_START);
75 }
76 76
77 // Search results UI. 77 // Search results UI.
78 search_results_page_view_ = new SearchResultPageView(); 78 search_results_page_view_ = new SearchResultPageView();
79 79
80 AppListModel::SearchResults* results = view_delegate->GetModel()->results(); 80 AppListModel::SearchResults* results = view_delegate->GetModel()->results();
81 search_results_page_view_->AddSearchResultContainerView( 81 search_results_page_view_->AddSearchResultContainerView(
82 results, new SearchResultListView(app_list_main_view_, view_delegate)); 82 results, new SearchResultListView(app_list_main_view_, view_delegate));
Matt Giuca 2015/02/05 04:33:17 nit: Newline here.
calamity 2015/02/05 07:08:40 Done.
83 if (app_list::switches::IsExperimentalAppListEnabled()) {
83 search_results_page_view_->AddSearchResultContainerView( 84 search_results_page_view_->AddSearchResultContainerView(
84 results, 85 results,
85 new SearchResultTileItemListView(GetSearchBoxView()->search_box())); 86 new SearchResultTileItemListView(GetSearchBoxView()->search_box()));
86
87 AddLauncherPage(search_results_page_view_,
88 AppListModel::STATE_SEARCH_RESULTS);
89 } else {
90 search_results_list_view_ =
91 new SearchResultListView(app_list_main_view_, view_delegate);
92 AddLauncherPage(search_results_list_view_,
93 AppListModel::STATE_SEARCH_RESULTS);
94 search_results_list_view_->SetResults(model->results());
95 } 87 }
88 AddLauncherPage(search_results_page_view_,
89 AppListModel::STATE_SEARCH_RESULTS);
96 90
97 apps_container_view_ = new AppsContainerView(app_list_main_view_, model); 91 apps_container_view_ = new AppsContainerView(app_list_main_view_, model);
98 92
99 AddLauncherPage(apps_container_view_, AppListModel::STATE_APPS); 93 AddLauncherPage(apps_container_view_, AppListModel::STATE_APPS);
100 94
101 int initial_page_index = app_list::switches::IsExperimentalAppListEnabled() 95 int initial_page_index = app_list::switches::IsExperimentalAppListEnabled()
102 ? GetPageIndexForState(AppListModel::STATE_START) 96 ? GetPageIndexForState(AppListModel::STATE_START)
103 : GetPageIndexForState(AppListModel::STATE_APPS); 97 : GetPageIndexForState(AppListModel::STATE_APPS);
104 DCHECK_GE(initial_page_index, 0); 98 DCHECK_GE(initial_page_index, 0);
105 99
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Set the visibility of the search box's back button. 211 // Set the visibility of the search box's back button.
218 app_list_main_view_->search_box_view()->back_button()->SetVisible( 212 app_list_main_view_->search_box_view()->back_button()->SetVisible(
219 state != AppListModel::STATE_START); 213 state != AppListModel::STATE_START);
220 app_list_main_view_->search_box_view()->Layout(); 214 app_list_main_view_->search_box_view()->Layout();
221 215
222 // Whenever the page changes, the custom launcher page is considered to have 216 // Whenever the page changes, the custom launcher page is considered to have
223 // been reset. 217 // been reset.
224 app_list_main_view_->model()->ClearCustomLauncherPageSubpages(); 218 app_list_main_view_->model()->ClearCustomLauncherPageSubpages();
225 } 219 }
226 220
227 // TODO(xiyuan): Highlight default match instead of the first.
228 if (state == AppListModel::STATE_SEARCH_RESULTS &&
229 search_results_list_view_ && search_results_list_view_->visible()) {
230 search_results_list_view_->OnContainerSelected(false);
Matt Giuca 2015/02/05 04:33:17 Where is this logic in the SearchResultsPageView v
calamity 2015/02/05 07:08:40 SearchResultPageView calls OnContainerSelected whe
231 }
232
233 if (search_results_list_view_)
234 search_results_list_view_->UpdateAutoLaunchState();
235
236 if (custom_page_view_) { 221 if (custom_page_view_) {
237 custom_page_view_->SetFocusable(state == 222 custom_page_view_->SetFocusable(state ==
238 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); 223 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
239 } 224 }
240 } 225 }
241 226
242 void ContentsView::ShowSearchResults(bool show) { 227 void ContentsView::ShowSearchResults(bool show) {
243 int search_page = GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS); 228 int search_page = GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS);
244 DCHECK_GE(search_page, 0); 229 DCHECK_GE(search_page, 0);
245 230
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 ShowSearchResults(false); 420 ShowSearchResults(false);
436 break; 421 break;
437 case AppListModel::INVALID_STATE: 422 case AppListModel::INVALID_STATE:
438 NOTREACHED(); 423 NOTREACHED();
439 break; 424 break;
440 } 425 }
441 return true; 426 return true;
442 } 427 }
443 428
444 gfx::Size ContentsView::GetDefaultContentsSize() const { 429 gfx::Size ContentsView::GetDefaultContentsSize() const {
445 const gfx::Size container_size = 430 return apps_container_view_->apps_grid_view()->GetPreferredSize();
446 apps_container_view_->apps_grid_view()->GetPreferredSize();
447 const gfx::Size results_size =
448 search_results_list_view_ ? search_results_list_view_->GetPreferredSize()
Matt Giuca 2015/02/05 04:33:17 Similarly, where is the logic to take the max of t
calamity 2015/02/05 07:08:40 The logic was 'if search results bigger, then use
Matt Giuca 2015/02/06 05:07:14 But that means if the search results are bigger, w
449 : gfx::Size();
450
451 int width = std::max(container_size.width(), results_size.width());
452 int height = std::max(container_size.height(), results_size.height());
453 return gfx::Size(width, height);
454 } 431 }
455 432
456 gfx::Size ContentsView::GetPreferredSize() const { 433 gfx::Size ContentsView::GetPreferredSize() const {
457 gfx::Rect search_box_bounds = GetDefaultSearchBoxBounds(); 434 gfx::Rect search_box_bounds = GetDefaultSearchBoxBounds();
458 gfx::Rect default_contents_bounds = GetDefaultContentsBounds(); 435 gfx::Rect default_contents_bounds = GetDefaultContentsBounds();
459 gfx::Vector2d bottom_right = 436 gfx::Vector2d bottom_right =
460 search_box_bounds.bottom_right().OffsetFromOrigin(); 437 search_box_bounds.bottom_right().OffsetFromOrigin();
461 bottom_right.SetToMax( 438 bottom_right.SetToMax(
462 default_contents_bounds.bottom_right().OffsetFromOrigin()); 439 default_contents_bounds.bottom_right().OffsetFromOrigin());
463 return gfx::Size(bottom_right.x(), bottom_right.y()); 440 return gfx::Size(bottom_right.x(), bottom_right.y());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 511 }
535 512
536 void ContentsView::TransitionStarted() { 513 void ContentsView::TransitionStarted() {
537 } 514 }
538 515
539 void ContentsView::TransitionChanged() { 516 void ContentsView::TransitionChanged() {
540 UpdatePageBounds(); 517 UpdatePageBounds();
541 } 518 }
542 519
543 } // namespace app_list 520 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698