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