OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/cocoa/tab_view.h" | 5 #include "chrome/browser/cocoa/tab_view.h" |
6 | 6 |
7 #include "chrome/browser/cocoa/nsimage_cache.h" | 7 #include "chrome/browser/cocoa/nsimage_cache.h" |
8 #include "chrome/browser/cocoa/tab_controller.h" | 8 #include "chrome/browser/cocoa/tab_controller.h" |
9 #include "chrome/browser/cocoa/tab_window_controller.h" | 9 #include "chrome/browser/cocoa/tab_window_controller.h" |
10 | 10 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 NSPoint thisPoint = [NSEvent mouseLocation]; | 260 NSPoint thisPoint = [NSEvent mouseLocation]; |
261 CGFloat stretchiness = thisPoint.y - dragOrigin_.y; | 261 CGFloat stretchiness = thisPoint.y - dragOrigin_.y; |
262 stretchiness = copysign(sqrtf(fabs(stretchiness))/sqrtf(kTearDistance), | 262 stretchiness = copysign(sqrtf(fabs(stretchiness))/sqrtf(kTearDistance), |
263 stretchiness) / 2.0; | 263 stretchiness) / 2.0; |
264 CGFloat offset = thisPoint.x - dragOrigin_.x; | 264 CGFloat offset = thisPoint.x - dragOrigin_.x; |
265 if (fabsf(offset) > 100) stretchiness = 0; | 265 if (fabsf(offset) > 100) stretchiness = 0; |
266 [sourceController_ insertPlaceholderForTab:self | 266 [sourceController_ insertPlaceholderForTab:self |
267 frame:NSOffsetRect(sourceTabFrame_, | 267 frame:NSOffsetRect(sourceTabFrame_, |
268 offset, 0) | 268 offset, 0) |
269 yStretchiness:stretchiness]; | 269 yStretchiness:stretchiness]; |
270 | 270 // Check that we haven't pulled the tab too far to start a drag. This |
| 271 // can include either pulling it too far down, or off the side of the tab |
| 272 // strip that would cause it to no longer be fully visible. |
| 273 BOOL stillVisible = [sourceController_ isTabFullyVisible:self]; |
271 CGFloat tearForce = fabs(thisPoint.y - dragOrigin_.y); | 274 CGFloat tearForce = fabs(thisPoint.y - dragOrigin_.y); |
272 if (tearForce > kTearDistance) { | 275 if (tearForce > kTearDistance || !stillVisible) { |
273 draggingWithinTabStrip_ = NO; | 276 draggingWithinTabStrip_ = NO; |
274 // When you finally leave the strip, we treat that as the origin. | 277 // When you finally leave the strip, we treat that as the origin. |
275 dragOrigin_.x = thisPoint.x; | 278 dragOrigin_.x = thisPoint.x; |
276 } else { | 279 } else { |
277 return; | 280 return; |
278 } | 281 } |
279 } | 282 } |
280 | 283 |
281 NSPoint lastPoint = | 284 NSPoint lastPoint = |
282 [[theEvent window] convertBaseToScreen:[theEvent locationInWindow]]; | 285 [[theEvent window] convertBaseToScreen:[theEvent locationInWindow]]; |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 [[NSGraphicsContext currentContext] restoreGraphicsState]; | 652 [[NSGraphicsContext currentContext] restoreGraphicsState]; |
650 } | 653 } |
651 | 654 |
652 // Called when the user hits the right mouse button (or control-clicks) to | 655 // Called when the user hits the right mouse button (or control-clicks) to |
653 // show a context menu. | 656 // show a context menu. |
654 - (void)rightMouseDown:(NSEvent*)theEvent { | 657 - (void)rightMouseDown:(NSEvent*)theEvent { |
655 [NSMenu popUpContextMenu:[self menu] withEvent:theEvent forView:self]; | 658 [NSMenu popUpContextMenu:[self menu] withEvent:theEvent forView:self]; |
656 } | 659 } |
657 | 660 |
658 @end | 661 @end |
OLD | NEW |