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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual ~HidingWindowAnimationObserverBase() { |
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 virtual 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 virtual 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual ~ImplicitHidingWindowAnimationObserver() {} |
169 | 169 |
170 // ui::ImplicitAnimationObserver: | 170 // ui::ImplicitAnimationObserver: |
171 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | 171 virtual 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 virtual ~RotateHidingWindowAnimationObserver() {} | 403 virtual ~RotateHidingWindowAnimationObserver() {} |
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 virtual void OnLayerAnimationEnded( |
413 ui::LayerAnimationSequence* sequence) OVERRIDE { | 413 ui::LayerAnimationSequence* sequence) override { |
414 OnAnimationCompleted(); | 414 OnAnimationCompleted(); |
415 } | 415 } |
416 virtual void OnLayerAnimationAborted( | 416 virtual void OnLayerAnimationAborted( |
417 ui::LayerAnimationSequence* sequence) OVERRIDE { | 417 ui::LayerAnimationSequence* sequence) override { |
418 OnAnimationCompleted(); | 418 OnAnimationCompleted(); |
419 } | 419 } |
420 virtual void OnLayerAnimationScheduled( | 420 virtual void OnLayerAnimationScheduled( |
421 ui::LayerAnimationSequence* sequence) OVERRIDE {} | 421 ui::LayerAnimationSequence* sequence) override {} |
422 | 422 |
423 private: | 423 private: |
424 DISALLOW_COPY_AND_ASSIGN(RotateHidingWindowAnimationObserver); | 424 DISALLOW_COPY_AND_ASSIGN(RotateHidingWindowAnimationObserver); |
425 }; | 425 }; |
426 | 426 |
427 void AddLayerAnimationsForRotate(aura::Window* window, bool show) { | 427 void AddLayerAnimationsForRotate(aura::Window* window, bool show) { |
428 if (show) | 428 if (show) |
429 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 429 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
430 | 430 |
431 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( | 431 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 // being accessed via Remote Desktop. | 663 // being accessed via Remote Desktop. |
664 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() == | 664 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() == |
665 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION) | 665 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION) |
666 return false; | 666 return false; |
667 | 667 |
668 // Let the user decide whether or not to play the animation. | 668 // Let the user decide whether or not to play the animation. |
669 return !gfx::Animation::ShouldRenderRichAnimation(); | 669 return !gfx::Animation::ShouldRenderRichAnimation(); |
670 } | 670 } |
671 | 671 |
672 } // namespace wm | 672 } // namespace wm |
OLD | NEW |