Chromium Code Reviews| 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. |
| 46 // Launcher pages are not required to have a NamedPage enum value. | |
| 47 enum NamedPage { | |
| 43 SHOW_APPS, | 48 SHOW_APPS, |
|
benwells
2014/06/06 06:12:29
Nit: should be NAMED_PAGE_APPS, etc.
Matt Giuca
2014/06/10 04:01:19
Done.
benwells
2014/06/10 08:06:42
There seems to be a new style for enums; as your e
Matt Giuca
2014/06/10 08:45:08
OK, renamed again.
| |
| 44 SHOW_SEARCH_RESULTS, | 49 SHOW_SEARCH_RESULTS, |
| 45 SHOW_START_PAGE, | 50 SHOW_START_PAGE, |
| 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() const { return active_page_; } | |
|
benwells
2014/06/06 06:12:29
Nit: active_page -> active_page_index
Matt Giuca
2014/06/10 04:01:19
Done.
| |
| 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 child of the ContentsView. Also adds it to the view model, | |
| 100 // having no named page associated with it. | |
| 101 void AddLauncherPage(views::View* view); | |
|
benwells
2014/06/06 06:12:29
Should these mention that it is added next in the
Matt Giuca
2014/06/10 04:01:19
Not sure what you mean -- the buttons along the bo
benwells
2014/06/10 08:06:42
I mean there is an ordering to the pages, and when
Matt Giuca
2014/06/10 08:45:08
Done.
| |
| 102 | |
| 103 // Adds |view| as a child of the ContentsView. Also adds it to the view model, | |
| 104 // associating it with |named_page|. | |
| 105 void AddLauncherPage(views::View* view, NamedPage named_page); | |
| 106 | |
| 87 // Gets the PaginationModel owned by the AppsGridView. | 107 // Gets the PaginationModel owned by the AppsGridView. |
| 88 PaginationModel* GetAppsPaginationModel(); | 108 PaginationModel* GetAppsPaginationModel(); |
| 89 | 109 |
| 90 // Overridden from ui::EventHandler: | 110 // Overridden from ui::EventHandler: |
| 91 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 111 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 92 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 112 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
| 93 | 113 |
| 94 ShowState show_state_; | 114 // Index into |view_model_| of the currently active page. |
| 115 int active_page_; | |
| 95 | 116 |
| 96 // Special sub views of the ContentsView. All owned by the views hierarchy. | 117 // Special sub views of the ContentsView. All owned by the views hierarchy. |
| 97 AppsContainerView* apps_container_view_; | 118 AppsContainerView* apps_container_view_; |
| 98 SearchResultListView* search_results_view_; | 119 SearchResultListView* search_results_view_; |
| 99 StartPageView* start_page_view_; | 120 StartPageView* start_page_view_; |
| 100 | 121 |
| 101 AppListMainView* app_list_main_view_; // Parent view, owns this. | 122 AppListMainView* app_list_main_view_; // Parent view, owns this. |
| 102 | 123 |
| 103 scoped_ptr<views::ViewModel> view_model_; | 124 scoped_ptr<views::ViewModel> view_model_; |
| 125 // Maps NamedPage onto |view_model_| indices. | |
| 126 std::map<NamedPage, int> named_page_to_view_; | |
| 104 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 127 scoped_ptr<views::BoundsAnimator> bounds_animator_; |
| 105 | 128 |
| 106 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 129 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
| 107 }; | 130 }; |
| 108 | 131 |
| 109 } // namespace app_list | 132 } // namespace app_list |
| 110 | 133 |
| 111 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 134 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
| OLD | NEW |