| 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> |
| 9 |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
| 12 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
| 13 | 15 |
| 14 namespace content { | 16 namespace content { |
| 15 class WebContents; | 17 class WebContents; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace views { | 20 namespace views { |
| 19 class BoundsAnimator; | 21 class BoundsAnimator; |
| 20 class ViewModel; | 22 class ViewModel; |
| 21 } | 23 } |
| 22 | 24 |
| 23 namespace app_list { | 25 namespace app_list { |
| 24 | 26 |
| 25 class AppsGridView; | 27 class AppsGridView; |
| 26 class ApplicationDragAndDropHost; | 28 class ApplicationDragAndDropHost; |
| 27 class AppListFolderItem; | 29 class AppListFolderItem; |
| 28 class AppListMainView; | 30 class AppListMainView; |
| 29 class AppListModel; | 31 class AppListModel; |
| 30 class AppListViewDelegate; | 32 class AppListViewDelegate; |
| 31 class AppsContainerView; | 33 class AppsContainerView; |
| 32 class PaginationModel; | 34 class PaginationModel; |
| 33 class SearchResultListView; | 35 class SearchResultListView; |
| 34 class StartPageView; | 36 class StartPageView; |
| 35 | 37 |
| 36 // A view to manage sub views under the search box (apps grid view + page | 38 // A view to manage launcher pages within the Launcher (eg. start page, apps |
| 37 // switcher and search results). The two sets of sub views are mutually | 39 // grid view, search results). There can be any number of launcher pages, only |
| 38 // exclusive. ContentsView manages a show state to choose one set to show | 40 // one of which can be active at a given time. ContentsView provides the user |
| 39 // and animates the transition between show states. | 41 // interface for switching between launcher pages, and animates the transition |
| 42 // between them. |
| 40 class APP_LIST_EXPORT ContentsView : public views::View { | 43 class APP_LIST_EXPORT ContentsView : public views::View { |
| 41 public: | 44 public: |
| 42 enum ShowState { | 45 // Values of this enum denote special launcher pages that require hard-coding. |
| 43 SHOW_APPS, | 46 // Launcher pages are not required to have a NamedPage enum value. |
| 44 SHOW_SEARCH_RESULTS, | 47 enum NamedPage { |
| 45 SHOW_START_PAGE, | 48 NAMED_PAGE_APPS, |
| 49 NAMED_PAGE_SEARCH_RESULTS, |
| 50 NAMED_PAGE_START, |
| 46 }; | 51 }; |
| 47 | 52 |
| 48 ContentsView(AppListMainView* app_list_main_view, | 53 ContentsView(AppListMainView* app_list_main_view, |
| 49 AppListModel* model, | 54 AppListModel* model, |
| 50 AppListViewDelegate* view_delegate); | 55 AppListViewDelegate* view_delegate); |
| 51 virtual ~ContentsView(); | 56 virtual ~ContentsView(); |
| 52 | 57 |
| 53 // The app list gets closed and drag and drop operations need to be cancelled. | 58 // The app list gets closed and drag and drop operations need to be cancelled. |
| 54 void CancelDrag(); | 59 void CancelDrag(); |
| 55 | 60 |
| 56 // If |drag_and_drop| is not NULL it will be called upon drag and drop | 61 // If |drag_and_drop| is not NULL it will be called upon drag and drop |
| 57 // operations outside the application list. | 62 // operations outside the application list. |
| 58 void SetDragAndDropHostOfCurrentAppList( | 63 void SetDragAndDropHostOfCurrentAppList( |
| 59 ApplicationDragAndDropHost* drag_and_drop_host); | 64 ApplicationDragAndDropHost* drag_and_drop_host); |
| 60 | 65 |
| 61 void ShowSearchResults(bool show); | 66 void ShowSearchResults(bool show); |
| 62 void ShowFolderContent(AppListFolderItem* folder); | 67 void ShowFolderContent(AppListFolderItem* folder); |
| 63 | 68 |
| 64 // Sets show state and animates the subviews to match the show state. | 69 // Sets the active launcher page and animates the pages into place. |
| 65 void SetShowState(ShowState show_state); | 70 void SetActivePage(int page_index); |
| 71 |
| 72 // The index of the currently active launcher page. |
| 73 int active_page_index() const { return active_page_; } |
| 74 |
| 75 // True if |named_page| is the current active laucher page. |
| 76 bool IsNamedPageActive(NamedPage named_page) const; |
| 77 |
| 78 // Gets the index of a launcher page in |view_model_|, by NamedPage. |
| 79 int GetPageIndexForNamedPage(NamedPage named_page) const; |
| 66 | 80 |
| 67 void Prerender(); | 81 void Prerender(); |
| 68 | 82 |
| 69 AppsContainerView* apps_container_view() { return apps_container_view_; } | 83 AppsContainerView* apps_container_view() { return apps_container_view_; } |
| 70 StartPageView* start_page_view() { return start_page_view_; } | 84 StartPageView* start_page_view() { return start_page_view_; } |
| 71 | 85 |
| 72 ShowState show_state() const { return show_state_; } | |
| 73 | |
| 74 // Overridden from views::View: | 86 // Overridden from views::View: |
| 75 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 87 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 76 virtual void Layout() OVERRIDE; | 88 virtual void Layout() OVERRIDE; |
| 77 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 89 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
| 78 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; | 90 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; |
| 79 | 91 |
| 80 private: | 92 private: |
| 81 // Invoked when show state is changed. | 93 // Invoked when active view is changed. |
| 82 void ShowStateChanged(); | 94 void ActivePageChanged(); |
| 83 | 95 |
| 84 void CalculateIdealBounds(); | 96 void CalculateIdealBounds(); |
| 85 void AnimateToIdealBounds(); | 97 void AnimateToIdealBounds(); |
| 86 | 98 |
| 99 // Adds |view| as a new page to the end of the list of launcher pages. The |
| 100 // view is inserted as a child of the ContentsView. There is no name |
| 101 // associated with the page. Returns the index of the new page. |
| 102 int AddLauncherPage(views::View* view); |
| 103 |
| 104 // Adds |view| as a new page to the end of the list of launcher pages. The |
| 105 // view is inserted as a child of the ContentsView. The page is associated |
| 106 // with the name |named_page|. Returns the index of the new page. |
| 107 int AddLauncherPage(views::View* view, NamedPage named_page); |
| 108 |
| 87 // Gets the PaginationModel owned by the AppsGridView. | 109 // Gets the PaginationModel owned by the AppsGridView. |
| 88 PaginationModel* GetAppsPaginationModel(); | 110 PaginationModel* GetAppsPaginationModel(); |
| 89 | 111 |
| 90 // Overridden from ui::EventHandler: | 112 // Overridden from ui::EventHandler: |
| 91 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 113 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 92 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 114 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
| 93 | 115 |
| 94 ShowState show_state_; | 116 // Index into |view_model_| of the currently active page. |
| 117 int active_page_; |
| 95 | 118 |
| 96 // Special sub views of the ContentsView. All owned by the views hierarchy. | 119 // Special sub views of the ContentsView. All owned by the views hierarchy. |
| 97 AppsContainerView* apps_container_view_; | 120 AppsContainerView* apps_container_view_; |
| 98 SearchResultListView* search_results_view_; | 121 SearchResultListView* search_results_view_; |
| 99 StartPageView* start_page_view_; | 122 StartPageView* start_page_view_; |
| 100 | 123 |
| 101 AppListMainView* app_list_main_view_; // Parent view, owns this. | 124 AppListMainView* app_list_main_view_; // Parent view, owns this. |
| 102 | 125 |
| 103 scoped_ptr<views::ViewModel> view_model_; | 126 scoped_ptr<views::ViewModel> view_model_; |
| 127 // Maps NamedPage onto |view_model_| indices. |
| 128 std::map<NamedPage, int> named_page_to_view_; |
| 104 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 129 scoped_ptr<views::BoundsAnimator> bounds_animator_; |
| 105 | 130 |
| 106 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 131 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
| 107 }; | 132 }; |
| 108 | 133 |
| 109 } // namespace app_list | 134 } // namespace app_list |
| 110 | 135 |
| 111 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 136 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
| OLD | NEW |