diff options
Diffstat (limited to 'ui/app_list/views/contents_view.cc')
-rw-r--r-- | ui/app_list/views/contents_view.cc | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc index 225c119..017c38c 100644 --- a/ui/app_list/views/contents_view.cc +++ b/ui/app_list/views/contents_view.cc @@ -11,7 +11,6 @@ #include "ui/app_list/app_list_view_delegate.h" #include "ui/app_list/pagination_model.h" #include "ui/app_list/views/app_list_main_view.h" -#include "ui/app_list/views/apps_container_view.h" #include "ui/app_list/views/apps_grid_view.h" #include "ui/app_list/views/search_result_list_view.h" #include "ui/events/event.h" @@ -23,8 +22,10 @@ namespace app_list { namespace { +const int kPreferredIconDimension = 48; + // Indexes of interesting views in ViewModel of ContentsView. -const int kIndexAppsContainer = 0; +const int kIndexAppsGrid = 0; const int kIndexSearchResults = 1; const int kMinMouseWheelToSwitchPage = 20; @@ -33,8 +34,9 @@ const int kMinHorizVelocityToSwitchPage = 800; const double kFinishTransitionThreshold = 0.33; -AppsContainerView* GetAppsContainerView(views::ViewModel* model) { - return static_cast<AppsContainerView*>(model->view_at(kIndexAppsContainer)); +// Helpers to get certain child view from |model|. +AppsGridView* GetAppsGridView(views::ViewModel* model) { + return static_cast<AppsGridView*>(model->view_at(kIndexAppsGrid)); } SearchResultListView* GetSearchResultListView(views::ViewModel* model) { @@ -57,16 +59,20 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view, kPageTransitionDurationInMs, kOverscrollPageTransitionDurationMs); - apps_container_view_ = new AppsContainerView( - app_list_main_view, pagination_model, model, start_page_contents); - AddChildView(apps_container_view_); - view_model_->Add(apps_container_view_, kIndexAppsContainer); + apps_grid_view_ = new AppsGridView( + app_list_main_view, pagination_model, start_page_contents); + apps_grid_view_->SetLayout(kPreferredIconDimension, + kPreferredCols, + kPreferredRows); + AddChildView(apps_grid_view_); + view_model_->Add(apps_grid_view_, kIndexAppsGrid); SearchResultListView* search_results_view = new SearchResultListView( app_list_main_view); AddChildView(search_results_view); view_model_->Add(search_results_view, kIndexSearchResults); + GetAppsGridView(view_model_.get())->SetModel(model); GetSearchResultListView(view_model_.get())->SetResults(model->results()); } @@ -74,14 +80,13 @@ ContentsView::~ContentsView() { } void ContentsView::CancelDrag() { - if (apps_container_view_->apps_grid_view()->has_dragged_view()) - apps_container_view_->apps_grid_view()->EndDrag(true); + if (apps_grid_view_ && apps_grid_view_->has_dragged_view()) + apps_grid_view_->EndDrag(true); } void ContentsView::SetDragAndDropHostOfCurrentAppList( ApplicationDragAndDropHost* drag_and_drop_host) { - apps_container_view_->apps_grid_view()-> - SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); + apps_grid_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); } void ContentsView::SetShowState(ShowState show_state) { @@ -109,7 +114,7 @@ void ContentsView::CalculateIdealBounds() { if (rect.IsEmpty()) return; - gfx::Rect container_frame(rect); + gfx::Rect grid_frame(rect); gfx::Rect results_frame(rect); // Offsets apps grid and result list based on |show_state_|. @@ -121,14 +126,14 @@ void ContentsView::CalculateIdealBounds() { results_frame.Offset(0, -contents_area_height); break; case SHOW_SEARCH_RESULTS: - container_frame.Offset(0, contents_area_height); + grid_frame.Offset(0, contents_area_height); break; default: NOTREACHED() << "Unknown show_state_ " << show_state_; break; } - view_model_->set_ideal_bounds(kIndexAppsContainer, container_frame); + view_model_->set_ideal_bounds(kIndexAppsGrid, grid_frame); view_model_->set_ideal_bounds(kIndexSearchResults, results_frame); } @@ -144,23 +149,19 @@ void ContentsView::ShowSearchResults(bool show) { SetShowState(show ? SHOW_SEARCH_RESULTS : SHOW_APPS); } -void ContentsView::ShowFolderContent(AppListFolderItem* item) { - apps_container_view_->ShowActiveFolder(item); -} - void ContentsView::Prerender() { const int selected_page = std::max(0, pagination_model_->selected_page()); - apps_container_view_->apps_grid_view()->Prerender(selected_page); + GetAppsGridView(view_model_.get())->Prerender(selected_page); } gfx::Size ContentsView::GetPreferredSize() { - const gfx::Size container_size = GetAppsContainerView(view_model_.get())-> - apps_grid_view()->GetPreferredSize(); + const gfx::Size grid_size = + GetAppsGridView(view_model_.get())->GetPreferredSize(); const gfx::Size results_size = GetSearchResultListView(view_model_.get())->GetPreferredSize(); - int width = std::max(container_size.width(), results_size.width()); - int height = std::max(container_size.height(), results_size.height()); + int width = std::max(grid_size.width(), results_size.width()); + int height = std::max(grid_size.height(), results_size.height()); return gfx::Size(width, height); } @@ -172,7 +173,7 @@ void ContentsView::Layout() { bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) { switch (show_state_) { case SHOW_APPS: - return GetAppsContainerView(view_model_.get())->OnKeyPressed(event); + return GetAppsGridView(view_model_.get())->OnKeyPressed(event); case SHOW_SEARCH_RESULTS: return GetSearchResultListView(view_model_.get())->OnKeyPressed(event); default: |