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

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

Issue 10910164: Removes the grid from ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ShelfBrowserTest Created 8 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
« no previous file with comments | « ash/wm/workspace/snap_sizer.h ('k') | ash/wm/workspace/workspace2.h » ('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 #include "ash/wm/workspace/snap_sizer.h" 5 #include "ash/wm/workspace/snap_sizer.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/wm/window_resizer.h" 10 #include "ash/wm/window_resizer.h"
(...skipping 20 matching lines...) Expand all
31 const int kPixelsBeforeAdjust = 100; 31 const int kPixelsBeforeAdjust = 100;
32 32
33 // When the smallest resolution does not fit on the screen, we take this 33 // When the smallest resolution does not fit on the screen, we take this
34 // fraction of the available space. 34 // fraction of the available space.
35 const int kMinimumScreenPercent = 90; 35 const int kMinimumScreenPercent = 90;
36 36
37 } // namespace 37 } // namespace
38 38
39 SnapSizer::SnapSizer(aura::Window* window, 39 SnapSizer::SnapSizer(aura::Window* window,
40 const gfx::Point& start, 40 const gfx::Point& start,
41 Edge edge, 41 Edge edge)
42 int grid_size)
43 : window_(window), 42 : window_(window),
44 edge_(edge), 43 edge_(edge),
45 grid_size_(grid_size),
46 time_last_update_(base::TimeTicks::Now()), 44 time_last_update_(base::TimeTicks::Now()),
47 size_index_(0), 45 size_index_(0),
48 resize_disabled_(false), 46 resize_disabled_(false),
49 num_moves_since_adjust_(0), 47 num_moves_since_adjust_(0),
50 last_adjust_x_(start.x()), 48 last_adjust_x_(start.x()),
51 last_update_x_(start.x()) { 49 last_update_x_(start.x()) {
52 target_bounds_ = GetTargetBounds(); 50 target_bounds_ = GetTargetBounds();
53 } 51 }
54 52
55 void SnapSizer::Update(const gfx::Point& location) { 53 void SnapSizer::Update(const gfx::Point& location) {
(...skipping 30 matching lines...) Expand all
86 } 84 }
87 85
88 void SnapSizer::SelectDefaultSizeAndDisableResize() { 86 void SnapSizer::SelectDefaultSizeAndDisableResize() {
89 resize_disabled_ = true; 87 resize_disabled_ = true;
90 size_index_ = 0; 88 size_index_ = 0;
91 target_bounds_ = GetTargetBounds(); 89 target_bounds_ = GetTargetBounds();
92 } 90 }
93 91
94 gfx::Rect SnapSizer::GetTargetBoundsForSize(size_t size_index) const { 92 gfx::Rect SnapSizer::GetTargetBoundsForSize(size_t size_index) const {
95 gfx::Rect work_area(ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(window_)); 93 gfx::Rect work_area(ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(window_));
96 int y = WindowResizer::AlignToGridRoundUp(work_area.y(), grid_size_); 94 int y = work_area.y();
97 // We don't align to the bottom of the grid as the launcher may not 95 // We don't align to the bottom of the grid as the launcher may not
98 // necessarily align to the grid (happens when auto-hidden). 96 // necessarily align to the grid (happens when auto-hidden).
99 int max_y = work_area.bottom(); 97 int max_y = work_area.bottom();
100 int width = kSizes[size_index]; 98 int width = kSizes[size_index];
101 if (resize_disabled_) { 99 if (resize_disabled_) {
102 width = std::max(1024, work_area.width() / 2); 100 width = std::max(1024, work_area.width() / 2);
103 } else { 101 } else {
104 while (width >= work_area.width()) { 102 while (width >= work_area.width()) {
105 if (size_index >= arraysize(kSizes)) 103 if (size_index >= arraysize(kSizes))
106 break; 104 break;
107 width = kSizes[++size_index]; 105 width = kSizes[++size_index];
108 } 106 }
109 } 107 }
110 108
111 // Make sure that we keep the size of the window smaller then a certain 109 // Make sure that we keep the size of the window smaller then a certain
112 // fraction of the screen space. 110 // fraction of the screen space.
113 width = std::min(width, kMinimumScreenPercent * work_area.width() / 100); 111 width = std::min(width, kMinimumScreenPercent * work_area.width() / 100);
114 112
115 if (edge_ == LEFT_EDGE) { 113 if (edge_ == LEFT_EDGE) {
116 int x = WindowResizer::AlignToGridRoundUp(work_area.x(), grid_size_); 114 int x = work_area.x();
117 int mid_x = WindowResizer::AlignToGridRoundUp( 115 int mid_x = x + width;
118 work_area.x() + width, grid_size_);
119 return gfx::Rect(x, y, mid_x - x, max_y - y); 116 return gfx::Rect(x, y, mid_x - x, max_y - y);
120 } 117 }
121 int max_x = 118 int max_x = work_area.right();
122 WindowResizer::AlignToGridRoundDown(work_area.right(), grid_size_); 119 int x = max_x - width;
123 int x = WindowResizer::AlignToGridRoundUp(max_x - width, grid_size_);
124 return gfx::Rect(x , y, max_x - x, max_y - y); 120 return gfx::Rect(x , y, max_x - x, max_y - y);
125 } 121 }
126 122
127 int SnapSizer::CalculateIncrement(int x, int reference_x) const { 123 int SnapSizer::CalculateIncrement(int x, int reference_x) const {
128 if (AlongEdge(x)) 124 if (AlongEdge(x))
129 return 1; 125 return 1;
130 if (x == reference_x) 126 if (x == reference_x)
131 return 0; 127 return 0;
132 if (edge_ == LEFT_EDGE) { 128 if (edge_ == LEFT_EDGE) {
133 if (x < reference_x) 129 if (x < reference_x)
(...skipping 21 matching lines...) Expand all
155 return GetTargetBoundsForSize(size_index_); 151 return GetTargetBoundsForSize(size_index_);
156 } 152 }
157 153
158 bool SnapSizer::AlongEdge(int x) const { 154 bool SnapSizer::AlongEdge(int x) const {
159 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window_)); 155 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window_));
160 return (x <= area.x()) || (x >= area.right() - 1); 156 return (x <= area.x()) || (x >= area.right() - 1);
161 } 157 }
162 158
163 } // namespace internal 159 } // namespace internal
164 } // namespace ash 160 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/snap_sizer.h ('k') | ash/wm/workspace/workspace2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698