| 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 <utility> | 
| 9 | 10 | 
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" | 
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" | 
|  | 13 #include "base/memory/linked_ptr.h" | 
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" | 
| 13 #include "ui/app_list/app_list_export.h" | 15 #include "ui/app_list/app_list_export.h" | 
| 14 #include "ui/app_list/app_list_model.h" | 16 #include "ui/app_list/app_list_model.h" | 
| 15 #include "ui/app_list/pagination_model.h" | 17 #include "ui/app_list/pagination_model.h" | 
| 16 #include "ui/app_list/pagination_model_observer.h" | 18 #include "ui/app_list/pagination_model_observer.h" | 
| 17 #include "ui/views/view.h" | 19 #include "ui/views/view.h" | 
| 18 #include "ui/views/view_model.h" | 20 #include "ui/views/view_model.h" | 
| 19 | 21 | 
| 20 namespace gfx { | 22 namespace gfx { | 
| 21 class Rect; | 23 class Rect; | 
| 22 } | 24 } | 
| 23 | 25 | 
| 24 namespace app_list { | 26 namespace app_list { | 
| 25 | 27 | 
| 26 class AppsGridView; | 28 class AppsGridView; | 
| 27 class ApplicationDragAndDropHost; | 29 class ApplicationDragAndDropHost; | 
| 28 class AppListFolderItem; | 30 class AppListFolderItem; | 
| 29 class AppListMainView; | 31 class AppListMainView; | 
| 30 class AppListModel; | 32 class AppListModel; | 
| 31 class AppListViewDelegate; | 33 class AppListViewDelegate; | 
| 32 class AppsContainerView; | 34 class AppsContainerView; | 
|  | 35 class ContentsAnimator; | 
| 33 class ContentsSwitcherView; | 36 class ContentsSwitcherView; | 
| 34 class PaginationModel; | 37 class PaginationModel; | 
| 35 class SearchResultListView; | 38 class SearchResultListView; | 
| 36 class StartPageView; | 39 class StartPageView; | 
| 37 | 40 | 
| 38 // 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 | 
| 39 // 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 | 
| 40 // 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 | 
| 41 // interface for switching between launcher pages, and animates the transition | 44 // interface for switching between launcher pages, and animates the transition | 
| 42 // between them. | 45 // between them. | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 98   const PaginationModel& pagination_model() { return pagination_model_; } | 101   const PaginationModel& pagination_model() { return pagination_model_; } | 
| 99 | 102 | 
| 100   // Returns search box bounds to use for content views that do not specify | 103   // Returns search box bounds to use for content views that do not specify | 
| 101   // their own custom layout. | 104   // their own custom layout. | 
| 102   gfx::Rect GetDefaultSearchBoxBounds() const; | 105   gfx::Rect GetDefaultSearchBoxBounds() const; | 
| 103 | 106 | 
| 104   // Returns the content area bounds to use for content views that do not | 107   // Returns the content area bounds to use for content views that do not | 
| 105   // specify their own custom layout. | 108   // specify their own custom layout. | 
| 106   gfx::Rect GetDefaultContentsBounds() const; | 109   gfx::Rect GetDefaultContentsBounds() const; | 
| 107 | 110 | 
|  | 111   // Exposes GetAnimatorForTransition for tests. | 
|  | 112   ContentsAnimator* GetAnimatorForTransitionForTests(int from_page, | 
|  | 113                                                      int to_page, | 
|  | 114                                                      bool* reverse) const { | 
|  | 115     return GetAnimatorForTransition(from_page, to_page, reverse); | 
|  | 116   } | 
|  | 117 | 
| 108   // Overridden from views::View: | 118   // Overridden from views::View: | 
| 109   gfx::Size GetPreferredSize() const override; | 119   gfx::Size GetPreferredSize() const override; | 
| 110   void Layout() override; | 120   void Layout() override; | 
| 111   bool OnKeyPressed(const ui::KeyEvent& event) override; | 121   bool OnKeyPressed(const ui::KeyEvent& event) override; | 
| 112 | 122 | 
| 113   // Overridden from PaginationModelObserver: | 123   // Overridden from PaginationModelObserver: | 
| 114   void TotalPagesChanged() override; | 124   void TotalPagesChanged() override; | 
| 115   void SelectedPageChanged(int old_selected, int new_selected) override; | 125   void SelectedPageChanged(int old_selected, int new_selected) override; | 
| 116   void TransitionStarted() override; | 126   void TransitionStarted() override; | 
| 117   void TransitionChanged() override; | 127   void TransitionChanged() override; | 
| 118 | 128 | 
| 119  private: | 129  private: | 
| 120   // Sets the active launcher page, accounting for whether the change is for | 130   // Sets the active launcher page, accounting for whether the change is for | 
| 121   // search results. | 131   // search results. | 
| 122   void SetActivePageInternal(int page_index, bool show_search_results); | 132   void SetActivePageInternal(int page_index, bool show_search_results); | 
| 123 | 133 | 
| 124   // Invoked when active view is changed. | 134   // Invoked when active view is changed. | 
| 125   void ActivePageChanged(bool show_search_results); | 135   void ActivePageChanged(bool show_search_results); | 
| 126 | 136 | 
| 127   // Returns the size of the default content area. | 137   // Returns the size of the default content area. | 
| 128   gfx::Size GetDefaultContentsSize() const; | 138   gfx::Size GetDefaultContentsSize() const; | 
| 129 | 139 | 
| 130   // Gets the origin (the off-screen resting place) for a given launcher page |  | 
| 131   // with index |page_index|. |  | 
| 132   gfx::Rect GetOffscreenPageBounds(int page_index) const; |  | 
| 133 |  | 
| 134   // Calculates and sets the bounds for the subviews. If there is currently an | 140   // Calculates and sets the bounds for the subviews. If there is currently an | 
| 135   // animation, this positions the views as appropriate for the current frame. | 141   // animation, this positions the views as appropriate for the current frame. | 
| 136   void UpdatePageBounds(); | 142   void UpdatePageBounds(); | 
| 137 | 143 | 
| 138   // 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 | 
| 139   // 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 | 
| 140   // |resource_id| is added to the ContentsSwitcherView. There is no name | 146   // |resource_id| is added to the ContentsSwitcherView. There is no name | 
| 141   // associated with the page. Returns the index of the new page. | 147   // associated with the page. Returns the index of the new page. | 
| 142   int AddLauncherPage(views::View* view, int resource_id); | 148   int AddLauncherPage(views::View* view, int resource_id); | 
| 143 | 149 | 
| 144   // Adds |view| as a new page to the end of the list of launcher pages. The | 150   // Adds |view| as a new page to the end of the list of launcher pages. The | 
| 145   // view is inserted as a child of the ContentsView, and a button with | 151   // view is inserted as a child of the ContentsView, and a button with | 
| 146   // |resource_id| is added to the ContentsSwitcherView. The page is associated | 152   // |resource_id| is added to the ContentsSwitcherView. The page is associated | 
| 147   // with the name |state|. Returns the index of the new page. | 153   // with the name |state|. Returns the index of the new page. | 
| 148   int AddLauncherPage(views::View* view, | 154   int AddLauncherPage(views::View* view, | 
| 149                       int resource_id, | 155                       int resource_id, | 
| 150                       AppListModel::State state); | 156                       AppListModel::State state); | 
| 151 | 157 | 
| 152   // Gets the PaginationModel owned by the AppsGridView. | 158   // Gets the PaginationModel owned by the AppsGridView. | 
| 153   // Note: This is different to |pagination_model_|, which manages top-level | 159   // Note: This is different to |pagination_model_|, which manages top-level | 
| 154   // launcher-page pagination. | 160   // launcher-page pagination. | 
| 155   PaginationModel* GetAppsPaginationModel(); | 161   PaginationModel* GetAppsPaginationModel(); | 
| 156 | 162 | 
|  | 163   // Adds a ContentsAnimator for a transition from |from_page| to |to_page|. | 
|  | 164   void AddAnimator(int from_page, | 
|  | 165                    int to_page, | 
|  | 166                    scoped_ptr<ContentsAnimator> animator); | 
|  | 167 | 
|  | 168   // Gets a ContentsAnimator for a transition from |from_page| to |to_page|. If | 
|  | 169   // the animator should be run in reverse (because it is a |to_page| to | 
|  | 170   // |from_page| animator), |reverse| is set to true; otherwise it is set to | 
|  | 171   // false. | 
|  | 172   ContentsAnimator* GetAnimatorForTransition(int from_page, | 
|  | 173                                              int to_page, | 
|  | 174                                              bool* reverse) const; | 
|  | 175 | 
| 157   // Special sub views of the ContentsView. All owned by the views hierarchy. | 176   // Special sub views of the ContentsView. All owned by the views hierarchy. | 
| 158   AppsContainerView* apps_container_view_; | 177   AppsContainerView* apps_container_view_; | 
| 159   SearchResultListView* search_results_view_; | 178   SearchResultListView* search_results_view_; | 
| 160   StartPageView* start_page_view_; | 179   StartPageView* start_page_view_; | 
| 161 | 180 | 
| 162   AppListMainView* app_list_main_view_;     // Parent view, owns this. | 181   AppListMainView* app_list_main_view_;     // Parent view, owns this. | 
| 163   // Sibling view, owned by |app_list_main_view_|. | 182   // Sibling view, owned by |app_list_main_view_|. | 
| 164   ContentsSwitcherView* contents_switcher_view_; | 183   ContentsSwitcherView* contents_switcher_view_; | 
| 165 | 184 | 
| 166   scoped_ptr<views::ViewModel> view_model_; | 185   scoped_ptr<views::ViewModel> view_model_; | 
| 167 | 186 | 
| 168   // Maps State onto |view_model_| indices. | 187   // Maps State onto |view_model_| indices. | 
| 169   std::map<AppListModel::State, int> state_to_view_; | 188   std::map<AppListModel::State, int> state_to_view_; | 
| 170 | 189 | 
| 171   // Maps |view_model_| indices onto State. | 190   // Maps |view_model_| indices onto State. | 
| 172   std::map<int, AppListModel::State> view_to_state_; | 191   std::map<int, AppListModel::State> view_to_state_; | 
| 173 | 192 | 
| 174   // The page that was showing before ShowSearchResults(true) was invoked. | 193   // The page that was showing before ShowSearchResults(true) was invoked. | 
| 175   int page_before_search_; | 194   int page_before_search_; | 
| 176 | 195 | 
| 177   // Manages the pagination for the launcher pages. | 196   // Manages the pagination for the launcher pages. | 
| 178   PaginationModel pagination_model_; | 197   PaginationModel pagination_model_; | 
| 179 | 198 | 
|  | 199   // Maps from {A, B} pair to ContentsAnimator, where A and B are page | 
|  | 200   // |view_model_| indices for an animation from A to B. | 
|  | 201   std::map<std::pair<int, int>, linked_ptr<ContentsAnimator>> | 
|  | 202       contents_animators_; | 
|  | 203 | 
|  | 204   // The animator for transitions not found in |contents_animators_|. | 
|  | 205   scoped_ptr<ContentsAnimator> default_animator_; | 
|  | 206 | 
| 180   DISALLOW_COPY_AND_ASSIGN(ContentsView); | 207   DISALLOW_COPY_AND_ASSIGN(ContentsView); | 
| 181 }; | 208 }; | 
| 182 | 209 | 
| 183 }  // namespace app_list | 210 }  // namespace app_list | 
| 184 | 211 | 
| 185 #endif  // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 212 #endif  // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 
| OLD | NEW | 
|---|