diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 15:18:22 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 15:18:22 +0000 |
commit | caf2f4e2142246201ad7589e8629ab9c47df022f (patch) | |
tree | 7bf8269dccb49d2cfce22a79b5ad787c36e6fcac /chrome/browser/cocoa/tab_view.mm | |
parent | a5d28334fcea7a34558d3c2afe6155dcd8379edc (diff) | |
download | chromium_src-caf2f4e2142246201ad7589e8629ab9c47df022f.zip chromium_src-caf2f4e2142246201ad7589e8629ab9c47df022f.tar.gz chromium_src-caf2f4e2142246201ad7589e8629ab9c47df022f.tar.bz2 |
Implement tab closing animations.
BUG=14919
TEST=tab opening and closing, tab dragging, trying to drag tabs while animating closed, http auth, tab modal sheets, anything involving tabs.
Review URL: http://codereview.chromium.org/348061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30959 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/tab_view.mm')
-rw-r--r-- | chrome/browser/cocoa/tab_view.mm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index fd8c737..fb97299 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -21,6 +21,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; @synthesize state = state_; @synthesize hoverAlpha = hoverAlpha_; +@synthesize isClosing = isClosing_; - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; @@ -136,6 +137,8 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; // Returns |YES| if this tab can be torn away into a new window. - (BOOL)canBeDragged { + if ([self isClosing]) + return NO; NSWindowController* controller = [sourceWindow_ windowController]; if ([controller isKindOfClass:[TabWindowController class]]) { TabWindowController* realController = @@ -189,6 +192,9 @@ static const NSTimeInterval kTearDuration = 0.333; static const CGFloat kRapidCloseDist = 2.5; - (void)mouseDown:(NSEvent*)theEvent { + if ([self isClosing]) + return; + NSPoint downLocation = [theEvent locationInWindow]; // During the tab closure animation (in particular, during rapid tab closure), @@ -232,7 +238,8 @@ static const CGFloat kRapidCloseDist = 2.5; NSArray* targets = [self dropTargetsForController:sourceController_]; moveWindowOnDrag_ = ([sourceController_ numberOfTabs] < 2 && ![targets count]) || - ![self canBeDragged]; + ![self canBeDragged] || + ![sourceController_ tabDraggingAllowed]; // If we are dragging a tab, a window with a single tab should immediately // snap off and not drag within the tab strip. if (!moveWindowOnDrag_) @@ -244,9 +251,9 @@ static const CGFloat kRapidCloseDist = 2.5; // ourselves. Ideally we should use the standard event loop. while (1) { theEvent = - [NSApp nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask - untilDate:[NSDate distantFuture] - inMode:NSDefaultRunLoopMode dequeue:YES]; + [NSApp nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask + untilDate:[NSDate distantFuture] + inMode:NSDefaultRunLoopMode dequeue:YES]; NSPoint thisPoint = [NSEvent mouseLocation]; NSEventType type = [theEvent type]; @@ -550,6 +557,9 @@ static const CGFloat kRapidCloseDist = 2.5; } - (void)otherMouseUp:(NSEvent*)theEvent { + if ([self isClosing]) + return; + // Support middle-click-to-close. if ([theEvent buttonNumber] == 2) { // |-hitTest:| takes a location in the superview's coordinates. @@ -718,6 +728,8 @@ static const CGFloat kRapidCloseDist = 2.5; // Called when the user hits the right mouse button (or control-clicks) to // show a context menu. - (void)rightMouseDown:(NSEvent*)theEvent { + if ([self isClosing]) + return; [NSMenu popUpContextMenu:[self menu] withEvent:theEvent forView:self]; } |