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 #include "chrome/browser/ui/cocoa/gradient_button_cell.h" | 5 #include "chrome/browser/ui/cocoa/gradient_button_cell.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/memory/scoped_nsobject.h" | 8 #import "base/memory/scoped_nsobject.h" |
9 #import "chrome/browser/themes/theme_service.h" | 9 #import "chrome/browser/themes/theme_service.h" |
10 #import "chrome/browser/ui/cocoa/image_utils.h" | 10 #import "chrome/browser/ui/cocoa/image_utils.h" |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 clipPath:&boundingPath]; | 718 clipPath:&boundingPath]; |
719 return boundingPath; | 719 return boundingPath; |
720 } | 720 } |
721 | 721 |
722 - (void)resetCursorRect:(NSRect)cellFrame inView:(NSView*)controlView { | 722 - (void)resetCursorRect:(NSRect)cellFrame inView:(NSView*)controlView { |
723 [super resetCursorRect:cellFrame inView:controlView]; | 723 [super resetCursorRect:cellFrame inView:controlView]; |
724 if (trackingArea_) | 724 if (trackingArea_) |
725 [self updateTrackingAreas]; | 725 [self updateTrackingAreas]; |
726 } | 726 } |
727 | 727 |
728 - (void)updateTrackingAreas { | 728 - (BOOL)isMouseReallyInside { |
729 BOOL mouseInView = NO; | 729 BOOL mouseInView = NO; |
730 NSView* controlView = [self controlView]; | 730 NSView* controlView = [self controlView]; |
731 NSWindow* window = [controlView window]; | 731 NSWindow* window = [controlView window]; |
732 NSRect bounds = [controlView bounds]; | 732 NSRect bounds = [controlView bounds]; |
733 if (window) { | 733 if (window) { |
734 NSPoint mousePoint = [window mouseLocationOutsideOfEventStream]; | 734 NSPoint mousePoint = [window mouseLocationOutsideOfEventStream]; |
735 mousePoint = [controlView convertPointFromBase:mousePoint]; | 735 mousePoint = [controlView convertPointFromBase:mousePoint]; |
736 mouseInView = [controlView mouse:mousePoint inRect:bounds]; | 736 mouseInView = [controlView mouse:mousePoint inRect:bounds]; |
737 } | 737 } |
| 738 return mouseInView; |
| 739 } |
| 740 |
| 741 - (void)updateTrackingAreas { |
| 742 NSView* controlView = [self controlView]; |
| 743 BOOL mouseInView = [self isMouseReallyInside]; |
738 | 744 |
739 if (trackingArea_.get()) | 745 if (trackingArea_.get()) |
740 [controlView removeTrackingArea:trackingArea_]; | 746 [controlView removeTrackingArea:trackingArea_]; |
741 | 747 |
742 NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | | 748 NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | |
743 NSTrackingActiveInActiveApp; | 749 NSTrackingActiveInActiveApp; |
744 if (mouseInView) | 750 if (mouseInView) |
745 options |= NSTrackingAssumeInside; | 751 options |= NSTrackingAssumeInside; |
746 | 752 |
747 trackingArea_.reset([[NSTrackingArea alloc] | 753 trackingArea_.reset([[NSTrackingArea alloc] |
748 initWithRect:bounds | 754 initWithRect:[controlView bounds] |
749 options:options | 755 options:options |
750 owner:self | 756 owner:self |
751 userInfo:nil]); | 757 userInfo:nil]); |
752 if (isMouseInside_ != mouseInView) { | 758 if (isMouseInside_ != mouseInView) { |
753 isMouseInside_ = mouseInView; | 759 [self setMouseInside:mouseInView animate:NO]; |
754 [controlView setNeedsDisplay:YES]; | 760 [controlView setNeedsDisplay:YES]; |
755 } | 761 } |
756 } | 762 } |
757 | 763 |
758 @end | 764 @end |
OLD | NEW |