Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Unified Diff: ash/wm/session_state_animator.h

Issue 10914016: ash: Extract animator from PowerButtonController (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: restore ASH_EXPORT Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/power_button_controller_unittest.cc ('k') | ash/wm/session_state_animator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..58bf7edba2dd385a50c4db2de372b2b7ef8650c5
--- /dev/null
+++ b/ash/wm/session_state_animator.h
@@ -0,0 +1,144 @@
+// 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 {
+namespace internal {
+
+// Displays onscreen animations for session state changes (lock/unlock, sign
+// out, shut down).
+class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver {
+ 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,
+ LAUNCHER = 1 << 1,
+
+ // All user session related containers including system background but
+ // not including desktop background (wallpaper).
+ NON_LOCK_SCREEN_CONTAINERS = 1 << 2,
+
+ // 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 << 3,
+
+ // Lock screen and lock screen modal containers.
+ LOCK_SCREEN_CONTAINERS = 1 << 4,
+
+ // Multiple system layers belong here like status, menu, tooltip
+ // and overlay layers.
+ LOCK_SCREEN_RELATED_CONTAINERS = 1 << 5,
+ };
+
+ // 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);
+ };
+
+ // A bitfield mask including LOCK_SCREEN_WALLPAPER,
+ // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS.
+ const static int kAllLockScreenContainersMask;
+
+ // A bitfield mask of all containers.
+ const static int kAllContainersMask;
+
+ 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;
+
+ 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 internal
+} // namespace ash
+
+#endif // ASH_WM_SESSION_STATE_ANIMATOR_H_
« no previous file with comments | « ash/wm/power_button_controller_unittest.cc ('k') | ash/wm/session_state_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698