| OLD | NEW |
| 1 // Copyright (c) 2011 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/image_button_cell.h" | 5 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "chrome/browser/themes/theme_service.h" | 8 #import "chrome/browser/themes/theme_service.h" |
| 9 #import "chrome/browser/ui/cocoa/image_utils.h" | 9 #import "chrome/browser/ui/cocoa/image_utils.h" |
| 10 #import "chrome/browser/ui/cocoa/themed_window.h" | 10 #import "chrome/browser/ui/cocoa/themed_window.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { | 61 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
| 62 BOOL windowHasFocus = [[controlView window] isMainWindow] || | 62 BOOL windowHasFocus = [[controlView window] isMainWindow] || |
| 63 [[controlView window] isKeyWindow]; | 63 [[controlView window] isKeyWindow]; |
| 64 CGFloat alpha = windowHasFocus ? 1.0 : kImageNoFocusAlpha; | 64 CGFloat alpha = windowHasFocus ? 1.0 : kImageNoFocusAlpha; |
| 65 | 65 |
| 66 NSImage* image = [self imageForID:imageID_[[self currentButtonState]] | 66 NSImage* image = [self imageForID:imageID_[[self currentButtonState]] |
| 67 controlView:controlView]; | 67 controlView:controlView]; |
| 68 NSRect imageRect; | 68 NSRect imageRect; |
| 69 imageRect.size = [image size]; | 69 imageRect.size = [image size]; |
| 70 imageRect.origin.x = cellFrame.origin.x + | 70 imageRect.origin.x = cellFrame.origin.x + |
| 71 roundf((cellFrame.size.width - imageRect.size.width) / 2.0); | 71 roundf((NSWidth(cellFrame) - NSWidth(imageRect)) / 2.0); |
| 72 imageRect.origin.y = cellFrame.origin.y + | 72 imageRect.origin.y = cellFrame.origin.y + |
| 73 roundf((cellFrame.size.height - imageRect.size.height) / 2.0); | 73 roundf((NSHeight(cellFrame) - NSHeight(imageRect)) / 2.0); |
| 74 | 74 |
| 75 [image drawInRect:imageRect | 75 [image drawInRect:imageRect |
| 76 fromRect:NSZeroRect | 76 fromRect:NSZeroRect |
| 77 operation:NSCompositeSourceOver | 77 operation:NSCompositeSourceOver |
| 78 fraction:alpha | 78 fraction:alpha |
| 79 neverFlipped:YES]; | 79 neverFlipped:YES]; |
| 80 | 80 |
| 81 if (overlayImageID_) { | 81 if (overlayImageID_) { |
| 82 NSImage* overlayImage = [self imageForID:overlayImageID_ | 82 NSImage* overlayImage = [self imageForID:overlayImageID_ |
| 83 controlView:controlView]; | 83 controlView:controlView]; |
| 84 NSRect overlayRect; | 84 NSRect overlayRect; |
| 85 overlayRect.size = [overlayImage size]; | 85 overlayRect.size = [overlayImage size]; |
| 86 overlayRect.origin.x = NSMaxX(imageRect) - overlayRect.size.width + | 86 overlayRect.origin.x = NSMaxX(imageRect) - NSWidth(overlayRect) + |
| 87 kOverlayOffsetX; | 87 kOverlayOffsetX; |
| 88 overlayRect.origin.y = NSMinY(imageRect) + kOverlayOffsetY; | 88 overlayRect.origin.y = NSMinY(imageRect) + kOverlayOffsetY; |
| 89 | 89 |
| 90 [overlayImage drawInRect:overlayRect | 90 [overlayImage drawInRect:overlayRect |
| 91 fromRect:NSZeroRect | 91 fromRect:NSZeroRect |
| 92 operation:NSCompositeSourceOver | 92 operation:NSCompositeSourceOver |
| 93 fraction:1.0 | 93 fraction:1.0 |
| 94 neverFlipped:YES]; | 94 neverFlipped:YES]; |
| 95 } | 95 } |
| 96 } | 96 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 - (void)mouseEntered:(NSEvent*)theEvent { | 160 - (void)mouseEntered:(NSEvent*)theEvent { |
| 161 [self setIsMouseInside:YES]; | 161 [self setIsMouseInside:YES]; |
| 162 } | 162 } |
| 163 | 163 |
| 164 - (void)mouseExited:(NSEvent*)theEvent { | 164 - (void)mouseExited:(NSEvent*)theEvent { |
| 165 [self setIsMouseInside:NO]; | 165 [self setIsMouseInside:NO]; |
| 166 } | 166 } |
| 167 | 167 |
| 168 @end | 168 @end |
| OLD | NEW |