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..37322febff0ec2de9f930100f52ba1f892a4241e |
--- /dev/null |
+++ b/ash/wm/session_state_animator.h |
@@ -0,0 +1,122 @@ |
+// 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 { |
+ |
+// Displays onscreen animations for session state changes (lock/unlock,sign out, |
Daniel Erat
2012/08/31 17:02:12
nit: add space after "lock/unlock,"
Denis Kuznetsov (DE-MUC)
2012/09/28 11:52:43
Done.
|
+// shut down). |
+class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver { |
+ public: |
+ // Groups of containers that can be animated. |
+ // Exposed here for TestApi::ContainerGroupIsAnimated(). |
Daniel Erat
2012/08/31 17:02:12
nit: remove this "Exposed here for" comment; it's
Denis Kuznetsov (DE-MUC)
2012/09/28 11:52:43
Done.
|
+ enum ContainerGroup { |
+ ALL_CONTAINERS = 0, |
+ SCREEN_LOCKER_CONTAINERS, |
+ SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
+ ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
+ }; |
+ |
+ // Animations that can be applied to groups of containers. |
+ // Exposed here for TestApi::ContainerGroupIsAnimated(). |
Daniel Erat
2012/08/31 17:02:12
ditto
Denis Kuznetsov (DE-MUC)
2012/09/28 11:52:43
Done.
|
+ enum AnimationType { |
+ SLOW_CLOSE = 0, |
+ UNDO_SLOW_CLOSE, |
+ FAST_CLOSE, |
+ FADE_IN, |
+ HIDE, |
+ RESTORE, |
+ }; |
+ |
+ // 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() { |
tfarina
2012/09/01 11:02:30
This looks like more complex than a simple getter
Denis Kuznetsov (DE-MUC)
2012/09/28 11:52:43
Done, but there is a bunch of similar methods in
|
+ animator_->HideBackgroundLayer(); |
+ animator_->hide_background_layer_timer_.Stop(); |
+ } |
+ |
+ |
+ bool ContainerGroupIsAnimated(ContainerGroup group, |
+ AnimationType 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: |
Daniel Erat
2012/08/31 17:02:12
nit: overridden methods should come after all othe
Denis Kuznetsov (DE-MUC)
2012/09/28 11:52:43
Done.
|
+ 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(ContainerGroup group, |
+ AnimationType type); |
Daniel Erat
2012/08/31 17:02:12
nit: add a blank line between a method's signature
Denis Kuznetsov (DE-MUC)
2012/09/28 11:52:43
Done.
|
+ // Fills |containers| with the containers described by |group|. |
+ void GetContainers(ContainerGroup group, |
+ aura::Window::Windows* containers); |
+ private: |
+ |
Daniel Erat
2012/08/31 17:02:12
nit: remove all of these blank lines
Denis Kuznetsov (DE-MUC)
2012/09/28 11:52:43
Done.
|
+ |
+ // 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_ |