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

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

Issue 10795013: Rename bounds accessors to be intuitive and consistent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 current += size; 274 current += size;
275 sizes->push_back(size); 275 sizes->push_back(size);
276 } 276 }
277 } 277 }
278 } 278 }
279 279
280 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( 280 void WorkspaceWindowResizer::AdjustBoundsForMainWindow(
281 gfx::Rect* bounds, int grid_size) const { 281 gfx::Rect* bounds, int grid_size) const {
282 // Always keep kMinOnscreenHeight on the bottom. 282 // Always keep kMinOnscreenHeight on the bottom.
283 gfx::Rect work_area( 283 gfx::Rect work_area(
284 ScreenAsh::GetDisplayWorkAreaParentBounds(details_.window)); 284 ScreenAsh::GetDisplayWorkAreaBoundsInParent(details_.window));
285 int max_y = AlignToGridRoundUp(work_area.bottom() - kMinOnscreenHeight, 285 int max_y = AlignToGridRoundUp(work_area.bottom() - kMinOnscreenHeight,
286 grid_size); 286 grid_size);
287 if (bounds->y() > max_y) 287 if (bounds->y() > max_y)
288 bounds->set_y(max_y); 288 bounds->set_y(max_y);
289 289
290 // Don't allow dragging above the top of the display. 290 // Don't allow dragging above the top of the display.
291 if (bounds->y() <= work_area.y()) 291 if (bounds->y() <= work_area.y())
292 bounds->set_y(work_area.y()); 292 bounds->set_y(work_area.y());
293 293
294 if (grid_size >= 0 && details_.window_component == HTCAPTION) 294 if (grid_size >= 0 && details_.window_component == HTCAPTION)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 bounds->height() < (bottom_edge - top_edge)) { 328 bounds->height() < (bottom_edge - top_edge)) {
329 // Only snap to the bottom if the window is smaller than the work area. 329 // Only snap to the bottom if the window is smaller than the work area.
330 // Doing otherwise can lead to window snapping in weird ways as it bounces 330 // Doing otherwise can lead to window snapping in weird ways as it bounces
331 // between snapping to top then bottom. 331 // between snapping to top then bottom.
332 bounds->set_y(bottom_edge - bounds->height()); 332 bounds->set_y(bottom_edge - bounds->height());
333 } 333 }
334 } 334 }
335 335
336 bool WorkspaceWindowResizer::TouchesBottomOfScreen() const { 336 bool WorkspaceWindowResizer::TouchesBottomOfScreen() const {
337 gfx::Rect work_area( 337 gfx::Rect work_area(
338 ScreenAsh::GetDisplayWorkAreaParentBounds(details_.window)); 338 ScreenAsh::GetDisplayWorkAreaBoundsInParent(details_.window));
339 return (attached_windows_.empty() && 339 return (attached_windows_.empty() &&
340 details_.window->bounds().bottom() == work_area.bottom()) || 340 details_.window->bounds().bottom() == work_area.bottom()) ||
341 (!attached_windows_.empty() && 341 (!attached_windows_.empty() &&
342 attached_windows_.back()->bounds().bottom() == work_area.bottom()); 342 attached_windows_.back()->bounds().bottom() == work_area.bottom());
343 } 343 }
344 344
345 int WorkspaceWindowResizer::PrimaryAxisSize(const gfx::Size& size) const { 345 int WorkspaceWindowResizer::PrimaryAxisSize(const gfx::Size& size) const {
346 return PrimaryAxisCoordinate(size.width(), size.height()); 346 return PrimaryAxisCoordinate(size.width(), size.height());
347 } 347 }
348 348
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 ++i; 416 ++i;
417 if (i != map.rend()) 417 if (i != map.rend())
418 parent->StackChildBelow(i->second, window); 418 parent->StackChildBelow(i->second, window);
419 } 419 }
420 } 420 }
421 421
422 WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType( 422 WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType(
423 const gfx::Point& location) const { 423 const gfx::Point& location) const {
424 // TODO: this likely only wants total display area, not the area of a single 424 // TODO: this likely only wants total display area, not the area of a single
425 // display. 425 // display.
426 gfx::Rect area(ScreenAsh::GetDisplayParentBounds(details_.window)); 426 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(details_.window));
427 if (location.x() <= area.x()) 427 if (location.x() <= area.x())
428 return SNAP_LEFT_EDGE; 428 return SNAP_LEFT_EDGE;
429 if (location.x() >= area.right() - 1) 429 if (location.x() >= area.right() - 1)
430 return SNAP_RIGHT_EDGE; 430 return SNAP_RIGHT_EDGE;
431 return SNAP_NONE; 431 return SNAP_NONE;
432 } 432 }
433 433
434 } // namespace internal 434 } // namespace internal
435 } // namespace ash 435 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_manager_unittest.cc ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698