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

Unified Diff: ash/wm/window_resizer.cc

Issue 10008084: Add ctrl+drag feature for allowing resizing window with exact positioning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add ctrl-drap for resizing window to pixel level. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/window_resizer.cc
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc
index 45941616afd1253577e050065d17283014b3a43b..d44c0842c986dffbf958464b2308f1b8837a2002 100644
--- a/ash/wm/window_resizer.cc
+++ b/ash/wm/window_resizer.cc
@@ -186,7 +186,8 @@ int WindowResizer::AlignToGridRoundDown(int location, int grid_size) {
// static
gfx::Rect WindowResizer::CalculateBoundsForDrag(
const Details& details,
- const gfx::Point& location) {
+ const gfx::Point& location,
+ bool disable_snap_to_grid) {
if (!details.is_resizable)
return details.initial_bounds;
@@ -196,7 +197,8 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag(
// The minimize size constraint may limit how much we change the window
// position. For example, dragging the left edge to the right should stop
// repositioning the window when the minimize size is reached.
- gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y);
+ gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y,
+ disable_snap_to_grid);
gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y);
gfx::Rect new_bounds(origin, size);
@@ -257,15 +259,21 @@ gfx::Point WindowResizer::GetOriginForDrag(const Details& details,
// static
gfx::Size WindowResizer::GetSizeForDrag(const Details& details,
int* delta_x,
- int* delta_y) {
+ int* delta_y,
+ bool disable_snap_to_grid) {
gfx::Size size = details.initial_bounds.size();
if (details.bounds_change & kBoundsChange_Resizes) {
gfx::Size min_size = details.window->delegate()->GetMinimumSize();
- min_size.set_width(AlignToGridRoundUp(min_size.width(), details.grid_size));
- min_size.set_height(AlignToGridRoundUp(min_size.height(),
- details.grid_size));
- size.SetSize(GetWidthForDrag(details, min_size.width(), delta_x),
- GetHeightForDrag(details, min_size.height(), delta_y));
+ min_size.set_width(
+ AlignToGridRoundUp(min_size.width(),
+ disable_snap_to_grid ? 0 : details.grid_size));
+ min_size.set_height(
+ AlignToGridRoundUp(min_size.height(),
+ disable_snap_to_grid? 0 : details.grid_size));
+ size.SetSize(GetWidthForDrag(details, min_size.width(), delta_x,
+ disable_snap_to_grid),
+ GetHeightForDrag(details, min_size.height(), delta_y,
+ disable_snap_to_grid));
}
return size;
}
@@ -273,13 +281,15 @@ gfx::Size WindowResizer::GetSizeForDrag(const Details& details,
// static
int WindowResizer::GetWidthForDrag(const Details& details,
int min_width,
- int* delta_x) {
+ int* delta_x,
+ bool disable_snap_to_grid) {
int width = details.initial_bounds.width();
if (details.size_change_direction & kBoundsChangeDirection_Horizontal) {
// Along the right edge, positive delta_x increases the window size.
int x_multiplier = IsRightEdge(details.window_component) ? 1 : -1;
width += x_multiplier * (*delta_x);
- int adjusted_width = AlignToGrid(width, details.grid_size);
+ int adjusted_width =
+ AlignToGrid(width, disable_snap_to_grid ? 0 : details.grid_size);
if (adjusted_width != width) {
*delta_x += -x_multiplier * (width - adjusted_width);
width = adjusted_width;
@@ -306,13 +316,15 @@ int WindowResizer::GetWidthForDrag(const Details& details,
// static
int WindowResizer::GetHeightForDrag(const Details& details,
int min_height,
- int* delta_y) {
+ int* delta_y,
+ bool disable_snap_to_grid) {
int height = details.initial_bounds.height();
if (details.size_change_direction & kBoundsChangeDirection_Vertical) {
// Along the bottom edge, positive delta_y increases the window size.
int y_multiplier = IsBottomEdge(details.window_component) ? 1 : -1;
height += y_multiplier * (*delta_y);
- int adjusted_height = AlignToGrid(height, details.grid_size);
+ int adjusted_height =
+ AlignToGrid(height, disable_snap_to_grid ? 0 : details.grid_size);
if (height != adjusted_height) {
*delta_y += -y_multiplier * (height - adjusted_height);
height = adjusted_height;

Powered by Google App Engine
This is Rietveld 408576698