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