Index: ash/wm/session_state_animator.cc |
diff --git a/ash/wm/session_state_animator.cc b/ash/wm/session_state_animator.cc |
index 180a034d5c18bcb4a02185a297e34e4a142562ba..7c53fb79e6c7e1f24dea217fa7fe405027ca2056 100644 |
--- a/ash/wm/session_state_animator.cc |
+++ b/ash/wm/session_state_animator.cc |
@@ -6,8 +6,12 @@ |
#include "ash/shell.h" |
#include "ash/shell_window_ids.h" |
+#include "ash/wm/workspace/workspace_animations.h" |
+#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/root_window.h" |
#include "ui/compositor/layer_animation_sequence.h" |
+#include "ui/compositor/layer_animation_observer.h" |
Daniel Erat
2012/10/22 17:45:48
keep this list alphabetized
|
+#include "ui/views/widget/widget.h" |
namespace ash { |
namespace internal { |
@@ -36,6 +40,9 @@ const int kLockFadeInAnimMs = 200; |
// pre-shutdown states. |
const float kSlowCloseSizeRatio = 0.95f; |
+//ToDo (antrim) : comment |
+const float kPartialFadeRatio = 0.3f; |
+ |
// Returns the transform that should be applied to containers for the slow-close |
// animation. |
gfx::Transform GetSlowCloseTransform() { |
@@ -100,6 +107,21 @@ void StartFastCloseAnimationForWindow(aura::Window* window) { |
0.0, base::TimeDelta::FromMilliseconds(kFastCloseAnimMs)))); |
} |
+// Fades |window| to a |target_opacity| for a |lengthMs| milliseconds. |
Daniel Erat
2012/10/22 17:45:48
s/lengthMs/length_ms/
|
+void StartPartialFadeAnimation(aura::Window* window, float target_opacity, |
Daniel Erat
2012/10/22 17:45:48
one argument per line
|
+ int length_ms, |
Daniel Erat
2012/10/22 17:45:48
use base::TimeDelta instead of int
|
+ ui::LayerAnimationObserver* observer) { |
+ ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
+ animator->set_preemption_strategy( |
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ ui::LayerAnimationSequence* sequence = new ui::LayerAnimationSequence( |
+ ui::LayerAnimationElement::CreateOpacityElement( |
+ target_opacity, base::TimeDelta::FromMilliseconds(length_ms))); |
+ animator->StartAnimation(sequence); |
+ if (observer) |
+ sequence->AddObserver(observer); |
+} |
+ |
// Fades |window| in to full opacity. |
void FadeInWindow(aura::Window* window) { |
ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
@@ -123,6 +145,59 @@ void RestoreWindow(aura::Window* window) { |
window->layer()->SetOpacity(1.0); |
} |
+void LiftUpWindow(aura::Window* window, int length_ms) { |
Daniel Erat
2012/10/22 17:45:48
pass in base::TimeDelta here instead of int
|
+ WorkspaceAnimationDetails details; |
+ details.direction = WORKSPACE_ANIMATE_UP; |
+ details.animate = true; |
+ details.animate_scale = true; |
+ details.animate_opacity = true; |
+ details.duration = base::TimeDelta::FromMilliseconds(length_ms); |
+ HideWorkspace(window, details); |
+} |
+ |
+void PutDownWindow(aura::Window* window, int length_ms) { |
Daniel Erat
2012/10/22 17:45:48
ditto
|
+ WorkspaceAnimationDetails details; |
+ details.direction = WORKSPACE_ANIMATE_DOWN; |
+ details.animate = true; |
+ details.animate_scale = true; |
+ details.animate_opacity = true; |
+ details.duration = base::TimeDelta::FromMilliseconds(length_ms); |
+ ShowWorkspace(window, details); |
+} |
+ |
+//ToDo(antrim) : comment. |
+class ForegroundDropAnimationObserver : public ui::LayerAnimationObserver { |
+ public: |
+ explicit ForegroundDropAnimationObserver(SessionStateAnimator* animator) |
+ : animator_(animator) { |
+ } |
+ virtual ~ForegroundDropAnimationObserver() { |
+ } |
+ |
+ private: |
+ // Overridden from ui::LayerAnimationObserver: |
+ virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) |
+ OVERRIDE { |
+ //Drop foreground once animation is over. |
Daniel Erat
2012/10/22 17:45:48
add space between "//" and "Drop"
|
+ animator_->DropForeground(); |
+ delete this; |
+ } |
+ |
+ virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) |
+ OVERRIDE { |
+ //Drop foreground once animation is over. |
Daniel Erat
2012/10/22 17:45:48
same here
|
+ animator_->DropForeground(); |
+ delete this; |
+ } |
+ |
+ virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) |
+ OVERRIDE {} |
+ |
+ SessionStateAnimator* animator_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ForegroundDropAnimationObserver); |
+}; |
+ |
} // namespace |
void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() { |
@@ -140,15 +215,15 @@ bool SessionStateAnimator::TestApi::ContainersAreAnimated( |
ui::Layer* layer = window->layer(); |
switch (type) { |
- case ANIMATION_SLOW_CLOSE: |
+ case ANIMATION_PARTIAL_CLOSE: |
if (layer->GetTargetTransform() != GetSlowCloseTransform()) |
return false; |
break; |
- case ANIMATION_UNDO_SLOW_CLOSE: |
+ case ANIMATION_UNDO_PARTIAL_CLOSE: |
if (layer->GetTargetTransform() != gfx::Transform()) |
return false; |
break; |
- case ANIMATION_FAST_CLOSE: |
+ case ANIMATION_FULL_CLOSE: |
if (layer->GetTargetTransform() != GetFastCloseTransform() || |
layer->GetTargetOpacity() > 0.0001) |
return false; |
@@ -249,6 +324,11 @@ void SessionStateAnimator::GetContainers(int container_mask, |
root_window, |
internal::kShellWindowId_LockScreenRelatedContainersContainer)); |
} |
+ if (container_mask & LOCK_SCREEN_SYSTEM_FOREGROUND) { |
+ containers->push_back(Shell::GetContainer( |
+ root_window, |
+ internal::kShellWindowId_TopmostContainer)); |
+ } |
} |
// Apply animation |type| to all containers described by |container_mask|. |
@@ -261,13 +341,13 @@ void SessionStateAnimator::StartAnimation(int container_mask, |
it != containers.end(); ++it) { |
aura::Window* window = *it; |
switch (type) { |
- case ANIMATION_SLOW_CLOSE: |
+ case ANIMATION_PARTIAL_CLOSE: |
StartSlowCloseAnimationForWindow(window); |
break; |
- case ANIMATION_UNDO_SLOW_CLOSE: |
+ case ANIMATION_UNDO_PARTIAL_CLOSE: |
StartUndoSlowCloseAnimationForWindow(window); |
break; |
- case ANIMATION_FAST_CLOSE: |
+ case ANIMATION_FULL_CLOSE: |
StartFastCloseAnimationForWindow(window); |
break; |
case ANIMATION_FADE_IN: |
@@ -279,6 +359,23 @@ void SessionStateAnimator::StartAnimation(int container_mask, |
case ANIMATION_RESTORE: |
RestoreWindow(window); |
break; |
+ case ANIMATION_LIFT_UP: |
+ LiftUpWindow(window, kSlowCloseAnimMs); |
+ break; |
+ case ANIMATION_PUT_DOWN: |
+ PutDownWindow(window, kSlowCloseAnimMs); |
+ break; |
+ case ANIMATION_PARTIAL_FADE_IN: |
+ StartPartialFadeAnimation(window, kPartialFadeRatio, kSlowCloseAnimMs, |
+ NULL); |
+ break; |
+ case ANIMATION_UNDO_PARTIAL_FADE_IN: |
+ StartPartialFadeAnimation(window, 0.0, kUndoSlowCloseAnimMs, |
+ new ForegroundDropAnimationObserver(this)); |
+ break; |
+ case ANIMATION_FULL_FADE_IN: |
+ StartPartialFadeAnimation(window, 1.0, kFastCloseAnimMs, NULL); |
+ break; |
default: |
NOTREACHED() << "Unhandled animation type " << type; |
} |
@@ -319,5 +416,22 @@ void SessionStateAnimator::ScheduleDropBlackLayer() { |
this, &SessionStateAnimator::DropBlackLayer); |
} |
+void SessionStateAnimator::CreateForeground() { |
+ LOG(ERROR) << "SessionStateAnimator::CreateForeground()"; |
Daniel Erat
2012/10/22 17:45:48
delete this
|
+ if (!foreground_.get()) { |
Daniel Erat
2012/10/22 17:45:48
nit: little bit cleaner to just do:
if (foregro
|
+ aura::Window* window = Shell::GetContainer( |
+ Shell::GetPrimaryRootWindow(), |
+ internal::kShellWindowId_TopmostContainer); |
+ HideWindow(window); |
+ foreground_.reset(new ColoredWindowController(window, "WhiteForeground")); |
Daniel Erat
2012/10/22 17:45:48
"SessionStateAnimatorForeground"?
|
+ foreground_->SetColor(SK_ColorWHITE); |
+ foreground_->GetWidget()->Show(); |
+ } |
+} |
+ |
+void SessionStateAnimator::DropForeground() { |
+ foreground_.reset(); |
+} |
+ |
} // namespace internal |
} // namespace ash |