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/views/corewm/window_animations.h" | 5 #include "ui/views/corewm/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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 void AnimateBounce(aura::Window* window) { | 352 void AnimateBounce(aura::Window* window) { |
353 ui::ScopedLayerAnimationSettings scoped_settings( | 353 ui::ScopedLayerAnimationSettings scoped_settings( |
354 window->layer()->GetAnimator()); | 354 window->layer()->GetAnimator()); |
355 scoped_settings.SetPreemptionStrategy( | 355 scoped_settings.SetPreemptionStrategy( |
356 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 356 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
357 window->layer()->set_delegate(window); | 357 window->layer()->set_delegate(window); |
358 scoped_ptr<ui::LayerAnimationSequence> sequence( | 358 scoped_ptr<ui::LayerAnimationSequence> sequence( |
359 new ui::LayerAnimationSequence); | 359 new ui::LayerAnimationSequence); |
360 sequence->AddElement(CreateGrowShrinkElement(window, true)); | 360 sequence->AddElement(CreateGrowShrinkElement(window, true)); |
361 ui::LayerAnimationElement::AnimatableProperties paused_properties; | |
362 paused_properties.insert(ui::LayerAnimationElement::BOUNDS); | |
363 sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement( | 361 sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement( |
364 paused_properties, | 362 ui::LayerAnimationElement::BOUNDS, |
365 base::TimeDelta::FromMilliseconds( | 363 base::TimeDelta::FromMilliseconds( |
366 kWindowAnimation_Bounce_DurationMS * | 364 kWindowAnimation_Bounce_DurationMS * |
367 (100 - 2 * kWindowAnimation_Bounce_GrowShrinkDurationPercent) / | 365 (100 - 2 * kWindowAnimation_Bounce_GrowShrinkDurationPercent) / |
368 100))); | 366 100))); |
369 sequence->AddElement(CreateGrowShrinkElement(window, false)); | 367 sequence->AddElement(CreateGrowShrinkElement(window, false)); |
370 window->layer()->GetAnimator()->StartAnimation(sequence.release()); | 368 window->layer()->GetAnimator()->StartAnimation(sequence.release()); |
371 } | 369 } |
372 | 370 |
373 void AddLayerAnimationsForRotate(aura::Window* window, bool show) { | 371 void AddLayerAnimationsForRotate(aura::Window* window, bool show) { |
374 window->layer()->set_delegate(window); | 372 window->layer()->set_delegate(window); |
375 if (show) | 373 if (show) |
376 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 374 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
377 | 375 |
378 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( | 376 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( |
379 kWindowAnimation_Rotate_DurationMS); | 377 kWindowAnimation_Rotate_DurationMS); |
380 | 378 |
381 if (!show) { | 379 if (!show) { |
382 new HidingWindowAnimationObserver(window); | 380 new HidingWindowAnimationObserver(window); |
383 window->layer()->GetAnimator()->SchedulePauseForProperties( | 381 window->layer()->GetAnimator()->SchedulePauseForProperties( |
384 duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100, | 382 duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100, |
385 ui::LayerAnimationElement::OPACITY, | 383 ui::LayerAnimationElement::OPACITY); |
386 -1); | |
387 } | 384 } |
388 scoped_ptr<ui::LayerAnimationElement> opacity( | 385 scoped_ptr<ui::LayerAnimationElement> opacity( |
389 ui::LayerAnimationElement::CreateOpacityElement( | 386 ui::LayerAnimationElement::CreateOpacityElement( |
390 show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity, | 387 show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity, |
391 duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100)); | 388 duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100)); |
392 opacity->set_tween_type(gfx::Tween::EASE_IN_OUT); | 389 opacity->set_tween_type(gfx::Tween::EASE_IN_OUT); |
393 window->layer()->GetAnimator()->ScheduleAnimation( | 390 window->layer()->GetAnimator()->ScheduleAnimation( |
394 new ui::LayerAnimationSequence(opacity.release())); | 391 new ui::LayerAnimationSequence(opacity.release())); |
395 | 392 |
396 float xcenter = window->bounds().width() * 0.5; | 393 float xcenter = window->bounds().width() * 0.5; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 561 |
565 bool WindowAnimationsDisabled(aura::Window* window) { | 562 bool WindowAnimationsDisabled(aura::Window* window) { |
566 return (window && | 563 return (window && |
567 window->GetProperty(aura::client::kAnimationsDisabledKey)) || | 564 window->GetProperty(aura::client::kAnimationsDisabledKey)) || |
568 CommandLine::ForCurrentProcess()->HasSwitch( | 565 CommandLine::ForCurrentProcess()->HasSwitch( |
569 switches::kWindowAnimationsDisabled); | 566 switches::kWindowAnimationsDisabled); |
570 } | 567 } |
571 | 568 |
572 } // namespace corewm | 569 } // namespace corewm |
573 } // namespace views | 570 } // namespace views |
OLD | NEW |