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

Side by Side Diff: ash/wm/window_resizer.cc

Issue 15008002: Make touch-resizing windows to screen edge possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move border immediately under the finger + change snapping distance back to 16 Created 7 years, 6 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 #include "ash/wm/window_resizer.h" 5 #include "ash/wm/window_resizer.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/wm/property_util.h" 9 #include "ash/wm/property_util.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const int WindowResizer::kBoundsChangeDirection_Horizontal = 1; 100 const int WindowResizer::kBoundsChangeDirection_Horizontal = 1;
101 // static 101 // static
102 const int WindowResizer::kBoundsChangeDirection_Vertical = 2; 102 const int WindowResizer::kBoundsChangeDirection_Vertical = 2;
103 103
104 WindowResizer::Details::Details() 104 WindowResizer::Details::Details()
105 : window(NULL), 105 : window(NULL),
106 window_component(HTNOWHERE), 106 window_component(HTNOWHERE),
107 bounds_change(0), 107 bounds_change(0),
108 position_change_direction(0), 108 position_change_direction(0),
109 size_change_direction(0), 109 size_change_direction(0),
110 is_resizable(false) { 110 is_resizable(false),
111 source(aura::client::WINDOW_MOVE_SOURCE_MOUSE) {
111 } 112 }
112 113
113 WindowResizer::Details::Details(aura::Window* window, 114 WindowResizer::Details::Details(aura::Window* window,
114 const gfx::Point& location, 115 const gfx::Point& location,
115 int window_component) 116 int window_component,
117 aura::client::WindowMoveSource source)
116 : window(window), 118 : window(window),
117 initial_bounds_in_parent(window->bounds()), 119 initial_bounds_in_parent(window->bounds()),
118 restore_bounds(gfx::Rect()), 120 restore_bounds(gfx::Rect()),
119 initial_location_in_parent(location), 121 initial_location_in_parent(location),
120 initial_opacity(window->layer()->opacity()), 122 initial_opacity(window->layer()->opacity()),
121 window_component(window_component), 123 window_component(window_component),
122 bounds_change(GetBoundsChangeForWindowComponent(window_component)), 124 bounds_change(GetBoundsChangeForWindowComponent(window_component)),
123 position_change_direction( 125 position_change_direction(
124 GetPositionChangeDirectionForWindowComponent(window_component)), 126 GetPositionChangeDirectionForWindowComponent(window_component)),
125 size_change_direction( 127 size_change_direction(
126 GetSizeChangeDirectionForWindowComponent(window_component)), 128 GetSizeChangeDirectionForWindowComponent(window_component)),
127 is_resizable(bounds_change != kBoundsChangeDirection_None) { 129 is_resizable(bounds_change != kBoundsChangeDirection_None),
130 source(source) {
128 if (wm::IsWindowNormal(window) && 131 if (wm::IsWindowNormal(window) &&
129 GetRestoreBoundsInScreen(window) && 132 GetRestoreBoundsInScreen(window) &&
130 window_component == HTCAPTION) 133 window_component == HTCAPTION)
131 restore_bounds = *GetRestoreBoundsInScreen(window); 134 restore_bounds = *GetRestoreBoundsInScreen(window);
132 } 135 }
133 136
134 WindowResizer::Details::~Details() { 137 WindowResizer::Details::~Details() {
135 } 138 }
136 139
137 WindowResizer::WindowResizer() { 140 WindowResizer::WindowResizer() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 if (!details.is_resizable) 177 if (!details.is_resizable)
175 return details.initial_bounds_in_parent; 178 return details.initial_bounds_in_parent;
176 179
177 gfx::Point location = passed_location; 180 gfx::Point location = passed_location;
178 gfx::Rect work_area = 181 gfx::Rect work_area =
179 ScreenAsh::GetDisplayWorkAreaBoundsInParent(details.window); 182 ScreenAsh::GetDisplayWorkAreaBoundsInParent(details.window);
180 183
181 int delta_x = location.x() - details.initial_location_in_parent.x(); 184 int delta_x = location.x() - details.initial_location_in_parent.x();
182 int delta_y = location.y() - details.initial_location_in_parent.y(); 185 int delta_y = location.y() - details.initial_location_in_parent.y();
183 186
187 AdjustDeltaForTouchResize(details, &delta_x, &delta_y);
188
184 // The minimize size constraint may limit how much we change the window 189 // The minimize size constraint may limit how much we change the window
185 // position. For example, dragging the left edge to the right should stop 190 // position. For example, dragging the left edge to the right should stop
186 // repositioning the window when the minimize size is reached. 191 // repositioning the window when the minimize size is reached.
187 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y); 192 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y);
188 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); 193 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y);
189 gfx::Rect new_bounds(origin, size); 194 gfx::Rect new_bounds(origin, size);
190 195
191 // Sizing has to keep the result on the screen. Note that this correction 196 // Sizing has to keep the result on the screen. Note that this correction
192 // has to come first since it might have an impact on the origin as well as 197 // has to come first since it might have an impact on the origin as well as
193 // on the size. 198 // on the size.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 new_bounds_in_screen.x()))); 263 new_bounds_in_screen.x())));
259 new_bounds = 264 new_bounds =
260 ScreenAsh::ConvertRectFromScreen(parent, new_bounds_in_screen); 265 ScreenAsh::ConvertRectFromScreen(parent, new_bounds_in_screen);
261 } 266 }
262 } 267 }
263 268
264 return new_bounds; 269 return new_bounds;
265 } 270 }
266 271
267 // static 272 // static
273 void WindowResizer::AdjustDeltaForTouchResize(const Details& details,
274 int* delta_x,
275 int* delta_y) {
276 if (details.source != aura::client::WINDOW_MOVE_SOURCE_TOUCH ||
277 !(details.bounds_change & kBoundsChange_Resizes))
278 return;
279
280 if (details.size_change_direction & kBoundsChangeDirection_Horizontal) {
281 if (IsRightEdge(details.window_component)) {
282 *delta_x += details.initial_location_in_parent.x() -
283 details.initial_bounds_in_parent.right();
sky 2013/06/14 15:57:27 nit: indent this 2 more (same on 286, 292 and 295)
mohsen 2013/06/14 16:21:48 Done.
284 } else {
285 *delta_x += details.initial_location_in_parent.x() -
286 details.initial_bounds_in_parent.x();
287 }
288 }
289 if (details.size_change_direction & kBoundsChangeDirection_Vertical) {
290 if (IsBottomEdge(details.window_component)) {
291 *delta_y += details.initial_location_in_parent.y() -
292 details.initial_bounds_in_parent.bottom();
293 } else {
294 *delta_y += details.initial_location_in_parent.y() -
295 details.initial_bounds_in_parent.y();
296 }
297 }
298 }
299
300 // static
268 bool WindowResizer::IsBottomEdge(int window_component) { 301 bool WindowResizer::IsBottomEdge(int window_component) {
269 return window_component == HTBOTTOMLEFT || 302 return window_component == HTBOTTOMLEFT ||
270 window_component == HTBOTTOM || 303 window_component == HTBOTTOM ||
271 window_component == HTBOTTOMRIGHT || 304 window_component == HTBOTTOMRIGHT ||
272 window_component == HTGROWBOX; 305 window_component == HTGROWBOX;
273 } 306 }
274 307
275 // static 308 // static
276 gfx::Point WindowResizer::GetOriginForDrag(const Details& details, 309 gfx::Point WindowResizer::GetOriginForDrag(const Details& details,
277 int delta_x, 310 int delta_x,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (height > max_height) { 396 if (height > max_height) {
364 height = max_height; 397 height = max_height;
365 *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() - 398 *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() -
366 max_height); 399 max_height);
367 } 400 }
368 } 401 }
369 return height; 402 return height;
370 } 403 }
371 404
372 } // namespace aura 405 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698