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_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 5 #ifndef ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
6 #define ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 6 #define ASH_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/wm/overview/overview_animation_type.h" | 12 #include "ash/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 "third_party/skia/include/core/SkColor.h" |
16 #include "ui/events/event_handler.h" | 16 #include "ui/events/event_handler.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
19 | 19 |
20 class SkRegion; | 20 class SkRegion; |
21 | 21 |
22 namespace aura { | |
23 class Window; | |
24 } | |
25 | |
22 namespace gfx { | 26 namespace gfx { |
23 class Rect; | 27 class Rect; |
24 } | 28 } |
25 | 29 |
26 namespace views { | 30 namespace views { |
27 class Widget; | 31 class Widget; |
28 } | 32 } |
29 | 33 |
30 namespace ash { | 34 namespace ash { |
31 | 35 |
32 class ScopedOverviewAnimationSettings; | 36 class ScopedOverviewAnimationSettings; |
33 class WmWindow; | |
34 | 37 |
35 // Manages a window, and it's transient children, in the overview mode. This | 38 // Manages a window, and it's transient children, in the overview mode. This |
36 // class allows transforming the windows with a helper to determine the best | 39 // class allows transforming the windows with a helper to determine the best |
37 // fit in certain bounds. The window's state is restored on destruction of this | 40 // fit in certain bounds. The window's state is restored on destruction of this |
38 // object. | 41 // object. |
39 class ASH_EXPORT ScopedTransformOverviewWindow : public ui::EventHandler { | 42 class ASH_EXPORT ScopedTransformOverviewWindow : public ui::EventHandler { |
40 public: | 43 public: |
41 class OverviewContentMask; | 44 class OverviewContentMask; |
42 using ScopedAnimationSettings = | 45 using ScopedAnimationSettings = |
43 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; | 46 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; |
(...skipping 12 matching lines...) Expand all Loading... | |
56 // |title_height| tall in transformed window. | 59 // |title_height| tall in transformed window. |
57 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect, | 60 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect, |
58 const gfx::Rect& bounds, | 61 const gfx::Rect& bounds, |
59 int top_view_inset, | 62 int top_view_inset, |
60 int title_height); | 63 int title_height); |
61 | 64 |
62 // Returns the transform turning |src_rect| into |dst_rect|. | 65 // Returns the transform turning |src_rect| into |dst_rect|. |
63 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect, | 66 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect, |
64 const gfx::Rect& dst_rect); | 67 const gfx::Rect& dst_rect); |
65 | 68 |
66 explicit ScopedTransformOverviewWindow(WmWindow* window); | 69 explicit ScopedTransformOverviewWindow(aura::Window* window); |
67 ~ScopedTransformOverviewWindow() override; | 70 ~ScopedTransformOverviewWindow() override; |
68 | 71 |
69 // Starts an animation sequence which will use animation settings specified by | 72 // Starts an animation sequence which will use animation settings specified by |
70 // |animation_type|. The |animation_settings| container is populated with | 73 // |animation_type|. The |animation_settings| container is populated with |
71 // scoped entities and the container should be destroyed at the end of the | 74 // scoped entities and the container should be destroyed at the end of the |
72 // animation sequence. | 75 // animation sequence. |
73 // | 76 // |
74 // Example: | 77 // Example: |
75 // ScopedTransformOverviewWindow overview_window(window); | 78 // ScopedTransformOverviewWindow overview_window(window); |
76 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings; | 79 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings; |
77 // overview_window.BeginScopedAnimation( | 80 // overview_window.BeginScopedAnimation( |
78 // OverviewAnimationType::OVERVIEW_ANIMATION_SELECTOR_ITEM_SCROLL_CANCEL, | 81 // OverviewAnimationType::OVERVIEW_ANIMATION_SELECTOR_ITEM_SCROLL_CANCEL, |
79 // &animation_settings); | 82 // &animation_settings); |
80 // // Calls to SetTransform & SetOpacity will use the same animation settings | 83 // // Calls to SetTransform & SetOpacity will use the same animation settings |
81 // // until scoped_settings is destroyed. | 84 // // until scoped_settings is destroyed. |
82 // overview_window.SetTransform(root_window, new_transform); | 85 // overview_window.SetTransform(root_window, new_transform); |
83 // overview_window.SetOpacity(1); | 86 // overview_window.SetOpacity(1); |
84 void BeginScopedAnimation(OverviewAnimationType animation_type, | 87 void BeginScopedAnimation(OverviewAnimationType animation_type, |
85 ScopedAnimationSettings* animation_settings); | 88 ScopedAnimationSettings* animation_settings); |
86 | 89 |
87 // Returns true if this window selector window contains the |target|. | 90 // Returns true if this window selector window contains the |target|. |
88 bool Contains(const WmWindow* target) const; | 91 bool Contains(const aura::Window* target) const; |
89 | 92 |
90 // Returns the original target bounds of all transformed windows. | 93 // Returns the original target bounds of all transformed windows. |
91 gfx::Rect GetTargetBoundsInScreen() const; | 94 gfx::Rect GetTargetBoundsInScreen() const; |
92 | 95 |
93 // Calculates the bounds of a |window_| after being transformed to the | 96 // Calculates the bounds of a |window_| after being transformed to the |
94 // selector's space. Those bounds are a union of all regular (normal and | 97 // selector's space. Those bounds are a union of all regular (normal and |
95 // panel) windows in the |window_|'s transient hierarchy. The returned Rect is | 98 // panel) windows in the |window_|'s transient hierarchy. The returned Rect is |
96 // in virtual screen coordinates. The returned bounds are adjusted to allow | 99 // in virtual screen coordinates. The returned bounds are adjusted to allow |
97 // the original |window_|'s header to be hidden. | 100 // the original |window_|'s header to be hidden. |
98 gfx::Rect GetTransformedBounds() const; | 101 gfx::Rect GetTransformedBounds() const; |
(...skipping 11 matching lines...) Expand all Loading... | |
110 | 113 |
111 // Informs the ScopedTransformOverviewWindow that the window being watched was | 114 // Informs the ScopedTransformOverviewWindow that the window being watched was |
112 // destroyed. This resets the internal window pointer. | 115 // destroyed. This resets the internal window pointer. |
113 void OnWindowDestroyed(); | 116 void OnWindowDestroyed(); |
114 | 117 |
115 // Prepares for overview mode by doing any necessary actions before entering. | 118 // Prepares for overview mode by doing any necessary actions before entering. |
116 void PrepareForOverview(); | 119 void PrepareForOverview(); |
117 | 120 |
118 // Applies the |transform| to the overview window and all of its transient | 121 // Applies the |transform| to the overview window and all of its transient |
119 // children. | 122 // children. |
120 void SetTransform(WmWindow* root_window, const gfx::Transform& transform); | 123 void SetTransform(aura::Window* root_window, const gfx::Transform& transform); |
121 | 124 |
122 // Set's the opacity of the managed windows. | 125 // Set's the opacity of the managed windows. |
123 void SetOpacity(float opacity); | 126 void SetOpacity(float opacity); |
124 | 127 |
125 // Hides the window header whose size is given in |TOP_VIEW_INSET| | 128 // Hides the window header whose size is given in |TOP_VIEW_INSET| |
126 // window property. | 129 // window property. |
127 void HideHeader(); | 130 void HideHeader(); |
128 | 131 |
129 // Shows the window header that is hidden by HideHeader(). | 132 // Shows the window header that is hidden by HideHeader(). |
130 void ShowHeader(); | 133 void ShowHeader(); |
131 | 134 |
132 // Creates/Deletes a mirror window for minimized windows. | 135 // Creates/Deletes a mirror window for minimized windows. |
133 void UpdateMirrorWindowForMinimizedState(); | 136 void UpdateMirrorWindowForMinimizedState(); |
134 | 137 |
135 WmWindow* window() const { return window_; } | 138 aura::Window* window() const { return window_; } |
136 | 139 |
137 // Closes the transient root of the window managed by |this|. | 140 // Closes the transient root of the window managed by |this|. |
138 void Close(); | 141 void Close(); |
139 | 142 |
140 // Returns the window used to show the content in overview mdoe. | 143 // Returns the window used to show the content in overview mode. |
141 // For minmiezd window, this will be a window that hosts mirrored layers. | 144 // For minimized window, this will be a window that hosts mirrored layers. |
142 WmWindow* GetOverviewWindow() const; | 145 aura::Window* GetOverviewWindow() const; |
143 | 146 |
144 // Ensures that a window is visible by setting its opacity to 1. | 147 // Ensures that a window is visible by setting its opacity to 1. |
145 void EnsureVisible(); | 148 void EnsureVisible(); |
146 | 149 |
147 // Returns the window created for minimized window, or nullptr | 150 // Returns the window created for minimized window, or nullptr |
148 // if it does not exit. | 151 // if it does not exit. |
msw
2017/05/23 22:50:24
nit: s/exit/exist/, poor comment spelling/grammar
varkha
2017/05/24 15:29:15
Done. Fixed a few places I could spot, see if you
| |
149 WmWindow* GetOverviewWindowForMinimizedState() const; | 152 aura::Window* GetOverviewWindowForMinimizedState() const; |
150 | 153 |
151 // ui::EventHandler: | 154 // ui::EventHandler: |
152 void OnGestureEvent(ui::GestureEvent* event) override; | 155 void OnGestureEvent(ui::GestureEvent* event) override; |
153 void OnMouseEvent(ui::MouseEvent* event) override; | 156 void OnMouseEvent(ui::MouseEvent* event) override; |
154 | 157 |
155 private: | 158 private: |
156 friend class WindowSelectorTest; | 159 friend class WindowSelectorTest; |
157 | 160 |
158 // Closes the window managed by |this|. | 161 // Closes the window managed by |this|. |
159 void CloseWidget(); | 162 void CloseWidget(); |
160 | 163 |
161 void CreateMirrorWindowForMinimizedState(); | 164 void CreateMirrorWindowForMinimizedState(); |
162 | 165 |
163 // Makes Close() execute synchronously when used in tests. | 166 // Makes Close() execute synchronously when used in tests. |
164 static void SetImmediateCloseForTests(); | 167 static void SetImmediateCloseForTests(); |
165 | 168 |
166 // A weak pointer to the real window in the overview. | 169 // A weak pointer to the real window in the overview. |
167 WmWindow* window_; | 170 aura::Window* window_; |
168 | 171 |
169 // Original window shape, if it was set on a window. | 172 // Original window shape, if it was set on a window. |
170 std::unique_ptr<SkRegion> original_window_shape_; | 173 std::unique_ptr<SkRegion> original_window_shape_; |
171 | 174 |
172 // True after the |original_window_shape_| has been set or after it has | 175 // True after the |original_window_shape_| has been set or after it has |
173 // been determined that window shape was not originally set on the |window_|. | 176 // been determined that window shape was not originally set on the |window_|. |
174 bool determined_original_window_shape_; | 177 bool determined_original_window_shape_; |
175 | 178 |
176 // Tracks if this window was ignored by the shelf. | 179 // Tracks if this window was ignored by the shelf. |
177 bool ignored_by_shelf_; | 180 bool ignored_by_shelf_; |
(...skipping 11 matching lines...) Expand all Loading... | |
189 std::unique_ptr<views::Widget> minimized_widget_; | 192 std::unique_ptr<views::Widget> minimized_widget_; |
190 | 193 |
191 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_; | 194 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_; |
192 | 195 |
193 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); | 196 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); |
194 }; | 197 }; |
195 | 198 |
196 } // namespace ash | 199 } // namespace ash |
197 | 200 |
198 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ | 201 #endif // ASH_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ |
OLD | NEW |