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