Index: ui/app_list/views/contents_view.h |
diff --git a/ui/app_list/views/contents_view.h b/ui/app_list/views/contents_view.h |
index e7df7bc0ccbf4b75207aaa04856e5a12c7561ebb..0a7bfc5cca48011abd644264cb2801597a2fb4af 100644 |
--- a/ui/app_list/views/contents_view.h |
+++ b/ui/app_list/views/contents_view.h |
@@ -5,6 +5,8 @@ |
#ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
#define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
+#include <map> |
+ |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
#include "base/memory/scoped_ptr.h" |
@@ -33,16 +35,19 @@ class PaginationModel; |
class SearchResultListView; |
class StartPageView; |
-// A view to manage sub views under the search box (apps grid view + page |
-// switcher and search results). The two sets of sub views are mutually |
-// exclusive. ContentsView manages a show state to choose one set to show |
-// and animates the transition between show states. |
+// A view to manage launcher pages within the Launcher (eg. start page, apps |
+// grid view, search results). There can be any number of launcher pages, only |
+// one of which can be active at a given time. ContentsView provides the user |
+// interface for switching between launcher pages, and animates the transition |
+// between them. |
class APP_LIST_EXPORT ContentsView : public views::View { |
public: |
- enum ShowState { |
- SHOW_APPS, |
- SHOW_SEARCH_RESULTS, |
- SHOW_START_PAGE, |
+ // Values of this enum denote special launcher pages that require hard-coding. |
+ // Launcher pages are not required to have a NamedPage enum value. |
+ enum NamedPage { |
+ NAMED_PAGE_APPS, |
+ NAMED_PAGE_SEARCH_RESULTS, |
+ NAMED_PAGE_START, |
}; |
ContentsView(AppListMainView* app_list_main_view, |
@@ -61,16 +66,23 @@ class APP_LIST_EXPORT ContentsView : public views::View { |
void ShowSearchResults(bool show); |
void ShowFolderContent(AppListFolderItem* folder); |
- // Sets show state and animates the subviews to match the show state. |
- void SetShowState(ShowState show_state); |
+ // Sets the active launcher page and animates the pages into place. |
+ void SetActivePage(int page_index); |
+ |
+ // The index of the currently active launcher page. |
+ int active_page_index() const { return active_page_; } |
+ |
+ // True if |named_page| is the current active laucher page. |
+ bool IsNamedPageActive(NamedPage named_page) const; |
+ |
+ // Gets the index of a launcher page in |view_model_|, by NamedPage. |
+ int GetPageIndexForNamedPage(NamedPage named_page) const; |
void Prerender(); |
AppsContainerView* apps_container_view() { return apps_container_view_; } |
StartPageView* start_page_view() { return start_page_view_; } |
- ShowState show_state() const { return show_state_; } |
- |
// Overridden from views::View: |
virtual gfx::Size GetPreferredSize() const OVERRIDE; |
virtual void Layout() OVERRIDE; |
@@ -78,12 +90,22 @@ class APP_LIST_EXPORT ContentsView : public views::View { |
virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; |
private: |
- // Invoked when show state is changed. |
- void ShowStateChanged(); |
+ // Invoked when active view is changed. |
+ void ActivePageChanged(); |
void CalculateIdealBounds(); |
void AnimateToIdealBounds(); |
+ // Adds |view| as a new page to the end of the list of launcher pages. The |
+ // view is inserted as a child of the ContentsView. There is no name |
+ // associated with the page. Returns the index of the new page. |
+ int AddLauncherPage(views::View* view); |
+ |
+ // Adds |view| as a new page to the end of the list of launcher pages. The |
+ // view is inserted as a child of the ContentsView. The page is associated |
+ // with the name |named_page|. Returns the index of the new page. |
+ int AddLauncherPage(views::View* view, NamedPage named_page); |
+ |
// Gets the PaginationModel owned by the AppsGridView. |
PaginationModel* GetAppsPaginationModel(); |
@@ -91,7 +113,8 @@ class APP_LIST_EXPORT ContentsView : public views::View { |
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
- ShowState show_state_; |
+ // Index into |view_model_| of the currently active page. |
+ int active_page_; |
// Special sub views of the ContentsView. All owned by the views hierarchy. |
AppsContainerView* apps_container_view_; |
@@ -101,6 +124,8 @@ class APP_LIST_EXPORT ContentsView : public views::View { |
AppListMainView* app_list_main_view_; // Parent view, owns this. |
scoped_ptr<views::ViewModel> view_model_; |
+ // Maps NamedPage onto |view_model_| indices. |
+ std::map<NamedPage, int> named_page_to_view_; |
scoped_ptr<views::BoundsAnimator> bounds_animator_; |
DISALLOW_COPY_AND_ASSIGN(ContentsView); |