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" | |
13 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
14 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
17 #include "ui/aura/window_tracker.h" | 16 #include "ui/aura/window_tracker.h" |
18 | 17 |
19 namespace ash { | 18 namespace ash { |
20 class DockedWindowLayoutManager; | 19 class DockedWindowLayoutManager; |
21 class PhantomWindowController; | 20 class PhantomWindowController; |
22 class TwoStepEdgeCycler; | 21 class TwoStepEdgeCycler; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 virtual void CompleteDrag() OVERRIDE; | 61 virtual void CompleteDrag() OVERRIDE; |
63 virtual void RevertDrag() OVERRIDE; | 62 virtual void RevertDrag() OVERRIDE; |
64 | 63 |
65 private: | 64 private: |
66 WorkspaceWindowResizer(wm::WindowState* window_state, | 65 WorkspaceWindowResizer(wm::WindowState* window_state, |
67 const std::vector<aura::Window*>& attached_windows); | 66 const std::vector<aura::Window*>& attached_windows); |
68 | 67 |
69 private: | 68 private: |
70 friend class WorkspaceWindowResizerTest; | 69 friend class WorkspaceWindowResizerTest; |
71 | 70 |
| 71 // The edge to which the window should be snapped at the end of the drag. |
| 72 enum SnapType { |
| 73 SNAP_LEFT, |
| 74 SNAP_RIGHT, |
| 75 SNAP_NONE |
| 76 }; |
| 77 |
72 // Lays out the attached windows. |bounds| is the bounds of the main window. | 78 // Lays out the attached windows. |bounds| is the bounds of the main window. |
73 void LayoutAttachedWindows(gfx::Rect* bounds); | 79 void LayoutAttachedWindows(gfx::Rect* bounds); |
74 | 80 |
75 // Calculates the new sizes of the attached windows, given that the main | 81 // Calculates the new sizes of the attached windows, given that the main |
76 // window has been resized (along the primary axis) by |delta|. | 82 // window has been resized (along the primary axis) by |delta|. |
77 // |available_size| is the maximum length of the space that the attached | 83 // |available_size| is the maximum length of the space that the attached |
78 // windows are allowed to occupy (ie: the distance between the right/bottom | 84 // windows are allowed to occupy (ie: the distance between the right/bottom |
79 // edge of the primary window and the right/bottom of the desktop area). | 85 // edge of the primary window and the right/bottom of the desktop area). |
80 // Populates |sizes| with the desired sizes of the attached windows, and | 86 // Populates |sizes| with the desired sizes of the attached windows, and |
81 // returns the number of pixels that couldn't be allocated to the attached | 87 // returns the number of pixels that couldn't be allocated to the attached |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int PrimaryAxisCoordinate(int x, int y) const; | 143 int PrimaryAxisCoordinate(int x, int y) const; |
138 | 144 |
139 // Updates the bounds of the phantom window for window snapping. | 145 // Updates the bounds of the phantom window for window snapping. |
140 void UpdateSnapPhantomWindow(const gfx::Point& location, | 146 void UpdateSnapPhantomWindow(const gfx::Point& location, |
141 const gfx::Rect& bounds); | 147 const gfx::Rect& bounds); |
142 | 148 |
143 // Restacks the windows z-order position so that one of the windows is at the | 149 // Restacks the windows z-order position so that one of the windows is at the |
144 // top of the z-order, and the rest directly underneath it. | 150 // top of the z-order, and the rest directly underneath it. |
145 void RestackWindows(); | 151 void RestackWindows(); |
146 | 152 |
147 // Returns the SnapType for the specified point. SNAP_NONE is used if no | 153 // Returns the edge to which the window should be snapped to if the user does |
148 // snapping should be used. | 154 // no more dragging. SNAP_NONE is returned if the window should not be |
| 155 // snapped. |
149 SnapType GetSnapType(const gfx::Point& location) const; | 156 SnapType GetSnapType(const gfx::Point& location) const; |
150 | 157 |
151 // Returns true if |bounds_in_parent| are valid bounds for snapped state type | 158 // Returns true if |bounds_in_parent| are valid bounds for snapped state type |
152 // |snapped_type|. | 159 // |snapped_type|. |
153 bool AreBoundsValidSnappedBounds(wm::WindowStateType snapped_type, | 160 bool AreBoundsValidSnappedBounds(wm::WindowStateType snapped_type, |
154 const gfx::Rect& bounds_in_parent) const; | 161 const gfx::Rect& bounds_in_parent) const; |
155 | 162 |
156 // Docks or undocks the dragged window. | 163 // Docks or undocks the dragged window. |
157 void SetDraggedWindowDocked(bool should_dock); | 164 void SetDraggedWindowDocked(bool should_dock); |
158 | 165 |
(...skipping 20 matching lines...) Expand all Loading... |
179 int total_initial_size_; | 186 int total_initial_size_; |
180 | 187 |
181 // Gives a previews of where the the window will end up. Only used if there | 188 // Gives a previews of where the the window will end up. Only used if there |
182 // is a grid and the caption is being dragged. | 189 // is a grid and the caption is being dragged. |
183 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_; | 190 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_; |
184 | 191 |
185 // Used to determine whether the window should be snapped or docked when | 192 // Used to determine whether the window should be snapped or docked when |
186 // the user drags a window to the edge of the screen. | 193 // the user drags a window to the edge of the screen. |
187 scoped_ptr<TwoStepEdgeCycler> edge_cycler_; | 194 scoped_ptr<TwoStepEdgeCycler> edge_cycler_; |
188 | 195 |
189 // Last SnapType. | 196 // The edge to which the window should be snapped to at the end of the drag. |
190 SnapType snap_type_; | 197 SnapType snap_type_; |
191 | 198 |
192 // Number of mouse moves since the last bounds change. Only used for phantom | 199 // Number of mouse moves since the last bounds change. Only used for phantom |
193 // placement to track when the mouse is moved while pushed against the edge of | 200 // placement to track when the mouse is moved while pushed against the edge of |
194 // the screen. | 201 // the screen. |
195 int num_mouse_moves_since_bounds_change_; | 202 int num_mouse_moves_since_bounds_change_; |
196 | 203 |
197 // The mouse location passed to Drag(). | 204 // The mouse location passed to Drag(). |
198 gfx::Point last_mouse_location_; | 205 gfx::Point last_mouse_location_; |
199 | 206 |
(...skipping 16 matching lines...) Expand all Loading... |
216 | 223 |
217 // Current instance for use by the WorkspaceWindowResizerTest. | 224 // Current instance for use by the WorkspaceWindowResizerTest. |
218 static WorkspaceWindowResizer* instance_; | 225 static WorkspaceWindowResizer* instance_; |
219 | 226 |
220 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); | 227 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); |
221 }; | 228 }; |
222 | 229 |
223 } // namespace ash | 230 } // namespace ash |
224 | 231 |
225 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ | 232 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ |
OLD | NEW |