| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace app_list { | 22 namespace app_list { |
| 23 | 23 |
| 24 class AppsGridView; | 24 class AppsGridView; |
| 25 class ApplicationDragAndDropHost; | 25 class ApplicationDragAndDropHost; |
| 26 class AppListFolderItem; | 26 class AppListFolderItem; |
| 27 class AppListMainView; | 27 class AppListMainView; |
| 28 class AppListModel; | 28 class AppListModel; |
| 29 class AppListViewDelegate; | 29 class AppListViewDelegate; |
| 30 class AppsContainerView; | 30 class AppsContainerView; |
| 31 class ContentsSwitcherView; |
| 31 class PaginationModel; | 32 class PaginationModel; |
| 32 class SearchResultListView; | 33 class SearchResultListView; |
| 33 class StartPageView; | 34 class StartPageView; |
| 34 | 35 |
| 35 // A view to manage launcher pages within the Launcher (eg. start page, apps | 36 // A view to manage launcher pages within the Launcher (eg. start page, apps |
| 36 // grid view, search results). There can be any number of launcher pages, only | 37 // grid view, search results). There can be any number of launcher pages, only |
| 37 // one of which can be active at a given time. ContentsView provides the user | 38 // one of which can be active at a given time. ContentsView provides the user |
| 38 // interface for switching between launcher pages, and animates the transition | 39 // interface for switching between launcher pages, and animates the transition |
| 39 // between them. | 40 // between them. |
| 40 class APP_LIST_EXPORT ContentsView : public views::View, | 41 class APP_LIST_EXPORT ContentsView : public views::View, |
| 41 public PaginationModelObserver { | 42 public PaginationModelObserver { |
| 42 public: | 43 public: |
| 43 // Values of this enum denote special launcher pages that require hard-coding. | 44 // Values of this enum denote special launcher pages that require hard-coding. |
| 44 // Launcher pages are not required to have a NamedPage enum value. | 45 // Launcher pages are not required to have a NamedPage enum value. |
| 45 enum NamedPage { | 46 enum NamedPage { |
| 46 NAMED_PAGE_APPS, | 47 NAMED_PAGE_APPS, |
| 47 NAMED_PAGE_SEARCH_RESULTS, | 48 NAMED_PAGE_SEARCH_RESULTS, |
| 48 NAMED_PAGE_START, | 49 NAMED_PAGE_START, |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 ContentsView(AppListMainView* app_list_main_view, | 52 ContentsView(AppListMainView* app_list_main_view); |
| 52 AppListModel* model, | |
| 53 AppListViewDelegate* view_delegate); | |
| 54 virtual ~ContentsView(); | 53 virtual ~ContentsView(); |
| 55 | 54 |
| 55 // Initialize the named (special) pages of the launcher. In the experimental |
| 56 // launcher, should be called after set_contents_switcher_view(), or switcher |
| 57 // buttons will not be created. |
| 58 void InitNamedPages(AppListModel* model, AppListViewDelegate* view_delegate); |
| 59 |
| 56 // The app list gets closed and drag and drop operations need to be cancelled. | 60 // The app list gets closed and drag and drop operations need to be cancelled. |
| 57 void CancelDrag(); | 61 void CancelDrag(); |
| 58 | 62 |
| 59 // If |drag_and_drop| is not NULL it will be called upon drag and drop | 63 // If |drag_and_drop| is not NULL it will be called upon drag and drop |
| 60 // operations outside the application list. | 64 // operations outside the application list. |
| 61 void SetDragAndDropHostOfCurrentAppList( | 65 void SetDragAndDropHostOfCurrentAppList( |
| 62 ApplicationDragAndDropHost* drag_and_drop_host); | 66 ApplicationDragAndDropHost* drag_and_drop_host); |
| 63 | 67 |
| 68 void set_contents_switcher_view( |
| 69 ContentsSwitcherView* contents_switcher_view) { |
| 70 contents_switcher_view_ = contents_switcher_view; |
| 71 } |
| 72 |
| 64 void ShowSearchResults(bool show); | 73 void ShowSearchResults(bool show); |
| 65 void ShowFolderContent(AppListFolderItem* folder); | 74 void ShowFolderContent(AppListFolderItem* folder); |
| 66 bool IsShowingSearchResults() const; | 75 bool IsShowingSearchResults() const; |
| 67 | 76 |
| 68 // Sets the active launcher page and animates the pages into place. | 77 // Sets the active launcher page and animates the pages into place. |
| 69 void SetActivePage(int page_index); | 78 void SetActivePage(int page_index); |
| 70 | 79 |
| 71 // The index of the currently active launcher page. | 80 // The index of the currently active launcher page. |
| 72 int GetActivePageIndex() const; | 81 int GetActivePageIndex() const; |
| 73 | 82 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void SetActivePageInternal(int page_index, bool show_search_results); | 116 void SetActivePageInternal(int page_index, bool show_search_results); |
| 108 | 117 |
| 109 // Invoked when active view is changed. | 118 // Invoked when active view is changed. |
| 110 void ActivePageChanged(bool show_search_results); | 119 void ActivePageChanged(bool show_search_results); |
| 111 | 120 |
| 112 // Calculates and sets the bounds for the subviews. If there is currently an | 121 // Calculates and sets the bounds for the subviews. If there is currently an |
| 113 // animation, this positions the views as appropriate for the current frame. | 122 // animation, this positions the views as appropriate for the current frame. |
| 114 void UpdatePageBounds(); | 123 void UpdatePageBounds(); |
| 115 | 124 |
| 116 // Adds |view| as a new page to the end of the list of launcher pages. The | 125 // Adds |view| as a new page to the end of the list of launcher pages. The |
| 117 // view is inserted as a child of the ContentsView. There is no name | 126 // view is inserted as a child of the ContentsView, and a button with |
| 127 // |resource_id| is added to the ContentsSwitcherView. There is no name |
| 118 // associated with the page. Returns the index of the new page. | 128 // associated with the page. Returns the index of the new page. |
| 119 int AddLauncherPage(views::View* view); | 129 int AddLauncherPage(views::View* view, int resource_id); |
| 120 | 130 |
| 121 // Adds |view| as a new page to the end of the list of launcher pages. The | 131 // Adds |view| as a new page to the end of the list of launcher pages. The |
| 122 // view is inserted as a child of the ContentsView. The page is associated | 132 // view is inserted as a child of the ContentsView, and a button with |
| 133 // |resource_id| is added to the ContentsSwitcherView. The page is associated |
| 123 // with the name |named_page|. Returns the index of the new page. | 134 // with the name |named_page|. Returns the index of the new page. |
| 124 int AddLauncherPage(views::View* view, NamedPage named_page); | 135 int AddLauncherPage(views::View* view, int resource_id, NamedPage named_page); |
| 125 | 136 |
| 126 // Gets the PaginationModel owned by the AppsGridView. | 137 // Gets the PaginationModel owned by the AppsGridView. |
| 127 // Note: This is different to |pagination_model_|, which manages top-level | 138 // Note: This is different to |pagination_model_|, which manages top-level |
| 128 // launcher-page pagination. | 139 // launcher-page pagination. |
| 129 PaginationModel* GetAppsPaginationModel(); | 140 PaginationModel* GetAppsPaginationModel(); |
| 130 | 141 |
| 131 // Overridden from ui::EventHandler: | 142 // Overridden from ui::EventHandler: |
| 132 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 143 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 133 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 144 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
| 134 | 145 |
| 135 // Special sub views of the ContentsView. All owned by the views hierarchy. | 146 // Special sub views of the ContentsView. All owned by the views hierarchy. |
| 136 AppsContainerView* apps_container_view_; | 147 AppsContainerView* apps_container_view_; |
| 137 SearchResultListView* search_results_view_; | 148 SearchResultListView* search_results_view_; |
| 138 StartPageView* start_page_view_; | 149 StartPageView* start_page_view_; |
| 139 | 150 |
| 140 AppListMainView* app_list_main_view_; // Parent view, owns this. | 151 AppListMainView* app_list_main_view_; // Parent view, owns this. |
| 152 // Sibling view, owned by |app_list_main_view_|. |
| 153 ContentsSwitcherView* contents_switcher_view_; |
| 141 | 154 |
| 142 scoped_ptr<views::ViewModel> view_model_; | 155 scoped_ptr<views::ViewModel> view_model_; |
| 143 // Maps NamedPage onto |view_model_| indices. | 156 // Maps NamedPage onto |view_model_| indices. |
| 144 std::map<NamedPage, int> named_page_to_view_; | 157 std::map<NamedPage, int> named_page_to_view_; |
| 145 | 158 |
| 146 // Manages the pagination for the launcher pages. | 159 // Manages the pagination for the launcher pages. |
| 147 PaginationModel pagination_model_; | 160 PaginationModel pagination_model_; |
| 148 | 161 |
| 149 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 162 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
| 150 }; | 163 }; |
| 151 | 164 |
| 152 } // namespace app_list | 165 } // namespace app_list |
| 153 | 166 |
| 154 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 167 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
| OLD | NEW |