| 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/pagination_model.h" |
| 15 #include "ui/app_list/pagination_model_observer.h" |
| 14 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 15 | 17 |
| 16 namespace views { | 18 namespace views { |
| 17 class BoundsAnimator; | |
| 18 class ViewModel; | 19 class ViewModel; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace app_list { | 22 namespace app_list { |
| 22 | 23 |
| 23 class AppsGridView; | 24 class AppsGridView; |
| 24 class ApplicationDragAndDropHost; | 25 class ApplicationDragAndDropHost; |
| 25 class AppListFolderItem; | 26 class AppListFolderItem; |
| 26 class AppListMainView; | 27 class AppListMainView; |
| 27 class AppListModel; | 28 class AppListModel; |
| 28 class AppListViewDelegate; | 29 class AppListViewDelegate; |
| 29 class AppsContainerView; | 30 class AppsContainerView; |
| 30 class PaginationModel; | 31 class PaginationModel; |
| 31 class SearchResultListView; | 32 class SearchResultListView; |
| 32 class StartPageView; | 33 class StartPageView; |
| 33 | 34 |
| 34 // A view to manage launcher pages within the Launcher (eg. start page, apps | 35 // A view to manage launcher pages within the Launcher (eg. start page, apps |
| 35 // grid view, search results). There can be any number of launcher pages, only | 36 // grid view, search results). There can be any number of launcher pages, only |
| 36 // one of which can be active at a given time. ContentsView provides the user | 37 // one of which can be active at a given time. ContentsView provides the user |
| 37 // interface for switching between launcher pages, and animates the transition | 38 // interface for switching between launcher pages, and animates the transition |
| 38 // between them. | 39 // between them. |
| 39 class APP_LIST_EXPORT ContentsView : public views::View { | 40 class APP_LIST_EXPORT ContentsView : public views::View, |
| 41 public PaginationModelObserver { |
| 40 public: | 42 public: |
| 41 // Values of this enum denote special launcher pages that require hard-coding. | 43 // Values of this enum denote special launcher pages that require hard-coding. |
| 42 // Launcher pages are not required to have a NamedPage enum value. | 44 // Launcher pages are not required to have a NamedPage enum value. |
| 43 enum NamedPage { | 45 enum NamedPage { |
| 44 NAMED_PAGE_APPS, | 46 NAMED_PAGE_APPS, |
| 45 NAMED_PAGE_SEARCH_RESULTS, | 47 NAMED_PAGE_SEARCH_RESULTS, |
| 46 NAMED_PAGE_START, | 48 NAMED_PAGE_START, |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 ContentsView(AppListMainView* app_list_main_view, | 51 ContentsView(AppListMainView* app_list_main_view, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 ApplicationDragAndDropHost* drag_and_drop_host); | 62 ApplicationDragAndDropHost* drag_and_drop_host); |
| 61 | 63 |
| 62 void ShowSearchResults(bool show); | 64 void ShowSearchResults(bool show); |
| 63 void ShowFolderContent(AppListFolderItem* folder); | 65 void ShowFolderContent(AppListFolderItem* folder); |
| 64 bool IsShowingSearchResults() const; | 66 bool IsShowingSearchResults() const; |
| 65 | 67 |
| 66 // Sets the active launcher page and animates the pages into place. | 68 // Sets the active launcher page and animates the pages into place. |
| 67 void SetActivePage(int page_index); | 69 void SetActivePage(int page_index); |
| 68 | 70 |
| 69 // The index of the currently active launcher page. | 71 // The index of the currently active launcher page. |
| 70 int active_page_index() const { return active_page_; } | 72 int GetActivePageIndex() const; |
| 71 | 73 |
| 72 // True if |named_page| is the current active laucher page. | 74 // True if |named_page| is the current active laucher page. |
| 73 bool IsNamedPageActive(NamedPage named_page) const; | 75 bool IsNamedPageActive(NamedPage named_page) const; |
| 74 | 76 |
| 75 // Gets the index of a launcher page in |view_model_|, by NamedPage. | 77 // Gets the index of a launcher page in |view_model_|, by NamedPage. |
| 76 int GetPageIndexForNamedPage(NamedPage named_page) const; | 78 int GetPageIndexForNamedPage(NamedPage named_page) const; |
| 77 | 79 |
| 80 int NumLauncherPages() const; |
| 81 |
| 78 void Prerender(); | 82 void Prerender(); |
| 79 | 83 |
| 80 AppsContainerView* apps_container_view() { return apps_container_view_; } | 84 AppsContainerView* apps_container_view() { return apps_container_view_; } |
| 81 StartPageView* start_page_view() { return start_page_view_; } | 85 StartPageView* start_page_view() { return start_page_view_; } |
| 82 SearchResultListView* search_results_view() { return search_results_view_; } | 86 SearchResultListView* search_results_view() { return search_results_view_; } |
| 87 views::View* GetPageView(int index); |
| 88 |
| 89 // Adds a blank launcher page. For use in tests only. |
| 90 void AddBlankPageForTesting(); |
| 83 | 91 |
| 84 // Overridden from views::View: | 92 // Overridden from views::View: |
| 85 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 93 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 86 virtual void Layout() OVERRIDE; | 94 virtual void Layout() OVERRIDE; |
| 87 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 95 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
| 88 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; | 96 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; |
| 89 | 97 |
| 98 // Overridden from PaginationModelObserver: |
| 99 virtual void TotalPagesChanged() OVERRIDE; |
| 100 virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE; |
| 101 virtual void TransitionStarted() OVERRIDE; |
| 102 virtual void TransitionChanged() OVERRIDE; |
| 103 |
| 90 private: | 104 private: |
| 91 // Invoked when active view is changed. | 105 // Invoked when active view is changed. |
| 92 void ActivePageChanged(); | 106 void ActivePageChanged(); |
| 93 | 107 |
| 94 void CalculateIdealBounds(); | 108 // Calculates and sets the bounds for the subviews. If there is currently an |
| 95 void AnimateToIdealBounds(); | 109 // animation, this positions the views as appropriate for the current frame. |
| 110 void UpdatePageBounds(); |
| 96 | 111 |
| 97 // Adds |view| as a new page to the end of the list of launcher pages. The | 112 // Adds |view| as a new page to the end of the list of launcher pages. The |
| 98 // view is inserted as a child of the ContentsView. There is no name | 113 // view is inserted as a child of the ContentsView. There is no name |
| 99 // associated with the page. Returns the index of the new page. | 114 // associated with the page. Returns the index of the new page. |
| 100 int AddLauncherPage(views::View* view); | 115 int AddLauncherPage(views::View* view); |
| 101 | 116 |
| 102 // Adds |view| as a new page to the end of the list of launcher pages. The | 117 // Adds |view| as a new page to the end of the list of launcher pages. The |
| 103 // view is inserted as a child of the ContentsView. The page is associated | 118 // view is inserted as a child of the ContentsView. The page is associated |
| 104 // with the name |named_page|. Returns the index of the new page. | 119 // with the name |named_page|. Returns the index of the new page. |
| 105 int AddLauncherPage(views::View* view, NamedPage named_page); | 120 int AddLauncherPage(views::View* view, NamedPage named_page); |
| 106 | 121 |
| 107 // Gets the PaginationModel owned by the AppsGridView. | 122 // Gets the PaginationModel owned by the AppsGridView. |
| 123 // Note: This is different to |pagination_model_|, which manages top-level |
| 124 // launcher-page pagination. |
| 108 PaginationModel* GetAppsPaginationModel(); | 125 PaginationModel* GetAppsPaginationModel(); |
| 109 | 126 |
| 110 // Overridden from ui::EventHandler: | 127 // Overridden from ui::EventHandler: |
| 111 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 128 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 112 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 129 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
| 113 | 130 |
| 114 // Index into |view_model_| of the currently active page. | |
| 115 int active_page_; | |
| 116 | |
| 117 // Special sub views of the ContentsView. All owned by the views hierarchy. | 131 // Special sub views of the ContentsView. All owned by the views hierarchy. |
| 118 AppsContainerView* apps_container_view_; | 132 AppsContainerView* apps_container_view_; |
| 119 SearchResultListView* search_results_view_; | 133 SearchResultListView* search_results_view_; |
| 120 StartPageView* start_page_view_; | 134 StartPageView* start_page_view_; |
| 121 | 135 |
| 122 AppListMainView* app_list_main_view_; // Parent view, owns this. | 136 AppListMainView* app_list_main_view_; // Parent view, owns this. |
| 123 | 137 |
| 124 scoped_ptr<views::ViewModel> view_model_; | 138 scoped_ptr<views::ViewModel> view_model_; |
| 125 // Maps NamedPage onto |view_model_| indices. | 139 // Maps NamedPage onto |view_model_| indices. |
| 126 std::map<NamedPage, int> named_page_to_view_; | 140 std::map<NamedPage, int> named_page_to_view_; |
| 127 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 141 |
| 142 // Manages the pagination for the launcher pages. |
| 143 PaginationModel pagination_model_; |
| 128 | 144 |
| 129 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 145 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
| 130 }; | 146 }; |
| 131 | 147 |
| 132 } // namespace app_list | 148 } // namespace app_list |
| 133 | 149 |
| 134 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 150 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
| OLD | NEW |