OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WORKSPACE_WINDOW_RESIZER_H_ | 5 #ifndef ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
6 #define ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ | 6 #define ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/wm/window_resizer.h" | 10 #include "ash/wm/window_resizer.h" |
11 #include "ash/wm/workspace/magnetism_matcher.h" | 11 #include "ash/wm/workspace/magnetism_matcher.h" |
| 12 #include "ash/wm/workspace/snap_types.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" |
15 #include "ui/aura/window_tracker.h" | 17 #include "ui/aura/window_tracker.h" |
16 | 18 |
17 namespace ash { | 19 namespace ash { |
18 namespace internal { | 20 namespace internal { |
19 | 21 |
| 22 class DockedWindowLayoutManager; |
20 class PhantomWindowController; | 23 class PhantomWindowController; |
21 class SnapSizer; | 24 class SnapSizer; |
22 class WindowSize; | 25 class WindowSize; |
23 | 26 |
24 // WindowResizer implementation for workspaces. This enforces that windows are | 27 // WindowResizer implementation for workspaces. This enforces that windows are |
25 // not allowed to vertically move or resize outside of the work area. As windows | 28 // not allowed to vertically move or resize outside of the work area. As windows |
26 // are moved outside the work area they are shrunk. We remember the height of | 29 // are moved outside the work area they are shrunk. We remember the height of |
27 // the window before it was moved so that if the window is again moved up we | 30 // the window before it was moved so that if the window is again moved up we |
28 // attempt to restore the old height. | 31 // attempt to restore the old height. |
29 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { | 32 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 67 |
65 private: | 68 private: |
66 WorkspaceWindowResizer(const Details& details, | 69 WorkspaceWindowResizer(const Details& details, |
67 const std::vector<aura::Window*>& attached_windows); | 70 const std::vector<aura::Window*>& attached_windows); |
68 | 71 |
69 private: | 72 private: |
70 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom); | 73 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom); |
71 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize); | 74 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize); |
72 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow); | 75 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow); |
73 | 76 |
74 // Type of snapping. | |
75 enum SnapType { | |
76 // Snap to the left/right edge of the screen. | |
77 SNAP_LEFT_EDGE, | |
78 SNAP_RIGHT_EDGE, | |
79 | |
80 // No snap position. | |
81 SNAP_NONE | |
82 }; | |
83 | |
84 // Returns the final bounds to place the window at. This differs from | 77 // Returns the final bounds to place the window at. This differs from |
85 // the current when snapping. | 78 // the current when snapping. |
86 gfx::Rect GetFinalBounds(const gfx::Rect& bounds) const; | 79 gfx::Rect GetFinalBounds(const gfx::Rect& bounds) const; |
87 | 80 |
88 // Lays out the attached windows. |bounds| is the bounds of the main window. | 81 // Lays out the attached windows. |bounds| is the bounds of the main window. |
89 void LayoutAttachedWindows(gfx::Rect* bounds); | 82 void LayoutAttachedWindows(gfx::Rect* bounds); |
90 | 83 |
91 // Calculates the new sizes of the attached windows, given that the main | 84 // Calculates the new sizes of the attached windows, given that the main |
92 // window has been resized (along the primary axis) by |delta|. | 85 // window has been resized (along the primary axis) by |delta|. |
93 // |available_size| is the maximum length of the space that the attached | 86 // |available_size| is the maximum length of the space that the attached |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 const gfx::Rect& bounds); | 150 const gfx::Rect& bounds); |
158 | 151 |
159 // Restacks the windows z-order position so that one of the windows is at the | 152 // Restacks the windows z-order position so that one of the windows is at the |
160 // top of the z-order, and the rest directly underneath it. | 153 // top of the z-order, and the rest directly underneath it. |
161 void RestackWindows(); | 154 void RestackWindows(); |
162 | 155 |
163 // Returns the SnapType for the specified point. SNAP_NONE is used if no | 156 // Returns the SnapType for the specified point. SNAP_NONE is used if no |
164 // snapping should be used. | 157 // snapping should be used. |
165 SnapType GetSnapType(const gfx::Point& location) const; | 158 SnapType GetSnapType(const gfx::Point& location) const; |
166 | 159 |
| 160 // Dock when a window is at its last step in snapping sequence, undock |
| 161 // otherwise. |
| 162 void UpdateDockedState(bool is_docked); |
| 163 |
167 aura::Window* window() const { return details_.window; } | 164 aura::Window* window() const { return details_.window; } |
168 | 165 |
169 const Details details_; | 166 const Details details_; |
170 | 167 |
171 const std::vector<aura::Window*> attached_windows_; | 168 const std::vector<aura::Window*> attached_windows_; |
172 | 169 |
173 // Set to true once Drag() is invoked and the bounds of the window change. | 170 // Set to true once Drag() is invoked and the bounds of the window change. |
174 bool did_move_or_resize_; | 171 bool did_move_or_resize_; |
175 | 172 |
176 // The initial size of each of the windows in |attached_windows_| along the | 173 // The initial size of each of the windows in |attached_windows_| along the |
(...skipping 27 matching lines...) Expand all Loading... |
204 // Window the drag has magnetically attached to. | 201 // Window the drag has magnetically attached to. |
205 aura::Window* magnetism_window_; | 202 aura::Window* magnetism_window_; |
206 | 203 |
207 // Used to verify |magnetism_window_| is still valid. | 204 // Used to verify |magnetism_window_| is still valid. |
208 aura::WindowTracker window_tracker_; | 205 aura::WindowTracker window_tracker_; |
209 | 206 |
210 // If |magnetism_window_| is non-NULL this indicates how the two windows | 207 // If |magnetism_window_| is non-NULL this indicates how the two windows |
211 // should attach. | 208 // should attach. |
212 MatchedEdge magnetism_edge_; | 209 MatchedEdge magnetism_edge_; |
213 | 210 |
| 211 // Dock container window layout manager. |
| 212 DockedWindowLayoutManager* dock_layout_; |
| 213 |
| 214 // Used to determine if this has been deleted during a drag such as when a tab |
| 215 // gets dragged into another browser window. |
| 216 base::WeakPtrFactory<WorkspaceWindowResizer> weak_ptr_factory_; |
| 217 |
214 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); | 218 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); |
215 }; | 219 }; |
216 | 220 |
217 } // namespace internal | 221 } // namespace internal |
218 } // namespace ash | 222 } // namespace ash |
219 | 223 |
220 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ | 224 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
OLD | NEW |