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

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

Issue 19054013: Implement automatic layout and stacking for docked windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_233331_sized
Patch Set: Implement automatic layout and stacking (published a flag) Created 7 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
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 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // to move or resize beyond that edge. 103 // to move or resize beyond that edge.
104 const int kStickyDistancePixels = 64; 104 const int kStickyDistancePixels = 64;
105 105
106 // Snapping distance used instead of WorkspaceWindowResizer::kScreenEdgeInset 106 // Snapping distance used instead of WorkspaceWindowResizer::kScreenEdgeInset
107 // when resizing a window using touchscreen. 107 // when resizing a window using touchscreen.
108 const int kScreenEdgeInsetForTouchResize = 32; 108 const int kScreenEdgeInsetForTouchResize = 32;
109 109
110 // Returns true if the window should stick to the edge. 110 // Returns true if the window should stick to the edge.
111 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) { 111 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) {
112 if (CommandLine::ForCurrentProcess()->HasSwitch( 112 if (CommandLine::ForCurrentProcess()->HasSwitch(
113 switches::kAshEnableStickyEdges)) { 113 switches::kAshEnableStickyEdges) ||
114 CommandLine::ForCurrentProcess()->HasSwitch(
115 switches::kAshEnableDockedWindows)) {
114 return distance_from_edge < 0 && 116 return distance_from_edge < 0 &&
115 distance_from_edge > -sticky_size; 117 distance_from_edge > -sticky_size;
116 } 118 }
117 return distance_from_edge < sticky_size && 119 return distance_from_edge < sticky_size &&
118 distance_from_edge > -sticky_size * 2; 120 distance_from_edge > -sticky_size * 2;
119 } 121 }
120 122
121 // Returns the coordinate along the secondary axis to snap to. 123 // Returns the coordinate along the secondary axis to snap to.
122 int CoordinateAlongSecondaryAxis(SecondaryMagnetismEdge edge, 124 int CoordinateAlongSecondaryAxis(SecondaryMagnetismEdge edge,
123 int leading, 125 int leading,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 new WorkspaceWindowResizer(details, attached_windows) : NULL; 346 new WorkspaceWindowResizer(details, attached_windows) : NULL;
345 } 347 }
346 348
347 void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent, 349 void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
348 int event_flags) { 350 int event_flags) {
349 last_mouse_location_ = location_in_parent; 351 last_mouse_location_ = location_in_parent;
350 352
351 int sticky_size; 353 int sticky_size;
352 if (event_flags & ui::EF_CONTROL_DOWN) { 354 if (event_flags & ui::EF_CONTROL_DOWN) {
353 sticky_size = 0; 355 sticky_size = 0;
354 } else if (CommandLine::ForCurrentProcess()->HasSwitch( 356 } else if (
355 switches::kAshEnableStickyEdges)) { 357 CommandLine::ForCurrentProcess()->HasSwitch(
358 switches::kAshEnableStickyEdges) ||
359 CommandLine::ForCurrentProcess()->HasSwitch(
360 switches::kAshEnableDockedWindows)) {
356 sticky_size = kStickyDistancePixels; 361 sticky_size = kStickyDistancePixels;
357 } else if ((details_.bounds_change & kBoundsChange_Resizes) && 362 } else if ((details_.bounds_change & kBoundsChange_Resizes) &&
358 details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { 363 details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
359 sticky_size = kScreenEdgeInsetForTouchResize; 364 sticky_size = kScreenEdgeInsetForTouchResize;
360 } else { 365 } else {
361 sticky_size = kScreenEdgeInset; 366 sticky_size = kScreenEdgeInset;
362 } 367 }
363 // |bounds| is in |window()->parent()|'s coordinates. 368 // |bounds| is in |window()->parent()|'s coordinates.
364 gfx::Rect bounds = CalculateBoundsForDrag(details_, location_in_parent); 369 gfx::Rect bounds = CalculateBoundsForDrag(details_, location_in_parent);
365 370
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); 925 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window()));
921 if (location.x() <= area.x()) 926 if (location.x() <= area.x())
922 return SNAP_LEFT_EDGE; 927 return SNAP_LEFT_EDGE;
923 if (location.x() >= area.right() - 1) 928 if (location.x() >= area.right() - 1)
924 return SNAP_RIGHT_EDGE; 929 return SNAP_RIGHT_EDGE;
925 return SNAP_NONE; 930 return SNAP_NONE;
926 } 931 }
927 932
928 } // namespace internal 933 } // namespace internal
929 } // namespace ash 934 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698