OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ | 5 #ifndef ASH_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ |
6 #define ASH_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ | 6 #define ASH_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/public/cpp/shelf_types.h" | 12 #include "ash/public/cpp/shelf_types.h" |
13 #include "ash/shelf/wm_shelf_observer.h" | 13 #include "ash/shelf/shelf_observer.h" |
14 #include "ash/wallpaper/wallpaper_controller_observer.h" | 14 #include "ash/wallpaper/wallpaper_controller_observer.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
18 #include "ui/gfx/animation/animation_delegate.h" | 18 #include "ui/gfx/animation/animation_delegate.h" |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 class SlideAnimation; | 21 class SlideAnimation; |
22 } // namespace gfx | 22 } // namespace gfx |
23 | 23 |
24 namespace ash { | 24 namespace ash { |
25 | 25 |
26 enum class AnimationChangeType; | 26 enum class AnimationChangeType; |
| 27 class Shelf; |
27 class ShelfBackgroundAnimatorObserver; | 28 class ShelfBackgroundAnimatorObserver; |
28 class ShelfBackgroundAnimatorTestApi; | 29 class ShelfBackgroundAnimatorTestApi; |
29 class WallpaperController; | 30 class WallpaperController; |
30 class WmShelf; | |
31 | 31 |
32 // Central controller for the Shelf and Dock opacity animations. | 32 // Central controller for the Shelf and Dock opacity animations. |
33 // | 33 // |
34 // The ShelfBackgroundAnimator is capable of observing a WmShelf instance for | 34 // The ShelfBackgroundAnimator is capable of observing a Shelf instance for |
35 // background type changes or clients can call PaintBackground() directly. | 35 // background type changes or clients can call PaintBackground() directly. |
36 // | 36 // |
37 // The Shelf uses 2 surfaces for the animations: | 37 // The Shelf uses 2 surfaces for the animations: |
38 // | 38 // |
39 // Material Design: | 39 // Material Design: |
40 // 1. Shelf button backgrounds | 40 // 1. Shelf button backgrounds |
41 // 2. Overlay for the SHELF_BACKGROUND_OVERLAP and SHELF_BACKGROUND_MAXIMIZED | 41 // 2. Overlay for the SHELF_BACKGROUND_OVERLAP and SHELF_BACKGROUND_MAXIMIZED |
42 // states. | 42 // states. |
43 class ASH_EXPORT ShelfBackgroundAnimator : public WmShelfObserver, | 43 class ASH_EXPORT ShelfBackgroundAnimator : public ShelfObserver, |
44 public gfx::AnimationDelegate, | 44 public gfx::AnimationDelegate, |
45 public WallpaperControllerObserver { | 45 public WallpaperControllerObserver { |
46 public: | 46 public: |
47 // The maximum alpha value that can be used. | 47 // The maximum alpha value that can be used. |
48 static const int kMaxAlpha = SK_AlphaOPAQUE; | 48 static const int kMaxAlpha = SK_AlphaOPAQUE; |
49 | 49 |
50 // Initializes this with the given |background_type|. This will observe the | 50 // Initializes this with the given |background_type|. This will observe the |
51 // |wm_shelf| for background type changes and the |wallpaper_controller| for | 51 // |shelf| for background type changes and the |wallpaper_controller| for |
52 // wallpaper changes if not null. | 52 // wallpaper changes if not null. |
53 ShelfBackgroundAnimator(ShelfBackgroundType background_type, | 53 ShelfBackgroundAnimator(ShelfBackgroundType background_type, |
54 WmShelf* wm_shelf, | 54 Shelf* shelf, |
55 WallpaperController* wallpaper_controller); | 55 WallpaperController* wallpaper_controller); |
56 ~ShelfBackgroundAnimator() override; | 56 ~ShelfBackgroundAnimator() override; |
57 | 57 |
58 ShelfBackgroundType target_background_type() const { | 58 ShelfBackgroundType target_background_type() const { |
59 return target_background_type_; | 59 return target_background_type_; |
60 } | 60 } |
61 | 61 |
62 // Initializes |observer| with current values using the Initialize() function. | 62 // Initializes |observer| with current values using the Initialize() function. |
63 void AddObserver(ShelfBackgroundAnimatorObserver* observer); | 63 void AddObserver(ShelfBackgroundAnimatorObserver* observer); |
64 void RemoveObserver(ShelfBackgroundAnimatorObserver* observer); | 64 void RemoveObserver(ShelfBackgroundAnimatorObserver* observer); |
(...skipping 12 matching lines...) Expand all Loading... |
77 // BACKGROUND_CHANGE_ANIMATE change type is received it will be ignored and | 77 // BACKGROUND_CHANGE_ANIMATE change type is received it will be ignored and |
78 // observers will NOT be notified. | 78 // observers will NOT be notified. |
79 void PaintBackground(ShelfBackgroundType background_type, | 79 void PaintBackground(ShelfBackgroundType background_type, |
80 AnimationChangeType change_type); | 80 AnimationChangeType change_type); |
81 | 81 |
82 // gfx::AnimationDelegate: | 82 // gfx::AnimationDelegate: |
83 void AnimationProgressed(const gfx::Animation* animation) override; | 83 void AnimationProgressed(const gfx::Animation* animation) override; |
84 void AnimationEnded(const gfx::Animation* animation) override; | 84 void AnimationEnded(const gfx::Animation* animation) override; |
85 | 85 |
86 protected: | 86 protected: |
87 // WmShelfObserver: | 87 // ShelfObserver: |
88 void OnBackgroundTypeChanged(ShelfBackgroundType background_type, | 88 void OnBackgroundTypeChanged(ShelfBackgroundType background_type, |
89 AnimationChangeType change_type) override; | 89 AnimationChangeType change_type) override; |
90 | 90 |
91 // WallpaperControllerObserver: | 91 // WallpaperControllerObserver: |
92 void OnWallpaperDataChanged() override; | 92 void OnWallpaperDataChanged() override; |
93 void OnWallpaperColorsChanged() override; | 93 void OnWallpaperColorsChanged() override; |
94 | 94 |
95 private: | 95 private: |
96 friend class ShelfBackgroundAnimatorTestApi; | 96 friend class ShelfBackgroundAnimatorTestApi; |
97 | 97 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 AnimationValues* item_background_values) const; | 149 AnimationValues* item_background_values) const; |
150 | 150 |
151 // Updates the animation values corresponding to the |t| value between 0 and | 151 // Updates the animation values corresponding to the |t| value between 0 and |
152 // 1. | 152 // 1. |
153 void SetAnimationValues(double t); | 153 void SetAnimationValues(double t); |
154 | 154 |
155 // Called when observers need to be notified. | 155 // Called when observers need to be notified. |
156 void NotifyObservers(); | 156 void NotifyObservers(); |
157 | 157 |
158 // The shelf to observe for changes to the shelf background type, can be null. | 158 // The shelf to observe for changes to the shelf background type, can be null. |
159 WmShelf* wm_shelf_; | 159 Shelf* shelf_; |
160 | 160 |
161 // The wallpaper controller to observe for changes and to extract colors from. | 161 // The wallpaper controller to observe for changes and to extract colors from. |
162 WallpaperController* wallpaper_controller_; | 162 WallpaperController* wallpaper_controller_; |
163 | 163 |
164 // The background type that this is animating towards or has reached. | 164 // The background type that this is animating towards or has reached. |
165 ShelfBackgroundType target_background_type_ = SHELF_BACKGROUND_DEFAULT; | 165 ShelfBackgroundType target_background_type_ = SHELF_BACKGROUND_DEFAULT; |
166 | 166 |
167 // The last background type this is animating away from. | 167 // The last background type this is animating away from. |
168 ShelfBackgroundType previous_background_type_ = SHELF_BACKGROUND_MAXIMIZED; | 168 ShelfBackgroundType previous_background_type_ = SHELF_BACKGROUND_MAXIMIZED; |
169 | 169 |
170 // Drives the animtion. | 170 // Drives the animtion. |
171 std::unique_ptr<gfx::SlideAnimation> animator_; | 171 std::unique_ptr<gfx::SlideAnimation> animator_; |
172 | 172 |
173 // Tracks the shelf background animation values. | 173 // Tracks the shelf background animation values. |
174 AnimationValues shelf_background_values_; | 174 AnimationValues shelf_background_values_; |
175 | 175 |
176 // Tracks the item background animation values. | 176 // Tracks the item background animation values. |
177 AnimationValues item_background_values_; | 177 AnimationValues item_background_values_; |
178 | 178 |
179 base::ObserverList<ShelfBackgroundAnimatorObserver> observers_; | 179 base::ObserverList<ShelfBackgroundAnimatorObserver> observers_; |
180 | 180 |
181 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimator); | 181 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimator); |
182 }; | 182 }; |
183 | 183 |
184 } // namespace ash | 184 } // namespace ash |
185 | 185 |
186 #endif // ASH_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ | 186 #endif // ASH_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ |
OLD | NEW |