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