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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 current_apps_page_ = new_selected; | 263 current_apps_page_ = new_selected; |
| 262 } | 264 } |
| 263 | 265 |
| 264 void AppListPresenterImpl::TransitionStarted() {} | 266 void AppListPresenterImpl::TransitionStarted() {} |
| 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 |
| 273 // Disable overscroll animation when the fullscreen app list feature is | |
| 274 // enabled. | |
| 275 if(is_fullscreen_app_list_enabled_) | |
|
vadimt
2017/06/23 23:44:04
Space after if. Run git cl format .
Please create
newcomer
2017/06/26 16:13:58
Done.
| |
| 276 return; | |
| 277 | |
| 271 PaginationModel* pagination_model = view_->GetAppsPaginationModel(); | 278 PaginationModel* pagination_model = view_->GetAppsPaginationModel(); |
| 272 | 279 |
| 273 const PaginationModel::Transition& transition = | 280 const PaginationModel::Transition& transition = |
| 274 pagination_model->transition(); | 281 pagination_model->transition(); |
| 282 | |
| 275 if (pagination_model->is_valid_page(transition.target_page)) | 283 if (pagination_model->is_valid_page(transition.target_page)) |
| 276 return; | 284 return; |
| 277 | 285 |
| 278 views::Widget* widget = view_->GetWidget(); | 286 views::Widget* widget = view_->GetWidget(); |
| 279 ui::LayerAnimator* widget_animator = | 287 ui::LayerAnimator* widget_animator = |
| 280 widget->GetNativeView()->layer()->GetAnimator(); | 288 widget->GetNativeView()->layer()->GetAnimator(); |
| 281 if (!pagination_model->IsRevertingCurrentTransition()) { | 289 if (!pagination_model->IsRevertingCurrentTransition()) { |
| 282 // Update cached |view_bounds_| if it is the first over-scroll move and | 290 // Update cached |view_bounds_| if it is the first over-scroll move and |
| 283 // widget does not have running animations. | 291 // widget does not have running animations. |
| 284 if (!should_snap_back_ && !widget_animator->is_animating()) | 292 if (!should_snap_back_ && !widget_animator->is_animating()) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 299 } else if (should_snap_back_) { | 307 } else if (should_snap_back_) { |
| 300 should_snap_back_ = false; | 308 should_snap_back_ = false; |
| 301 ui::ScopedLayerAnimationSettings animation(widget_animator); | 309 ui::ScopedLayerAnimationSettings animation(widget_animator); |
| 302 animation.SetTransitionDuration( | 310 animation.SetTransitionDuration( |
| 303 base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); | 311 base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); |
| 304 widget->SetBounds(view_bounds_); | 312 widget->SetBounds(view_bounds_); |
| 305 } | 313 } |
| 306 } | 314 } |
| 307 | 315 |
| 308 } // namespace app_list | 316 } // namespace app_list |
| OLD | NEW |