Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.h

Issue 11411344: Extract the code for supporing extended desktop from WorkspaceWindowResizer into DragWindowResizer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "ui/aura/window_tracker.h" 15 #include "ui/aura/window_tracker.h"
16 16
17 namespace aura {
18 class RootWindow;
19 } // namespace aura
20
21 namespace ui {
22 class Layer;
23 } // namespace ui
24
25 namespace ash { 17 namespace ash {
26 namespace internal { 18 namespace internal {
27 19
28 class DragWindowController;
29 class PhantomWindowController; 20 class PhantomWindowController;
30 class SnapSizer; 21 class SnapSizer;
31 class WindowSize; 22 class WindowSize;
32 23
33 // WindowResizer implementation for workspaces. This enforces that windows are 24 // WindowResizer implementation for workspaces. This enforces that windows are
34 // not allowed to vertically move or resize outside of the work area. As windows 25 // not allowed to vertically move or resize outside of the work area. As windows
35 // are moved outside the work area they are shrunk. We remember the height of 26 // are moved outside the work area they are shrunk. We remember the height of
36 // the window before it was moved so that if the window is again moved up we 27 // the window before it was moved so that if the window is again moved up we
37 // attempt to restore the old height. 28 // attempt to restore the old height.
38 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { 29 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
39 public: 30 public:
31 WorkspaceWindowResizer(const Details& details,
32 const std::vector<aura::Window*>& attached_windows);
33
40 // When dragging an attached window this is the min size we'll make sure is 34 // When dragging an attached window this is the min size we'll make sure is
41 // visible. In the vertical direction we take the max of this and that from 35 // visible. In the vertical direction we take the max of this and that from
42 // the delegate. 36 // the delegate.
43 static const int kMinOnscreenSize; 37 static const int kMinOnscreenSize;
44 38
45 // Min height we'll force on screen when dragging the caption. 39 // Min height we'll force on screen when dragging the caption.
46 // TODO: this should come from a property on the window. 40 // TODO: this should come from a property on the window.
47 static const int kMinOnscreenHeight; 41 static const int kMinOnscreenHeight;
48 42
49 // Snap region when dragging close to the edges. That is, as the window gets 43 // Snap region when dragging close to the edges. That is, as the window gets
50 // this close to an edge of the screen it snaps to the edge. 44 // this close to an edge of the screen it snaps to the edge.
51 static const int kScreenEdgeInset; 45 static const int kScreenEdgeInset;
52 46
53 virtual ~WorkspaceWindowResizer(); 47 virtual ~WorkspaceWindowResizer();
54 48
55 static WorkspaceWindowResizer* Create( 49 static WorkspaceWindowResizer* Create(
56 aura::Window* window, 50 aura::Window* window,
57 const gfx::Point& location_in_parent, 51 const gfx::Point& location_in_parent,
58 int window_component, 52 int window_component,
59 const std::vector<aura::Window*>& attached_windows); 53 const std::vector<aura::Window*>& attached_windows);
60 54
61 // Returns true if the drag will result in changing the window in anyway.
62 bool is_resizable() const { return details_.is_resizable; }
63
64 const gfx::Point& initial_location_in_parent() const {
65 return details_.initial_location_in_parent;
66 }
67
68 // Overridden from WindowResizer: 55 // Overridden from WindowResizer:
69 virtual void Drag(const gfx::Point& location_in_parent, 56 virtual void Drag(const gfx::Point& location_in_parent,
70 int event_flags) OVERRIDE; 57 int event_flags) OVERRIDE;
71 virtual void CompleteDrag(int event_flags) OVERRIDE; 58 virtual void CompleteDrag(int event_flags) OVERRIDE;
72 virtual void RevertDrag() OVERRIDE; 59 virtual void RevertDrag() OVERRIDE;
73 virtual aura::Window* GetTarget() OVERRIDE; 60 virtual aura::Window* GetTarget() OVERRIDE;
74 61
75 private: 62 const gfx::Point& GetInitialLocationInParentForTest() const {
76 WorkspaceWindowResizer(const Details& details, 63 return details_.initial_location_in_parent;
77 const std::vector<aura::Window*>& attached_windows); 64 }
78 65
79 private: 66 private:
80 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, DragWindowController);
81 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom); 67 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom);
82 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize); 68 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize);
83 69
84 // Type of snapping. 70 // Type of snapping.
85 enum SnapType { 71 enum SnapType {
86 // Snap to the left/right edge of the screen. 72 // Snap to the left/right edge of the screen.
87 SNAP_LEFT_EDGE, 73 SNAP_LEFT_EDGE,
88 SNAP_RIGHT_EDGE, 74 SNAP_RIGHT_EDGE,
89 75
90 // No snap position. 76 // No snap position.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 146
161 // Returns a coordinate along the primary axis. Used to share code for 147 // Returns a coordinate along the primary axis. Used to share code for
162 // left/right multi window resize and top/bottom resize. 148 // left/right multi window resize and top/bottom resize.
163 int PrimaryAxisSize(const gfx::Size& size) const; 149 int PrimaryAxisSize(const gfx::Size& size) const;
164 int PrimaryAxisCoordinate(int x, int y) const; 150 int PrimaryAxisCoordinate(int x, int y) const;
165 151
166 // Updates the bounds of the phantom window for window snapping. 152 // Updates the bounds of the phantom window for window snapping.
167 void UpdateSnapPhantomWindow(const gfx::Point& location, 153 void UpdateSnapPhantomWindow(const gfx::Point& location,
168 const gfx::Rect& bounds); 154 const gfx::Rect& bounds);
169 155
170 // Updates the bounds of the phantom window for window dragging. Set true on
171 // |in_original_root| if the pointer is still in |window()->GetRootWindow()|.
172 void UpdateDragWindow(const gfx::Rect& bounds, bool in_original_root);
173
174 // Restacks the windows z-order position so that one of the windows is at the 156 // Restacks the windows z-order position so that one of the windows is at the
175 // top of the z-order, and the rest directly underneath it. 157 // top of the z-order, and the rest directly underneath it.
176 void RestackWindows(); 158 void RestackWindows();
177 159
178 // Returns the SnapType for the specified point. SNAP_NONE is used if no 160 // Returns the SnapType for the specified point. SNAP_NONE is used if no
179 // snapping should be used. 161 // snapping should be used.
180 SnapType GetSnapType(const gfx::Point& location) const; 162 SnapType GetSnapType(const gfx::Point& location) const;
181 163
182 // Returns true if we should allow the mouse pointer to warp.
183 bool ShouldAllowMouseWarp() const;
184
185 aura::Window* window() const { return details_.window; } 164 aura::Window* window() const { return details_.window; }
186 165
187 const Details details_; 166 const Details details_;
188 167
189 const std::vector<aura::Window*> attached_windows_; 168 const std::vector<aura::Window*> attached_windows_;
190 169
191 // 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.
192 bool did_move_or_resize_; 171 bool did_move_or_resize_;
193 172
194 // 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
195 // primary axis. 174 // primary axis.
196 std::vector<int> initial_size_; 175 std::vector<int> initial_size_;
197 176
198 // Sum of the minimum sizes of the attached windows. 177 // Sum of the minimum sizes of the attached windows.
199 int total_min_; 178 int total_min_;
200 179
201 // Sum of the sizes in |initial_size_|. 180 // Sum of the sizes in |initial_size_|.
202 int total_initial_size_; 181 int total_initial_size_;
203 182
204 // Gives a previews of where the the window will end up. Only used if there 183 // Gives a previews of where the the window will end up. Only used if there
205 // is a grid and the caption is being dragged. 184 // is a grid and the caption is being dragged.
206 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_; 185 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_;
207 186
208 // Shows a semi-transparent image of the window being dragged.
209 scoped_ptr<DragWindowController> drag_window_controller_;
210
211 // Used to determine the target position of a snap. 187 // Used to determine the target position of a snap.
212 scoped_ptr<SnapSizer> snap_sizer_; 188 scoped_ptr<SnapSizer> snap_sizer_;
213 189
214 // Last SnapType. 190 // Last SnapType.
215 SnapType snap_type_; 191 SnapType snap_type_;
216 192
217 // 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
218 // 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
219 // the screen. 195 // the screen.
220 int num_mouse_moves_since_bounds_change_; 196 int num_mouse_moves_since_bounds_change_;
221 197
222 // The mouse location passed to Drag(). 198 // The mouse location passed to Drag().
223 gfx::Point last_mouse_location_; 199 gfx::Point last_mouse_location_;
224 200
225 // If non-NULL the destructor sets this to true. Used to determine if this has
226 // been deleted.
227 bool* destroyed_;
228
229 // Window the drag has magnetically attached to. 201 // Window the drag has magnetically attached to.
230 aura::Window* magnetism_window_; 202 aura::Window* magnetism_window_;
231 203
232 // Used to verify |magnetism_window_| is still valid. 204 // Used to verify |magnetism_window_| is still valid.
233 aura::WindowTracker window_tracker_; 205 aura::WindowTracker window_tracker_;
234 206
235 // 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
236 // should attach. 208 // should attach.
237 MatchedEdge magnetism_edge_; 209 MatchedEdge magnetism_edge_;
238 210
239 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); 211 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer);
240 }; 212 };
241 213
242 } // namespace internal 214 } // namespace internal
243 } // namespace ash 215 } // namespace ash
244 216
245 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ 217 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698