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_COMMON_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ | 5 #ifndef ASH_COMMON_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ |
6 #define ASH_COMMON_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ | 6 #define ASH_COMMON_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
11 #include "ash/common/shelf/wm_shelf_observer.h" | 12 #include "ash/common/shelf/wm_shelf_observer.h" |
12 #include "ash/common/wm/background_animator.h" | 13 #include "ash/common/wm/background_animator.h" |
13 #include "ash/public/cpp/shelf_types.h" | 14 #include "ash/public/cpp/shelf_types.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
16 | 17 |
17 namespace ash { | 18 namespace ash { |
18 | 19 |
19 class ShelfBackgroundAnimatorObserver; | 20 class ShelfBackgroundAnimatorObserver; |
20 class ShelfBackgroundAnimatorTestApi; | 21 class ShelfBackgroundAnimatorTestApi; |
21 class WmShelf; | 22 class WmShelf; |
22 | 23 |
23 // Central controller for the Shelf and Dock opacity animations. | 24 // Central controller for the Shelf and Dock opacity animations. |
24 // | 25 // |
25 // The ShelfBackgroundAnimator is capable of observing a WmShelf instance for | 26 // The ShelfBackgroundAnimator is capable of observing a WmShelf instance for |
26 // background type changes or clients can call PaintBackground() directly. | 27 // background type changes or clients can call PaintBackground() directly. |
27 // | 28 // |
28 // The Shelf uses 3 surfaces for the animations: | 29 // The Shelf uses 2 surfaces for the animations: |
29 // | 30 // |
30 // Non-Material Design: | |
31 // 1. Shelf button backgrounds | |
32 // 2. Opaque overlay for the SHELF_BACKGROUND_MAXIMIZED state. | |
33 // 3. Shelf and Dock assets for the SHELF_BACKGROUND_OVERLAP state. | |
34 // Material Design: | 31 // Material Design: |
35 // 1. Shelf button backgrounds | 32 // 1. Shelf button backgrounds |
36 // 2. Opaque overlay for the SHELF_BACKGROUND_OVERLAP and | 33 // 2. Opaque overlay for the SHELF_BACKGROUND_OVERLAP and |
37 // SHELF_BACKGROUND_MAXIMIZED states. | 34 // SHELF_BACKGROUND_MAXIMIZED states. |
38 class ASH_EXPORT ShelfBackgroundAnimator : public WmShelfObserver, | 35 class ASH_EXPORT ShelfBackgroundAnimator : public WmShelfObserver, |
39 public BackgroundAnimatorDelegate { | 36 public BackgroundAnimatorDelegate { |
40 public: | 37 public: |
41 // Initializes this with the given |background_type|. This will observe the | 38 // Initializes this with the given |background_type|. This will observe the |
42 // |wm_shelf| for background type changes if |wm_shelf| is not null. | 39 // |wm_shelf| for background type changes if |wm_shelf| is not null. |
43 ShelfBackgroundAnimator(ShelfBackgroundType background_type, | 40 ShelfBackgroundAnimator(ShelfBackgroundType background_type, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 ShelfBackgroundType target_background_type_ = SHELF_BACKGROUND_DEFAULT; | 98 ShelfBackgroundType target_background_type_ = SHELF_BACKGROUND_DEFAULT; |
102 | 99 |
103 // The last background type this is animating away from. | 100 // The last background type this is animating away from. |
104 ShelfBackgroundType previous_background_type_ = SHELF_BACKGROUND_MAXIMIZED; | 101 ShelfBackgroundType previous_background_type_ = SHELF_BACKGROUND_MAXIMIZED; |
105 | 102 |
106 // Animates the solid color background of the Shelf. | 103 // Animates the solid color background of the Shelf. |
107 // TODO(bruthig): Replace all BackgroundAnimators with a single | 104 // TODO(bruthig): Replace all BackgroundAnimators with a single |
108 // gfx::SlideAnimation. | 105 // gfx::SlideAnimation. |
109 std::unique_ptr<BackgroundAnimator> opaque_background_animator_; | 106 std::unique_ptr<BackgroundAnimator> opaque_background_animator_; |
110 | 107 |
111 // Animates the asset/image based background of the Shelf. | |
112 // TODO(bruthig): Remove when non-md is no longer needed (crbug.com/614453). | |
113 std::unique_ptr<BackgroundAnimator> asset_background_animator_; | |
114 | |
115 // Animates the backgrounds of Shelf child Views. | 108 // Animates the backgrounds of Shelf child Views. |
116 std::unique_ptr<BackgroundAnimator> item_background_animator_; | 109 std::unique_ptr<BackgroundAnimator> item_background_animator_; |
117 | 110 |
118 base::ObserverList<ShelfBackgroundAnimatorObserver> observers_; | 111 base::ObserverList<ShelfBackgroundAnimatorObserver> observers_; |
119 | 112 |
120 // True if the existing BackgroundAnimators can be re-used to animate to the | 113 // True if the existing BackgroundAnimators can be re-used to animate to the |
121 // |previous_background_type_|. This allows for pre-empted animations to take | 114 // |previous_background_type_|. This allows for pre-empted animations to take |
122 // the same amount of time to reverse to the |previous_background_type_|. | 115 // the same amount of time to reverse to the |previous_background_type_|. |
123 bool can_reuse_animators_ = false; | 116 bool can_reuse_animators_ = false; |
124 | 117 |
125 // Tracks how many animators completed successfully since the last | 118 // Tracks how many animators completed successfully since the last |
126 // CreateAnimators() call. Used to properly set |can_reuse_animators_|. | 119 // CreateAnimators() call. Used to properly set |can_reuse_animators_|. |
127 int successful_animator_count_ = 0; | 120 int successful_animator_count_ = 0; |
128 | 121 |
129 // The shelf to observe for changes to the shelf background type, can be null. | 122 // The shelf to observe for changes to the shelf background type, can be null. |
130 WmShelf* wm_shelf_; | 123 WmShelf* wm_shelf_; |
131 | 124 |
132 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimator); | 125 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimator); |
133 }; | 126 }; |
134 | 127 |
135 } // namespace ash | 128 } // namespace ash |
136 | 129 |
137 #endif // ASH_COMMON_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ | 130 #endif // ASH_COMMON_SHELF_SHELF_BACKGROUND_ANIMATOR_H_ |
OLD | NEW |