Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/cocoa/download_item_cell.mm

Issue 371060: Mac: Make download items less annoying by handling clicks more correctly. (Closed)
Patch Set: add comment, fix layout-o Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698