summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 08:23:08 +0000
committerantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 08:23:08 +0000
commita07615f3fbf7376b504e094f6c27d9613ef66ad7 (patch)
treeb531f3c7e6b8bd522059f4d8e5af74b20bc0171e
parente12c2d0c1f9478a7f62fa84d21e7a5d055a65320 (diff)
downloadchromium_src-a07615f3fbf7376b504e094f6c27d9613ef66ad7.zip
chromium_src-a07615f3fbf7376b504e094f6c27d9613ef66ad7.tar.gz
chromium_src-a07615f3fbf7376b504e094f6c27d9613ef66ad7.tar.bz2
Added new lock/shutdown implementations in session_state_controller_impl2/session_state_animator.
This CL is a follow-up for https://codereview.chromium.org/11230050/. BUG=138171, 139461 Review URL: https://chromiumcodereview.appspot.com/11220002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163790 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/root_window_controller.cc3
-rw-r--r--ash/shell_window_ids.h3
-rw-r--r--ash/wm/session_state_animator.cc121
-rw-r--r--ash/wm/session_state_animator.h18
-rw-r--r--ash/wm/session_state_controller_impl2.cc84
5 files changed, 166 insertions, 63 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index b0d29a0..0634ec9 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -616,6 +616,9 @@ void RootWindowController::CreateContainersInRootWindow(
"OverlayContainer",
lock_screen_related_containers);
SetUsesScreenCoordinates(overlay_container);
+
+ CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
+ "PowerButtonAnimationContainer", root_window) ;
}
} // namespace internal
diff --git a/ash/shell_window_ids.h b/ash/shell_window_ids.h
index f4aca62..c508c16 100644
--- a/ash/shell_window_ids.h
+++ b/ash/shell_window_ids.h
@@ -104,6 +104,9 @@ const int kShellWindowId_OverlayContainer = 21;
// ID of the window created by PhantomWindowController.
const int kShellWindowId_PhantomWindow = 22;
+// The topmost container, used for power off animation.
+const int kShellWindowId_PowerButtonAnimationContainer = 23;
+
} // namespace internal
} // namespace ash
diff --git a/ash/wm/session_state_animator.cc b/ash/wm/session_state_animator.cc
index 92006619..55f3fa1 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_observer.h"
#include "ui/compositor/layer_animation_sequence.h"
+#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;
+// Maximum opacity of white layer when animating pre-shutdown state.
+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,22 @@ void StartFastCloseAnimationForWindow(aura::Window* window) {
0.0, base::TimeDelta::FromMilliseconds(kFastCloseAnimMs))));
}
+// Fades |window| to |target_opacity| over |length| milliseconds.
+void StartPartialFadeAnimation(aura::Window* window,
+ float target_opacity,
+ base::TimeDelta length,
+ 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, length));
+ 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 +146,60 @@ void RestoreWindow(aura::Window* window) {
window->layer()->SetOpacity(1.0);
}
+void RaiseWindow(aura::Window* window, base::TimeDelta length) {
+ WorkspaceAnimationDetails details;
+ details.direction = WORKSPACE_ANIMATE_UP;
+ details.animate = true;
+ details.animate_scale = true;
+ details.animate_opacity = true;
+ details.duration = length;
+ HideWorkspace(window, details);
+}
+
+void LowerWindow(aura::Window* window, base::TimeDelta length) {
+ WorkspaceAnimationDetails details;
+ details.direction = WORKSPACE_ANIMATE_DOWN;
+ details.animate = true;
+ details.animate_scale = true;
+ details.animate_opacity = true;
+ details.duration = length;
+ ShowWorkspace(window, details);
+}
+
+// Animation observer that will drop animated foreground once animation is
+// finished. It is used in when undoing shutdown animation.
+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.
+ animator_->DropForeground();
+ delete this;
+ }
+
+ virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq)
+ OVERRIDE {
+ // Drop foreground once animation is over.
+ animator_->DropForeground();
+ delete this;
+ }
+
+ virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq)
+ OVERRIDE {}
+
+ SessionStateAnimator* animator_;
+
+ DISALLOW_COPY_AND_ASSIGN(ForegroundDropAnimationObserver);
+};
+
} // namespace
void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() {
@@ -249,6 +326,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_PowerButtonAnimationContainer));
+ }
}
// Apply animation |type| to all containers described by |container_mask|.
@@ -279,6 +361,28 @@ void SessionStateAnimator::StartAnimation(int container_mask,
case ANIMATION_RESTORE:
RestoreWindow(window);
break;
+ case ANIMATION_RAISE:
+ RaiseWindow(window,
+ base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs));
+ break;
+ case ANIMATION_LOWER:
+ LowerWindow(window,
+ base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs));
+ break;
+ case ANIMATION_PARTIAL_FADE_IN:
+ StartPartialFadeAnimation(window, kPartialFadeRatio,
+ base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs),
+ NULL);
+ break;
+ case ANIMATION_UNDO_PARTIAL_FADE_IN:
+ StartPartialFadeAnimation(window, 0.0,
+ base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs),
+ new ForegroundDropAnimationObserver(this));
+ break;
+ case ANIMATION_FULL_FADE_IN:
+ StartPartialFadeAnimation(window, 1.0,
+ base::TimeDelta::FromMilliseconds(kFastCloseAnimMs), NULL);
+ break;
default:
NOTREACHED() << "Unhandled animation type " << type;
}
@@ -319,5 +423,22 @@ void SessionStateAnimator::ScheduleDropBlackLayer() {
this, &SessionStateAnimator::DropBlackLayer);
}
+void SessionStateAnimator::CreateForeground() {
+ if (foreground_.get())
+ return;
+ aura::Window* window = Shell::GetContainer(
+ Shell::GetPrimaryRootWindow(),
+ internal::kShellWindowId_PowerButtonAnimationContainer);
+ HideWindow(window);
+ foreground_.reset(
+ new ColoredWindowController(window, "SessionStateAnimatorForeground"));
+ foreground_->SetColor(SK_ColorWHITE);
+ foreground_->GetWidget()->Show();
+}
+
+void SessionStateAnimator::DropForeground() {
+ foreground_.reset();
+}
+
} // namespace internal
} // namespace ash
diff --git a/ash/wm/session_state_animator.h b/ash/wm/session_state_animator.h
index 43f2f14..4a43cc8 100644
--- a/ash/wm/session_state_animator.h
+++ b/ash/wm/session_state_animator.h
@@ -6,6 +6,7 @@
#define ASH_WM_SESSION_STATE_ANIMATOR_H_
#include "ash/ash_export.h"
+#include "ash/wm/workspace/colored_window_controller.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/timer.h"
@@ -36,6 +37,11 @@ class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver {
ANIMATION_FADE_IN,
ANIMATION_HIDE,
ANIMATION_RESTORE,
+ ANIMATION_RAISE,
+ ANIMATION_LOWER,
+ ANIMATION_PARTIAL_FADE_IN,
+ ANIMATION_UNDO_PARTIAL_FADE_IN,
+ ANIMATION_FULL_FADE_IN,
};
// Specific containers or groups of containers that can be animated.
@@ -59,6 +65,8 @@ class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver {
// Multiple system layers belong here like status, menu, tooltip
// and overlay layers.
LOCK_SCREEN_RELATED_CONTAINERS = 1 << 5,
+
+ LOCK_SCREEN_SYSTEM_FOREGROUND = 1 << 6,
};
// Helper class used by tests to access internal state.
@@ -106,6 +114,12 @@ class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver {
void ShowBlackLayer();
void DropBlackLayer();
+ // Create |foreground_| layer if it doesn't already exist, but makes it
+ // completely transparent.
+ void CreateForeground();
+ // Destroy |foreground_| when it is not needed anymore.
+ void DropForeground();
+
// Drops back layer after |UNDO_SLOW_CLOSE| animation delay.
void ScheduleDropBlackLayer();
@@ -129,6 +143,10 @@ class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver {
// http://crbug.com/113445
scoped_ptr<ui::Layer> black_layer_;
+ // White foreground that is used during shutdown animation to "fade
+ // everything into white".
+ scoped_ptr<ColoredWindowController> foreground_;
+
// Started when we abort the pre-lock state. When it fires, we hide
// |black_layer_|, as the desktop background is now covering the whole
// screen.
diff --git a/ash/wm/session_state_controller_impl2.cc b/ash/wm/session_state_controller_impl2.cc
index 20ce21f..a1e2ef8 100644
--- a/ash/wm/session_state_controller_impl2.cc
+++ b/ash/wm/session_state_controller_impl2.cc
@@ -54,7 +54,6 @@ void SessionStateControllerImpl2::OnAppTerminating() {
Shell* shell = ash::Shell::GetInstance();
shell->env_filter()->set_cursor_hidden_by_filter(false);
shell->cursor_manager()->ShowCursor(false);
- animator_->ShowBlackLayer();
animator_->StartAnimation(
internal::SessionStateAnimator::kAllContainersMask,
internal::SessionStateAnimator::ANIMATION_HIDE);
@@ -80,11 +79,8 @@ void SessionStateControllerImpl2::OnLockStateChanged(bool locked) {
}
} else {
animator_->StartAnimation(
- internal::SessionStateAnimator::DESKTOP_BACKGROUND |
- internal::SessionStateAnimator::LAUNCHER |
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_RESTORE);
- animator_->DropBlackLayer();
+ internal::SessionStateAnimator::ANIMATION_LOWER);
}
}
@@ -92,18 +88,9 @@ void SessionStateControllerImpl2::OnStartingLock() {
if (shutting_down_ || system_is_locked_)
return;
- // Ensure that the black layer is visible -- if the screen was locked via
- // the wrench menu, we won't have already shown the black background
- // as part of the slow-close animation.
- animator_->ShowBlackLayer();
-
- animator_->StartAnimation(
- internal::SessionStateAnimator::LAUNCHER,
- internal::SessionStateAnimator::ANIMATION_HIDE);
-
animator_->StartAnimation(
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_FULL_CLOSE);
+ internal::SessionStateAnimator::ANIMATION_RAISE);
// Hide the screen locker containers so we can make them fade in later.
animator_->StartAnimation(
@@ -112,29 +99,28 @@ void SessionStateControllerImpl2::OnStartingLock() {
}
void SessionStateControllerImpl2::StartLockAnimationAndLockImmediately() {
- animator_->ShowBlackLayer();
animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE);
+ internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
+ internal::SessionStateAnimator::LAUNCHER,
+ internal::SessionStateAnimator::ANIMATION_RAISE);
OnLockTimeout();
}
void SessionStateControllerImpl2::StartLockAnimation(bool shutdown_after_lock) {
shutdown_after_lock_ = shutdown_after_lock;
- animator_->ShowBlackLayer();
animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE);
+ internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
+ internal::SessionStateAnimator::LAUNCHER,
+ internal::SessionStateAnimator::ANIMATION_RAISE);
StartLockTimer();
}
void SessionStateControllerImpl2::StartShutdownAnimation() {
- animator_->ShowBlackLayer();
+ animator_->CreateForeground();
animator_->StartAnimation(
- internal::SessionStateAnimator::kAllContainersMask,
- internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE);
-
+ internal::SessionStateAnimator::LOCK_SCREEN_SYSTEM_FOREGROUND,
+ internal::SessionStateAnimator::ANIMATION_PARTIAL_FADE_IN);
StartPreShutdownAnimationTimer();
}
@@ -164,8 +150,7 @@ void SessionStateControllerImpl2::CancelLockAnimation() {
shutdown_after_lock_ = false;
animator_->StartAnimation(
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE);
- animator_->ScheduleDropBlackLayer();
+ internal::SessionStateAnimator::ANIMATION_LOWER);
lock_timer_.Stop();
}
@@ -186,29 +171,16 @@ void SessionStateControllerImpl2::CancelShutdownAnimation() {
shutdown_after_lock_ = false;
return;
}
+ animator_->CreateForeground();
+ animator_->StartAnimation(
+ internal::SessionStateAnimator::LOCK_SCREEN_SYSTEM_FOREGROUND,
+ internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_FADE_IN);
- if (system_is_locked_) {
- // If we've already started shutdown transition at lock screen
- // desktop background needs to be restored immediately.
- animator_->StartAnimation(
- internal::SessionStateAnimator::DESKTOP_BACKGROUND,
- internal::SessionStateAnimator::ANIMATION_RESTORE);
- animator_->StartAnimation(
- internal::SessionStateAnimator::kAllLockScreenContainersMask,
- internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE);
- animator_->ScheduleDropBlackLayer();
- } else {
- animator_->StartAnimation(
- internal::SessionStateAnimator::kAllContainersMask,
- internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE);
- animator_->ScheduleDropBlackLayer();
- }
pre_shutdown_timer_.Stop();
}
void SessionStateControllerImpl2::RequestShutdown() {
if (!shutting_down_)
- animator_->ShowBlackLayer();
RequestShutdownImpl();
}
@@ -220,23 +192,10 @@ void SessionStateControllerImpl2::RequestShutdownImpl() {
shell->env_filter()->set_cursor_hidden_by_filter(false);
shell->cursor_manager()->ShowCursor(false);
- animator_->ShowBlackLayer();
- if (login_status_ != user::LOGGED_IN_NONE) {
- // Hide the other containers before starting the animation.
- // ANIMATION_FULL_CLOSE will make the screen locker windows partially
- // transparent, and we don't want the other windows to show through.
- animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
- internal::SessionStateAnimator::LAUNCHER,
- internal::SessionStateAnimator::ANIMATION_HIDE);
- animator_->StartAnimation(
- internal::SessionStateAnimator::kAllLockScreenContainersMask,
- internal::SessionStateAnimator::ANIMATION_FULL_CLOSE);
- } else {
- animator_->StartAnimation(
- internal::SessionStateAnimator::kAllContainersMask,
- internal::SessionStateAnimator::ANIMATION_FULL_CLOSE);
- }
+ animator_->CreateForeground();
+ animator_->StartAnimation(
+ internal::SessionStateAnimator::LOCK_SCREEN_SYSTEM_FOREGROUND,
+ internal::SessionStateAnimator::ANIMATION_FULL_FADE_IN);
StartRealShutdownTimer();
}
@@ -273,8 +232,7 @@ void SessionStateControllerImpl2::OnLockFailTimeout() {
animator_->StartAnimation(
internal::SessionStateAnimator::LAUNCHER |
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_RESTORE);
- animator_->DropBlackLayer();
+ internal::SessionStateAnimator::ANIMATION_LOWER);
}
void SessionStateControllerImpl2::StartLockToShutdownTimer() {