| OLD | NEW |
| 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 "ash/wm/workspace/colored_window_controller.h" | 9 #include "ash/wm/workspace/colored_window_controller.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/timer.h" | 12 #include "base/timer.h" |
| 13 #include "ui/aura/root_window_observer.h" | |
| 14 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 15 | 14 |
| 16 namespace gfx { | 15 namespace gfx { |
| 17 class Rect; | 16 class Rect; |
| 18 class Size; | 17 class Size; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace ui { | 20 namespace ui { |
| 22 class Layer; | 21 class Layer; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace ash { | 24 namespace ash { |
| 26 namespace internal { | 25 namespace internal { |
| 27 | 26 |
| 28 // Displays onscreen animations for session state changes (lock/unlock, sign | 27 // Displays onscreen animations for session state changes (lock/unlock, sign |
| 29 // out, shut down). | 28 // out, shut down). |
| 30 class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver { | 29 class ASH_EXPORT SessionStateAnimator { |
| 31 public: | 30 public: |
| 32 // Animations that can be applied to groups of containers. | 31 // Animations that can be applied to groups of containers. |
| 33 enum AnimationType { | 32 enum AnimationType { |
| 34 ANIMATION_PARTIAL_CLOSE = 0, | 33 ANIMATION_PARTIAL_CLOSE = 0, |
| 35 ANIMATION_UNDO_PARTIAL_CLOSE, | 34 ANIMATION_UNDO_PARTIAL_CLOSE, |
| 36 ANIMATION_FULL_CLOSE, | 35 ANIMATION_FULL_CLOSE, |
| 37 ANIMATION_FADE_IN, | 36 ANIMATION_FADE_IN, |
| 38 ANIMATION_HIDE, | 37 ANIMATION_HIDE, |
| 39 ANIMATION_RESTORE, | 38 ANIMATION_RESTORE, |
| 40 ANIMATION_RAISE, | 39 ANIMATION_RAISE, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 | 67 |
| 69 LOCK_SCREEN_SYSTEM_FOREGROUND = 1 << 6, | 68 LOCK_SCREEN_SYSTEM_FOREGROUND = 1 << 6, |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 // Helper class used by tests to access internal state. | 71 // Helper class used by tests to access internal state. |
| 73 class ASH_EXPORT TestApi { | 72 class ASH_EXPORT TestApi { |
| 74 public: | 73 public: |
| 75 explicit TestApi(SessionStateAnimator* animator) | 74 explicit TestApi(SessionStateAnimator* animator) |
| 76 : animator_(animator) {} | 75 : animator_(animator) {} |
| 77 | 76 |
| 78 bool hide_black_layer_timer_is_running() const { | |
| 79 return animator_->hide_black_layer_timer_.IsRunning(); | |
| 80 } | |
| 81 | |
| 82 void TriggerHideBlackLayerTimeout(); | |
| 83 | |
| 84 // Returns true if containers of a given |container_mask| | 77 // Returns true if containers of a given |container_mask| |
| 85 // were last animated with |type| (probably; the analysis is fairly ad-hoc). | 78 // were last animated with |type| (probably; the analysis is fairly ad-hoc). |
| 86 // |container_mask| is a bitfield of a Container. | 79 // |container_mask| is a bitfield of a Container. |
| 87 bool ContainersAreAnimated(int container_mask, AnimationType type) const; | 80 bool ContainersAreAnimated(int container_mask, AnimationType type) const; |
| 88 | 81 |
| 89 // Returns true if |black_layer_| is non-NULL and visible. | |
| 90 bool BlackLayerIsVisible() const; | |
| 91 | |
| 92 // Returns |black_layer_|'s bounds, or an empty rect if the layer is | |
| 93 // NULL. | |
| 94 gfx::Rect GetBlackLayerBounds() const; | |
| 95 | |
| 96 private: | 82 private: |
| 97 SessionStateAnimator* animator_; // not owned | 83 SessionStateAnimator* animator_; // not owned |
| 98 | 84 |
| 99 DISALLOW_COPY_AND_ASSIGN(TestApi); | 85 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 100 }; | 86 }; |
| 101 | 87 |
| 102 // A bitfield mask including LOCK_SCREEN_WALLPAPER, | 88 // A bitfield mask including LOCK_SCREEN_WALLPAPER, |
| 103 // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS. | 89 // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS. |
| 104 const static int kAllLockScreenContainersMask; | 90 const static int kAllLockScreenContainersMask; |
| 105 | 91 |
| 106 // A bitfield mask of all containers. | 92 // A bitfield mask of all containers. |
| 107 const static int kAllContainersMask; | 93 const static int kAllContainersMask; |
| 108 | 94 |
| 109 SessionStateAnimator(); | 95 SessionStateAnimator(); |
| 110 virtual ~SessionStateAnimator(); | 96 virtual ~SessionStateAnimator(); |
| 111 | 97 |
| 112 // Shows or hides |black_layer_|. The show method creates and | |
| 113 // initializes the layer if it doesn't already exist. | |
| 114 void ShowBlackLayer(); | |
| 115 void DropBlackLayer(); | |
| 116 | |
| 117 // Create |foreground_| layer if it doesn't already exist, but makes it | 98 // Create |foreground_| layer if it doesn't already exist, but makes it |
| 118 // completely transparent. | 99 // completely transparent. |
| 119 void CreateForeground(); | 100 void CreateForeground(); |
| 120 // Destroy |foreground_| when it is not needed anymore. | 101 // Destroy |foreground_| when it is not needed anymore. |
| 121 void DropForeground(); | 102 void DropForeground(); |
| 122 | 103 |
| 123 // Drops back layer after |UNDO_SLOW_CLOSE| animation delay. | |
| 124 void ScheduleDropBlackLayer(); | |
| 125 | |
| 126 // Apply animation |type| to all containers included in |container_mask|. | 104 // Apply animation |type| to all containers included in |container_mask|. |
| 127 void StartAnimation(int container_mask, | 105 void StartAnimation(int container_mask, |
| 128 AnimationType type); | 106 AnimationType type); |
| 129 | 107 |
| 130 // Fills |containers| with the containers included in |container_mask|. | 108 // Fills |containers| with the containers included in |container_mask|. |
| 131 void GetContainers(int container_mask, | 109 void GetContainers(int container_mask, |
| 132 aura::Window::Windows* containers); | 110 aura::Window::Windows* containers); |
| 133 | 111 |
| 134 // aura::RootWindowObserver overrides: | |
| 135 virtual void OnRootWindowResized(const aura::RootWindow* root, | |
| 136 const gfx::Size& old_size) OVERRIDE; | |
| 137 | |
| 138 private: | 112 private: |
| 139 // Layer that's stacked under all of the root window's children to provide a | |
| 140 // black background when we're scaling all of the other windows down. | |
| 141 // TODO(derat): Remove this in favor of having the compositor only clear the | |
| 142 // viewport when there are regions not covered by a layer: | |
| 143 // http://crbug.com/113445 | |
| 144 scoped_ptr<ui::Layer> black_layer_; | |
| 145 | |
| 146 // White foreground that is used during shutdown animation to "fade | 113 // White foreground that is used during shutdown animation to "fade |
| 147 // everything into white". | 114 // everything into white". |
| 148 scoped_ptr<ColoredWindowController> foreground_; | 115 scoped_ptr<ColoredWindowController> foreground_; |
| 149 | 116 |
| 150 // Started when we abort the pre-lock state. When it fires, we hide | |
| 151 // |black_layer_|, as the desktop background is now covering the whole | |
| 152 // screen. | |
| 153 base::OneShotTimer<SessionStateAnimator> hide_black_layer_timer_; | |
| 154 | |
| 155 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator); | 117 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator); |
| 156 }; | 118 }; |
| 157 | 119 |
| 158 } // namespace internal | 120 } // namespace internal |
| 159 } // namespace ash | 121 } // namespace ash |
| 160 | 122 |
| 161 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_ | 123 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_ |
| OLD | NEW |