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/hover_button.h" | 5 #import "chrome/browser/ui/cocoa/hover_button.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/tracking_area.h" | 7 #import "chrome/browser/ui/cocoa/tracking_area.h" |
8 | 8 |
9 @implementation HoverButton | 9 @implementation HoverButton |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // http://crbug.com/31279 | 54 // http://crbug.com/31279 |
55 [self checkImageState]; | 55 [self checkImageState]; |
56 } | 56 } |
57 | 57 |
58 - (void)setTrackingEnabled:(BOOL)enabled { | 58 - (void)setTrackingEnabled:(BOOL)enabled { |
59 if (enabled) { | 59 if (enabled) { |
60 trackingArea_.reset( | 60 trackingArea_.reset( |
61 [[CrTrackingArea alloc] initWithRect:[self bounds] | 61 [[CrTrackingArea alloc] initWithRect:[self bounds] |
62 options:NSTrackingMouseEnteredAndExited | | 62 options:NSTrackingMouseEnteredAndExited | |
63 NSTrackingActiveAlways | 63 NSTrackingActiveAlways |
64 proxiedOwner:self | 64 owner:self |
65 userInfo:nil]); | 65 userInfo:nil]); |
66 [self addTrackingArea:trackingArea_.get()]; | 66 [self addTrackingArea:trackingArea_.get()]; |
67 | 67 |
68 // If you have a separate window that overlaps the close button, and you | 68 // If you have a separate window that overlaps the close button, and you |
69 // move the mouse directly over the close button without entering another | 69 // move the mouse directly over the close button without entering another |
70 // part of the tab strip, we don't get any mouseEntered event since the | 70 // part of the tab strip, we don't get any mouseEntered event since the |
71 // tracking area was disabled when we entered. | 71 // tracking area was disabled when we entered. |
72 // Done with a delay of 0 because sometimes an event appears to be missed | 72 // Done with a delay of 0 because sometimes an event appears to be missed |
73 // between the activation of the tracking area and the call to | 73 // between the activation of the tracking area and the call to |
74 // checkImageState resulting in the button state being incorrect. | 74 // checkImageState resulting in the button state being incorrect. |
(...skipping 23 matching lines...) Expand all Loading... |
98 self.hoverState = NSPointInRect(mouseLoc, [self bounds]) ? | 98 self.hoverState = NSPointInRect(mouseLoc, [self bounds]) ? |
99 kHoverStateMouseOver : kHoverStateNone; | 99 kHoverStateMouseOver : kHoverStateNone; |
100 } | 100 } |
101 | 101 |
102 - (void)setHoverState:(HoverState)state { | 102 - (void)setHoverState:(HoverState)state { |
103 hoverState_ = state; | 103 hoverState_ = state; |
104 [self setNeedsDisplay:YES]; | 104 [self setNeedsDisplay:YES]; |
105 } | 105 } |
106 | 106 |
107 @end | 107 @end |
OLD | NEW |