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

Side by Side Diff: ash/wm/session_state_animator.h

Issue 326813004: Added quick lock mechanism while in Touchview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add docs for TestSessionStateAnimator::AnimationSequence. Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_WM_SESSION_STATE_ANIMATOR_H_ 5 #ifndef ASH_WM_SESSION_STATE_ANIMATOR_H_
6 #define ASH_WM_SESSION_STATE_ANIMATOR_H_ 6 #define ASH_WM_SESSION_STATE_ANIMATOR_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/callback.h"
11 #include "base/timer/timer.h" 11 #include "base/time/time.h"
12 #include "ui/aura/window.h"
13 #include "ui/compositor/layer_animation_observer.h"
14
15 namespace gfx {
16 class Rect;
17 class Size;
18 }
19
20 namespace ui {
21 class Layer;
22 }
23 12
24 namespace ash { 13 namespace ash {
25 14
26 // Displays onscreen animations for session state changes (lock/unlock, sign 15 // Displays onscreen animations for session state changes (lock/unlock, sign
27 // out, shut down). 16 // out, shut down).
28 class ASH_EXPORT SessionStateAnimator { 17 class ASH_EXPORT SessionStateAnimator {
29 public: 18 public:
30 // Animations that can be applied to groups of containers. 19 // Animations that can be applied to groups of containers.
31 enum AnimationType { 20 enum AnimationType {
32 ANIMATION_PARTIAL_CLOSE = 0, 21 ANIMATION_PARTIAL_CLOSE = 0,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // user session windows are hidden and lock UI is shown on top of it. 80 // user session windows are hidden and lock UI is shown on top of it.
92 // This layer is included in shutdown animation. 81 // This layer is included in shutdown animation.
93 LOCK_SCREEN_BACKGROUND = 1 << 3, 82 LOCK_SCREEN_BACKGROUND = 1 << 3,
94 83
95 // Lock screen and lock screen modal containers. 84 // Lock screen and lock screen modal containers.
96 LOCK_SCREEN_CONTAINERS = 1 << 4, 85 LOCK_SCREEN_CONTAINERS = 1 << 4,
97 86
98 // Multiple system layers belong here like status, menu, tooltip 87 // Multiple system layers belong here like status, menu, tooltip
99 // and overlay layers. 88 // and overlay layers.
100 LOCK_SCREEN_RELATED_CONTAINERS = 1 << 5, 89 LOCK_SCREEN_RELATED_CONTAINERS = 1 << 5,
101 };
102 90
103 // Helper class used by tests to access internal state. 91 ROOT_CONTAINER = 1 << 6,
Daniel Erat 2014/09/08 16:16:02 nit: add a comment describing this mask
bruthig 2014/09/09 17:32:34 Added, if you can think of a better description le
104 class ASH_EXPORT TestApi {
105 public:
106 explicit TestApi(SessionStateAnimator* animator)
107 : animator_(animator) {}
108
109 // Returns true if containers of a given |container_mask|
110 // were last animated with |type| (probably; the analysis is fairly ad-hoc).
111 // |container_mask| is a bitfield of a Container.
112 bool ContainersAreAnimated(int container_mask, AnimationType type) const;
113
114 // Returns true if root window was last animated with |type| (probably;
115 // the analysis is fairly ad-hoc).
116 bool RootWindowIsAnimated(AnimationType type) const;
117
118 private:
119 SessionStateAnimator* animator_; // not owned
120
121 DISALLOW_COPY_AND_ASSIGN(TestApi);
122 }; 92 };
123 93
124 // A bitfield mask including LOCK_SCREEN_WALLPAPER, 94 // A bitfield mask including LOCK_SCREEN_WALLPAPER,
125 // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS. 95 // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS.
126 const static int kAllLockScreenContainersMask; 96 static const int kAllLockScreenContainersMask;
127 97
128 // A bitfield mask of all containers. 98 // A bitfield mask of all containers except the ROOT_CONTAINER.
129 const static int kAllContainersMask; 99 static const int kAllNonRootContainersMask;
100
101 // The AnimationSequence groups together multiple animations and invokes a
102 // callback once all contained animations are completed successfully.
103 // Subclasses of AnimationSequence should call one of OnAnimationCompleted or
104 // OnAnimationAborted once and behaviour is undefined if called multiple
105 // times.
106 // AnimationSequences will destroy themselves once EndSquence and one of
107 // OnAnimationCompleted or OnAnimationAborted has been called.
108 //
109 // Typical usage:
110 // AnimationSequence* animation_sequence =
111 // session_state_animator->BegineAnimationSequence(some_callback);
Daniel Erat 2014/09/08 16:16:02 nit: s/Begine/Begin/
bruthig 2014/09/09 17:32:34 Done.
112 // animation_sequence->StartAnimation(
113 // SessionStateAnimator::LAUNCHER,
114 // SessionStateAnimator::ANIMATION_FADE_IN,
115 // SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
116 // animation_sequence->StartAnimation(
117 // SessionStateAnimator::LAUNCHER,
118 // SessionStateAnimator::ANIMATION_FADE_IN,
119 // SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
120 // animation_sequence->EndSequence();
121 // // some_callback won't be called until here even if the animations
122 // // were completed before the EndSequence call.
123 //
124 class AnimationSequence {
125 public:
126 virtual ~AnimationSequence();
127
128 // Apply animation |type| to all containers included in |container_mask|
129 // with specified |speed|.
130 virtual void StartAnimation(int container_mask,
131 AnimationType type,
132 AnimationSpeed speed) = 0;
133
134 // Ends the animation sequence and enables the callback to be invoked
135 // when the animation sequence has completed. No more animations should be
136 // started after EndSequence is called because the AnimationSequenceObserver
137 // may have destroyed itself.
138 // NOTE: Clients of AnimationSequence should not access it after EndSequence
139 // has been called.
140 virtual void EndSequence();
141
142 protected:
143 // AnimationSequence should not be instantiated directly, only through
144 // subclasses.
145 explicit AnimationSequence(base::Closure callback);
146
147 // Subclasses should call this when the contained animations completed
148 // successfully.
149 // NOTE: This should NOT be accessed after OnAnimationCompleted has been
150 // called.
151 virtual void OnAnimationCompleted();
152
153 // Subclasses should call this when the contained animations did NOT
154 // complete successfully.
155 // NOTE: This should NOT be accessed after OnAnimationAborted has been
156 // called.
157 virtual void OnAnimationAborted();
158
159 private:
160 // Destroys this and calls the callback if the contained animations
161 // completed successfully.
162 void CleanupIfSequenceCompleted();
163
164 // Tracks whether the sequence has ended.
165 bool sequence_ended_;
166
167 // Track whether the contained animations have completed or not, both
168 // successfully and unsuccessfully.
169 bool animation_completed_;
170
171 // Flag to specify whether the callback should be invoked once the sequence
172 // has completed.
173 bool invoke_callback_;
174
175 // Callback to be called.
176 base::Closure callback_;
177
178 DISALLOW_COPY_AND_ASSIGN(AnimationSequence);
179 };
130 180
131 SessionStateAnimator(); 181 SessionStateAnimator();
132 virtual ~SessionStateAnimator(); 182 virtual ~SessionStateAnimator();
133 183
134 // Reports animation duration for |speed|. 184 // Reports animation duration for |speed|.
135 static base::TimeDelta GetDuration(AnimationSpeed speed); 185 virtual base::TimeDelta GetDuration(AnimationSpeed speed);
136
137 // Fills |containers| with the containers included in |container_mask|.
138 static void GetContainers(int container_mask,
139 aura::Window::Windows* containers);
140 186
141 // Apply animation |type| to all containers included in |container_mask| with 187 // Apply animation |type| to all containers included in |container_mask| with
142 // specified |speed|. 188 // specified |speed|.
143 void StartAnimation(int container_mask, 189 virtual void StartAnimation(int container_mask,
144 AnimationType type, 190 AnimationType type,
145 AnimationSpeed speed); 191 AnimationSpeed speed) = 0;
146 192
147 // Apply animation |type| to all containers included in |container_mask| with 193 // Apply animation |type| to all containers included in |container_mask| with
148 // specified |speed| and call a |callback| at the end of the animation, if it 194 // specified |speed| and call a |callback| at the end of the animation, if it
149 // is not null. 195 // is not null.
150 void StartAnimationWithCallback(int container_mask, 196 virtual void StartAnimationWithCallback(
151 AnimationType type, 197 int container_mask,
152 AnimationSpeed speed, 198 AnimationType type,
153 base::Callback<void(void)>& callback); 199 AnimationSpeed speed,
200 base::Closure callback) = 0;
154 201
155 // Apply animation |type| to all containers included in |container_mask| with 202 // Begins an animation sequence. Use this when you need to be notified when
156 // specified |speed| and add |observer| to all animations. 203 // a group of animations are completed. See AnimationSequence documentation
157 void StartAnimationWithObserver(int container_mask, 204 // for more details.
158 AnimationType type, 205 virtual AnimationSequence* BeginAnimationSequence(
159 AnimationSpeed speed, 206 base::Closure callback) = 0;
160 ui::LayerAnimationObserver* observer);
161 207
162 // Applies animation |type| whith specified |speed| to the root container. 208 private:
163 void StartGlobalAnimation(AnimationType type,
164 AnimationSpeed speed);
165
166 // Apply animation |type| to window |window| with |speed| and add |observer|
167 // if it is not NULL to the last animation sequence.
168 void RunAnimationForWindow(aura::Window* window,
169 AnimationType type,
170 AnimationSpeed speed,
171 ui::LayerAnimationObserver* observer);
172
173 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator); 209 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator);
174 }; 210 };
175 211
176 } // namespace ash 212 } // namespace ash
177 213
178 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_ 214 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698