diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-02 18:51:59 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-02 18:51:59 +0000 |
commit | 125628446db08f0a43be1dbe9681376514fa836d (patch) | |
tree | b854e5215e2df43cf4951f226b24ad56377a5caa /chrome | |
parent | 699ffb85a67ee640e266f8348622f22aa5d8a908 (diff) | |
download | chromium_src-125628446db08f0a43be1dbe9681376514fa836d.zip chromium_src-125628446db08f0a43be1dbe9681376514fa836d.tar.gz chromium_src-125628446db08f0a43be1dbe9681376514fa836d.tar.bz2 |
Adds mouseover images to the close tab button on Mac.
BUG=none
TEST=Mousing over the close button should change its image.
Review URL: http://codereview.chromium.org/113857
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/cocoa/tab_view.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_view.mm | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/tab_view.h b/chrome/browser/cocoa/tab_view.h index 96536d7..2124c20 100644 --- a/chrome/browser/cocoa/tab_view.h +++ b/chrome/browser/cocoa/tab_view.h @@ -7,6 +7,8 @@ #import <Cocoa/Cocoa.h> +#include "base/scoped_nsobject.h" + @class TabController, TabWindowController; // A view that handles the event tracking (clicking and dragging) for a tab @@ -20,6 +22,9 @@ // in and out on mouseovers. IBOutlet NSButton* closeButton_; + // Tracking area for close button mouseover images. + scoped_nsobject<NSTrackingArea> trackingArea_; + // All following variables are valid for the duration of a drag. // These are released on mouseUp: BOOL isTheOnlyTab_; // Is this the only tab in the window? diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index 02b9867..fe45b592 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -17,8 +17,23 @@ return self; } +- (void)awakeFromNib { + // Set up the tracking rect for the close button mouseover. Add it + // to the |closeButton_| view, but we'll handle the message ourself. + // The mouseover is always enabled, because the close button works + // regardless of key/main/active status. + trackingArea_.reset( + [[NSTrackingArea alloc] initWithRect:[closeButton_ bounds] + options:NSTrackingMouseEnteredAndExited | + NSTrackingActiveAlways + owner:self + userInfo:nil]); + [closeButton_ addTrackingArea:trackingArea_.get()]; +} + - (void)dealloc { // [self gtm_unregisterForThemeNotifications]; + [closeButton_ removeTrackingArea:trackingArea_.get()]; [super dealloc]; } @@ -29,6 +44,18 @@ return YES; } +- (void)mouseEntered:(NSEvent *)theEvent { + // We only set up one tracking area, so we know any mouseEntered: + // messages are for close button mouseovers. + [closeButton_ setImage:[NSImage imageNamed:@"close_bar_h"]]; +} + +- (void)mouseExited:(NSEvent *)theEvent { + // We only set up one tracking area, so we know any mouseExited: + // messages are for close button mouseovers. + [closeButton_ setImage:[NSImage imageNamed:@"close_bar"]]; +} + // Determines which view a click in our frame actually hit. It's either this // view or our child close button. - (NSView *)hitTest:(NSPoint)aPoint { |