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_WORKSPACE_WINDOW_RESIZER_H_ | 5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_WINDOW_RESIZER_H_ |
6 #define ASH_WM_WORKSPACE_WORKSPACE_WINDOW_RESIZER_H_ | 6 #define ASH_WM_WORKSPACE_WORKSPACE_WINDOW_RESIZER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 static const int kScreenEdgeInset; | 47 static const int kScreenEdgeInset; |
48 | 48 |
49 // Distance in pixels that the cursor must move past an edge for a window | 49 // Distance in pixels that the cursor must move past an edge for a window |
50 // to move or resize beyond that edge. | 50 // to move or resize beyond that edge. |
51 static const int kStickyDistancePixels; | 51 static const int kStickyDistancePixels; |
52 | 52 |
53 ~WorkspaceWindowResizer() override; | 53 ~WorkspaceWindowResizer() override; |
54 | 54 |
55 static WorkspaceWindowResizer* Create( | 55 static WorkspaceWindowResizer* Create( |
56 wm::WindowState* window_state, | 56 wm::WindowState* window_state, |
57 const std::vector<WmWindow*>& attached_windows); | 57 const std::vector<aura::Window*>& attached_windows); |
58 | 58 |
59 // WindowResizer: | 59 // WindowResizer: |
60 void Drag(const gfx::Point& location_in_parent, int event_flags) override; | 60 void Drag(const gfx::Point& location_in_parent, int event_flags) override; |
61 void CompleteDrag() override; | 61 void CompleteDrag() override; |
62 void RevertDrag() override; | 62 void RevertDrag() override; |
63 | 63 |
64 private: | 64 private: |
65 friend class WorkspaceWindowResizerTest; | 65 friend class WorkspaceWindowResizerTest; |
66 | 66 |
67 // The edge to which the window should be snapped at the end of the drag. | 67 // The edge to which the window should be snapped at the end of the drag. |
68 enum SnapType { SNAP_LEFT, SNAP_RIGHT, SNAP_NONE }; | 68 enum SnapType { SNAP_LEFT, SNAP_RIGHT, SNAP_NONE }; |
69 | 69 |
70 WorkspaceWindowResizer(wm::WindowState* window_state, | 70 WorkspaceWindowResizer(wm::WindowState* window_state, |
71 const std::vector<WmWindow*>& attached_windows); | 71 const std::vector<aura::Window*>& attached_windows); |
72 | 72 |
73 // Lays out the attached windows. |bounds| is the bounds of the main window. | 73 // Lays out the attached windows. |bounds| is the bounds of the main window. |
74 void LayoutAttachedWindows(gfx::Rect* bounds); | 74 void LayoutAttachedWindows(gfx::Rect* bounds); |
75 | 75 |
76 // Calculates the new sizes of the attached windows, given that the main | 76 // Calculates the new sizes of the attached windows, given that the main |
77 // window has been resized (along the primary axis) by |delta|. | 77 // window has been resized (along the primary axis) by |delta|. |
78 // |available_size| is the maximum length of the space that the attached | 78 // |available_size| is the maximum length of the space that the attached |
79 // windows are allowed to occupy (ie: the distance between the right/bottom | 79 // windows are allowed to occupy (ie: the distance between the right/bottom |
80 // edge of the primary window and the right/bottom of the desktop area). | 80 // edge of the primary window and the right/bottom of the desktop area). |
81 // Populates |sizes| with the desired sizes of the attached windows, and | 81 // Populates |sizes| with the desired sizes of the attached windows, and |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // snapped. | 149 // snapped. |
150 SnapType GetSnapType(const gfx::Point& location) const; | 150 SnapType GetSnapType(const gfx::Point& location) const; |
151 | 151 |
152 // Returns true if |bounds_in_parent| are valid bounds for snapped state type | 152 // Returns true if |bounds_in_parent| are valid bounds for snapped state type |
153 // |snapped_type|. | 153 // |snapped_type|. |
154 bool AreBoundsValidSnappedBounds(wm::WindowStateType snapped_type, | 154 bool AreBoundsValidSnappedBounds(wm::WindowStateType snapped_type, |
155 const gfx::Rect& bounds_in_parent) const; | 155 const gfx::Rect& bounds_in_parent) const; |
156 | 156 |
157 wm::WindowState* window_state() { return window_state_; } | 157 wm::WindowState* window_state() { return window_state_; } |
158 | 158 |
159 const std::vector<WmWindow*> attached_windows_; | 159 const std::vector<aura::Window*> attached_windows_; |
160 | 160 |
161 // Returns the currently used instance for test. | 161 // Returns the currently used instance for test. |
162 static WorkspaceWindowResizer* GetInstanceForTest(); | 162 static WorkspaceWindowResizer* GetInstanceForTest(); |
163 | 163 |
164 bool did_lock_cursor_; | 164 bool did_lock_cursor_; |
165 | 165 |
166 // Set to true once Drag() is invoked and the bounds of the window change. | 166 // Set to true once Drag() is invoked and the bounds of the window change. |
167 bool did_move_or_resize_; | 167 bool did_move_or_resize_; |
168 | 168 |
169 // True if the window initially had |bounds_changed_by_user_| set in state. | 169 // True if the window initially had |bounds_changed_by_user_| set in state. |
(...skipping 22 matching lines...) Expand all Loading... |
192 | 192 |
193 // Number of mouse moves since the last bounds change. Only used for phantom | 193 // Number of mouse moves since the last bounds change. Only used for phantom |
194 // placement to track when the mouse is moved while pushed against the edge of | 194 // placement to track when the mouse is moved while pushed against the edge of |
195 // the screen. | 195 // the screen. |
196 int num_mouse_moves_since_bounds_change_; | 196 int num_mouse_moves_since_bounds_change_; |
197 | 197 |
198 // The mouse location passed to Drag(). | 198 // The mouse location passed to Drag(). |
199 gfx::Point last_mouse_location_; | 199 gfx::Point last_mouse_location_; |
200 | 200 |
201 // Window the drag has magnetically attached to. | 201 // Window the drag has magnetically attached to. |
202 WmWindow* magnetism_window_; | 202 aura::Window* magnetism_window_; |
203 | 203 |
204 // Used to verify |magnetism_window_| is still valid. | 204 // Used to verify |magnetism_window_| is still valid. |
205 aura::WindowTracker window_tracker_; | 205 aura::WindowTracker window_tracker_; |
206 | 206 |
207 // 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 |
208 // should attach. | 208 // should attach. |
209 MatchedEdge magnetism_edge_; | 209 MatchedEdge magnetism_edge_; |
210 | 210 |
211 // Used to determine if this has been deleted during a drag such as when a tab | 211 // Used to determine if this has been deleted during a drag such as when a tab |
212 // gets dragged into another browser window. | 212 // gets dragged into another browser window. |
213 base::WeakPtrFactory<WorkspaceWindowResizer> weak_ptr_factory_; | 213 base::WeakPtrFactory<WorkspaceWindowResizer> weak_ptr_factory_; |
214 | 214 |
215 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); | 215 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); |
216 }; | 216 }; |
217 | 217 |
218 } // namespace ash | 218 } // namespace ash |
219 | 219 |
220 #endif // ASH_WM_WORKSPACE_WORKSPACE_WINDOW_RESIZER_H_ | 220 #endif // ASH_WM_WORKSPACE_WORKSPACE_WINDOW_RESIZER_H_ |
OLD | NEW |