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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_SESSION_STATE_ANIMATOR_H_
6 #define ASH_WM_SESSION_STATE_ANIMATOR_H_
7
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time.h"
12 #include "base/timer.h"
13 #include "ui/aura/root_window_observer.h"
14 #include "ui/aura/window.h"
15
16 namespace gfx {
17 class Rect;
18 class Size;
19 }
20
21 namespace ui {
22 class Layer;
23 }
24
25 namespace ash {
26 namespace internal {
27
28 // Displays onscreen animations for session state changes (lock/unlock, sign
29 // out, shut down).
30 class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver {
31 public:
32 // Animations that can be applied to groups of containers.
33 enum AnimationType {
34 ANIMATION_SLOW_CLOSE = 0,
35 ANIMATION_UNDO_SLOW_CLOSE,
36 ANIMATION_FAST_CLOSE,
37 ANIMATION_FADE_IN,
38 ANIMATION_HIDE,
39 ANIMATION_RESTORE,
40 };
41
42 // Specific containers or groups of containers that can be animated.
43 enum Container {
44 DESKTOP_BACKGROUND = 1 << 0,
45 LAUNCHER = 1 << 1,
46
47 // All user session related containers including system background but
48 // not including desktop background (wallpaper).
49 NON_LOCK_SCREEN_CONTAINERS = 1 << 2,
50
51 // Desktop wallpaper is moved to this layer when screen is locked.
52 // This layer is excluded from lock animation so that wallpaper stays as is,
53 // user session windows are hidden and lock UI is shown on top of it.
54 // This layer is included in shutdown animation.
55 LOCK_SCREEN_BACKGROUND = 1 << 3,
56
57 // Lock screen and lock screen modal containers.
58 LOCK_SCREEN_CONTAINERS = 1 << 4,
59
60 // Multiple system layers belong here like status, menu, tooltip
61 // and overlay layers.
62 LOCK_SCREEN_RELATED_CONTAINERS = 1 << 5,
63 };
64
65 // Helper class used by tests to access internal state.
66 class ASH_EXPORT TestApi {
67 public:
68 explicit TestApi(SessionStateAnimator* animator)
69 : animator_(animator) {}
70
71 bool hide_black_layer_timer_is_running() const {
72 return animator_->hide_black_layer_timer_.IsRunning();
73 }
74
75 void TriggerHideBlackLayerTimeout();
76
77 // Returns true if containers of a given |container_mask|
78 // were last animated with |type| (probably; the analysis is fairly ad-hoc).
79 // |container_mask| is a bitfield of a Container.
80 bool ContainersAreAnimated(int container_mask, AnimationType type) const;
81
82 // Returns true if |black_layer_| is non-NULL and visible.
83 bool BlackLayerIsVisible() const;
84
85 // Returns |black_layer_|'s bounds, or an empty rect if the layer is
86 // NULL.
87 gfx::Rect GetBlackLayerBounds() const;
88
89 private:
90 SessionStateAnimator* animator_; // not owned
91
92 DISALLOW_COPY_AND_ASSIGN(TestApi);
93 };
94
95 // A bitfield mask including LOCK_SCREEN_WALLPAPER,
96 // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS.
97 const static int kAllLockScreenContainersMask;
98
99 // A bitfield mask of all containers.
100 const static int kAllContainersMask;
101
102 SessionStateAnimator();
103 virtual ~SessionStateAnimator();
104
105 // Shows or hides |black_layer_|. The show method creates and
106 // initializes the layer if it doesn't already exist.
107 void ShowBlackLayer();
108 void DropBlackLayer();
109
110 // Drops back layer after |UNDO_SLOW_CLOSE| animation delay.
111 void ScheduleDropBlackLayer();
112
113 // Apply animation |type| to all containers included in |container_mask|.
114 void StartAnimation(int container_mask,
115 AnimationType type);
116
117 // Fills |containers| with the containers included in |container_mask|.
118 void GetContainers(int container_mask,
119 aura::Window::Windows* containers);
120
121 // aura::RootWindowObserver overrides:
122 virtual void OnRootWindowResized(const aura::RootWindow* root,
123 const gfx::Size& old_size) OVERRIDE;
124
125 private:
126 // Layer that's stacked under all of the root window's children to provide a
127 // black background when we're scaling all of the other windows down.
128 // TODO(derat): Remove this in favor of having the compositor only clear the
129 // viewport when there are regions not covered by a layer:
130 // http://crbug.com/113445
131 scoped_ptr<ui::Layer> black_layer_;
132
133 // Started when we abort the pre-lock state. When it fires, we hide
134 // |black_layer_|, as the desktop background is now covering the whole
135 // screen.
136 base::OneShotTimer<SessionStateAnimator> hide_black_layer_timer_;
137
138 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator);
139 };
140
141 } // namespace internal
142 } // namespace ash
143
144 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_
OLDNEW
« 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