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

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: Fix win_aura error 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
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
(...skipping 12 matching lines...) Expand all
51 static const int kScreenEdgeInset; 42 static const int kScreenEdgeInset;
52 43
53 virtual ~WorkspaceWindowResizer(); 44 virtual ~WorkspaceWindowResizer();
54 45
55 static WorkspaceWindowResizer* Create( 46 static WorkspaceWindowResizer* Create(
56 aura::Window* window, 47 aura::Window* window,
57 const gfx::Point& location_in_parent, 48 const gfx::Point& location_in_parent,
58 int window_component, 49 int window_component,
59 const std::vector<aura::Window*>& attached_windows); 50 const std::vector<aura::Window*>& attached_windows);
60 51
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: 52 // Overridden from WindowResizer:
69 virtual void Drag(const gfx::Point& location_in_parent, 53 virtual void Drag(const gfx::Point& location_in_parent,
70 int event_flags) OVERRIDE; 54 int event_flags) OVERRIDE;
71 virtual void CompleteDrag(int event_flags) OVERRIDE; 55 virtual void CompleteDrag(int event_flags) OVERRIDE;
72 virtual void RevertDrag() OVERRIDE; 56 virtual void RevertDrag() OVERRIDE;
73 virtual aura::Window* GetTarget() OVERRIDE; 57 virtual aura::Window* GetTarget() OVERRIDE;
74 58
59 const gfx::Point& GetInitialLocationInParentForTest() const {
60 return details_.initial_location_in_parent;
61 }
62
75 private: 63 private:
76 WorkspaceWindowResizer(const Details& details, 64 WorkspaceWindowResizer(const Details& details,
77 const std::vector<aura::Window*>& attached_windows); 65 const std::vector<aura::Window*>& attached_windows);
78 66
79 private: 67 private:
80 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, DragWindowController);
81 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom); 68 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom);
82 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize); 69 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize);
83 70
84 // Type of snapping. 71 // Type of snapping.
85 enum SnapType { 72 enum SnapType {
86 // Snap to the left/right edge of the screen. 73 // Snap to the left/right edge of the screen.
87 SNAP_LEFT_EDGE, 74 SNAP_LEFT_EDGE,
88 SNAP_RIGHT_EDGE, 75 SNAP_RIGHT_EDGE,
89 76
90 // No snap position. 77 // No snap position.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 147
161 // Returns a coordinate along the primary axis. Used to share code for 148 // Returns a coordinate along the primary axis. Used to share code for
162 // left/right multi window resize and top/bottom resize. 149 // left/right multi window resize and top/bottom resize.
163 int PrimaryAxisSize(const gfx::Size& size) const; 150 int PrimaryAxisSize(const gfx::Size& size) const;
164 int PrimaryAxisCoordinate(int x, int y) const; 151 int PrimaryAxisCoordinate(int x, int y) const;
165 152
166 // Updates the bounds of the phantom window for window snapping. 153 // Updates the bounds of the phantom window for window snapping.
167 void UpdateSnapPhantomWindow(const gfx::Point& location, 154 void UpdateSnapPhantomWindow(const gfx::Point& location,
168 const gfx::Rect& bounds); 155 const gfx::Rect& bounds);
169 156
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 157 // 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. 158 // top of the z-order, and the rest directly underneath it.
176 void RestackWindows(); 159 void RestackWindows();
177 160
178 // Returns the SnapType for the specified point. SNAP_NONE is used if no 161 // Returns the SnapType for the specified point. SNAP_NONE is used if no
179 // snapping should be used. 162 // snapping should be used.
180 SnapType GetSnapType(const gfx::Point& location) const; 163 SnapType GetSnapType(const gfx::Point& location) const;
181 164
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; } 165 aura::Window* window() const { return details_.window; }
186 166
187 const Details details_; 167 const Details details_;
188 168
189 const std::vector<aura::Window*> attached_windows_; 169 const std::vector<aura::Window*> attached_windows_;
190 170
191 // Set to true once Drag() is invoked and the bounds of the window change. 171 // Set to true once Drag() is invoked and the bounds of the window change.
192 bool did_move_or_resize_; 172 bool did_move_or_resize_;
193 173
194 // The initial size of each of the windows in |attached_windows_| along the 174 // The initial size of each of the windows in |attached_windows_| along the
195 // primary axis. 175 // primary axis.
196 std::vector<int> initial_size_; 176 std::vector<int> initial_size_;
197 177
198 // Sum of the minimum sizes of the attached windows. 178 // Sum of the minimum sizes of the attached windows.
199 int total_min_; 179 int total_min_;
200 180
201 // Sum of the sizes in |initial_size_|. 181 // Sum of the sizes in |initial_size_|.
202 int total_initial_size_; 182 int total_initial_size_;
203 183
204 // Gives a previews of where the the window will end up. Only used if there 184 // 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. 185 // is a grid and the caption is being dragged.
206 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_; 186 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_;
207 187
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. 188 // Used to determine the target position of a snap.
212 scoped_ptr<SnapSizer> snap_sizer_; 189 scoped_ptr<SnapSizer> snap_sizer_;
213 190
214 // Last SnapType. 191 // Last SnapType.
215 SnapType snap_type_; 192 SnapType snap_type_;
216 193
217 // Number of mouse moves since the last bounds change. Only used for phantom 194 // 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 195 // placement to track when the mouse is moved while pushed against the edge of
219 // the screen. 196 // the screen.
220 int num_mouse_moves_since_bounds_change_; 197 int num_mouse_moves_since_bounds_change_;
221 198
222 // The mouse location passed to Drag(). 199 // The mouse location passed to Drag().
223 gfx::Point last_mouse_location_; 200 gfx::Point last_mouse_location_;
224 201
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. 202 // Window the drag has magnetically attached to.
230 aura::Window* magnetism_window_; 203 aura::Window* magnetism_window_;
231 204
232 // Used to verify |magnetism_window_| is still valid. 205 // Used to verify |magnetism_window_| is still valid.
233 aura::WindowTracker window_tracker_; 206 aura::WindowTracker window_tracker_;
234 207
235 // If |magnetism_window_| is non-NULL this indicates how the two windows 208 // If |magnetism_window_| is non-NULL this indicates how the two windows
236 // should attach. 209 // should attach.
237 MatchedEdge magnetism_edge_; 210 MatchedEdge magnetism_edge_;
238 211
239 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); 212 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer);
240 }; 213 };
241 214
242 } // namespace internal 215 } // namespace internal
243 } // namespace ash 216 } // namespace ash
244 217
245 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ 218 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_
OLDNEW
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698