| 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/download_item_cell.h" | 5 #import "chrome/browser/cocoa/download_item_cell.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas_paint.h" | 7 #include "app/gfx/canvas_paint.h" |
| 8 #include "app/gfx/text_elider.h" | 8 #include "app/gfx/text_elider.h" |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (trackingAreaButton_) { | 189 if (trackingAreaButton_) { |
| 190 [[self controlView] removeTrackingArea:trackingAreaButton_.get()]; | 190 [[self controlView] removeTrackingArea:trackingAreaButton_.get()]; |
| 191 trackingAreaButton_.reset(nil); | 191 trackingAreaButton_.reset(nil); |
| 192 } | 192 } |
| 193 if (trackingAreaDropdown_) { | 193 if (trackingAreaDropdown_) { |
| 194 [[self controlView] removeTrackingArea:trackingAreaDropdown_.get()]; | 194 [[self controlView] removeTrackingArea:trackingAreaDropdown_.get()]; |
| 195 trackingAreaDropdown_.reset(nil); | 195 trackingAreaDropdown_.reset(nil); |
| 196 } | 196 } |
| 197 | 197 |
| 198 // Use two distinct tracking rects for left and right parts. | 198 // Use two distinct tracking rects for left and right parts. |
| 199 // The tracking areas are also used to decide how to handle clicks. They must |
| 200 // always be active, so the click is handled correctly when a download item |
| 201 // is clicked while chrome is not the active app ( http://crbug.com/21916 ). |
| 199 NSRect bounds = [[self controlView] bounds]; | 202 NSRect bounds = [[self controlView] bounds]; |
| 200 NSRect buttonRect, dropdownRect; | 203 NSRect buttonRect, dropdownRect; |
| 201 NSDivideRect(bounds, &dropdownRect, &buttonRect, | 204 NSDivideRect(bounds, &dropdownRect, &buttonRect, |
| 202 kDropdownAreaWidth, NSMaxXEdge); | 205 kDropdownAreaWidth, NSMaxXEdge); |
| 203 | 206 |
| 204 trackingAreaButton_.reset([[NSTrackingArea alloc] | 207 trackingAreaButton_.reset([[NSTrackingArea alloc] |
| 205 initWithRect:buttonRect | 208 initWithRect:buttonRect |
| 206 options:(NSTrackingMouseEnteredAndExited | | 209 options:(NSTrackingMouseEnteredAndExited | |
| 207 NSTrackingActiveInActiveApp) | 210 NSTrackingActiveAlways) |
| 208 owner:self | 211 owner:self |
| 209 userInfo:nil]); | 212 userInfo:nil]); |
| 210 [[self controlView] addTrackingArea:trackingAreaButton_.get()]; | 213 [[self controlView] addTrackingArea:trackingAreaButton_.get()]; |
| 211 | 214 |
| 212 trackingAreaDropdown_.reset([[NSTrackingArea alloc] | 215 trackingAreaDropdown_.reset([[NSTrackingArea alloc] |
| 213 initWithRect:dropdownRect | 216 initWithRect:dropdownRect |
| 214 options:(NSTrackingMouseEnteredAndExited | | 217 options:(NSTrackingMouseEnteredAndExited | |
| 215 NSTrackingActiveInActiveApp) | 218 NSTrackingActiveAlways) |
| 216 owner:self | 219 owner:self |
| 217 userInfo:nil]); | 220 userInfo:nil]); |
| 218 [[self controlView] addTrackingArea:trackingAreaDropdown_.get()]; | 221 [[self controlView] addTrackingArea:trackingAreaDropdown_.get()]; |
| 219 } | 222 } |
| 220 | 223 |
| 221 - (void)setShowsBorderOnlyWhileMouseInside:(BOOL)showOnly { | 224 - (void)setShowsBorderOnlyWhileMouseInside:(BOOL)showOnly { |
| 222 // Override to make sure it doesn't do anything if it's called accidentally. | 225 // Override to make sure it doesn't do anything if it's called accidentally. |
| 223 } | 226 } |
| 224 | 227 |
| 225 - (void)mouseEntered:(NSEvent*)theEvent { | 228 - (void)mouseEntered:(NSEvent*)theEvent { |
| 226 mouseInsideCount_++; | 229 mouseInsideCount_++; |
| 227 if ([theEvent trackingArea] == trackingAreaButton_.get()) | 230 if ([theEvent trackingArea] == trackingAreaButton_.get()) |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 } | 555 } |
| 553 return self; | 556 return self; |
| 554 } | 557 } |
| 555 | 558 |
| 556 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 559 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
| 557 [super setCurrentProgress:progress]; | 560 [super setCurrentProgress:progress]; |
| 558 [cell_ animation:self progressed:progress]; | 561 [cell_ animation:self progressed:progress]; |
| 559 } | 562 } |
| 560 | 563 |
| 561 @end | 564 @end |
| OLD | NEW |