| 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/cocoa/bookmark_button_cell.h" | 5 #import "chrome/browser/cocoa/bookmark_button_cell.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/nsimage_cache_mac.h" | 9 #include "base/nsimage_cache_mac.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 NSButton* button = static_cast<NSButton*>([self controlView]); | 173 NSButton* button = static_cast<NSButton*>([self controlView]); |
| 174 if (button) { | 174 if (button) { |
| 175 DCHECK([button isKindOfClass:[NSButton class]]); | 175 DCHECK([button isKindOfClass:[NSButton class]]); |
| 176 [button setAttributedTitle:ats.get()]; | 176 [button setAttributedTitle:ats.get()]; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 // To implement "hover open a bookmark button to open the folder" | 180 // To implement "hover open a bookmark button to open the folder" |
| 181 // which feels like menus, we override NSButtonCell's mouseEntered: | 181 // which feels like menus, we override NSButtonCell's mouseEntered: |
| 182 // and mouseExited:, then and pass them along to our owning control. | 182 // and mouseExited:, then and pass them along to our owning control. |
| 183 // Note: as verified in a debugger, mouseEntered: does NOT increase |
| 184 // the retainCount of the cell or its owning control. |
| 183 - (void)mouseEntered:(NSEvent*)event { | 185 - (void)mouseEntered:(NSEvent*)event { |
| 184 [super mouseEntered:event]; | 186 [super mouseEntered:event]; |
| 185 [[self controlView] mouseEntered:event]; | 187 [[self controlView] mouseEntered:event]; |
| 186 } | 188 } |
| 187 | 189 |
| 188 // See comment above mouseEntered:, above. | 190 // See comment above mouseEntered:, above. |
| 189 - (void)mouseExited:(NSEvent*)event { | 191 - (void)mouseExited:(NSEvent*)event { |
| 192 [[self controlView] mouseExited:event]; |
| 190 [super mouseExited:event]; | 193 [super mouseExited:event]; |
| 191 [[self controlView] mouseExited:event]; | |
| 192 } | 194 } |
| 193 | 195 |
| 194 - (void)setDrawFolderArrow:(BOOL)draw { | 196 - (void)setDrawFolderArrow:(BOOL)draw { |
| 195 drawFolderArrow_ = draw; | 197 drawFolderArrow_ = draw; |
| 196 if (draw && !arrowImage_) { | 198 if (draw && !arrowImage_) { |
| 197 arrowImage_.reset([nsimage_cache::ImageNamed(@"menu_hierarchy_arrow.pdf") | 199 arrowImage_.reset([nsimage_cache::ImageNamed(@"menu_hierarchy_arrow.pdf") |
| 198 retain]); | 200 retain]); |
| 199 } | 201 } |
| 200 } | 202 } |
| 201 | 203 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 228 (NSHeight(imageRect) / 2.0)); | 230 (NSHeight(imageRect) / 2.0)); |
| 229 [arrowImage_ drawInRect:drawRect | 231 [arrowImage_ drawInRect:drawRect |
| 230 fromRect:imageRect | 232 fromRect:imageRect |
| 231 operation:NSCompositeSourceOver | 233 operation:NSCompositeSourceOver |
| 232 fraction:[self isEnabled] ? 1.0 : 0.5 | 234 fraction:[self isEnabled] ? 1.0 : 0.5 |
| 233 neverFlipped:YES]; | 235 neverFlipped:YES]; |
| 234 } | 236 } |
| 235 } | 237 } |
| 236 | 238 |
| 237 @end | 239 @end |
| OLD | NEW |