| 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 #include "chrome/browser/cocoa/tab_window_controller.h" | 6 #include "chrome/browser/cocoa/tab_window_controller.h" |
| 7 | 7 |
| 8 @implementation TabView | 8 @implementation TabView |
| 9 | 9 |
| 10 - (id)initWithFrame:(NSRect)frame { | 10 - (id)initWithFrame:(NSRect)frame { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // hierarchy) first. We want to handle clicks and drags in this class and | 25 // hierarchy) first. We want to handle clicks and drags in this class and |
| 26 // leave the background button for display purposes only. | 26 // leave the background button for display purposes only. |
| 27 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { | 27 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { |
| 28 return YES; | 28 return YES; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // Determines which view a click in our frame actually hit. It's either this | 31 // Determines which view a click in our frame actually hit. It's either this |
| 32 // view or our child close button. | 32 // view or our child close button. |
| 33 - (NSView *)hitTest:(NSPoint)aPoint { | 33 - (NSView *)hitTest:(NSPoint)aPoint { |
| 34 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; | 34 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; |
| 35 NSRect frame = [self frame]; |
| 36 |
| 37 // Reduce the width of the hit rect slightly to remove the overlap |
| 38 // between adjacent tabs. The drawing code in TabCell has the top |
| 39 // corners of the tab inset by height*2/3, so we inset by half of |
| 40 // that here. This doesn't completely eliminate the overlap, but it |
| 41 // works well enough. |
| 42 NSRect hitRect = NSInsetRect(frame, frame.size.height / 3.0f, 0); |
| 35 if (NSPointInRect(viewPoint, [closeButton_ frame])) return closeButton_; | 43 if (NSPointInRect(viewPoint, [closeButton_ frame])) return closeButton_; |
| 36 if (NSPointInRect(aPoint, [self frame])) return self; | 44 if (NSPointInRect(aPoint, hitRect)) return self; |
| 37 return nil; | 45 return nil; |
| 38 } | 46 } |
| 39 | 47 |
| 40 // Handle clicks and drags in this button. We get here because we have | 48 // Handle clicks and drags in this button. We get here because we have |
| 41 // overridden acceptsFirstMouse: and the click is within our bounds. | 49 // overridden acceptsFirstMouse: and the click is within our bounds. |
| 42 // TODO(pinkerton/alcor): This routine needs *a lot* of work to marry Cole's | 50 // TODO(pinkerton/alcor): This routine needs *a lot* of work to marry Cole's |
| 43 // ideas of dragging cocoa views between windows and how the Browser and | 51 // ideas of dragging cocoa views between windows and how the Browser and |
| 44 // TabStrip models want to manage tabs. | 52 // TabStrip models want to manage tabs. |
| 45 - (void)mouseDown:(NSEvent *)theEvent { | 53 - (void)mouseDown:(NSEvent *)theEvent { |
| 46 static const CGFloat kTearDistance = 36.0; | 54 static const CGFloat kTearDistance = 36.0; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 TabWindowController* dropController = sourceController; | 303 TabWindowController* dropController = sourceController; |
| 296 [dropController dropTabView:[dropController selectedTabView] | 304 [dropController dropTabView:[dropController selectedTabView] |
| 297 fromController:nil]; | 305 fromController:nil]; |
| 298 } | 306 } |
| 299 } | 307 } |
| 300 | 308 |
| 301 [sourceController removePlaceholder]; | 309 [sourceController removePlaceholder]; |
| 302 } | 310 } |
| 303 | 311 |
| 304 @end | 312 @end |
| OLD | NEW |