Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / ash / wm / session_state_animator_impl.cc
blobca8d2ccd26b5229d4041e1269d2614ef009b1250
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
3 // found in the LICENSE file.
5 #include "ash/wm/session_state_animator_impl.h"
7 #include <vector>
9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h"
11 #include "ash/wm/window_animations.h"
12 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/compositor/layer_animation_observer.h"
15 #include "ui/compositor/layer_animation_sequence.h"
16 #include "ui/compositor/scoped_layer_animation_settings.h"
17 #include "ui/views/widget/widget.h"
19 namespace ash {
20 namespace {
22 // Slightly-smaller size that we scale the screen down to for the pre-lock and
23 // pre-shutdown states.
24 const float kSlowCloseSizeRatio = 0.95f;
26 // Maximum opacity of white layer when animating pre-shutdown state.
27 const float kPartialFadeRatio = 0.3f;
29 // Minimum size. Not zero as it causes numeric issues.
30 const float kMinimumScale = 1e-4f;
32 // Returns the primary root window's container.
33 aura::Window* GetBackground() {
34 aura::Window* root_window = Shell::GetPrimaryRootWindow();
35 return Shell::GetContainer(root_window,
36 kShellWindowId_DesktopBackgroundContainer);
39 // Returns the transform that should be applied to containers for the slow-close
40 // animation.
41 gfx::Transform GetSlowCloseTransform() {
42 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size();
43 gfx::Transform transform;
44 transform.Translate(
45 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.width() + 0.5),
46 floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.height() + 0.5));
47 transform.Scale(kSlowCloseSizeRatio, kSlowCloseSizeRatio);
48 return transform;
51 // Returns the transform that should be applied to containers for the fast-close
52 // animation.
53 gfx::Transform GetFastCloseTransform() {
54 gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size();
55 gfx::Transform transform;
57 transform.Translate(floor(0.5 * root_size.width() + 0.5),
58 floor(0.5 * root_size.height() + 0.5));
59 transform.Scale(kMinimumScale, kMinimumScale);
60 return transform;
63 // Slowly shrinks |window| to a slightly-smaller size.
64 void StartSlowCloseAnimationForWindow(aura::Window* window,
65 base::TimeDelta duration,
66 ui::LayerAnimationObserver* observer) {
67 ui::LayerAnimator* animator = window->layer()->GetAnimator();
68 animator->set_preemption_strategy(
69 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
70 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
71 ui::LayerAnimationElement::CreateTransformElement(
72 GetSlowCloseTransform(),
73 duration));
74 if (observer)
75 sequence->AddObserver(observer);
76 animator->StartAnimation(sequence);
79 // Quickly undoes the effects of the slow-close animation on |window|.
80 void StartUndoSlowCloseAnimationForWindow(
81 aura::Window* window,
82 base::TimeDelta duration,
83 ui::LayerAnimationObserver* observer) {
84 ui::LayerAnimator* animator = window->layer()->GetAnimator();
85 animator->set_preemption_strategy(
86 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
87 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
88 ui::LayerAnimationElement::CreateTransformElement(
89 gfx::Transform(),
90 duration));
91 if (observer)
92 sequence->AddObserver(observer);
93 animator->StartAnimation(sequence);
96 // Quickly shrinks |window| down to a point in the center of the screen and
97 // fades it out to 0 opacity.
98 void StartFastCloseAnimationForWindow(aura::Window* window,
99 base::TimeDelta duration,
100 ui::LayerAnimationObserver* observer) {
101 ui::LayerAnimator* animator = window->layer()->GetAnimator();
102 animator->set_preemption_strategy(
103 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
104 animator->StartAnimation(
105 new ui::LayerAnimationSequence(
106 ui::LayerAnimationElement::CreateTransformElement(
107 GetFastCloseTransform(), duration)));
108 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
109 ui::LayerAnimationElement::CreateOpacityElement(0.0, duration));
110 if (observer)
111 sequence->AddObserver(observer);
112 animator->StartAnimation(sequence);
115 // Fades |window| to |target_opacity| over |duration|.
116 void StartPartialFadeAnimation(aura::Window* window,
117 float target_opacity,
118 base::TimeDelta duration,
119 ui::LayerAnimationObserver* observer) {
120 ui::LayerAnimator* animator = window->layer()->GetAnimator();
121 animator->set_preemption_strategy(
122 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
123 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
124 ui::LayerAnimationElement::CreateOpacityElement(
125 target_opacity, duration));
126 if (observer)
127 sequence->AddObserver(observer);
128 animator->StartAnimation(sequence);
131 // Fades |window| to |opacity| over |duration|.
132 void StartOpacityAnimationForWindow(aura::Window* window,
133 float opacity,
134 base::TimeDelta duration,
135 ui::LayerAnimationObserver* observer) {
136 ui::LayerAnimator* animator = window->layer()->GetAnimator();
137 animator->set_preemption_strategy(
138 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
139 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
140 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration));
141 if (observer)
142 sequence->AddObserver(observer);
143 animator->StartAnimation(sequence);
146 // Makes |window| fully transparent instantaneously.
147 void HideWindowImmediately(aura::Window* window,
148 ui::LayerAnimationObserver* observer) {
149 window->layer()->SetOpacity(0.0);
150 if (observer)
151 observer->OnLayerAnimationEnded(NULL);
154 // Restores |window| to its original position and scale and full opacity
155 // instantaneously.
156 void RestoreWindow(aura::Window* window, ui::LayerAnimationObserver* observer) {
157 window->layer()->SetTransform(gfx::Transform());
158 window->layer()->SetOpacity(1.0);
159 if (observer)
160 observer->OnLayerAnimationEnded(NULL);
163 void HideWindow(aura::Window* window,
164 base::TimeDelta duration,
165 bool above,
166 ui::LayerAnimationObserver* observer) {
167 ui::Layer* layer = window->layer();
168 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
170 settings.SetPreemptionStrategy(
171 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
172 settings.SetTransitionDuration(duration);
174 settings.SetTweenType(gfx::Tween::EASE_OUT);
175 SetTransformForScaleAnimation(layer,
176 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW);
178 settings.SetTweenType(gfx::Tween::EASE_IN_OUT);
179 layer->SetOpacity(0.0f);
181 // After the animation completes snap the transform back to the identity,
182 // otherwise any one that asks for screen bounds gets a slightly scaled
183 // version.
184 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
185 settings.SetTransitionDuration(base::TimeDelta());
186 layer->SetTransform(gfx::Transform());
188 // A bit of a dirty trick: we need to catch the end of the animation we don't
189 // control. So we use two facts we know: which animator will be used and the
190 // target opacity to add "Do nothing" animation sequence.
191 // Unfortunately, we can not just use empty LayerAnimationSequence, because
192 // it does not call NotifyEnded().
193 if (observer) {
194 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
195 ui::LayerAnimationElement::CreateOpacityElement(
196 0.0, base::TimeDelta()));
197 sequence->AddObserver(observer);
198 layer->GetAnimator()->ScheduleAnimation(sequence);
202 // Animates |window| to identity transform and full opacity over |duration|.
203 void TransformWindowToBaseState(aura::Window* window,
204 base::TimeDelta duration,
205 ui::LayerAnimationObserver* observer) {
206 ui::Layer* layer = window->layer();
207 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
209 // Animate to target values.
210 settings.SetPreemptionStrategy(
211 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
212 settings.SetTransitionDuration(duration);
214 settings.SetTweenType(gfx::Tween::EASE_OUT);
215 layer->SetTransform(gfx::Transform());
217 settings.SetTweenType(gfx::Tween::EASE_IN_OUT);
218 layer->SetOpacity(1.0f);
220 // A bit of a dirty trick: we need to catch the end of the animation we don't
221 // control. So we use two facts we know: which animator will be used and the
222 // target opacity to add "Do nothing" animation sequence.
223 // Unfortunately, we can not just use empty LayerAnimationSequence, because
224 // it does not call NotifyEnded().
225 if (observer) {
226 ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence(
227 ui::LayerAnimationElement::CreateOpacityElement(
228 1.0, base::TimeDelta()));
229 sequence->AddObserver(observer);
230 layer->GetAnimator()->ScheduleAnimation(sequence);
234 void ShowWindow(aura::Window* window,
235 base::TimeDelta duration,
236 bool above,
237 ui::LayerAnimationObserver* observer) {
238 ui::Layer* layer = window->layer();
239 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
241 // Set initial state of animation
242 settings.SetPreemptionStrategy(
243 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
244 settings.SetTransitionDuration(base::TimeDelta());
245 SetTransformForScaleAnimation(layer,
246 above ? LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW);
248 TransformWindowToBaseState(window, duration, observer);
251 // Starts grayscale/brightness animation for |window| over |duration|. Target
252 // value for both grayscale and brightness are specified by |target|.
253 void StartGrayscaleBrightnessAnimationForWindow(
254 aura::Window* window,
255 float target,
256 base::TimeDelta duration,
257 gfx::Tween::Type tween_type,
258 ui::LayerAnimationObserver* observer) {
259 ui::LayerAnimator* animator = window->layer()->GetAnimator();
261 scoped_ptr<ui::LayerAnimationSequence> brightness_sequence(
262 new ui::LayerAnimationSequence());
263 scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence(
264 new ui::LayerAnimationSequence());
266 scoped_ptr<ui::LayerAnimationElement> brightness_element(
267 ui::LayerAnimationElement::CreateBrightnessElement(
268 target, duration));
269 brightness_element->set_tween_type(tween_type);
270 brightness_sequence->AddElement(brightness_element.release());
272 scoped_ptr<ui::LayerAnimationElement> grayscale_element(
273 ui::LayerAnimationElement::CreateGrayscaleElement(
274 target, duration));
275 grayscale_element->set_tween_type(tween_type);
276 grayscale_sequence->AddElement(grayscale_element.release());
278 std::vector<ui::LayerAnimationSequence*> animations;
279 animations.push_back(brightness_sequence.release());
280 animations.push_back(grayscale_sequence.release());
282 if (observer)
283 animations[0]->AddObserver(observer);
285 animator->set_preemption_strategy(
286 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
288 animator->StartTogether(animations);
291 // Animation observer that will drop animated foreground once animation is
292 // finished. It is used in when undoing shutdown animation.
293 class CallbackAnimationObserver : public ui::LayerAnimationObserver {
294 public:
295 explicit CallbackAnimationObserver(base::Closure callback)
296 : callback_(callback) {
298 ~CallbackAnimationObserver() override {}
300 private:
301 // Overridden from ui::LayerAnimationObserver:
302 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override {
303 // Drop foreground once animation is over.
304 callback_.Run();
305 delete this;
308 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override {
309 // Drop foreground once animation is over.
310 callback_.Run();
311 delete this;
314 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {}
316 base::Closure callback_;
318 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver);
322 bool IsLayerAnimated(ui::Layer* layer,
323 SessionStateAnimator::AnimationType type) {
324 switch (type) {
325 case SessionStateAnimator::ANIMATION_PARTIAL_CLOSE:
326 if (layer->GetTargetTransform() != GetSlowCloseTransform())
327 return false;
328 break;
329 case SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE:
330 if (layer->GetTargetTransform() != gfx::Transform())
331 return false;
332 break;
333 case SessionStateAnimator::ANIMATION_FULL_CLOSE:
334 if (layer->GetTargetTransform() != GetFastCloseTransform() ||
335 layer->GetTargetOpacity() > 0.0001)
336 return false;
337 break;
338 case SessionStateAnimator::ANIMATION_FADE_IN:
339 if (layer->GetTargetOpacity() < 0.9999)
340 return false;
341 break;
342 case SessionStateAnimator::ANIMATION_FADE_OUT:
343 if (layer->GetTargetOpacity() > 0.0001)
344 return false;
345 break;
346 case SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY:
347 if (layer->GetTargetOpacity() > 0.0001)
348 return false;
349 break;
350 case SessionStateAnimator::ANIMATION_RESTORE:
351 if (layer->opacity() < 0.9999 || layer->transform() != gfx::Transform())
352 return false;
353 break;
354 case SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS:
355 if ((layer->GetTargetBrightness() < 0.9999) ||
356 (layer->GetTargetGrayscale() < 0.9999))
357 return false;
358 break;
359 case SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS:
360 if ((layer->GetTargetBrightness() > 0.0001) ||
361 (layer->GetTargetGrayscale() > 0.0001))
362 return false;
363 break;
364 case SessionStateAnimator::ANIMATION_DROP:
365 case SessionStateAnimator::ANIMATION_UNDO_LIFT:
366 //ToDo(antim) : check other effects
367 if (layer->GetTargetOpacity() < 0.9999)
368 return false;
369 break;
370 //ToDo(antim) : check other effects
371 case SessionStateAnimator::ANIMATION_LIFT:
372 if (layer->GetTargetOpacity() > 0.0001)
373 return false;
374 break;
375 case SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN:
376 //ToDo(antim) : check other effects
377 if (layer->GetTargetOpacity() < 0.9999)
378 return false;
379 break;
380 //ToDo(antim) : check other effects
381 case SessionStateAnimator::ANIMATION_LOWER_BELOW_SCREEN:
382 if (layer->GetTargetOpacity() > 0.0001)
383 return false;
384 break;
385 default:
386 NOTREACHED() << "Unhandled animation type " << type;
387 return false;
389 return true;
392 void GetContainersInRootWindow(int container_mask,
393 aura::Window* root_window,
394 aura::Window::Windows* containers) {
395 if (container_mask & SessionStateAnimator::ROOT_CONTAINER) {
396 containers->push_back(root_window);
399 if (container_mask & SessionStateAnimator::DESKTOP_BACKGROUND) {
400 containers->push_back(Shell::GetContainer(
401 root_window, kShellWindowId_DesktopBackgroundContainer));
403 if (container_mask & SessionStateAnimator::LAUNCHER) {
404 containers->push_back(
405 Shell::GetContainer(root_window, kShellWindowId_ShelfContainer));
407 if (container_mask & SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS) {
408 // TODO(antrim): Figure out a way to eliminate a need to exclude launcher
409 // in such way.
410 aura::Window* non_lock_screen_containers = Shell::GetContainer(
411 root_window, kShellWindowId_NonLockScreenContainersContainer);
412 // |non_lock_screen_containers| may already be removed in some tests.
413 if (non_lock_screen_containers) {
414 for (aura::Window* window : non_lock_screen_containers->children()) {
415 if (window->id() == kShellWindowId_ShelfContainer)
416 continue;
417 containers->push_back(window);
421 if (container_mask & SessionStateAnimator::LOCK_SCREEN_BACKGROUND) {
422 containers->push_back(Shell::GetContainer(
423 root_window, kShellWindowId_LockScreenBackgroundContainer));
425 if (container_mask & SessionStateAnimator::LOCK_SCREEN_CONTAINERS) {
426 containers->push_back(Shell::GetContainer(
427 root_window, kShellWindowId_LockScreenContainersContainer));
429 if (container_mask & SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS) {
430 containers->push_back(Shell::GetContainer(
431 root_window, kShellWindowId_LockScreenRelatedContainersContainer));
435 } // namespace
437 // This observer is intended to use in cases when some action has to be taken
438 // once some animation successfully completes (i.e. it was not aborted).
439 // Observer will count a number of sequences it is attached to, and a number of
440 // finished sequences (either Ended or Aborted). Once these two numbers are
441 // equal, observer will delete itself, calling callback passed to constructor if
442 // there were no aborted animations.
443 // This way it can be either used to wait for some animation to be finished in
444 // multiple layers, to wait once a sequence of animations is finished in one
445 // layer or the mixture of both.
446 class SessionStateAnimatorImpl::AnimationSequence
447 : public SessionStateAnimator::AnimationSequence,
448 public ui::LayerAnimationObserver {
449 public:
450 explicit AnimationSequence(
451 SessionStateAnimatorImpl* animator,
452 base::Closure callback)
453 : SessionStateAnimator::AnimationSequence(callback),
454 animator_(animator),
455 sequences_attached_(0),
456 sequences_completed_(0) {
459 // SessionStateAnimator::AnimationSequence:
460 void StartAnimation(int container_mask,
461 SessionStateAnimator::AnimationType type,
462 SessionStateAnimator::AnimationSpeed speed) override {
463 animator_->StartAnimationInSequence(container_mask, type, speed, this);
466 private:
467 ~AnimationSequence() override {}
469 // ui::LayerAnimationObserver:
470 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {
471 sequences_completed_++;
472 if (sequences_completed_ == sequences_attached_)
473 OnAnimationCompleted();
476 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {
477 sequences_completed_++;
478 if (sequences_completed_ == sequences_attached_)
479 OnAnimationAborted();
482 void OnLayerAnimationScheduled(
483 ui::LayerAnimationSequence* sequence) override {}
485 void OnAttachedToSequence(ui::LayerAnimationSequence* sequence) override {
486 LayerAnimationObserver::OnAttachedToSequence(sequence);
487 sequences_attached_++;
490 SessionStateAnimatorImpl* animator_; // not owned
492 // Number of sequences this observer was attached to.
493 int sequences_attached_;
495 // Number of sequences either ended or aborted.
496 int sequences_completed_;
498 DISALLOW_COPY_AND_ASSIGN(AnimationSequence);
501 bool SessionStateAnimatorImpl::TestApi::ContainersAreAnimated(
502 int container_mask, AnimationType type) const {
503 aura::Window::Windows containers;
504 animator_->GetContainers(container_mask, &containers);
505 for (aura::Window::Windows::const_iterator it = containers.begin();
506 it != containers.end(); ++it) {
507 aura::Window* window = *it;
508 ui::Layer* layer = window->layer();
509 if (!IsLayerAnimated(layer, type))
510 return false;
512 return true;
515 bool SessionStateAnimatorImpl::TestApi::RootWindowIsAnimated(AnimationType type)
516 const {
517 aura::Window* root_window = Shell::GetPrimaryRootWindow();
518 ui::Layer* layer = root_window->layer();
519 return IsLayerAnimated(layer, type);
522 SessionStateAnimatorImpl::SessionStateAnimatorImpl() {
525 SessionStateAnimatorImpl::~SessionStateAnimatorImpl() {
528 // Fills |containers| with the containers described by |container_mask|.
529 void SessionStateAnimatorImpl::GetContainers(
530 int container_mask,
531 aura::Window::Windows* containers) {
532 containers->clear();
534 for (aura::Window* root_window : Shell::GetAllRootWindows())
535 GetContainersInRootWindow(container_mask, root_window, containers);
537 // Some of containers may be null in some tests.
538 containers->erase(
539 std::remove(containers->begin(), containers->end(), nullptr),
540 containers->end());
543 void SessionStateAnimatorImpl::StartAnimation(int container_mask,
544 AnimationType type,
545 AnimationSpeed speed) {
546 aura::Window::Windows containers;
547 GetContainers(container_mask, &containers);
548 for (aura::Window::Windows::const_iterator it = containers.begin();
549 it != containers.end(); ++it) {
550 RunAnimationForWindow(*it, type, speed, NULL);
554 void SessionStateAnimatorImpl::StartAnimationWithCallback(
555 int container_mask,
556 AnimationType type,
557 AnimationSpeed speed,
558 base::Closure callback) {
559 aura::Window::Windows containers;
560 GetContainers(container_mask, &containers);
561 for (aura::Window::Windows::const_iterator it = containers.begin();
562 it != containers.end(); ++it) {
563 ui::LayerAnimationObserver* observer =
564 new CallbackAnimationObserver(callback);
565 RunAnimationForWindow(*it, type, speed, observer);
569 SessionStateAnimator::AnimationSequence*
570 SessionStateAnimatorImpl::BeginAnimationSequence(base::Closure callback) {
571 return new AnimationSequence(this, callback);
574 bool SessionStateAnimatorImpl::IsBackgroundHidden() const {
575 return !GetBackground()->IsVisible();
578 void SessionStateAnimatorImpl::ShowBackground() {
579 ui::ScopedLayerAnimationSettings settings(
580 GetBackground()->layer()->GetAnimator());
581 settings.SetTransitionDuration(base::TimeDelta());
582 GetBackground()->Show();
585 void SessionStateAnimatorImpl::HideBackground() {
586 ui::ScopedLayerAnimationSettings settings(
587 GetBackground()->layer()->GetAnimator());
588 settings.SetTransitionDuration(base::TimeDelta());
589 GetBackground()->Hide();
592 void SessionStateAnimatorImpl::StartAnimationInSequence(
593 int container_mask,
594 AnimationType type,
595 AnimationSpeed speed,
596 AnimationSequence* observer) {
597 aura::Window::Windows containers;
598 GetContainers(container_mask, &containers);
599 for (aura::Window::Windows::const_iterator it = containers.begin();
600 it != containers.end(); ++it) {
601 RunAnimationForWindow(*it, type, speed, observer);
605 void SessionStateAnimatorImpl::RunAnimationForWindow(
606 aura::Window* window,
607 AnimationType type,
608 AnimationSpeed speed,
609 ui::LayerAnimationObserver* observer) {
610 base::TimeDelta duration = GetDuration(speed);
612 switch (type) {
613 case ANIMATION_PARTIAL_CLOSE:
614 StartSlowCloseAnimationForWindow(window, duration, observer);
615 break;
616 case ANIMATION_UNDO_PARTIAL_CLOSE:
617 StartUndoSlowCloseAnimationForWindow(window, duration, observer);
618 break;
619 case ANIMATION_FULL_CLOSE:
620 StartFastCloseAnimationForWindow(window, duration, observer);
621 break;
622 case ANIMATION_FADE_IN:
623 StartOpacityAnimationForWindow(window, 1.0, duration, observer);
624 break;
625 case ANIMATION_FADE_OUT:
626 StartOpacityAnimationForWindow(window, 0.0, duration, observer);
627 break;
628 case ANIMATION_HIDE_IMMEDIATELY:
629 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE);
630 HideWindowImmediately(window, observer);
631 break;
632 case ANIMATION_RESTORE:
633 DCHECK_EQ(speed, ANIMATION_SPEED_IMMEDIATE);
634 RestoreWindow(window, observer);
635 break;
636 case ANIMATION_LIFT:
637 HideWindow(window, duration, true, observer);
638 break;
639 case ANIMATION_DROP:
640 ShowWindow(window, duration, true, observer);
641 break;
642 case ANIMATION_UNDO_LIFT:
643 TransformWindowToBaseState(window, duration, observer);
644 break;
645 case ANIMATION_RAISE_TO_SCREEN:
646 ShowWindow(window, duration, false, observer);
647 break;
648 case ANIMATION_LOWER_BELOW_SCREEN:
649 HideWindow(window, duration, false, observer);
650 break;
651 case ANIMATION_PARTIAL_FADE_IN:
652 StartPartialFadeAnimation(
653 window, kPartialFadeRatio, duration, observer);
654 break;
655 case ANIMATION_UNDO_PARTIAL_FADE_IN:
656 StartPartialFadeAnimation(window, 0.0, duration, observer);
657 break;
658 case ANIMATION_FULL_FADE_IN:
659 StartPartialFadeAnimation(window, 1.0, duration, observer);
660 break;
661 case ANIMATION_GRAYSCALE_BRIGHTNESS:
662 StartGrayscaleBrightnessAnimationForWindow(
663 window, 1.0, duration, gfx::Tween::EASE_IN, observer);
664 break;
665 case ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS:
666 StartGrayscaleBrightnessAnimationForWindow(
667 window, 0.0, duration, gfx::Tween::EASE_IN_OUT, observer);
668 break;
672 } // namespace ash