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 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/common/wm/overview/overview_animation_type.h" | 12 #include "ash/common/wm/overview/overview_animation_type.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "third_party/skia/include/core/SkColor.h" | |
16 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
17 #include "ui/gfx/transform.h" | 16 #include "ui/gfx/transform.h" |
18 | 17 |
19 class SkRegion; | 18 class SkRegion; |
20 | 19 |
21 namespace gfx { | 20 namespace gfx { |
22 class Rect; | 21 class Rect; |
23 } | 22 } |
24 | 23 |
25 namespace ash { | 24 namespace ash { |
26 | 25 |
27 class ScopedOverviewAnimationSettings; | 26 class ScopedOverviewAnimationSettings; |
28 class WmWindow; | 27 class WmWindow; |
29 | 28 |
30 // 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 |
31 // 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 |
32 // 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 |
33 // object. | 32 // object. |
34 class ASH_EXPORT ScopedTransformOverviewWindow { | 33 class ASH_EXPORT ScopedTransformOverviewWindow { |
35 public: | 34 public: |
36 class OverviewContentMask; | |
37 using ScopedAnimationSettings = | 35 using ScopedAnimationSettings = |
38 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; | 36 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; |
39 | 37 |
40 // Calculates and returns an optimal scale ratio. With MD this is only | 38 // Calculates and returns an optimal scale ratio. With MD this is only |
41 // taking into account |size.height()| as the width can vary. Without MD this | 39 // taking into account |size.height()| as the width can vary. Without MD this |
42 // returns the scale that allows the item to fully fit within |size|. | 40 // returns the scale that allows the item to fully fit within |size|. |
43 static float GetItemScale(const gfx::Size& source, | 41 static float GetItemScale(const gfx::Size& source, |
44 const gfx::Size& target, | 42 const gfx::Size& target, |
45 int top_view_inset, | 43 int top_view_inset, |
46 int title_height); | 44 int title_height); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 gfx::Rect GetTargetBoundsInScreen() const; | 90 gfx::Rect GetTargetBoundsInScreen() const; |
93 | 91 |
94 // Calculates the bounds of a |window_| after being transformed to the | 92 // Calculates the bounds of a |window_| after being transformed to the |
95 // selector's space. With Material Design those bounds are a union of all | 93 // selector's space. With Material Design those bounds are a union of all |
96 // regular (normal and panel) windows in the |window_|'s transient hierarchy. | 94 // regular (normal and panel) windows in the |window_|'s transient hierarchy. |
97 // The returned Rect is in virtual screen coordinates. When |hide_header| is | 95 // The returned Rect is in virtual screen coordinates. When |hide_header| is |
98 // true the returned bounds are adjusted to allow the original |window_|'s | 96 // true the returned bounds are adjusted to allow the original |window_|'s |
99 // header to be hidden. | 97 // header to be hidden. |
100 gfx::Rect GetTransformedBounds(bool hide_header) const; | 98 gfx::Rect GetTransformedBounds(bool hide_header) const; |
101 | 99 |
102 // Returns TOP_VIEW_COLOR property of |window_| unless there are transient | |
103 // ancestors in which case returns SK_ColorTRANSPARENT. | |
104 SkColor GetTopColor() const; | |
105 | |
106 // Returns TOP_VIEW_INSET property of |window_| unless there are transient | 100 // Returns TOP_VIEW_INSET property of |window_| unless there are transient |
107 // ancestors in which case returns 0. | 101 // ancestors in which case returns 0. |
108 int GetTopInset() const; | 102 int GetTopInset() const; |
109 | 103 |
110 // Restores and animates the managed window to it's non overview mode state. | 104 // Restores and animates the managed window to it's non overview mode state. |
111 void RestoreWindow(); | 105 void RestoreWindow(); |
112 | 106 |
113 // Forces the managed window to be shown (ie not hidden or minimized) when | 107 // Forces the managed window to be shown (ie not hidden or minimized) when |
114 // calling RestoreWindow(). | 108 // calling RestoreWindow(). |
115 void ShowWindowOnExit(); | 109 void ShowWindowOnExit(); |
116 | 110 |
117 // Informs the ScopedTransformOverviewWindow that the window being watched was | 111 // Informs the ScopedTransformOverviewWindow that the window being watched was |
118 // destroyed. This resets the internal window pointer. | 112 // destroyed. This resets the internal window pointer. |
119 void OnWindowDestroyed(); | 113 void OnWindowDestroyed(); |
120 | 114 |
121 // Prepares for overview mode by doing any necessary actions before entering. | 115 // Prepares for overview mode by doing any necessary actions before entering. |
122 void PrepareForOverview(); | 116 void PrepareForOverview(); |
123 | 117 |
124 // Applies the |transform| to the overview window and all of its transient | 118 // Applies the |transform| to the overview window and all of its transient |
125 // children. | 119 // 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 // 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 // SetAlphaShape to mask the header. |
126 void SetTransform(WmWindow* root_window, | 124 void SetTransform(WmWindow* root_window, |
127 const gfx::Transform& transform, | 125 const gfx::Transform& transform, |
128 bool use_mask); | 126 bool use_mask, |
| 127 bool use_shape, |
| 128 float radius); |
129 | 129 |
130 // Set's the opacity of the managed windows. | 130 // Set's the opacity of the managed windows. |
131 void SetOpacity(float opacity); | 131 void SetOpacity(float opacity); |
132 | 132 |
133 // Creates a mask layer with the bottom edge using rounded corners of | |
134 // |radius|. When |use_mask| is set, hides the original window header and uses | |
135 // rounded rectangle mask which may be resource-intensive. When |use_shape| is | |
136 // set and |use_mask| is not, uses SetAlphaShape to mask the header. | |
137 void HideHeaderAndSetShape(bool use_mask, bool use_shape, int radius); | |
138 | |
139 // Restores original window shape and removes the mask if installed. Safe to | |
140 // call even if HideHeaderAndSetShape() has not been called. | |
141 void ShowHeaderAndResetShape(); | |
142 | |
143 WmWindow* window() const { return window_; } | 133 WmWindow* window() const { return window_; } |
144 | 134 |
145 // Closes the transient root of the window managed by |this|. | 135 // Closes the transient root of the window managed by |this|. |
146 void Close(); | 136 void Close(); |
147 | 137 |
148 private: | 138 private: |
149 friend class WindowSelectorTest; | 139 friend class WindowSelectorTest; |
| 140 class OverviewContentMask; |
150 | 141 |
151 enum OriginalVisibility { | 142 enum OriginalVisibility { |
152 ORIGINALLY_VISIBLE, | 143 ORIGINALLY_VISIBLE, |
153 ORIGINALLY_MINIMIZED, | 144 ORIGINALLY_MINIMIZED, |
154 ORIGINALLY_DOCKED_MINIMIZED, | 145 ORIGINALLY_DOCKED_MINIMIZED, |
155 }; | 146 }; |
156 | 147 |
157 // Shows the window if it was minimized. | 148 // Shows the window if it was minimized. |
158 void ShowWindowIfMinimized(); | 149 void ShowWindowIfMinimized(); |
159 | 150 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 float original_opacity_; | 188 float original_opacity_; |
198 | 189 |
199 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_; | 190 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_; |
200 | 191 |
201 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); | 192 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); |
202 }; | 193 }; |
203 | 194 |
204 } // namespace ash | 195 } // namespace ash |
205 | 196 |
206 #endif // ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 197 #endif // ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
OLD | NEW |