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

Unified 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: fix hide animation 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/window_animations.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_animations.cc
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index 8faaef550236a3fc11f09f0ac14ddaf637257169..2c080ffe73da49b45f1001e05b422fad1ffc7c64 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -69,6 +69,13 @@ const int kDefaultAnimationDurationForMenuMS = 150;
const float kCrossFadeDurationMinMs = 100.f;
const float kCrossFadeDurationMaxMs = 400.f;
+// Durations for the brightness/grayscale fade animation, in milliseconds.
+const int kBrightnessGrayscaleFadeDurationMs = 2000;
+
+// Brightness/grayscale values for hide/show window animations.
+const float kWindowAnimation_HideBrightnessGrayscale = 1.f;
+const float kWindowAnimation_ShowBrightnessGrayscale = 0.f;
+
const float kWindowAnimation_HideOpacity = 0.f;
const float kWindowAnimation_ShowOpacity = 1.f;
const float kWindowAnimation_TranslateFactor = -0.025f;
@@ -465,6 +472,66 @@ void AnimateHideWindow_Minimize(aura::Window* window) {
AddLayerAnimationsForMinimize(window, false);
}
+void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
+ bool show) {
+ window->layer()->set_delegate(window);
+
+ float start_value, end_value;
+ if (show) {
+ start_value = kWindowAnimation_HideBrightnessGrayscale;
+ end_value = kWindowAnimation_ShowBrightnessGrayscale;
+ } else {
+ start_value = kWindowAnimation_ShowBrightnessGrayscale;
+ end_value = kWindowAnimation_HideBrightnessGrayscale;
+ }
+
+ window->layer()->SetLayerBrightness(start_value);
+ window->layer()->SetLayerGrayscale(start_value);
+ if (show) {
+ window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
+ window->layer()->SetVisible(true);
+ }
+
+ ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
+ settings.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs));
+ if (!show)
+ settings.AddObserver(new HidingWindowAnimationObserver(window));
+
+ scoped_ptr<ui::LayerAnimationSequence> brightness_sequence(
+ new ui::LayerAnimationSequence());
+ scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence(
+ new ui::LayerAnimationSequence());
+
+ brightness_sequence->AddElement(
+ ui::LayerAnimationElement::CreateBrightnessElement(
+ end_value,
+ base::TimeDelta::FromMilliseconds(
+ kBrightnessGrayscaleFadeDurationMs)));
+ grayscale_sequence->AddElement(
+ ui::LayerAnimationElement::CreateGrayscaleElement(
+ end_value,
+ base::TimeDelta::FromMilliseconds(
+ kBrightnessGrayscaleFadeDurationMs)));
+
+ std::vector<ui::LayerAnimationSequence*> animations;
+ animations.push_back(brightness_sequence.release());
+ animations.push_back(grayscale_sequence.release());
+ window->layer()->GetAnimator()->ScheduleTogether(animations);
+ if (!show) {
+ window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
+ window->layer()->SetVisible(false);
+ }
+}
+
+void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
+ AnimateShowHideWindowCommon_BrightnessGrayscale(window, true);
+}
+
+void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
+ AnimateShowHideWindowCommon_BrightnessGrayscale(window, false);
+}
+
bool AnimateShowWindow(aura::Window* window) {
if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_SHOW))
return false;
@@ -485,6 +552,9 @@ bool AnimateShowWindow(aura::Window* window) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateShowWindow_Minimize(window);
return true;
+ case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
+ AnimateShowWindow_BrightnessGrayscale(window);
+ return true;
default:
NOTREACHED();
return false;
@@ -511,6 +581,9 @@ bool AnimateHideWindow(aura::Window* window) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateHideWindow_Minimize(window);
return true;
+ case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
+ AnimateHideWindow_BrightnessGrayscale(window);
+ return true;
default:
NOTREACHED();
return false;
« no previous file with comments | « ash/wm/window_animations.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698