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 #ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
| 14 #include "ui/app_list/app_list_model.h" |
14 #include "ui/app_list/pagination_model.h" | 15 #include "ui/app_list/pagination_model.h" |
15 #include "ui/app_list/pagination_model_observer.h" | 16 #include "ui/app_list/pagination_model_observer.h" |
16 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Rect; | 20 class Rect; |
20 } | 21 } |
21 | 22 |
22 namespace views { | 23 namespace views { |
23 class ViewModel; | 24 class ViewModel; |
(...skipping 14 matching lines...) Expand all Loading... |
38 class StartPageView; | 39 class StartPageView; |
39 | 40 |
40 // A view to manage launcher pages within the Launcher (eg. start page, apps | 41 // A view to manage launcher pages within the Launcher (eg. start page, apps |
41 // grid view, search results). There can be any number of launcher pages, only | 42 // grid view, search results). There can be any number of launcher pages, only |
42 // one of which can be active at a given time. ContentsView provides the user | 43 // one of which can be active at a given time. ContentsView provides the user |
43 // interface for switching between launcher pages, and animates the transition | 44 // interface for switching between launcher pages, and animates the transition |
44 // between them. | 45 // between them. |
45 class APP_LIST_EXPORT ContentsView : public views::View, | 46 class APP_LIST_EXPORT ContentsView : public views::View, |
46 public PaginationModelObserver { | 47 public PaginationModelObserver { |
47 public: | 48 public: |
48 // Values of this enum denote special launcher pages that require hard-coding. | |
49 // Launcher pages are not required to have a NamedPage enum value. | |
50 enum NamedPage { | |
51 NAMED_PAGE_APPS, | |
52 NAMED_PAGE_SEARCH_RESULTS, | |
53 NAMED_PAGE_START, | |
54 }; | |
55 | |
56 ContentsView(AppListMainView* app_list_main_view); | 49 ContentsView(AppListMainView* app_list_main_view); |
57 virtual ~ContentsView(); | 50 virtual ~ContentsView(); |
58 | 51 |
59 // Initialize the named (special) pages of the launcher. In the experimental | 52 // Initialize the pages of the launcher. In the experimental launcher, should |
60 // launcher, should be called after set_contents_switcher_view(), or switcher | 53 // be called after set_contents_switcher_view(), or switcher buttons will not |
61 // buttons will not be created. | 54 // be created. |
62 void InitNamedPages(AppListModel* model, AppListViewDelegate* view_delegate); | 55 void Init(AppListModel* model, AppListViewDelegate* view_delegate); |
63 | 56 |
64 // The app list gets closed and drag and drop operations need to be cancelled. | 57 // The app list gets closed and drag and drop operations need to be cancelled. |
65 void CancelDrag(); | 58 void CancelDrag(); |
66 | 59 |
67 // If |drag_and_drop| is not NULL it will be called upon drag and drop | 60 // If |drag_and_drop| is not NULL it will be called upon drag and drop |
68 // operations outside the application list. | 61 // operations outside the application list. |
69 void SetDragAndDropHostOfCurrentAppList( | 62 void SetDragAndDropHostOfCurrentAppList( |
70 ApplicationDragAndDropHost* drag_and_drop_host); | 63 ApplicationDragAndDropHost* drag_and_drop_host); |
71 | 64 |
72 void SetContentsSwitcherView(ContentsSwitcherView* contents_switcher_view); | 65 void SetContentsSwitcherView(ContentsSwitcherView* contents_switcher_view); |
73 | 66 |
74 // Shows/hides the search results. Hiding the search results will cause the | 67 // Shows/hides the search results. Hiding the search results will cause the |
75 // app list to return to the page that was displayed before | 68 // app list to return to the page that was displayed before |
76 // ShowSearchResults(true) was invoked. | 69 // ShowSearchResults(true) was invoked. |
77 void ShowSearchResults(bool show); | 70 void ShowSearchResults(bool show); |
78 bool IsShowingSearchResults() const; | 71 bool IsShowingSearchResults() const; |
79 | 72 |
80 void ShowFolderContent(AppListFolderItem* folder); | 73 void ShowFolderContent(AppListFolderItem* folder); |
81 | 74 |
82 // Sets the active launcher page and animates the pages into place. | 75 // Sets the active launcher page and animates the pages into place. |
83 void SetActivePage(int page_index); | 76 void SetActivePage(int page_index); |
84 | 77 |
85 // The index of the currently active launcher page. | 78 // The index of the currently active launcher page. |
86 int GetActivePageIndex() const; | 79 int GetActivePageIndex() const; |
87 | 80 |
88 // True if |named_page| is the current active laucher page. | 81 // True if |show_state| is the current active laucher page. |
89 bool IsNamedPageActive(NamedPage named_page) const; | 82 bool IsShowStateActive(AppListModel::ShowState show_state) const; |
90 | 83 |
91 // Gets the index of a launcher page in |view_model_|, by NamedPage. Returns | 84 // Gets the index of a launcher page in |view_model_|, by ShowState. Returns |
92 // -1 if there is no view for |named_page|. | 85 // -1 if there is no view for |show_state|. |
93 int GetPageIndexForNamedPage(NamedPage named_page) const; | 86 int GetPageIndexForShowState(AppListModel::ShowState show_state) const; |
94 | 87 |
95 int NumLauncherPages() const; | 88 int NumLauncherPages() const; |
96 | 89 |
97 void Prerender(); | 90 void Prerender(); |
98 | 91 |
99 AppsContainerView* apps_container_view() { return apps_container_view_; } | 92 AppsContainerView* apps_container_view() { return apps_container_view_; } |
100 StartPageView* start_page_view() { return start_page_view_; } | 93 StartPageView* start_page_view() { return start_page_view_; } |
101 SearchResultListView* search_results_view() { return search_results_view_; } | 94 SearchResultListView* search_results_view() { return search_results_view_; } |
102 views::View* GetPageView(int index); | 95 views::View* GetPageView(int index); |
103 | 96 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 138 |
146 // Adds |view| as a new page to the end of the list of launcher pages. The | 139 // Adds |view| as a new page to the end of the list of launcher pages. The |
147 // view is inserted as a child of the ContentsView, and a button with | 140 // view is inserted as a child of the ContentsView, and a button with |
148 // |resource_id| is added to the ContentsSwitcherView. There is no name | 141 // |resource_id| is added to the ContentsSwitcherView. There is no name |
149 // associated with the page. Returns the index of the new page. | 142 // associated with the page. Returns the index of the new page. |
150 int AddLauncherPage(views::View* view, int resource_id); | 143 int AddLauncherPage(views::View* view, int resource_id); |
151 | 144 |
152 // Adds |view| as a new page to the end of the list of launcher pages. The | 145 // Adds |view| as a new page to the end of the list of launcher pages. The |
153 // view is inserted as a child of the ContentsView, and a button with | 146 // view is inserted as a child of the ContentsView, and a button with |
154 // |resource_id| is added to the ContentsSwitcherView. The page is associated | 147 // |resource_id| is added to the ContentsSwitcherView. The page is associated |
155 // with the name |named_page|. Returns the index of the new page. | 148 // with the name |show_state|. Returns the index of the new page. |
156 int AddLauncherPage(views::View* view, int resource_id, NamedPage named_page); | 149 int AddLauncherPage(views::View* view, |
| 150 int resource_id, |
| 151 AppListModel::ShowState show_state); |
157 | 152 |
158 // Gets the PaginationModel owned by the AppsGridView. | 153 // Gets the PaginationModel owned by the AppsGridView. |
159 // Note: This is different to |pagination_model_|, which manages top-level | 154 // Note: This is different to |pagination_model_|, which manages top-level |
160 // launcher-page pagination. | 155 // launcher-page pagination. |
161 PaginationModel* GetAppsPaginationModel(); | 156 PaginationModel* GetAppsPaginationModel(); |
162 | 157 |
163 // Special sub views of the ContentsView. All owned by the views hierarchy. | 158 // Special sub views of the ContentsView. All owned by the views hierarchy. |
164 AppsContainerView* apps_container_view_; | 159 AppsContainerView* apps_container_view_; |
165 SearchResultListView* search_results_view_; | 160 SearchResultListView* search_results_view_; |
166 StartPageView* start_page_view_; | 161 StartPageView* start_page_view_; |
167 | 162 |
168 AppListMainView* app_list_main_view_; // Parent view, owns this. | 163 AppListMainView* app_list_main_view_; // Parent view, owns this. |
169 // Sibling view, owned by |app_list_main_view_|. | 164 // Sibling view, owned by |app_list_main_view_|. |
170 ContentsSwitcherView* contents_switcher_view_; | 165 ContentsSwitcherView* contents_switcher_view_; |
171 | 166 |
172 scoped_ptr<views::ViewModel> view_model_; | 167 scoped_ptr<views::ViewModel> view_model_; |
173 // Maps NamedPage onto |view_model_| indices. | 168 // Maps ShowState onto |view_model_| indices. |
174 std::map<NamedPage, int> named_page_to_view_; | 169 std::map<AppListModel::ShowState, int> show_state_to_view_; |
175 | 170 |
176 // The page that was showing before ShowSearchResults(true) was invoked. | 171 // The page that was showing before ShowSearchResults(true) was invoked. |
177 int page_before_search_; | 172 int page_before_search_; |
178 | 173 |
179 // Manages the pagination for the launcher pages. | 174 // Manages the pagination for the launcher pages. |
180 PaginationModel pagination_model_; | 175 PaginationModel pagination_model_; |
181 | 176 |
182 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 177 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
183 }; | 178 }; |
184 | 179 |
185 } // namespace app_list | 180 } // namespace app_list |
186 | 181 |
187 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 182 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
OLD | NEW |