OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 5 #ifndef ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
6 #define ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 6 #define ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class ScopedOverviewAnimationSettings; | 26 class ScopedOverviewAnimationSettings; |
27 class WmWindow; | 27 class WmWindow; |
28 | 28 |
29 // Manages a window, and it's transient children, in the overview mode. This | 29 // Manages a window, and it's transient children, in the overview mode. This |
30 // class allows transforming the windows with a helper to determine the best | 30 // class allows transforming the windows with a helper to determine the best |
31 // fit in certain bounds. The window's state is restored on destruction of this | 31 // fit in certain bounds. The window's state is restored on destruction of this |
32 // object. | 32 // object. |
33 class ASH_EXPORT ScopedTransformOverviewWindow { | 33 class ASH_EXPORT ScopedTransformOverviewWindow { |
34 public: | 34 public: |
| 35 class OverviewContentMask; |
35 using ScopedAnimationSettings = | 36 using ScopedAnimationSettings = |
36 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; | 37 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; |
37 | 38 |
38 // Calculates and returns an optimal scale ratio. With MD this is only | 39 // Calculates and returns an optimal scale ratio. With MD this is only |
39 // taking into account |size.height()| as the width can vary. Without MD this | 40 // taking into account |size.height()| as the width can vary. Without MD this |
40 // returns the scale that allows the item to fully fit within |size|. | 41 // returns the scale that allows the item to fully fit within |size|. |
41 static float GetItemScale(const gfx::Size& source, | 42 static float GetItemScale(const gfx::Size& source, |
42 const gfx::Size& target, | 43 const gfx::Size& target, |
43 int top_view_inset, | 44 int top_view_inset, |
44 int title_height); | 45 int title_height); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void OnWindowDestroyed(); | 114 void OnWindowDestroyed(); |
114 | 115 |
115 // Prepares for overview mode by doing any necessary actions before entering. | 116 // Prepares for overview mode by doing any necessary actions before entering. |
116 void PrepareForOverview(); | 117 void PrepareForOverview(); |
117 | 118 |
118 // Applies the |transform| to the overview window and all of its transient | 119 // Applies the |transform| to the overview window and all of its transient |
119 // children. With Material Design creates a mask layer with the bottom edge | 120 // children. With Material Design creates a mask layer with the bottom edge |
120 // using rounded corners of |radius|. When |use_mask| is set, hides the | 121 // using rounded corners of |radius|. When |use_mask| is set, hides the |
121 // original window header and uses rounded rectangle mask which may be | 122 // original window header and uses rounded rectangle mask which may be |
122 // resource-intensive. When |use_shape| is set and |use_mask| is not, uses | 123 // resource-intensive. When |use_shape| is set and |use_mask| is not, uses |
123 // SetAlphaShape to mask the header. | 124 // SetAlphaShape to mask the header. If |animate| is set, the shape or mask |
| 125 // is set only upon the animation completion. |
124 void SetTransform(WmWindow* root_window, | 126 void SetTransform(WmWindow* root_window, |
125 const gfx::Transform& transform, | 127 const gfx::Transform& transform, |
126 bool use_mask, | 128 bool use_mask, |
127 bool use_shape, | 129 bool use_shape, |
128 float radius); | 130 float radius, |
| 131 bool animate); |
129 | 132 |
130 // Set's the opacity of the managed windows. | 133 // Set's the opacity of the managed windows. |
131 void SetOpacity(float opacity); | 134 void SetOpacity(float opacity); |
132 | 135 |
133 WmWindow* window() const { return window_; } | 136 WmWindow* window() const { return window_; } |
134 | 137 |
135 // Closes the transient root of the window managed by |this|. | 138 // Closes the transient root of the window managed by |this|. |
136 void Close(); | 139 void Close(); |
137 | 140 |
138 private: | 141 private: |
| 142 class OverviewWindowAnimationObserver; |
139 friend class WindowSelectorTest; | 143 friend class WindowSelectorTest; |
140 class OverviewContentMask; | |
141 | 144 |
142 enum OriginalVisibility { | 145 enum OriginalVisibility { |
143 ORIGINALLY_VISIBLE, | 146 ORIGINALLY_VISIBLE, |
144 ORIGINALLY_MINIMIZED, | 147 ORIGINALLY_MINIMIZED, |
145 ORIGINALLY_DOCKED_MINIMIZED, | 148 ORIGINALLY_DOCKED_MINIMIZED, |
146 }; | 149 }; |
147 | 150 |
148 // Shows the window if it was minimized. | 151 // Shows the window if it was minimized. |
149 void ShowWindowIfMinimized(); | 152 void ShowWindowIfMinimized(); |
150 | 153 |
151 // Closes the window managed by |this|. | 154 // Closes the window managed by |this|. |
152 void CloseWidget(); | 155 void CloseWidget(); |
153 | 156 |
154 // Makes Close() execute synchronously when used in tests. | 157 // Makes Close() execute synchronously when used in tests. |
155 static void SetImmediateCloseForTests(); | 158 static void SetImmediateCloseForTests(); |
156 | 159 |
157 // A weak pointer to the real window in the overview. | 160 // A weak pointer to the real window in the overview. |
158 WmWindow* window_; | 161 WmWindow* window_; |
159 | 162 |
160 // Mask layer that hides the original window header. | 163 // Mask layer that hides the original window header. |
161 std::unique_ptr<OverviewContentMask> mask_; | 164 std::unique_ptr<OverviewContentMask> mask_; |
162 | 165 |
163 // Original window shape, if it was set on a window. | 166 // Original window shape, if it was set on a window. |
164 std::unique_ptr<SkRegion> original_window_shape_; | 167 std::unique_ptr<SkRegion> original_window_shape_; |
165 | 168 |
| 169 // Observes transform animation and hides the window header when the animation |
| 170 // completes. |
| 171 std::unique_ptr<OverviewWindowAnimationObserver> animation_observer_; |
| 172 |
166 // True after the |original_window_shape_| has been set or after it has | 173 // True after the |original_window_shape_| has been set or after it has |
167 // been determined that window shape was not originally set on the |window_|. | 174 // been determined that window shape was not originally set on the |window_|. |
168 bool determined_original_window_shape_; | 175 bool determined_original_window_shape_; |
169 | 176 |
170 // Original visibility of |window_| upon entering overview mode that needs to | 177 // Original visibility of |window_| upon entering overview mode that needs to |
171 // be restored unless the window gets selected. | 178 // be restored unless the window gets selected. |
172 OriginalVisibility original_visibility_; | 179 OriginalVisibility original_visibility_; |
173 | 180 |
174 // Tracks if this window was ignored by the shelf. | 181 // Tracks if this window was ignored by the shelf. |
175 bool ignored_by_shelf_; | 182 bool ignored_by_shelf_; |
(...skipping 12 matching lines...) Expand all Loading... |
188 float original_opacity_; | 195 float original_opacity_; |
189 | 196 |
190 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_; | 197 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_; |
191 | 198 |
192 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); | 199 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); |
193 }; | 200 }; |
194 | 201 |
195 } // namespace ash | 202 } // namespace ash |
196 | 203 |
197 #endif // ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 204 #endif // ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
OLD | NEW |