OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/window_overview_mode.h" | 5 #include "athena/wm/window_overview_mode.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
22 #include "ui/compositor/closure_animation_observer.h" | 22 #include "ui/compositor/closure_animation_observer.h" |
23 #include "ui/compositor/compositor.h" | 23 #include "ui/compositor/compositor.h" |
24 #include "ui/compositor/compositor_animation_observer.h" | 24 #include "ui/compositor/compositor_animation_observer.h" |
25 #include "ui/compositor/scoped_layer_animation_settings.h" | 25 #include "ui/compositor/scoped_layer_animation_settings.h" |
26 #include "ui/events/event_handler.h" | 26 #include "ui/events/event_handler.h" |
27 #include "ui/events/gestures/fling_curve.h" | 27 #include "ui/events/gestures/fling_curve.h" |
28 #include "ui/gfx/frame_time.h" | 28 #include "ui/gfx/frame_time.h" |
29 #include "ui/gfx/transform.h" | 29 #include "ui/gfx/transform.h" |
30 #include "ui/wm/core/shadow_types.h" | 30 #include "ui/wm/core/shadow_types.h" |
| 31 #include "ui/wm/core/window_animations.h" |
31 #include "ui/wm/core/window_util.h" | 32 #include "ui/wm/core/window_util.h" |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 struct WindowOverviewState { | 36 struct WindowOverviewState { |
36 // The transform for when the window is at the topmost position. | 37 // The transform for when the window is at the topmost position. |
37 gfx::Transform top; | 38 gfx::Transform top; |
38 | 39 |
39 // The transform for when the window is at the bottom-most position. | 40 // The transform for when the window is at the bottom-most position. |
40 gfx::Transform bottom; | 41 gfx::Transform bottom; |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 const bool swipe_towards_right = event.details().velocity_x() > 0; | 473 const bool swipe_towards_right = event.details().velocity_x() > 0; |
473 if (dragging_towards_right != swipe_towards_right) | 474 if (dragging_towards_right != swipe_towards_right) |
474 return false; | 475 return false; |
475 const float kMinVelocityForDismissal = 500.f; | 476 const float kMinVelocityForDismissal = 500.f; |
476 return std::abs(event.details().velocity_x()) > kMinVelocityForDismissal; | 477 return std::abs(event.details().velocity_x()) > kMinVelocityForDismissal; |
477 } | 478 } |
478 | 479 |
479 void CloseDragWindow(const ui::GestureEvent& gesture) { | 480 void CloseDragWindow(const ui::GestureEvent& gesture) { |
480 // Animate |dragged_window_| offscreen first, then destroy it. | 481 // Animate |dragged_window_| offscreen first, then destroy it. |
481 { | 482 { |
482 ui::ScopedLayerAnimationSettings settings( | 483 wm::ScopedHidingAnimationSettings settings(dragged_window_); |
483 dragged_window_->layer()->GetAnimator()); | 484 settings.layer_animation_settings()->SetPreemptionStrategy( |
484 settings.SetPreemptionStrategy( | |
485 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 485 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
486 settings.AddObserver(new ui::ClosureAnimationObserver( | |
487 base::Bind(&base::DeletePointer<aura::Window>, dragged_window_))); | |
488 | 486 |
489 WindowOverviewState* dragged_state = | 487 WindowOverviewState* dragged_state = |
490 dragged_window_->GetProperty(kWindowOverviewState); | 488 dragged_window_->GetProperty(kWindowOverviewState); |
491 CHECK(dragged_state); | 489 CHECK(dragged_state); |
492 gfx::Transform transform = dragged_window_->layer()->transform(); | 490 gfx::Transform transform = dragged_window_->layer()->transform(); |
493 gfx::RectF transformed_bounds = dragged_window_->bounds(); | 491 gfx::RectF transformed_bounds = dragged_window_->bounds(); |
494 transform.TransformRect(&transformed_bounds); | 492 transform.TransformRect(&transformed_bounds); |
495 float transform_x = 0.f; | 493 float transform_x = 0.f; |
496 if (gesture.location().x() > dragged_start_location_.x()) | 494 if (gesture.location().x() > dragged_start_location_.x()) |
497 transform_x = container_->bounds().right() - transformed_bounds.x(); | 495 transform_x = container_->bounds().right() - transformed_bounds.x(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 537 |
540 aura::Window* next = *(iter + 1); | 538 aura::Window* next = *(iter + 1); |
541 WindowOverviewState* next_state = | 539 WindowOverviewState* next_state = |
542 next->GetProperty(kWindowOverviewState); | 540 next->GetProperty(kWindowOverviewState); |
543 UpdateTerminalStateForWindowAtIndex( | 541 UpdateTerminalStateForWindowAtIndex( |
544 window, list.end() - iter, list.size()); | 542 window, list.end() - iter, list.size()); |
545 SetWindowProgress(window, next_state->progress); | 543 SetWindowProgress(window, next_state->progress); |
546 } | 544 } |
547 } | 545 } |
548 | 546 |
| 547 delete dragged_window_; |
549 dragged_window_ = NULL; | 548 dragged_window_ = NULL; |
550 } | 549 } |
551 | 550 |
552 void RestoreDragWindow() { | 551 void RestoreDragWindow() { |
553 CHECK(dragged_window_); | 552 CHECK(dragged_window_); |
554 WindowOverviewState* dragged_state = | 553 WindowOverviewState* dragged_state = |
555 dragged_window_->GetProperty(kWindowOverviewState); | 554 dragged_window_->GetProperty(kWindowOverviewState); |
556 CHECK(dragged_state); | 555 CHECK(dragged_state); |
557 | 556 |
558 ui::ScopedLayerAnimationSettings settings( | 557 ui::ScopedLayerAnimationSettings settings( |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 aura::Window* container, | 746 aura::Window* container, |
748 const WindowListProvider* window_list_provider, | 747 const WindowListProvider* window_list_provider, |
749 SplitViewController* split_view_controller, | 748 SplitViewController* split_view_controller, |
750 WindowOverviewModeDelegate* delegate) { | 749 WindowOverviewModeDelegate* delegate) { |
751 return scoped_ptr<WindowOverviewMode>( | 750 return scoped_ptr<WindowOverviewMode>( |
752 new WindowOverviewModeImpl(container, window_list_provider, | 751 new WindowOverviewModeImpl(container, window_list_provider, |
753 split_view_controller, delegate)); | 752 split_view_controller, delegate)); |
754 } | 753 } |
755 | 754 |
756 } // namespace athena | 755 } // namespace athena |
OLD | NEW |