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