Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/presenter/app_list_presenter_impl.h" | 5 #include "ui/app_list/presenter/app_list_presenter_impl.h" |
| 6 | 6 |
| 7 #include "base/metrics/user_metrics.h" | 7 #include "base/metrics/user_metrics.h" |
| 8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
| 9 #include "ui/app_list/app_list_features.h" | |
| 9 #include "ui/app_list/app_list_switches.h" | 10 #include "ui/app_list/app_list_switches.h" |
| 10 #include "ui/app_list/pagination_model.h" | 11 #include "ui/app_list/pagination_model.h" |
| 11 #include "ui/app_list/presenter/app_list_presenter_delegate_factory.h" | 12 #include "ui/app_list/presenter/app_list_presenter_delegate_factory.h" |
| 12 #include "ui/app_list/views/app_list_view.h" | 13 #include "ui/app_list/views/app_list_view.h" |
| 13 #include "ui/aura/client/focus_client.h" | 14 #include "ui/aura/client/focus_client.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
| 16 #include "ui/compositor/scoped_layer_animation_settings.h" | 17 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 17 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 18 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 19 | 20 |
| 20 namespace app_list { | 21 namespace app_list { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Duration for show/hide animation in milliseconds. | 24 // Duration for show/hide animation in milliseconds. |
| 24 constexpr int kAnimationDurationMs = 200; | 25 constexpr int kAnimationDurationMs = 200; |
| 25 | 26 |
| 26 // The maximum shift in pixels when over-scroll happens. | 27 // The maximum shift in pixels when over-scroll happens. |
| 27 constexpr int kMaxOverScrollShift = 48; | 28 constexpr int kMaxOverScrollShift = 48; |
| 28 | 29 |
| 29 inline ui::Layer* GetLayer(views::Widget* widget) { | 30 inline ui::Layer* GetLayer(views::Widget* widget) { |
| 30 return widget->GetNativeView()->layer(); | 31 return widget->GetNativeView()->layer(); |
| 31 } | 32 } |
| 32 | 33 |
| 33 } // namespace | 34 } // namespace |
| 34 | 35 |
| 35 AppListPresenterImpl::AppListPresenterImpl( | 36 AppListPresenterImpl::AppListPresenterImpl( |
| 36 std::unique_ptr<AppListPresenterDelegateFactory> factory) | 37 std::unique_ptr<AppListPresenterDelegateFactory> factory) |
| 37 : factory_(std::move(factory)) { | 38 : factory_(std::move(factory)), |
| 39 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) { | |
| 38 DCHECK(factory_); | 40 DCHECK(factory_); |
| 39 } | 41 } |
| 40 | 42 |
| 41 AppListPresenterImpl::~AppListPresenterImpl() { | 43 AppListPresenterImpl::~AppListPresenterImpl() { |
| 42 Dismiss(); | 44 Dismiss(); |
| 43 presenter_delegate_.reset(); | 45 presenter_delegate_.reset(); |
| 44 // Ensures app list view goes before the controller since pagination model | 46 // Ensures app list view goes before the controller since pagination model |
| 45 // lives in the controller and app list view would access it on destruction. | 47 // lives in the controller and app list view would access it on destruction. |
| 46 if (view_) { | 48 if (view_) { |
| 47 view_->GetAppsPaginationModel()->RemoveObserver(this); | 49 view_->GetAppsPaginationModel()->RemoveObserver(this); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 | 267 |
| 266 void AppListPresenterImpl::TransitionChanged() { | 268 void AppListPresenterImpl::TransitionChanged() { |
| 267 // |view_| could be NULL when app list is closed with a running transition. | 269 // |view_| could be NULL when app list is closed with a running transition. |
| 268 if (!view_) | 270 if (!view_) |
| 269 return; | 271 return; |
| 270 | 272 |
| 271 PaginationModel* pagination_model = view_->GetAppsPaginationModel(); | 273 PaginationModel* pagination_model = view_->GetAppsPaginationModel(); |
| 272 | 274 |
| 273 const PaginationModel::Transition& transition = | 275 const PaginationModel::Transition& transition = |
| 274 pagination_model->transition(); | 276 pagination_model->transition(); |
| 275 if (pagination_model->is_valid_page(transition.target_page)) | 277 |
| 278 // Disable overscroll animation when the fullscreen app list feature is | |
| 279 // enabled or when the transition is to a valid page. | |
| 280 if (is_fullscreen_app_list_enabled_ || | |
|
xiyuan
2017/06/23 20:02:44
nit: Move this to around line 272 and on its own "
newcomer
2017/06/26 16:13:58
Done!
| |
| 281 pagination_model->is_valid_page(transition.target_page)) | |
| 276 return; | 282 return; |
| 277 | 283 |
| 278 views::Widget* widget = view_->GetWidget(); | 284 views::Widget* widget = view_->GetWidget(); |
| 279 ui::LayerAnimator* widget_animator = | 285 ui::LayerAnimator* widget_animator = |
| 280 widget->GetNativeView()->layer()->GetAnimator(); | 286 widget->GetNativeView()->layer()->GetAnimator(); |
| 281 if (!pagination_model->IsRevertingCurrentTransition()) { | 287 if (!pagination_model->IsRevertingCurrentTransition()) { |
| 282 // Update cached |view_bounds_| if it is the first over-scroll move and | 288 // Update cached |view_bounds_| if it is the first over-scroll move and |
| 283 // widget does not have running animations. | 289 // widget does not have running animations. |
| 284 if (!should_snap_back_ && !widget_animator->is_animating()) | 290 if (!should_snap_back_ && !widget_animator->is_animating()) |
| 285 view_bounds_ = widget->GetWindowBoundsInScreen(); | 291 view_bounds_ = widget->GetWindowBoundsInScreen(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 299 } else if (should_snap_back_) { | 305 } else if (should_snap_back_) { |
| 300 should_snap_back_ = false; | 306 should_snap_back_ = false; |
| 301 ui::ScopedLayerAnimationSettings animation(widget_animator); | 307 ui::ScopedLayerAnimationSettings animation(widget_animator); |
| 302 animation.SetTransitionDuration( | 308 animation.SetTransitionDuration( |
| 303 base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); | 309 base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); |
| 304 widget->SetBounds(view_bounds_); | 310 widget->SetBounds(view_bounds_); |
| 305 } | 311 } |
| 306 } | 312 } |
| 307 | 313 |
| 308 } // namespace app_list | 314 } // namespace app_list |
| OLD | NEW |