| OLD | NEW |
| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 SearchResultListView* GetSearchResultListView(views::ViewModel* model) { | 41 SearchResultListView* GetSearchResultListView(views::ViewModel* model) { |
| 42 return static_cast<SearchResultListView*>( | 42 return static_cast<SearchResultListView*>( |
| 43 model->view_at(kIndexSearchResults)); | 43 model->view_at(kIndexSearchResults)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 ContentsView::ContentsView(AppListMainView* app_list_main_view, | 48 ContentsView::ContentsView(AppListMainView* app_list_main_view, |
| 49 PaginationModel* pagination_model) | 49 PaginationModel* pagination_model, |
| 50 AppListModel* model) |
| 50 : show_state_(SHOW_APPS), | 51 : show_state_(SHOW_APPS), |
| 51 pagination_model_(pagination_model), | 52 pagination_model_(pagination_model), |
| 52 view_model_(new views::ViewModel), | 53 view_model_(new views::ViewModel), |
| 53 bounds_animator_(new views::BoundsAnimator(this)) { | 54 bounds_animator_(new views::BoundsAnimator(this)) { |
| 55 DCHECK(model); |
| 54 pagination_model_->SetTransitionDurations( | 56 pagination_model_->SetTransitionDurations( |
| 55 kPageTransitionDurationInMs, | 57 kPageTransitionDurationInMs, |
| 56 kOverscrollPageTransitionDurationMs); | 58 kOverscrollPageTransitionDurationMs); |
| 57 | 59 |
| 58 apps_grid_view_ = new AppsGridView(app_list_main_view, pagination_model); | 60 apps_grid_view_ = new AppsGridView(app_list_main_view, pagination_model); |
| 59 apps_grid_view_->SetLayout(kPreferredIconDimension, | 61 apps_grid_view_->SetLayout(kPreferredIconDimension, |
| 60 kPreferredCols, | 62 kPreferredCols, |
| 61 kPreferredRows); | 63 kPreferredRows); |
| 62 AddChildView(apps_grid_view_); | 64 AddChildView(apps_grid_view_); |
| 63 view_model_->Add(apps_grid_view_, kIndexAppsGrid); | 65 view_model_->Add(apps_grid_view_, kIndexAppsGrid); |
| 64 | 66 |
| 65 SearchResultListView* search_results_view = new SearchResultListView( | 67 SearchResultListView* search_results_view = new SearchResultListView( |
| 66 app_list_main_view); | 68 app_list_main_view); |
| 67 AddChildView(search_results_view); | 69 AddChildView(search_results_view); |
| 68 view_model_->Add(search_results_view, kIndexSearchResults); | 70 view_model_->Add(search_results_view, kIndexSearchResults); |
| 71 |
| 72 GetAppsGridView(view_model_.get())->SetModel(model); |
| 73 GetSearchResultListView(view_model_.get())->SetResults(model->results()); |
| 69 } | 74 } |
| 70 | 75 |
| 71 ContentsView::~ContentsView() { | 76 ContentsView::~ContentsView() { |
| 72 } | 77 } |
| 73 | 78 |
| 74 void ContentsView::SetModel(AppListModel* model) { | |
| 75 if (model) { | |
| 76 GetAppsGridView(view_model_.get())->SetModel(model); | |
| 77 GetSearchResultListView(view_model_.get())->SetResults(model->results()); | |
| 78 } else { | |
| 79 GetAppsGridView(view_model_.get())->SetModel(NULL); | |
| 80 GetSearchResultListView(view_model_.get())->SetResults(NULL); | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 void ContentsView::SetDragAndDropHostOfCurrentAppList( | 79 void ContentsView::SetDragAndDropHostOfCurrentAppList( |
| 85 app_list::ApplicationDragAndDropHost* drag_and_drop_host) { | 80 app_list::ApplicationDragAndDropHost* drag_and_drop_host) { |
| 86 apps_grid_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); | 81 apps_grid_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); |
| 87 } | 82 } |
| 88 | 83 |
| 89 void ContentsView::SetShowState(ShowState show_state) { | 84 void ContentsView::SetShowState(ShowState show_state) { |
| 90 if (show_state_ == show_state) | 85 if (show_state_ == show_state) |
| 91 return; | 86 return; |
| 92 | 87 |
| 93 show_state_ = show_state; | 88 show_state_ = show_state; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (!pagination_model_->has_transition()) { | 247 if (!pagination_model_->has_transition()) { |
| 253 pagination_model_->SelectPageRelative(offset > 0 ? -1 : 1, | 248 pagination_model_->SelectPageRelative(offset > 0 ? -1 : 1, |
| 254 true); | 249 true); |
| 255 } | 250 } |
| 256 event->SetHandled(); | 251 event->SetHandled(); |
| 257 event->StopPropagation(); | 252 event->StopPropagation(); |
| 258 } | 253 } |
| 259 } | 254 } |
| 260 | 255 |
| 261 } // namespace app_list | 256 } // namespace app_list |
| OLD | NEW |