| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/new_tab_button.h" | 5 #import "chrome/browser/ui/cocoa/new_tab_button.h" |
| 6 #import "chrome/browser/ui/cocoa/image_button_cell.h" | 6 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
| 7 | 7 |
| 8 // A simple override of the ImageButtonCell to disable handling of |
| 9 // -mouseEntered. |
| 10 @interface NewTabButtonCell : ImageButtonCell |
| 11 |
| 12 - (void)mouseEntered:(NSEvent*)theEvent; |
| 13 |
| 14 @end |
| 15 |
| 16 @implementation NewTabButtonCell |
| 17 |
| 18 - (void)mouseEntered:(NSEvent*)theEvent { |
| 19 // Ignore this since the NTB enter is handled by the TabStripController. |
| 20 } |
| 21 |
| 22 @end |
| 23 |
| 24 |
| 8 @implementation NewTabButton | 25 @implementation NewTabButton |
| 9 | 26 |
| 10 + (Class)cellClass { | 27 + (Class)cellClass { |
| 11 return [ImageButtonCell class]; | 28 return [NewTabButtonCell class]; |
| 12 } | 29 } |
| 13 | 30 |
| 14 // Approximate the shape. It doesn't need to be perfect. This will need to be | 31 // Approximate the shape. It doesn't need to be perfect. This will need to be |
| 15 // updated if the size or shape of the icon ever changes. | 32 // updated if the size or shape of the icon ever changes. |
| 16 // TODO(pinkerton): use a click mask image instead of hard-coding points. | 33 // TODO(pinkerton): use a click mask image instead of hard-coding points. |
| 17 - (NSBezierPath*)pathForButton { | 34 - (NSBezierPath*)pathForButton { |
| 18 if (imagePath_.get()) | 35 if (imagePath_.get()) |
| 19 return imagePath_.get(); | 36 return imagePath_.get(); |
| 20 | 37 |
| 21 // Cache the path as it doesn't change (the coordinates are local to this | 38 // Cache the path as it doesn't change (the coordinates are local to this |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 | 55 |
| 39 // Override to only accept clicks within the bounds of the defined path, not | 56 // Override to only accept clicks within the bounds of the defined path, not |
| 40 // the entire bounding box. |aPoint| is in the superview's coordinate system. | 57 // the entire bounding box. |aPoint| is in the superview's coordinate system. |
| 41 - (NSView*)hitTest:(NSPoint)aPoint { | 58 - (NSView*)hitTest:(NSPoint)aPoint { |
| 42 if ([self pointIsOverButton:aPoint]) | 59 if ([self pointIsOverButton:aPoint]) |
| 43 return [super hitTest:aPoint]; | 60 return [super hitTest:aPoint]; |
| 44 return nil; | 61 return nil; |
| 45 } | 62 } |
| 46 | 63 |
| 47 @end | 64 @end |
| OLD | NEW |