| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/tab_view.h" | 5 #import "chrome/browser/cocoa/tab_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/nsimage_cache_mac.h" | 8 #include "base/nsimage_cache_mac.h" |
| 9 #import "chrome/browser/cocoa/tab_controller.h" | 9 #import "chrome/browser/cocoa/tab_controller.h" |
| 10 #import "chrome/browser/cocoa/tab_window_controller.h" | 10 #import "chrome/browser/cocoa/tab_window_controller.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 if ([theEvent trackingArea] == closeTrackingArea_) { | 109 if ([theEvent trackingArea] == closeTrackingArea_) { |
| 110 [closeButton_ setImage:nsimage_cache::ImageNamed(@"close_bar.pdf")]; | 110 [closeButton_ setImage:nsimage_cache::ImageNamed(@"close_bar.pdf")]; |
| 111 } else { | 111 } else { |
| 112 lastHoverUpdate_ = [NSDate timeIntervalSinceReferenceDate]; | 112 lastHoverUpdate_ = [NSDate timeIntervalSinceReferenceDate]; |
| 113 isMouseInside_ = NO; | 113 isMouseInside_ = NO; |
| 114 [self adjustHoverValue]; | 114 [self adjustHoverValue]; |
| 115 [self setNeedsDisplay:YES]; | 115 [self setNeedsDisplay:YES]; |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 // The tracking areas have been moved. Make sure that the close button is |
| 120 // highlighting correctly with respect to the cursor position with the new |
| 121 // tracking area locations. |
| 122 - (void)updateTrackingAreas { |
| 123 [super updateTrackingAreas]; |
| 124 |
| 125 // Update the close buttons if the tab has moved. |
| 126 NSPoint mouseLoc = [[self window] mouseLocationOutsideOfEventStream]; |
| 127 mouseLoc = [self convertPointFromBase:mouseLoc]; |
| 128 NSString* name = nil; |
| 129 if (NSPointInRect(mouseLoc, [closeButton_ frame])) { |
| 130 name = @"close_bar_h.pdf"; |
| 131 } else { |
| 132 name = @"close_bar.pdf"; |
| 133 } |
| 134 NSImage* newImage = nsimage_cache::ImageNamed(name); |
| 135 NSImage* buttonImage = [closeButton_ image]; |
| 136 if (![buttonImage isEqual:newImage]) { |
| 137 [closeButton_ setImage:newImage]; |
| 138 } |
| 139 } |
| 140 |
| 119 // Determines which view a click in our frame actually hit. It's either this | 141 // Determines which view a click in our frame actually hit. It's either this |
| 120 // view or our child close button. | 142 // view or our child close button. |
| 121 - (NSView*)hitTest:(NSPoint)aPoint { | 143 - (NSView*)hitTest:(NSPoint)aPoint { |
| 122 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; | 144 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; |
| 123 NSRect frame = [self frame]; | 145 NSRect frame = [self frame]; |
| 124 | 146 |
| 125 // Reduce the width of the hit rect slightly to remove the overlap | 147 // Reduce the width of the hit rect slightly to remove the overlap |
| 126 // between adjacent tabs. The drawing code in TabCell has the top | 148 // between adjacent tabs. The drawing code in TabCell has the top |
| 127 // corners of the tab inset by height*2/3, so we inset by half of | 149 // corners of the tab inset by height*2/3, so we inset by half of |
| 128 // that here. This doesn't completely eliminate the overlap, but it | 150 // that here. This doesn't completely eliminate the overlap, but it |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 } | 791 } |
| 770 | 792 |
| 771 - (void)viewDidMoveToWindow { | 793 - (void)viewDidMoveToWindow { |
| 772 [super viewDidMoveToWindow]; | 794 [super viewDidMoveToWindow]; |
| 773 if ([self window]) { | 795 if ([self window]) { |
| 774 [controller_ updateTitleColor]; | 796 [controller_ updateTitleColor]; |
| 775 } | 797 } |
| 776 } | 798 } |
| 777 | 799 |
| 778 @end | 800 @end |
| OLD | NEW |