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

Side by Side Diff: ash/wm/app_list_controller.cc

Issue 11275320: app_list: Make over scroll animation faster. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/app_list/app_list_constants.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 "ash/wm/app_list_controller.h" 5 #include "ash/wm/app_list_controller.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/wm/property_util.h" 12 #include "ash/wm/property_util.h"
13 #include "ash/wm/shelf_layout_manager.h" 13 #include "ash/wm/shelf_layout_manager.h"
14 #include "ui/app_list/app_list_constants.h"
14 #include "ui/app_list/app_list_view.h" 15 #include "ui/app_list/app_list_view.h"
15 #include "ui/app_list/pagination_model.h" 16 #include "ui/app_list/pagination_model.h"
16 #include "ui/aura/focus_manager.h" 17 #include "ui/aura/focus_manager.h"
17 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
18 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
19 #include "ui/base/events/event.h" 20 #include "ui/base/events/event.h"
20 #include "ui/compositor/layer.h" 21 #include "ui/compositor/layer.h"
21 #include "ui/compositor/scoped_layer_animation_settings.h" 22 #include "ui/compositor/scoped_layer_animation_settings.h"
22 #include "ui/gfx/transform_util.h" 23 #include "ui/gfx/transform_util.h"
23 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
24 25
25 namespace ash { 26 namespace ash {
26 namespace internal { 27 namespace internal {
27 28
28 namespace { 29 namespace {
29 30
30 // Duration for show/hide animation in milliseconds. 31 // Duration for show/hide animation in milliseconds.
31 const int kAnimationDurationMs = 200; 32 const int kAnimationDurationMs = 200;
32 33
33 // Offset in pixels to animation away/towards the launcher. 34 // Offset in pixels to animation away/towards the launcher.
34 const int kAnimationOffset = 8; 35 const int kAnimationOffset = 8;
35 36
36 // Duration for snap back animation after over-scroll in milliseconds.
37 const int kSnapBackAnimationDurationMs = 100;
38
39 // The maximum shift in pixels when over-scroll happens. 37 // The maximum shift in pixels when over-scroll happens.
40 const int kMaxOverScrollShift = 48; 38 const int kMaxOverScrollShift = 48;
41 39
42 ui::Layer* GetLayer(views::Widget* widget) { 40 ui::Layer* GetLayer(views::Widget* widget) {
43 return widget->GetNativeView()->layer(); 41 return widget->GetNativeView()->layer();
44 } 42 }
45 43
46 // Gets arrow location based on shelf alignment. 44 // Gets arrow location based on shelf alignment.
47 views::BubbleBorder::ArrowLocation GetBubbleArrowLocation( 45 views::BubbleBorder::ArrowLocation GetBubbleArrowLocation(
48 aura::Window* window) { 46 aura::Window* window) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // |view_| could be NULL when app list is closed with a running transition. 339 // |view_| could be NULL when app list is closed with a running transition.
342 if (!view_) 340 if (!view_)
343 return; 341 return;
344 342
345 const app_list::PaginationModel::Transition& transition = 343 const app_list::PaginationModel::Transition& transition =
346 pagination_model_->transition(); 344 pagination_model_->transition();
347 if (pagination_model_->is_valid_page(transition.target_page)) 345 if (pagination_model_->is_valid_page(transition.target_page))
348 return; 346 return;
349 347
350 views::Widget* widget = view_->GetWidget(); 348 views::Widget* widget = view_->GetWidget();
349 ui::LayerAnimator* widget_animator = GetLayer(widget)->GetAnimator();
351 if (!pagination_model_->IsRevertingCurrentTransition()) { 350 if (!pagination_model_->IsRevertingCurrentTransition()) {
352 // Update cached |view_bounds_| before the first over-scroll move. 351 // Update cached |view_bounds_| if it is the first over-scroll move and
353 if (!should_snap_back_) 352 // widget does not have running animations.
353 if (!should_snap_back_ && !widget_animator->is_animating())
354 view_bounds_ = widget->GetWindowBoundsInScreen(); 354 view_bounds_ = widget->GetWindowBoundsInScreen();
355 355
356 const int current_page = pagination_model_->selected_page(); 356 const int current_page = pagination_model_->selected_page();
357 const int dir = transition.target_page > current_page ? -1 : 1; 357 const int dir = transition.target_page > current_page ? -1 : 1;
358 358
359 const double progress = 1.0 - pow(1.0 - transition.progress, 4); 359 const double progress = 1.0 - pow(1.0 - transition.progress, 4);
360 const int shift = kMaxOverScrollShift * progress * dir; 360 const int shift = kMaxOverScrollShift * progress * dir;
361 361
362 gfx::Rect shifted(view_bounds_); 362 gfx::Rect shifted(view_bounds_);
363 shifted.set_x(shifted.x() + shift); 363 shifted.set_x(shifted.x() + shift);
364 widget->SetBounds(shifted); 364 widget->SetBounds(shifted);
365 should_snap_back_ = true; 365 should_snap_back_ = true;
366 } else if (should_snap_back_) { 366 } else if (should_snap_back_) {
367 should_snap_back_ = false; 367 should_snap_back_ = false;
368 ui::ScopedLayerAnimationSettings animation(GetLayer(widget)->GetAnimator()); 368 ui::ScopedLayerAnimationSettings animation(widget_animator);
369 animation.SetTransitionDuration( 369 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
370 base::TimeDelta::FromMilliseconds(kSnapBackAnimationDurationMs)); 370 app_list::kOverscrollPageTransitionDurationMs));
371 widget->SetBounds(view_bounds_); 371 widget->SetBounds(view_bounds_);
372 } 372 }
373 } 373 }
374 374
375 } // namespace internal 375 } // namespace internal
376 } // namespace ash 376 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/app_list/app_list_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698