| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/wrench_menu/menu_tracked_button.h" | 5 #import "chrome/browser/ui/cocoa/wrench_menu/menu_tracked_button.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include "base/mac/mac_util.h" |
| 8 | 8 |
| 9 @interface MenuTrackedButton (Private) | 9 @interface MenuTrackedButton (Private) |
| 10 - (void)doHighlight:(BOOL)highlight; | 10 - (void)doHighlight:(BOOL)highlight; |
| 11 - (void)checkMouseInRect; | 11 - (void)checkMouseInRect; |
| 12 - (NSRect)insetBounds; | 12 - (NSRect)insetBounds; |
| 13 - (BOOL)shouldHighlightOnHover; | 13 - (BOOL)shouldHighlightOnHover; |
| 14 @end | 14 @end |
| 15 | 15 |
| 16 @implementation MenuTrackedButton | 16 @implementation MenuTrackedButton |
| 17 | 17 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 // Returns the bounds of the receiver slightly inset to avoid highlighting both | 100 // Returns the bounds of the receiver slightly inset to avoid highlighting both |
| 101 // buttons in a pair that overlap. | 101 // buttons in a pair that overlap. |
| 102 - (NSRect)insetBounds { | 102 - (NSRect)insetBounds { |
| 103 return NSInsetRect([self bounds], 2, 1); | 103 return NSInsetRect([self bounds], 2, 1); |
| 104 } | 104 } |
| 105 | 105 |
| 106 - (BOOL)shouldHighlightOnHover { | 106 - (BOOL)shouldHighlightOnHover { |
| 107 // Apple does not define NSAppKitVersionNumber10_5 when using the 10.5 SDK. | |
| 108 // The Internets have come up with this solution. | |
| 109 #ifndef NSAppKitVersionNumber10_5 | |
| 110 #define NSAppKitVersionNumber10_5 949 | |
| 111 #endif | |
| 112 | |
| 113 // There's a cell drawing bug in 10.5 that was fixed on 10.6. Hover states | 107 // There's a cell drawing bug in 10.5 that was fixed on 10.6. Hover states |
| 114 // look terrible due to this, so disable highlighting on 10.5. | 108 // look terrible due to this, so disable highlighting on 10.5. |
| 115 return std::floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5; | 109 return base::mac::IsOSSnowLeopardOrLater(); |
| 116 } | 110 } |
| 117 | 111 |
| 118 @end | 112 @end |
| OLD | NEW |