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

Side by Side Diff: ui/app_list/contents_view.cc

Issue 10890049: app_list: Touch scroll and animation improvement. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « ui/app_list/apps_grid_view.cc ('k') | ui/app_list/pagination_model.h » ('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 #include "ui/app_list/contents_view.h" 5 #include "ui/app_list/contents_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/app_list/app_list_view.h" 9 #include "ui/app_list/app_list_view.h"
10 #include "ui/app_list/apps_grid_view.h" 10 #include "ui/app_list/apps_grid_view.h"
(...skipping 13 matching lines...) Expand all
24 const int kPreferredCols = 4; 24 const int kPreferredCols = 4;
25 const int kPreferredRows = 4; 25 const int kPreferredRows = 4;
26 26
27 // Indexes of interesting views in ViewModel of ContentsView. 27 // Indexes of interesting views in ViewModel of ContentsView.
28 const int kIndexAppsGrid = 0; 28 const int kIndexAppsGrid = 0;
29 const int kIndexPageSwitcher = 1; 29 const int kIndexPageSwitcher = 1;
30 const int kIndexSearchResults = 2; 30 const int kIndexSearchResults = 2;
31 31
32 const int kMinMouseWheelToSwitchPage = 20; 32 const int kMinMouseWheelToSwitchPage = 20;
33 const int kMinScrollToSwitchPage = 20; 33 const int kMinScrollToSwitchPage = 20;
34 const int kMinHorizVelocityToSwitchPage = 1100; 34 const int kMinHorizVelocityToSwitchPage = 800;
35
36 const double kFinishTransitionThreshold = 0.33;
37 const int kTransitionAnimationDurationInMs = 180;
35 38
36 // Helpers to get certain child view from |model|. 39 // Helpers to get certain child view from |model|.
37 AppsGridView* GetAppsGridView(views::ViewModel* model) { 40 AppsGridView* GetAppsGridView(views::ViewModel* model) {
38 return static_cast<AppsGridView*>(model->view_at(kIndexAppsGrid)); 41 return static_cast<AppsGridView*>(model->view_at(kIndexAppsGrid));
39 } 42 }
40 43
41 PageSwitcher* GetPageSwitcherView(views::ViewModel* model) { 44 PageSwitcher* GetPageSwitcherView(views::ViewModel* model) {
42 return static_cast<PageSwitcher*>(model->view_at(kIndexPageSwitcher)); 45 return static_cast<PageSwitcher*>(model->view_at(kIndexPageSwitcher));
43 } 46 }
44 47
45 SearchResultListView* GetSearchResultListView(views::ViewModel* model) { 48 SearchResultListView* GetSearchResultListView(views::ViewModel* model) {
46 return static_cast<SearchResultListView*>( 49 return static_cast<SearchResultListView*>(
47 model->view_at(kIndexSearchResults)); 50 model->view_at(kIndexSearchResults));
48 } 51 }
49 52
50 } // namespace 53 } // namespace
51 54
52 ContentsView::ContentsView(AppListView* app_list_view, 55 ContentsView::ContentsView(AppListView* app_list_view,
53 PaginationModel* pagination_model) 56 PaginationModel* pagination_model)
54 : show_state_(SHOW_APPS), 57 : show_state_(SHOW_APPS),
55 pagination_model_(pagination_model), 58 pagination_model_(pagination_model),
56 view_model_(new views::ViewModel), 59 view_model_(new views::ViewModel),
57 ALLOW_THIS_IN_INITIALIZER_LIST( 60 ALLOW_THIS_IN_INITIALIZER_LIST(
58 bounds_animator_(new views::BoundsAnimator(this))) { 61 bounds_animator_(new views::BoundsAnimator(this))) {
62 pagination_model_->SetTransitionDuration(kTransitionAnimationDurationInMs);
63
59 AppsGridView* apps_grid_view = new AppsGridView(app_list_view, 64 AppsGridView* apps_grid_view = new AppsGridView(app_list_view,
60 pagination_model); 65 pagination_model);
61 apps_grid_view->SetLayout(kPreferredIconDimension, 66 apps_grid_view->SetLayout(kPreferredIconDimension,
62 kPreferredCols, 67 kPreferredCols,
63 kPreferredRows); 68 kPreferredRows);
64 AddChildView(apps_grid_view); 69 AddChildView(apps_grid_view);
65 view_model_->Add(apps_grid_view, kIndexAppsGrid); 70 view_model_->Add(apps_grid_view, kIndexAppsGrid);
66 71
67 PageSwitcher* page_switcher_view = new PageSwitcher(pagination_model); 72 PageSwitcher* page_switcher_view = new PageSwitcher(pagination_model);
68 AddChildView(page_switcher_view); 73 AddChildView(page_switcher_view);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 case ui::ET_GESTURE_SCROLL_BEGIN: 200 case ui::ET_GESTURE_SCROLL_BEGIN:
196 pagination_model_->StartScroll(); 201 pagination_model_->StartScroll();
197 return ui::GESTURE_STATUS_CONSUMED; 202 return ui::GESTURE_STATUS_CONSUMED;
198 case ui::ET_GESTURE_SCROLL_UPDATE: 203 case ui::ET_GESTURE_SCROLL_UPDATE:
199 // event.details.scroll_x() > 0 means moving contents to right. That is, 204 // event.details.scroll_x() > 0 means moving contents to right. That is,
200 // transitioning to previous page. 205 // transitioning to previous page.
201 pagination_model_->UpdateScroll( 206 pagination_model_->UpdateScroll(
202 event.details().scroll_x() / GetContentsBounds().width()); 207 event.details().scroll_x() / GetContentsBounds().width());
203 return ui::GESTURE_STATUS_CONSUMED; 208 return ui::GESTURE_STATUS_CONSUMED;
204 case ui::ET_GESTURE_SCROLL_END: 209 case ui::ET_GESTURE_SCROLL_END:
205 pagination_model_->EndScroll(); 210 pagination_model_->EndScroll(pagination_model_->
211 transition().progress < kFinishTransitionThreshold);
206 return ui::GESTURE_STATUS_CONSUMED; 212 return ui::GESTURE_STATUS_CONSUMED;
207 case ui::ET_SCROLL_FLING_START: { 213 case ui::ET_SCROLL_FLING_START: {
208 pagination_model_->EndScroll(); 214 pagination_model_->EndScroll(true);
209 if (fabs(event.details().velocity_x()) > kMinHorizVelocityToSwitchPage) { 215 if (fabs(event.details().velocity_x()) > kMinHorizVelocityToSwitchPage) {
210 pagination_model_->ResetTransitionAnimation();
211 pagination_model_->SelectPageRelative( 216 pagination_model_->SelectPageRelative(
212 event.details().velocity_x() < 0 ? 1 : -1, 217 event.details().velocity_x() < 0 ? 1 : -1,
213 true); 218 true);
214 } 219 }
215 return ui::GESTURE_STATUS_CONSUMED; 220 return ui::GESTURE_STATUS_CONSUMED;
216 } 221 }
217 default: 222 default:
218 break; 223 break;
219 } 224 }
220 225
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 pagination_model_->SelectPageRelative(event.x_offset() > 0 ? -1 : 1, 260 pagination_model_->SelectPageRelative(event.x_offset() > 0 ? -1 : 1,
256 true); 261 true);
257 } 262 }
258 return true; 263 return true;
259 } 264 }
260 265
261 return false; 266 return false;
262 } 267 }
263 268
264 } // namespace app_list 269 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/apps_grid_view.cc ('k') | ui/app_list/pagination_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698