Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: ui/app_list/views/contents_view.h

Issue 701773002: App list: Added contents view custom animation framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed default animator reverse not being set. Oooops. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/app_list/views/contents_animator.cc ('k') | ui/app_list/views/contents_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
31 class AppListViewDelegate; 32 class AppListViewDelegate;
32 class AppsContainerView; 33 class AppsContainerView;
34 class ContentsAnimator;
33 class ContentsSwitcherView; 35 class ContentsSwitcherView;
34 class PaginationModel; 36 class PaginationModel;
35 class SearchResultListView; 37 class SearchResultListView;
36 class SearchResultPageView; 38 class SearchResultPageView;
37 class StartPageView; 39 class StartPageView;
38 40
39 // 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
40 // 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
41 // 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
42 // interface for switching between launcher pages, and animates the transition 44 // interface for switching between launcher pages, and animates the transition
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const PaginationModel& pagination_model() { return pagination_model_; } 106 const PaginationModel& pagination_model() { return pagination_model_; }
105 107
106 // Returns search box bounds to use for content views that do not specify 108 // Returns search box bounds to use for content views that do not specify
107 // their own custom layout. 109 // their own custom layout.
108 gfx::Rect GetDefaultSearchBoxBounds() const; 110 gfx::Rect GetDefaultSearchBoxBounds() const;
109 111
110 // Returns the content area bounds to use for content views that do not 112 // Returns the content area bounds to use for content views that do not
111 // specify their own custom layout. 113 // specify their own custom layout.
112 gfx::Rect GetDefaultContentsBounds() const; 114 gfx::Rect GetDefaultContentsBounds() const;
113 115
116 // Exposes GetAnimatorForTransition for tests.
117 ContentsAnimator* GetAnimatorForTransitionForTests(int from_page,
118 int to_page,
119 bool* reverse) const {
120 return GetAnimatorForTransition(from_page, to_page, reverse);
121 }
122
114 // Overridden from views::View: 123 // Overridden from views::View:
115 gfx::Size GetPreferredSize() const override; 124 gfx::Size GetPreferredSize() const override;
116 void Layout() override; 125 void Layout() override;
117 bool OnKeyPressed(const ui::KeyEvent& event) override; 126 bool OnKeyPressed(const ui::KeyEvent& event) override;
118 127
119 // Overridden from PaginationModelObserver: 128 // Overridden from PaginationModelObserver:
120 void TotalPagesChanged() override; 129 void TotalPagesChanged() override;
121 void SelectedPageChanged(int old_selected, int new_selected) override; 130 void SelectedPageChanged(int old_selected, int new_selected) override;
122 void TransitionStarted() override; 131 void TransitionStarted() override;
123 void TransitionChanged() override; 132 void TransitionChanged() override;
124 133
125 private: 134 private:
126 // Sets the active launcher page, accounting for whether the change is for 135 // Sets the active launcher page, accounting for whether the change is for
127 // search results. 136 // search results.
128 void SetActivePageInternal(int page_index, bool show_search_results); 137 void SetActivePageInternal(int page_index, bool show_search_results);
129 138
130 // Invoked when active view is changed. 139 // Invoked when active view is changed.
131 void ActivePageChanged(); 140 void ActivePageChanged();
132 141
133 // Returns the size of the default content area. 142 // Returns the size of the default content area.
134 gfx::Size GetDefaultContentsSize() const; 143 gfx::Size GetDefaultContentsSize() const;
135 144
136 // Gets the origin (the off-screen resting place) for a given launcher page
137 // with index |page_index|.
138 gfx::Rect GetOffscreenPageBounds(int page_index) const;
139
140 // Notifies the view delegate that the custom launcher page's animation has 145 // Notifies the view delegate that the custom launcher page's animation has
141 // changed. 146 // changed.
142 void NotifyCustomLauncherPageAnimationChanged(double progress, 147 void NotifyCustomLauncherPageAnimationChanged(double progress,
143 int current_page, 148 int current_page,
144 int target_page); 149 int target_page);
145 150
146 // Calculates and sets the bounds for the subviews. If there is currently an 151 // Calculates and sets the bounds for the subviews. If there is currently an
147 // animation, this positions the views as appropriate for the current frame. 152 // animation, this positions the views as appropriate for the current frame.
148 void UpdatePageBounds(); 153 void UpdatePageBounds();
149 154
150 // Adds |view| as a new page to the end of the list of launcher pages. The 155 // Adds |view| as a new page to the end of the list of launcher pages. The
151 // view is inserted as a child of the ContentsView, and a button with 156 // view is inserted as a child of the ContentsView, and a button with
152 // |resource_id| is added to the ContentsSwitcherView. There is no name 157 // |resource_id| is added to the ContentsSwitcherView. There is no name
153 // associated with the page. Returns the index of the new page. 158 // associated with the page. Returns the index of the new page.
154 int AddLauncherPage(views::View* view, int resource_id); 159 int AddLauncherPage(views::View* view, int resource_id);
155 160
156 // Adds |view| as a new page to the end of the list of launcher pages. The 161 // Adds |view| as a new page to the end of the list of launcher pages. The
157 // view is inserted as a child of the ContentsView, and a button with 162 // view is inserted as a child of the ContentsView, and a button with
158 // |resource_id| is added to the ContentsSwitcherView. The page is associated 163 // |resource_id| is added to the ContentsSwitcherView. The page is associated
159 // with the name |state|. Returns the index of the new page. 164 // with the name |state|. Returns the index of the new page.
160 int AddLauncherPage(views::View* view, 165 int AddLauncherPage(views::View* view,
161 int resource_id, 166 int resource_id,
162 AppListModel::State state); 167 AppListModel::State state);
163 168
164 // Gets the PaginationModel owned by the AppsGridView. 169 // Gets the PaginationModel owned by the AppsGridView.
165 // Note: This is different to |pagination_model_|, which manages top-level 170 // Note: This is different to |pagination_model_|, which manages top-level
166 // launcher-page pagination. 171 // launcher-page pagination.
167 PaginationModel* GetAppsPaginationModel(); 172 PaginationModel* GetAppsPaginationModel();
168 173
174 // Adds a ContentsAnimator for a transition from |from_state| to |to_state|.
175 void AddAnimator(AppListModel::State from_state,
176 AppListModel::State to_state,
177 scoped_ptr<ContentsAnimator> animator);
178
179 // Gets a ContentsAnimator for a transition from |from_page| to |to_page|. If
180 // the animator should be run in reverse (because it is a |to_page| to
181 // |from_page| animator), |reverse| is set to true; otherwise it is set to
182 // false.
183 ContentsAnimator* GetAnimatorForTransition(int from_page,
184 int to_page,
185 bool* reverse) const;
186
169 // Special sub views of the ContentsView. All owned by the views hierarchy. 187 // Special sub views of the ContentsView. All owned by the views hierarchy.
170 AppsContainerView* apps_container_view_; 188 AppsContainerView* apps_container_view_;
171 189
172 // Only used in the normal app list. 190 // Only used in the normal app list.
173 SearchResultListView* search_results_list_view_; 191 SearchResultListView* search_results_list_view_;
174 192
175 // Only used in the experimental app list. 193 // Only used in the experimental app list.
176 SearchResultPageView* search_results_page_view_; 194 SearchResultPageView* search_results_page_view_;
177 StartPageView* start_page_view_; 195 StartPageView* start_page_view_;
178 196
179 AppListMainView* app_list_main_view_; // Parent view, owns this. 197 AppListMainView* app_list_main_view_; // Parent view, owns this.
180 // Sibling view, owned by |app_list_main_view_|. 198 // Sibling view, owned by |app_list_main_view_|.
181 ContentsSwitcherView* contents_switcher_view_; 199 ContentsSwitcherView* contents_switcher_view_;
182 200
183 scoped_ptr<views::ViewModel> view_model_; 201 scoped_ptr<views::ViewModel> view_model_;
184 202
185 // Maps State onto |view_model_| indices. 203 // Maps State onto |view_model_| indices.
186 std::map<AppListModel::State, int> state_to_view_; 204 std::map<AppListModel::State, int> state_to_view_;
187 205
188 // Maps |view_model_| indices onto State. 206 // Maps |view_model_| indices onto State.
189 std::map<int, AppListModel::State> view_to_state_; 207 std::map<int, AppListModel::State> view_to_state_;
190 208
191 // The page that was showing before ShowSearchResults(true) was invoked. 209 // The page that was showing before ShowSearchResults(true) was invoked.
192 int page_before_search_; 210 int page_before_search_;
193 211
194 // Manages the pagination for the launcher pages. 212 // Manages the pagination for the launcher pages.
195 PaginationModel pagination_model_; 213 PaginationModel pagination_model_;
196 214
215 // Maps from {A, B} pair to ContentsAnimator, where A and B are page
216 // |view_model_| indices for an animation from A to B.
217 std::map<std::pair<int, int>, linked_ptr<ContentsAnimator>>
218 contents_animators_;
219
220 // The animator for transitions not found in |contents_animators_|.
221 scoped_ptr<ContentsAnimator> default_animator_;
222
197 DISALLOW_COPY_AND_ASSIGN(ContentsView); 223 DISALLOW_COPY_AND_ASSIGN(ContentsView);
198 }; 224 };
199 225
200 } // namespace app_list 226 } // namespace app_list
201 227
202 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ 228 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
OLDNEW
« no previous file with comments | « ui/app_list/views/contents_animator.cc ('k') | ui/app_list/views/contents_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698