| 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 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "ui/app_list/app_list_export.h" | 14 #include "ui/app_list/app_list_export.h" |
| 15 #include "ui/app_list/app_list_model.h" | 15 #include "ui/app_list/app_list_model.h" |
| 16 #include "ui/app_list/app_list_model_observer.h" | |
| 17 #include "ui/app_list/pagination_model.h" | 16 #include "ui/app_list/pagination_model.h" |
| 18 #include "ui/app_list/pagination_model_observer.h" | 17 #include "ui/app_list/pagination_model_observer.h" |
| 19 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 20 #include "ui/views/view_model.h" | 19 #include "ui/views/view_model.h" |
| 21 | 20 |
| 22 namespace gfx { | 21 namespace gfx { |
| 23 class Rect; | 22 class Rect; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace app_list { | 25 namespace app_list { |
| 27 | 26 |
| 28 class AppsGridView; | 27 class AppsGridView; |
| 29 class AppListPage; | 28 class AppListPage; |
| 30 class ApplicationDragAndDropHost; | 29 class ApplicationDragAndDropHost; |
| 31 class AppListFolderItem; | 30 class AppListFolderItem; |
| 32 class AppListMainView; | 31 class AppListMainView; |
| 33 class AppsContainerView; | 32 class AppsContainerView; |
| 34 class CustomLauncherPageView; | 33 class CustomLauncherPageView; |
| 35 class PaginationModel; | 34 class PaginationModel; |
| 36 class SearchBoxView; | 35 class SearchBoxView; |
| 37 class SearchResultPageView; | 36 class SearchResultPageView; |
| 38 class StartPageView; | 37 class StartPageView; |
| 39 | 38 |
| 40 // A view to manage launcher pages within the Launcher (eg. start page, apps | 39 // 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 | 40 // 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 | 41 // 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 | 42 // interface for switching between launcher pages, and animates the transition |
| 44 // between them. | 43 // between them. |
| 45 class APP_LIST_EXPORT ContentsView : public views::View, | 44 class APP_LIST_EXPORT ContentsView : public views::View, |
| 46 public PaginationModelObserver, | 45 public PaginationModelObserver { |
| 47 public AppListModelObserver { | |
| 48 public: | 46 public: |
| 49 explicit ContentsView(AppListMainView* app_list_main_view); | 47 explicit ContentsView(AppListMainView* app_list_main_view); |
| 50 ~ContentsView() override; | 48 ~ContentsView() override; |
| 51 | 49 |
| 52 // Initialize the pages of the launcher. Should be called after | 50 // Initialize the pages of the launcher. Should be called after |
| 53 // set_contents_switcher_view(). | 51 // set_contents_switcher_view(). |
| 54 void Init(AppListModel* model); | 52 void Init(AppListModel* model); |
| 55 | 53 |
| 56 // 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. |
| 57 void CancelDrag(); | 55 void CancelDrag(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void Layout() override; | 127 void Layout() override; |
| 130 bool OnKeyPressed(const ui::KeyEvent& event) override; | 128 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 131 const char* GetClassName() const override; | 129 const char* GetClassName() const override; |
| 132 | 130 |
| 133 // Overridden from PaginationModelObserver: | 131 // Overridden from PaginationModelObserver: |
| 134 void TotalPagesChanged() override; | 132 void TotalPagesChanged() override; |
| 135 void SelectedPageChanged(int old_selected, int new_selected) override; | 133 void SelectedPageChanged(int old_selected, int new_selected) override; |
| 136 void TransitionStarted() override; | 134 void TransitionStarted() override; |
| 137 void TransitionChanged() override; | 135 void TransitionChanged() override; |
| 138 | 136 |
| 139 // Overridden from AppListModelObserver: | |
| 140 void OnSearchAnswerAvailableChanged(bool has_answer) override; | |
| 141 | |
| 142 private: | 137 private: |
| 143 // Sets the active launcher page, accounting for whether the change is for | 138 // Sets the active launcher page, accounting for whether the change is for |
| 144 // search results. | 139 // search results. |
| 145 void SetActiveStateInternal(int page_index, | 140 void SetActiveStateInternal(int page_index, |
| 146 bool show_search_results, | 141 bool show_search_results, |
| 147 bool animate); | 142 bool animate); |
| 148 | 143 |
| 149 // Invoked when active view is changed. | 144 // Invoked when active view is changed. |
| 150 void ActivePageChanged(); | 145 void ActivePageChanged(); |
| 151 | 146 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 178 |
| 184 // Unowned pointer to application list model. | 179 // Unowned pointer to application list model. |
| 185 AppListModel* model_; | 180 AppListModel* model_; |
| 186 | 181 |
| 187 // Sub-views of the ContentsView. All owned by the views hierarchy. | 182 // Sub-views of the ContentsView. All owned by the views hierarchy. |
| 188 AppsContainerView* apps_container_view_; | 183 AppsContainerView* apps_container_view_; |
| 189 SearchResultPageView* search_results_page_view_; | 184 SearchResultPageView* search_results_page_view_; |
| 190 StartPageView* start_page_view_; | 185 StartPageView* start_page_view_; |
| 191 CustomLauncherPageView* custom_page_view_; | 186 CustomLauncherPageView* custom_page_view_; |
| 192 | 187 |
| 193 // Unowned pointer to the container of the search answer web view. This | |
| 194 // container view is a sub-view of search_results_page_view_. | |
| 195 View* search_answer_container_view_; | |
| 196 | |
| 197 // The child page views. Owned by the views hierarchy. | 188 // The child page views. Owned by the views hierarchy. |
| 198 std::vector<AppListPage*> app_list_pages_; | 189 std::vector<AppListPage*> app_list_pages_; |
| 199 | 190 |
| 200 // Parent view. Owned by the views hierarchy. | 191 // Parent view. Owned by the views hierarchy. |
| 201 AppListMainView* app_list_main_view_; | 192 AppListMainView* app_list_main_view_; |
| 202 | 193 |
| 203 // Maps State onto |view_model_| indices. | 194 // Maps State onto |view_model_| indices. |
| 204 std::map<AppListModel::State, int> state_to_view_; | 195 std::map<AppListModel::State, int> state_to_view_; |
| 205 | 196 |
| 206 // Maps |view_model_| indices onto State. | 197 // Maps |view_model_| indices onto State. |
| 207 std::map<int, AppListModel::State> view_to_state_; | 198 std::map<int, AppListModel::State> view_to_state_; |
| 208 | 199 |
| 209 // The page that was showing before ShowSearchResults(true) was invoked. | 200 // The page that was showing before ShowSearchResults(true) was invoked. |
| 210 int page_before_search_; | 201 int page_before_search_; |
| 211 | 202 |
| 212 // Manages the pagination for the launcher pages. | 203 // Manages the pagination for the launcher pages. |
| 213 PaginationModel pagination_model_; | 204 PaginationModel pagination_model_; |
| 214 | 205 |
| 215 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 206 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
| 216 }; | 207 }; |
| 217 | 208 |
| 218 } // namespace app_list | 209 } // namespace app_list |
| 219 | 210 |
| 220 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 211 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
| OLD | NEW |