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

Unified Diff: ui/app_list/views/contents_view.cc

Issue 27777002: Implement app list folder management page UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/app_list/views/contents_view.cc
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc
index 017c38ca91205b559e74602c1d2507796e961417..4e172b5450342726abdcce6a6f4f3df81fd9be6e 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -10,6 +10,7 @@
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_view_delegate.h"
#include "ui/app_list/pagination_model.h"
+#include "ui/app_list/views/app_list_folder_view.h"
#include "ui/app_list/views/app_list_main_view.h"
#include "ui/app_list/views/apps_grid_view.h"
#include "ui/app_list/views/search_result_list_view.h"
@@ -22,11 +23,10 @@ namespace app_list {
namespace {
-const int kPreferredIconDimension = 48;
-
// Indexes of interesting views in ViewModel of ContentsView.
const int kIndexAppsGrid = 0;
const int kIndexSearchResults = 1;
+const int kIndexFolderContent = 2;
const int kMinMouseWheelToSwitchPage = 20;
const int kMinScrollToSwitchPage = 20;
@@ -44,6 +44,10 @@ SearchResultListView* GetSearchResultListView(views::ViewModel* model) {
model->view_at(kIndexSearchResults));
}
+AppListFolderView* GetAppListFolderView(views::ViewModel* model) {
+ return static_cast<AppListFolderView*>(model->view_at(kIndexFolderContent));
+}
+
} // namespace
ContentsView::ContentsView(AppListMainView* app_list_main_view,
@@ -51,6 +55,7 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view,
AppListModel* model,
content::WebContents* start_page_contents)
: show_state_(SHOW_APPS),
+ previous_show_state_(show_state_),
pagination_model_(pagination_model),
view_model_(new views::ViewModel),
bounds_animator_(new views::BoundsAnimator(this)) {
@@ -73,7 +78,18 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view,
view_model_->Add(search_results_view, kIndexSearchResults);
GetAppsGridView(view_model_.get())->SetModel(model);
+ if (model)
+ GetAppsGridView(view_model_.get())->SetApps(model->apps());
GetSearchResultListView(view_model_.get())->SetResults(model->results());
+
+ AppListFolderView* folder_view = new AppListFolderView(
+ this,
+ model,
+ app_list_main_view,
+ pagination_model,
+ start_page_contents);
+ AddChildView(folder_view);
+ view_model_->Add(folder_view, kIndexFolderContent);
xiyuan 2013/10/17 23:50:30 Suggest to put folder view and root grid view into
jennyz 2013/10/18 22:09:02 Added a new AppsContainerView to achieve the above
}
ContentsView::~ContentsView() {
@@ -93,6 +109,7 @@ void ContentsView::SetShowState(ShowState show_state) {
if (show_state_ == show_state)
return;
+ previous_show_state_ = show_state_;
show_state_ = show_state;
ShowStateChanged();
}
@@ -116,6 +133,7 @@ void ContentsView::CalculateIdealBounds() {
gfx::Rect grid_frame(rect);
gfx::Rect results_frame(rect);
+ gfx::Rect folder_frame(rect);
// Offsets apps grid and result list based on |show_state_|.
// SearchResultListView is on top of apps grid. Visible view is left in
@@ -124,9 +142,15 @@ void ContentsView::CalculateIdealBounds() {
switch (show_state_) {
case SHOW_APPS:
results_frame.Offset(0, -contents_area_height);
+ folder_frame.Offset(0, -contents_area_height);
break;
case SHOW_SEARCH_RESULTS:
grid_frame.Offset(0, contents_area_height);
+ folder_frame.Offset(0, -contents_area_height);
+ break;
+ case SHOW_FOLDER_CONTENT:
+ results_frame.Offset(0, -contents_area_height);
+ grid_frame.Offset(0, contents_area_height);
break;
default:
NOTREACHED() << "Unknown show_state_ " << show_state_;
@@ -135,6 +159,7 @@ void ContentsView::CalculateIdealBounds() {
view_model_->set_ideal_bounds(kIndexAppsGrid, grid_frame);
view_model_->set_ideal_bounds(kIndexSearchResults, results_frame);
+ view_model_->set_ideal_bounds(kIndexFolderContent, folder_frame);
}
void ContentsView::AnimateToIdealBounds() {
@@ -146,7 +171,16 @@ void ContentsView::AnimateToIdealBounds() {
}
void ContentsView::ShowSearchResults(bool show) {
- SetShowState(show ? SHOW_SEARCH_RESULTS : SHOW_APPS);
+ SetShowState(show ? SHOW_SEARCH_RESULTS : previous_show_state_);
+}
+
+void ContentsView::ShowFolderContent(AppListFolderItem* item) {
+ GetAppListFolderView(view_model_.get())->SetAppListFolderItem(item);
+ SetShowState(SHOW_FOLDER_CONTENT);
+}
+
+void ContentsView::ShowApps() {
+ SetShowState(SHOW_APPS);
}
void ContentsView::Prerender() {
@@ -176,6 +210,8 @@ bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) {
return GetAppsGridView(view_model_.get())->OnKeyPressed(event);
case SHOW_SEARCH_RESULTS:
return GetSearchResultListView(view_model_.get())->OnKeyPressed(event);
+ case SHOW_FOLDER_CONTENT:
+ return GetAppListFolderView(view_model_.get())->OnKeyPressed(event);
default:
NOTREACHED() << "Unknown show state " << show_state_;
}

Powered by Google App Engine
This is Rietveld 408576698