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

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

Issue 23471004: Only support left/right maximizing at 50% width when the --ash-enable-alternate-caption-button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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 ash { 17 namespace ash {
18 namespace internal { 18 namespace internal {
19 19
20 class PhantomWindowController; 20 class PhantomWindowController;
21 class SnapSizer;
22 class WindowSize; 21 class WindowSize;
23 22
24 // WindowResizer implementation for workspaces. This enforces that windows are 23 // WindowResizer implementation for workspaces. This enforces that windows are
25 // not allowed to vertically move or resize outside of the work area. As windows 24 // 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 25 // 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 26 // the window before it was moved so that if the window is again moved up we
28 // attempt to restore the old height. 27 // attempt to restore the old height.
29 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { 28 class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
30 public: 29 public:
31 // When dragging an attached window this is the min size we'll make sure is 30 // When dragging an attached window this is the min size we'll make sure is
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const std::vector<aura::Window*>& attached_windows); 66 const std::vector<aura::Window*>& attached_windows);
68 67
69 private: 68 private:
70 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom); 69 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom);
71 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize); 70 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize);
72 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow); 71 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow);
73 72
74 // Type of snapping. 73 // Type of snapping.
75 enum SnapType { 74 enum SnapType {
76 // Snap to the left/right edge of the screen. 75 // Snap to the left/right edge of the screen.
77 SNAP_LEFT_EDGE, 76 SNAP_LEFT,
78 SNAP_RIGHT_EDGE, 77 SNAP_RIGHT,
79 78
80 // No snap position. 79 // No snap position.
81 SNAP_NONE 80 SNAP_NONE
82 }; 81 };
83 82
84 // Returns the final bounds to place the window at. This differs from
85 // the current when snapping.
86 gfx::Rect GetFinalBounds(const gfx::Rect& bounds) const;
87
88 // Lays out the attached windows. |bounds| is the bounds of the main window. 83 // Lays out the attached windows. |bounds| is the bounds of the main window.
89 void LayoutAttachedWindows(gfx::Rect* bounds); 84 void LayoutAttachedWindows(gfx::Rect* bounds);
90 85
91 // Calculates the new sizes of the attached windows, given that the main 86 // Calculates the new sizes of the attached windows, given that the main
92 // window has been resized (along the primary axis) by |delta|. 87 // window has been resized (along the primary axis) by |delta|.
93 // |available_size| is the maximum length of the space that the attached 88 // |available_size| is the maximum length of the space that the attached
94 // windows are allowed to occupy (ie: the distance between the right/bottom 89 // windows are allowed to occupy (ie: the distance between the right/bottom
95 // edge of the primary window and the right/bottom of the desktop area). 90 // edge of the primary window and the right/bottom of the desktop area).
96 // Populates |sizes| with the desired sizes of the attached windows, and 91 // Populates |sizes| with the desired sizes of the attached windows, and
97 // returns the number of pixels that couldn't be allocated to the attached 92 // returns the number of pixels that couldn't be allocated to the attached
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Sum of the minimum sizes of the attached windows. 175 // Sum of the minimum sizes of the attached windows.
181 int total_min_; 176 int total_min_;
182 177
183 // Sum of the sizes in |initial_size_|. 178 // Sum of the sizes in |initial_size_|.
184 int total_initial_size_; 179 int total_initial_size_;
185 180
186 // Gives a previews of where the the window will end up. Only used if there 181 // Gives a previews of where the the window will end up. Only used if there
187 // is a grid and the caption is being dragged. 182 // is a grid and the caption is being dragged.
188 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_; 183 scoped_ptr<PhantomWindowController> snap_phantom_window_controller_;
189 184
190 // Used to determine the target position of a snap.
191 scoped_ptr<SnapSizer> snap_sizer_;
192
193 // Last SnapType. 185 // Last SnapType.
194 SnapType snap_type_; 186 SnapType snap_type_;
195 187
196 // Number of mouse moves since the last bounds change. Only used for phantom 188 // Number of mouse moves since the last bounds change. Only used for phantom
197 // placement to track when the mouse is moved while pushed against the edge of 189 // placement to track when the mouse is moved while pushed against the edge of
198 // the screen. 190 // the screen.
199 int num_mouse_moves_since_bounds_change_; 191 int num_mouse_moves_since_bounds_change_;
200 192
201 // The mouse location passed to Drag(). 193 // The mouse location passed to Drag().
202 gfx::Point last_mouse_location_; 194 gfx::Point last_mouse_location_;
203 195
204 // Window the drag has magnetically attached to. 196 // Window the drag has magnetically attached to.
205 aura::Window* magnetism_window_; 197 aura::Window* magnetism_window_;
206 198
207 // Used to verify |magnetism_window_| is still valid. 199 // Used to verify |magnetism_window_| is still valid.
208 aura::WindowTracker window_tracker_; 200 aura::WindowTracker window_tracker_;
209 201
210 // If |magnetism_window_| is non-NULL this indicates how the two windows 202 // If |magnetism_window_| is non-NULL this indicates how the two windows
211 // should attach. 203 // should attach.
212 MatchedEdge magnetism_edge_; 204 MatchedEdge magnetism_edge_;
213 205
214 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer); 206 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer);
215 }; 207 };
216 208
217 } // namespace internal 209 } // namespace internal
218 } // namespace ash 210 } // namespace ash
219 211
220 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_ 212 #endif // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698