Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: ash/wm/window_animations.cc

Issue 10800020: Add brightness/grayscale animations and use them for OOBE boot transition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove test change Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ash/wm/window_animations.h" 5 #include "ash/wm/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
62 kWindowAnimation_Vertical_TranslateY); 62 kWindowAnimation_Vertical_TranslateY);
63 63
64 namespace { 64 namespace {
65 65
66 const int kDefaultAnimationDurationForMenuMS = 150; 66 const int kDefaultAnimationDurationForMenuMS = 150;
67 67
68 // Durations for the cross-fade animation, in milliseconds. 68 // Durations for the cross-fade animation, in milliseconds.
69 const float kCrossFadeDurationMinMs = 100.f; 69 const float kCrossFadeDurationMinMs = 100.f;
70 const float kCrossFadeDurationMaxMs = 400.f; 70 const float kCrossFadeDurationMaxMs = 400.f;
71 71
72 // Durations for the brightness/grayscale fade animation, in milliseconds.
73 const int kBrightnessGrayscaleFadeDurationMs = 2000;
sky 2012/07/19 19:22:19 This is a really long time. Are you sure we want 2
Nikita (slow) 2012/07/19 20:47:09 Yes, that what it should look like according to mo
Nikita (slow) 2012/07/20 18:21:29 Confirmed with UX.
74
75 // Brightness/grayscale values for hide/show window animations.
76 const float kWindowAnimation_HideBrightness = 1.f;
77 const float kWindowAnimation_HideGrayscale = 1.f;
78 const float kWindowAnimation_ShowBrightness = 0.f;
79 const float kWindowAnimation_ShowGrayscale = 0.f;
80
72 const float kWindowAnimation_HideOpacity = 0.f; 81 const float kWindowAnimation_HideOpacity = 0.f;
73 const float kWindowAnimation_ShowOpacity = 1.f; 82 const float kWindowAnimation_ShowOpacity = 1.f;
74 const float kWindowAnimation_TranslateFactor = -0.025f; 83 const float kWindowAnimation_TranslateFactor = -0.025f;
75 const float kWindowAnimation_ScaleFactor = 1.05f; 84 const float kWindowAnimation_ScaleFactor = 1.05f;
76 const float kWindowAnimation_MinimizeRotate = -5.f; 85 const float kWindowAnimation_MinimizeRotate = -5.f;
77 86
78 // Amount windows are scaled during workspace animations. 87 // Amount windows are scaled during workspace animations.
79 const float kWorkspaceScale = .95f; 88 const float kWorkspaceScale = .95f;
80 89
81 int64 Round64(float f) { 90 int64 Round64(float f) {
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 window->layer()->set_delegate(NULL); 467 window->layer()->set_delegate(NULL);
459 468
460 // Property sets within this scope will be implicitly animated. 469 // Property sets within this scope will be implicitly animated.
461 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 470 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
462 settings.AddObserver(new HidingWindowAnimationObserver(window)); 471 settings.AddObserver(new HidingWindowAnimationObserver(window));
463 window->layer()->SetVisible(false); 472 window->layer()->SetVisible(false);
464 473
465 AddLayerAnimationsForMinimize(window, false); 474 AddLayerAnimationsForMinimize(window, false);
466 } 475 }
467 476
477 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
478 window->layer()->set_delegate(window);
479 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
480 window->layer()->SetLayerBrightness(kWindowAnimation_HideBrightness);
481 window->layer()->SetLayerGrayscale(kWindowAnimation_HideGrayscale);
482
483 window->layer()->SetVisible(true);
484
485 scoped_ptr<ui::LayerAnimationSequence> brightness_sequence(
486 new ui::LayerAnimationSequence());
487 scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence(
488 new ui::LayerAnimationSequence());
489
490 brightness_sequence->AddElement(
491 ui::LayerAnimationElement::CreateBrightnessElement(
492 kWindowAnimation_ShowBrightness,
493 base::TimeDelta::FromMilliseconds(
494 kBrightnessGrayscaleFadeDurationMs)));
495 grayscale_sequence->AddElement(
496 ui::LayerAnimationElement::CreateGrayscaleElement(
497 kWindowAnimation_ShowGrayscale,
498 base::TimeDelta::FromMilliseconds(
499 kBrightnessGrayscaleFadeDurationMs)));
500
501 std::vector<ui::LayerAnimationSequence*> animations;
502 animations.push_back(brightness_sequence.release());
503 animations.push_back(grayscale_sequence.release());
504 window->layer()->GetAnimator()->ScheduleTogether(animations);
505 }
506
468 bool AnimateShowWindow(aura::Window* window) { 507 bool AnimateShowWindow(aura::Window* window) {
469 if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_SHOW)) 508 if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_SHOW))
470 return false; 509 return false;
471 510
472 switch (GetWindowVisibilityAnimationType(window)) { 511 switch (GetWindowVisibilityAnimationType(window)) {
473 case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP: 512 case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP:
474 AnimateShowWindow_Drop(window); 513 AnimateShowWindow_Drop(window);
475 return true; 514 return true;
476 case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL: 515 case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL:
477 AnimateShowWindow_Vertical(window); 516 AnimateShowWindow_Vertical(window);
478 return true; 517 return true;
479 case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE: 518 case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE:
480 AnimateShowWindow_Fade(window); 519 AnimateShowWindow_Fade(window);
481 return true; 520 return true;
482 case WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_SHOW: 521 case WINDOW_VISIBILITY_ANIMATION_TYPE_WORKSPACE_SHOW:
483 AnimateShowWindow_Workspace(window); 522 AnimateShowWindow_Workspace(window);
484 return true; 523 return true;
485 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE: 524 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
486 AnimateShowWindow_Minimize(window); 525 AnimateShowWindow_Minimize(window);
487 return true; 526 return true;
527 case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
sky 2012/07/19 19:22:19 What about the hide case?
Nikita (slow) 2012/07/19 20:47:09 Yes, I might refactor code a bit to support revers
Nikita (slow) 2012/07/20 18:21:29 Done.
528 AnimateShowWindow_BrightnessGrayscale(window);
529 return true;
488 default: 530 default:
489 NOTREACHED(); 531 NOTREACHED();
490 return false; 532 return false;
491 } 533 }
492 } 534 }
493 535
494 bool AnimateHideWindow(aura::Window* window) { 536 bool AnimateHideWindow(aura::Window* window) {
495 if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_HIDE)) 537 if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_HIDE))
496 return false; 538 return false;
497 539
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 AnimateHideWindow(window); 820 AnimateHideWindow(window);
779 } 821 }
780 } 822 }
781 823
782 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) { 824 void SetDelayedOldLayerDeletionInCrossFadeForTest(bool value) {
783 delayed_old_layer_deletion_in_cross_fade_for_test_ = value; 825 delayed_old_layer_deletion_in_cross_fade_for_test_ = value;
784 } 826 }
785 827
786 } // namespace internal 828 } // namespace internal
787 } // namespace ash 829 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698