OLD | NEW |
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/wm/core/window_animations.h" | 5 #include "ui/wm/core/window_animations.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // deleted, and b) to ensure that the animation is visible even if the | 56 // deleted, and b) to ensure that the animation is visible even if the |
57 // window gets restacked below other windows when focus or activation | 57 // window gets restacked below other windows when focus or activation |
58 // changes. | 58 // changes. |
59 // The subclass will determine when the animation is completed. | 59 // The subclass will determine when the animation is completed. |
60 class HidingWindowAnimationObserverBase : public aura::WindowObserver { | 60 class HidingWindowAnimationObserverBase : public aura::WindowObserver { |
61 public: | 61 public: |
62 explicit HidingWindowAnimationObserverBase(aura::Window* window) | 62 explicit HidingWindowAnimationObserverBase(aura::Window* window) |
63 : window_(window) { | 63 : window_(window) { |
64 window_->AddObserver(this); | 64 window_->AddObserver(this); |
65 } | 65 } |
66 virtual ~HidingWindowAnimationObserverBase() { | 66 ~HidingWindowAnimationObserverBase() override { |
67 if (window_) | 67 if (window_) |
68 window_->RemoveObserver(this); | 68 window_->RemoveObserver(this); |
69 } | 69 } |
70 | 70 |
71 // aura::WindowObserver: | 71 // aura::WindowObserver: |
72 virtual void OnWindowDestroying(aura::Window* window) override { | 72 void OnWindowDestroying(aura::Window* window) override { |
73 DCHECK_EQ(window, window_); | 73 DCHECK_EQ(window, window_); |
74 WindowInvalid(); | 74 WindowInvalid(); |
75 } | 75 } |
76 | 76 |
77 virtual void OnWindowDestroyed(aura::Window* window) override { | 77 void OnWindowDestroyed(aura::Window* window) override { |
78 DCHECK_EQ(window, window_); | 78 DCHECK_EQ(window, window_); |
79 WindowInvalid(); | 79 WindowInvalid(); |
80 } | 80 } |
81 | 81 |
82 // Detach the current layers and create new layers for |window_|. | 82 // Detach the current layers and create new layers for |window_|. |
83 // Stack the original layers above |window_| and its transient | 83 // Stack the original layers above |window_| and its transient |
84 // children. If the window has transient children, the original | 84 // children. If the window has transient children, the original |
85 // layers will be moved above the top most transient child so that | 85 // layers will be moved above the top most transient child so that |
86 // activation change does not put the window above the animating | 86 // activation change does not put the window above the animating |
87 // layer. | 87 // layer. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 // A HidingWindowAnimationObserver that deletes observer and detached | 159 // A HidingWindowAnimationObserver that deletes observer and detached |
160 // layers upon the completion of the implicit animation. | 160 // layers upon the completion of the implicit animation. |
161 class ImplicitHidingWindowAnimationObserver | 161 class ImplicitHidingWindowAnimationObserver |
162 : public HidingWindowAnimationObserverBase, | 162 : public HidingWindowAnimationObserverBase, |
163 public ui::ImplicitAnimationObserver { | 163 public ui::ImplicitAnimationObserver { |
164 public: | 164 public: |
165 ImplicitHidingWindowAnimationObserver( | 165 ImplicitHidingWindowAnimationObserver( |
166 aura::Window* window, | 166 aura::Window* window, |
167 ui::ScopedLayerAnimationSettings* settings); | 167 ui::ScopedLayerAnimationSettings* settings); |
168 virtual ~ImplicitHidingWindowAnimationObserver() {} | 168 ~ImplicitHidingWindowAnimationObserver() override {} |
169 | 169 |
170 // ui::ImplicitAnimationObserver: | 170 // ui::ImplicitAnimationObserver: |
171 virtual void OnImplicitAnimationsCompleted() override; | 171 void OnImplicitAnimationsCompleted() override; |
172 | 172 |
173 private: | 173 private: |
174 DISALLOW_COPY_AND_ASSIGN(ImplicitHidingWindowAnimationObserver); | 174 DISALLOW_COPY_AND_ASSIGN(ImplicitHidingWindowAnimationObserver); |
175 }; | 175 }; |
176 | 176 |
177 namespace { | 177 namespace { |
178 | 178 |
179 const int kDefaultAnimationDurationForMenuMS = 150; | 179 const int kDefaultAnimationDurationForMenuMS = 150; |
180 | 180 |
181 const float kWindowAnimation_HideOpacity = 0.f; | 181 const float kWindowAnimation_HideOpacity = 0.f; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 } | 393 } |
394 | 394 |
395 // A HidingWindowAnimationObserver that deletes observer and detached | 395 // A HidingWindowAnimationObserver that deletes observer and detached |
396 // layers when the last_sequence has been completed or aborted. | 396 // layers when the last_sequence has been completed or aborted. |
397 class RotateHidingWindowAnimationObserver | 397 class RotateHidingWindowAnimationObserver |
398 : public HidingWindowAnimationObserverBase, | 398 : public HidingWindowAnimationObserverBase, |
399 public ui::LayerAnimationObserver { | 399 public ui::LayerAnimationObserver { |
400 public: | 400 public: |
401 explicit RotateHidingWindowAnimationObserver(aura::Window* window) | 401 explicit RotateHidingWindowAnimationObserver(aura::Window* window) |
402 : HidingWindowAnimationObserverBase(window) {} | 402 : HidingWindowAnimationObserverBase(window) {} |
403 virtual ~RotateHidingWindowAnimationObserver() {} | 403 ~RotateHidingWindowAnimationObserver() override {} |
404 | 404 |
405 // Destroys itself after |last_sequence| ends or is aborted. Does not take | 405 // Destroys itself after |last_sequence| ends or is aborted. Does not take |
406 // ownership of |last_sequence|, which should not be NULL. | 406 // ownership of |last_sequence|, which should not be NULL. |
407 void SetLastSequence(ui::LayerAnimationSequence* last_sequence) { | 407 void SetLastSequence(ui::LayerAnimationSequence* last_sequence) { |
408 last_sequence->AddObserver(this); | 408 last_sequence->AddObserver(this); |
409 } | 409 } |
410 | 410 |
411 // ui::LayerAnimationObserver: | 411 // ui::LayerAnimationObserver: |
412 virtual void OnLayerAnimationEnded( | 412 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override { |
413 ui::LayerAnimationSequence* sequence) override { | |
414 OnAnimationCompleted(); | 413 OnAnimationCompleted(); |
415 } | 414 } |
416 virtual void OnLayerAnimationAborted( | 415 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override { |
417 ui::LayerAnimationSequence* sequence) override { | |
418 OnAnimationCompleted(); | 416 OnAnimationCompleted(); |
419 } | 417 } |
420 virtual void OnLayerAnimationScheduled( | 418 void OnLayerAnimationScheduled( |
421 ui::LayerAnimationSequence* sequence) override {} | 419 ui::LayerAnimationSequence* sequence) override {} |
422 | 420 |
423 private: | 421 private: |
424 DISALLOW_COPY_AND_ASSIGN(RotateHidingWindowAnimationObserver); | 422 DISALLOW_COPY_AND_ASSIGN(RotateHidingWindowAnimationObserver); |
425 }; | 423 }; |
426 | 424 |
427 void AddLayerAnimationsForRotate(aura::Window* window, bool show) { | 425 void AddLayerAnimationsForRotate(aura::Window* window, bool show) { |
428 if (show) | 426 if (show) |
429 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 427 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
430 | 428 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 // being accessed via Remote Desktop. | 661 // being accessed via Remote Desktop. |
664 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() == | 662 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() == |
665 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION) | 663 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION) |
666 return false; | 664 return false; |
667 | 665 |
668 // Let the user decide whether or not to play the animation. | 666 // Let the user decide whether or not to play the animation. |
669 return !gfx::Animation::ShouldRenderRichAnimation(); | 667 return !gfx::Animation::ShouldRenderRichAnimation(); |
670 } | 668 } |
671 | 669 |
672 } // namespace wm | 670 } // namespace wm |
OLD | NEW |