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..894875c5737bf8d4484ee550ca2f0eff12394f47 |
| --- /dev/null |
| +++ b/ash/wm/session_state_animator.h |
| @@ -0,0 +1,125 @@ |
| +// 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 "ash/shell_observer.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 { |
| + |
| +// Animations that can be applied to groups of containers. |
| +// Exposed here for TestApi::ContainerGroupIsAnimated(). |
| +enum SessionStateAnimationType { |
| + ANIMATION_SLOW_CLOSE = 0, |
| + ANIMATION_UNDO_SLOW_CLOSE, |
| + ANIMATION_FAST_CLOSE, |
| + ANIMATION_FADE_IN, |
| + ANIMATION_HIDE, |
| + ANIMATION_RESTORE, |
| +}; |
| + |
| + |
| +// Groups of containers that can be animated. |
| +// Exposed here for TestApi::ContainerGroupIsAnimated(). |
| +enum AnimationContainerGroup { |
|
Daniel Erat
2012/08/30 18:05:24
This is too generally-named to go in the toplevel
Denis Kuznetsov (DE-MUC)
2012/08/30 18:17:48
Yes, they seem to be too long.
Would StateAnimatio
Daniel Erat
2012/08/30 18:28:17
I think that it's really best to keep these enums
Daniel Erat
2012/08/30 21:10:10
Alternately, I'd be fine moving the enums inside t
Denis Kuznetsov (DE-MUC)
2012/08/31 16:02:37
Done.
|
| + ALL_CONTAINERS = 0, |
| + SCREEN_LOCKER_CONTAINERS, |
| + SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| + ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| +}; |
| + |
| +// Displays onscreen animations for session state changes (lock/unlock,sign out, |
| +// shut down). |
| +class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver { |
| + public: |
| + |
| + |
| + // Helper class used by tests to access internal state. |
| + class ASH_EXPORT TestApi { |
| + public: |
| + explicit TestApi(SessionStateAnimator* animator) |
| + : animator_(animator) {} |
| + |
| + bool hide_background_layer_timer_is_running() const { |
| + return animator_->hide_background_layer_timer_.IsRunning(); |
| + } |
| + |
| + void trigger_hide_background_layer_timeout() { |
| + animator_->HideBackgroundLayer(); |
| + animator_->hide_background_layer_timer_.Stop(); |
| + } |
| + |
| + |
| + bool ContainerGroupIsAnimated(AnimationContainerGroup group, |
| + SessionStateAnimationType type) const; |
| + |
| + // Returns true if |background_layer_| is non-NULL and visible. |
| + bool BackgroundLayerIsVisible() const; |
| + |
| + // Returns |background_layer_|'s bounds, or an empty rect if the layer is |
| + // NULL. |
| + gfx::Rect GetBackgroundLayerBounds() const; |
| + |
| + private: |
| + SessionStateAnimator* animator_; // not owned |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestApi); |
| + }; |
| + |
| + SessionStateAnimator(); |
| + virtual ~SessionStateAnimator(); |
| + |
| + // aura::RootWindowObserver overrides: |
| + virtual void OnRootWindowResized(const aura::RootWindow* root, |
| + const gfx::Size& old_size) OVERRIDE; |
| + // Shows or hides |background_layer_|. The show method creates and |
| + // initializes the layer if it doesn't already exist. |
| + void ShowBackgroundLayer(); |
| + void HideBackgroundLayer(); |
| + void DropBackgroundLayer(); |
| + |
| + // Apply animation |type| to all containers described by |group|. |
| + void StartAnimation(AnimationContainerGroup group, |
| + SessionStateAnimationType type); |
| + // Fills |containers| with the containers described by |group|. |
| + void GetContainers(AnimationContainerGroup group, |
| + aura::Window::Windows* containers); |
| + 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> background_layer_; |
| + |
| + // Started when we abort the pre-lock state. When it fires, we hide |
| + // |background_layer_|, as the desktop background is now covering the whole |
| + // screen. |
| + base::OneShotTimer<SessionStateAnimator> hide_background_layer_timer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_WM_SESSION_STATE_ANIMATOR_H_ |