Chromium Code Reviews| Index: ash/wm/session_state_animator.h |
| diff --git a/ash/wm/session_state_animator.h b/ash/wm/session_state_animator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d85884395a1e1496119592fd5d93f28dc299f5c3 |
| --- /dev/null |
| +++ b/ash/wm/session_state_animator.h |
| @@ -0,0 +1,140 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_WM_SESSION_STATE_ANIMATOR_H_ |
| +#define ASH_WM_SESSION_STATE_ANIMATOR_H_ |
| + |
| +#include "ash/ash_export.h" |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time.h" |
| +#include "base/timer.h" |
| +#include "ui/aura/root_window_observer.h" |
| +#include "ui/aura/window.h" |
| + |
| +namespace gfx { |
| +class Rect; |
| +class Size; |
| +} |
| + |
| +namespace ui { |
| +class Layer; |
| +} |
| + |
| +namespace ash { |
|
Daniel Erat
2012/09/28 15:00:43
nit: can this go inside of ash::internal?
|
| + |
| +// Displays onscreen animations for session state changes (lock/unlock, sign |
| +// out, shut down). |
| +class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver { |
|
Daniel Erat
2012/09/28 15:00:43
nit: is ASH_EXPORT actually needed here? (i'm not
|
| + public: |
| + // Animations that can be applied to groups of containers. |
| + enum AnimationType { |
| + ANIMATION_SLOW_CLOSE = 0, |
| + ANIMATION_UNDO_SLOW_CLOSE, |
| + ANIMATION_FAST_CLOSE, |
| + ANIMATION_FADE_IN, |
| + ANIMATION_HIDE, |
| + ANIMATION_RESTORE, |
| + }; |
| + |
| + // Specific containers or groups of containers that can be animated. |
| + enum Container { |
| + DESKTOP_BACKGROUND = 1 << 0, |
| + |
| + // All user session related containers including system background but |
| + // not including desktop background (wallpaper). |
| + NON_LOCK_SCREEN_CONTAINERS = 1 << 1, |
| + |
| + // Desktop wallpaper is moved to this layer when screen is locked. |
| + // This layer is excluded from lock animation so that wallpaper stays as is, |
| + // user session windows are hidden and lock UI is shown on top of it. |
| + // This layer is included in shutdown animation. |
| + LOCK_SCREEN_BACKGROUND = 1 << 2, |
| + |
| + // Lock screen and lock screen modal containers. |
| + LOCK_SCREEN_CONTAINERS = 1 << 3, |
| + |
| + // Multiple system layers belong here like status, menu, tooltip |
| + // and overlay layers. |
| + LOCK_SCREEN_RELATED_CONTAINERS = 1 << 4, |
| + }; |
| + |
| + // Helper class used by tests to access internal state. |
| + class ASH_EXPORT TestApi { |
| + public: |
| + explicit TestApi(SessionStateAnimator* animator) |
| + : animator_(animator) {} |
| + |
| + bool hide_black_layer_timer_is_running() const { |
| + return animator_->hide_black_layer_timer_.IsRunning(); |
| + } |
| + |
| + void TriggerHideBlackLayerTimeout(); |
| + |
| + // Returns true if containers of a given |container_mask| |
| + // were last animated with |type| (probably; the analysis is fairly ad-hoc). |
| + // |container_mask| is a bitfield of a Container. |
| + bool ContainersAreAnimated(int container_mask, AnimationType type) const; |
| + |
| + // Returns true if |black_layer_| is non-NULL and visible. |
| + bool BlackLayerIsVisible() const; |
| + |
| + // Returns |black_layer_|'s bounds, or an empty rect if the layer is |
| + // NULL. |
| + gfx::Rect GetBlackLayerBounds() const; |
| + |
| + private: |
| + SessionStateAnimator* animator_; // not owned |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestApi); |
| + }; |
| + |
| + // Helper method that returns a bitfield mask of all containers. |
| + static int GetAllContainersMask(); |
|
Daniel Erat
2012/09/28 15:00:43
nit: instead of static methods, this and GetAllLoc
|
| + |
| + // Helper method that returns a bitfield mask including LOCK_SCREEN_WALLPAPER, |
| + // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS. |
| + static int GetAllLockScreenContainersMask(); |
| + |
| + SessionStateAnimator(); |
| + virtual ~SessionStateAnimator(); |
| + |
| + // Shows or hides |black_layer_|. The show method creates and |
| + // initializes the layer if it doesn't already exist. |
| + void ShowBlackLayer(); |
| + void DropBlackLayer(); |
| + |
| + // Drops back layer after |UNDO_SLOW_CLOSE| animation delay. |
| + void ScheduleDropBlackLayer(); |
| + |
| + // Apply animation |type| to all containers included in |container_mask|. |
| + void StartAnimation(int container_mask, |
| + AnimationType type); |
| + |
| + // Fills |containers| with the containers included in |container_mask|. |
| + void GetContainers(int container_mask, |
| + aura::Window::Windows* containers); |
| + |
| + // aura::RootWindowObserver overrides: |
| + virtual void OnRootWindowResized(const aura::RootWindow* root, |
| + const gfx::Size& old_size) OVERRIDE; |
|
Daniel Erat
2012/09/28 15:00:43
nit: add a blank line after this
|
| + private: |
| + // Layer that's stacked under all of the root window's children to provide a |
| + // black background when we're scaling all of the other windows down. |
| + // TODO(derat): Remove this in favor of having the compositor only clear the |
| + // viewport when there are regions not covered by a layer: |
| + // http://crbug.com/113445 |
| + scoped_ptr<ui::Layer> black_layer_; |
| + |
| + // 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. |
| + base::OneShotTimer<SessionStateAnimator> hide_black_layer_timer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_WM_SESSION_STATE_ANIMATOR_H_ |