Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
| 10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 return; | 164 return; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // First, go through the magnetic drag cycle. We break out of this if | 167 // First, go through the magnetic drag cycle. We break out of this if |
| 168 // "stretchiness" ever exceeds a set amount. | 168 // "stretchiness" ever exceeds a set amount. |
| 169 tabWasDragged_ = YES; | 169 tabWasDragged_ = YES; |
| 170 | 170 |
| 171 if (draggingWithinTabStrip_) { | 171 if (draggingWithinTabStrip_) { |
| 172 NSPoint thisPoint = [NSEvent mouseLocation]; | 172 NSPoint thisPoint = [NSEvent mouseLocation]; |
| 173 CGFloat offset = thisPoint.x - dragOrigin_.x; | 173 CGFloat offset = thisPoint.x - dragOrigin_.x; |
| 174 // Only begin dragging the tab horizontally if it's torn out of its dead | |
| 175 // zone. | |
| 176 if (!outOfTabHorizontalDeadZone_ && fabs(offset) > kTearDistance) { | |
|
Avi (use Gerrit)
2016/11/30 00:01:22
Do we want kTearDistance? That's 36 pixels, and wh
erikchen
2016/11/30 15:05:16
Agreed that this should be significantly smaller.
njagsarran
2016/11/30 17:44:49
Looks like Views uses 10, what do you guys think o
njagsarran
2016/11/30 20:26:32
Done.
| |
| 177 outOfTabHorizontalDeadZone_ = YES; | |
| 178 } | |
| 179 if (outOfTabHorizontalDeadZone_) | |
|
Avi (use Gerrit)
2016/11/30 00:01:22
You'd need to adjust the indentation here with a n
njagsarran
2016/11/30 20:26:32
Done.
| |
| 174 [sourceController_ insertPlaceholderForTab:[draggedTab_ tabView] | 180 [sourceController_ insertPlaceholderForTab:[draggedTab_ tabView] |
| 175 frame:NSOffsetRect(sourceTabFrame_, | 181 frame:NSOffsetRect(sourceTabFrame_, |
| 176 offset, 0)]; | 182 offset, 0)]; |
| 177 // Check that we haven't pulled the tab too far to start a drag. This | 183 // Check that we haven't pulled the tab too far to start a drag. This |
| 178 // can include either pulling it too far down, or off the side of the tab | 184 // can include either pulling it too far down, or off the side of the tab |
| 179 // strip that would cause it to no longer be fully visible. | 185 // strip that would cause it to no longer be fully visible. |
| 180 BOOL stillVisible = | 186 BOOL stillVisible = |
| 181 [sourceController_ isTabFullyVisible:[draggedTab_ tabView]]; | 187 [sourceController_ isTabFullyVisible:[draggedTab_ tabView]]; |
| 182 CGFloat tearForce = fabs(thisPoint.y - dragOrigin_.y); | 188 CGFloat tearForce = fabs(thisPoint.y - dragOrigin_.y); |
| 183 if ([sourceController_ tabTearingAllowed] && | 189 if ([sourceController_ tabTearingAllowed] && |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 // placeholder). | 428 // placeholder). |
| 423 [draggedController_ showNewTabButton:YES]; | 429 [draggedController_ showNewTabButton:YES]; |
| 424 | 430 |
| 425 if (draggingWithinTabStrip_) { | 431 if (draggingWithinTabStrip_) { |
| 426 if (tabWasDragged_) { | 432 if (tabWasDragged_) { |
| 427 // Move tab to new location. | 433 // Move tab to new location. |
| 428 DCHECK([sourceController_ numberOfTabs]); | 434 DCHECK([sourceController_ numberOfTabs]); |
| 429 TabWindowController* dropController = sourceController_; | 435 TabWindowController* dropController = sourceController_; |
| 430 [dropController moveTabViews:@[ [dropController activeTabView] ] | 436 [dropController moveTabViews:@[ [dropController activeTabView] ] |
| 431 fromController:nil]; | 437 fromController:nil]; |
| 438 outOfTabHorizontalDeadZone_ = NO; | |
|
erikchen
2016/11/30 15:05:16
presumably we always want to reset this when the d
njagsarran
2016/11/30 20:26:32
Done.
| |
| 432 } | 439 } |
| 433 } else if (targetController_) { | 440 } else if (targetController_) { |
| 434 // Move between windows. If |targetController_| is nil, we're not dropping | 441 // Move between windows. If |targetController_| is nil, we're not dropping |
| 435 // into any existing window. | 442 // into any existing window. |
| 436 [targetController_ moveTabViews:[draggedController_ tabViews] | 443 [targetController_ moveTabViews:[draggedController_ tabViews] |
| 437 fromController:draggedController_]; | 444 fromController:draggedController_]; |
| 438 // Force redraw to avoid flashes of old content before returning to event | 445 // Force redraw to avoid flashes of old content before returning to event |
| 439 // loop. | 446 // loop. |
| 440 [[targetController_ window] display]; | 447 [[targetController_ window] display]; |
| 441 [targetController_ showWindow:nil]; | 448 [targetController_ showWindow:nil]; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 [[targetController_ window] makeMainWindow]; | 562 [[targetController_ window] makeMainWindow]; |
| 556 } else { | 563 } else { |
| 557 [dragWindow_ setAlphaValue:0.5]; | 564 [dragWindow_ setAlphaValue:0.5]; |
| 558 [[draggedController_ overlayWindow] setHasShadow:NO]; | 565 [[draggedController_ overlayWindow] setHasShadow:NO]; |
| 559 [[draggedController_ window] makeMainWindow]; | 566 [[draggedController_ window] makeMainWindow]; |
| 560 } | 567 } |
| 561 chromeIsVisible_ = shouldBeVisible; | 568 chromeIsVisible_ = shouldBeVisible; |
| 562 } | 569 } |
| 563 | 570 |
| 564 @end | 571 @end |
| OLD | NEW |