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 "ash/shell_observer.h" | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/time.h" | |
13 #include "base/timer.h" | |
14 #include "ui/aura/root_window_observer.h" | |
15 #include "ui/aura/window.h" | |
16 | |
17 namespace gfx { | |
18 class Rect; | |
19 class Size; | |
20 } | |
21 | |
22 namespace ui { | |
23 class Layer; | |
24 } | |
25 | |
26 namespace ash { | |
27 | |
28 // Animations that can be applied to groups of containers. | |
29 // Exposed here for TestApi::ContainerGroupIsAnimated(). | |
30 enum SessionStateAnimationType { | |
31 ANIMATION_SLOW_CLOSE = 0, | |
32 ANIMATION_UNDO_SLOW_CLOSE, | |
33 ANIMATION_FAST_CLOSE, | |
34 ANIMATION_FADE_IN, | |
35 ANIMATION_HIDE, | |
36 ANIMATION_RESTORE, | |
37 }; | |
38 | |
39 | |
40 // Groups of containers that can be animated. | |
41 // Exposed here for TestApi::ContainerGroupIsAnimated(). | |
42 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.
| |
43 ALL_CONTAINERS = 0, | |
44 SCREEN_LOCKER_CONTAINERS, | |
45 SCREEN_LOCKER_AND_RELATED_CONTAINERS, | |
46 ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, | |
47 }; | |
48 | |
49 // Displays onscreen animations for session state changes (lock/unlock,sign out, | |
50 // shut down). | |
51 class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver { | |
52 public: | |
53 | |
54 | |
55 // Helper class used by tests to access internal state. | |
56 class ASH_EXPORT TestApi { | |
57 public: | |
58 explicit TestApi(SessionStateAnimator* animator) | |
59 : animator_(animator) {} | |
60 | |
61 bool hide_background_layer_timer_is_running() const { | |
62 return animator_->hide_background_layer_timer_.IsRunning(); | |
63 } | |
64 | |
65 void trigger_hide_background_layer_timeout() { | |
66 animator_->HideBackgroundLayer(); | |
67 animator_->hide_background_layer_timer_.Stop(); | |
68 } | |
69 | |
70 | |
71 bool ContainerGroupIsAnimated(AnimationContainerGroup group, | |
72 SessionStateAnimationType type) const; | |
73 | |
74 // Returns true if |background_layer_| is non-NULL and visible. | |
75 bool BackgroundLayerIsVisible() const; | |
76 | |
77 // Returns |background_layer_|'s bounds, or an empty rect if the layer is | |
78 // NULL. | |
79 gfx::Rect GetBackgroundLayerBounds() const; | |
80 | |
81 private: | |
82 SessionStateAnimator* animator_; // not owned | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(TestApi); | |
85 }; | |
86 | |
87 SessionStateAnimator(); | |
88 virtual ~SessionStateAnimator(); | |
89 | |
90 // aura::RootWindowObserver overrides: | |
91 virtual void OnRootWindowResized(const aura::RootWindow* root, | |
92 const gfx::Size& old_size) OVERRIDE; | |
93 // Shows or hides |background_layer_|. The show method creates and | |
94 // initializes the layer if it doesn't already exist. | |
95 void ShowBackgroundLayer(); | |
96 void HideBackgroundLayer(); | |
97 void DropBackgroundLayer(); | |
98 | |
99 // Apply animation |type| to all containers described by |group|. | |
100 void StartAnimation(AnimationContainerGroup group, | |
101 SessionStateAnimationType type); | |
102 // Fills |containers| with the containers described by |group|. | |
103 void GetContainers(AnimationContainerGroup group, | |
104 aura::Window::Windows* containers); | |
105 private: | |
106 | |
107 | |
108 // Layer that's stacked under all of the root window's children to provide a | |
109 // black background when we're scaling all of the other windows down. | |
110 // TODO(derat): Remove this in favor of having the compositor only clear the | |
111 // viewport when there are regions not covered by a layer: | |
112 // http://crbug.com/113445 | |
113 scoped_ptr<ui::Layer> background_layer_; | |
114 | |
115 // Started when we abort the pre-lock state. When it fires, we hide | |
116 // |background_layer_|, as the desktop background is now covering the whole | |
117 // screen. | |
118 base::OneShotTimer<SessionStateAnimator> hide_background_layer_timer_; | |
119 | |
120 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator); | |
121 }; | |
122 | |
123 } // namespace ash | |
124 | |
125 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_ | |
OLD | NEW |