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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "chrome/browser/ui/cocoa/tracking_area.h" |
| 9 |
8 | 10 |
9 // A button that changes when you hover over it and click it. | 11 // A button that changes when you hover over it and click it. |
10 @interface HoverButton : NSButton { | 12 @interface HoverButton : NSButton { |
11 @protected | 13 @protected |
12 // Enumeration of the hover states that the close button can be in at any one | 14 // Enumeration of the hover states that the close button can be in at any one |
13 // time. The button cannot be in more than one hover state at a time. | 15 // time. The button cannot be in more than one hover state at a time. |
14 enum HoverState { | 16 enum HoverState { |
15 kHoverStateNone = 0, | 17 kHoverStateNone = 0, |
16 kHoverStateMouseOver = 1, | 18 kHoverStateMouseOver = 1, |
17 kHoverStateMouseDown = 2 | 19 kHoverStateMouseDown = 2 |
18 }; | 20 }; |
19 | 21 |
20 HoverState hoverState_; | 22 HoverState hoverState_; |
21 | 23 |
22 @private | 24 @private |
23 // Tracking area for button mouseover states. | 25 // Tracking area for button mouseover states. |
24 scoped_nsobject<NSTrackingArea> trackingArea_; | 26 ScopedCrTrackingArea trackingArea_; |
25 } | 27 } |
26 | 28 |
27 // Enables or disables the |NSTrackingRect|s for the button. | 29 @property(nonatomic) HoverState hoverState; |
| 30 |
| 31 // Enables or disables the tracking for the button. |
28 - (void)setTrackingEnabled:(BOOL)enabled; | 32 - (void)setTrackingEnabled:(BOOL)enabled; |
29 | 33 |
30 // Checks to see whether the mouse is in the button's bounds and update | 34 // Checks to see whether the mouse is in the button's bounds and update |
31 // the image in case it gets out of sync. This occurs to the close button | 35 // the image in case it gets out of sync. This occurs to the close button |
32 // when you close a tab so the tab to the left of it takes its place, and | 36 // when you close a tab so the tab to the left of it takes its place, and |
33 // drag the button without moving the mouse before you press the button down. | 37 // drag the button without moving the mouse before you press the button down. |
34 - (void)checkImageState; | 38 - (void)checkImageState; |
35 @end | 39 @end |
OLD | NEW |