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

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

Issue 10545050: mac: Use NSWidth() and friends in a few more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 8 years, 6 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/cocoa/download/download_item_cell.h" 5 #import "chrome/browser/ui/cocoa/download/download_item_cell.h"
6 6
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/download/download_item_model.h" 8 #include "chrome/browser/download/download_item_model.h"
9 #include "chrome/browser/download/download_util.h" 9 #include "chrome/browser/download/download_util.h"
10 #import "chrome/browser/themes/theme_service.h" 10 #import "chrome/browser/themes/theme_service.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, 383 themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT,
384 true); 384 true);
385 return [self pressedWithDefaultThemeOnPart:part] 385 return [self pressedWithDefaultThemeOnPart:part]
386 ? [NSColor alternateSelectedControlTextColor] : themeTextColor; 386 ? [NSColor alternateSelectedControlTextColor] : themeTextColor;
387 } 387 }
388 388
389 - (void)drawSecondaryTitleInRect:(NSRect)innerFrame { 389 - (void)drawSecondaryTitleInRect:(NSRect)innerFrame {
390 if (![self secondaryTitle] || statusAlpha_ <= 0) 390 if (![self secondaryTitle] || statusAlpha_ <= 0)
391 return; 391 return;
392 392
393 CGFloat textWidth = innerFrame.size.width - 393 CGFloat textWidth = NSWidth(innerFrame) -
394 (kTextPosLeft + kTextPaddingRight + kDropdownAreaWidth); 394 (kTextPosLeft + kTextPaddingRight + kDropdownAreaWidth);
395 NSString* secondaryText = [self elideStatus:textWidth]; 395 NSString* secondaryText = [self elideStatus:textWidth];
396 NSColor* secondaryColor = 396 NSColor* secondaryColor =
397 [self titleColorForPart:kDownloadItemMouseOverButtonPart]; 397 [self titleColorForPart:kDownloadItemMouseOverButtonPart];
398 398
399 // If text is light-on-dark, lightening it alone will do nothing. 399 // If text is light-on-dark, lightening it alone will do nothing.
400 // Therefore we mute luminance a wee bit before drawing in this case. 400 // Therefore we mute luminance a wee bit before drawing in this case.
401 if (![secondaryColor gtm_isDarkColor]) 401 if (![secondaryColor gtm_isDarkColor])
402 secondaryColor = [secondaryColor gtm_colorByAdjustingLuminance:-0.2]; 402 secondaryColor = [secondaryColor gtm_colorByAdjustingLuminance:-0.2];
403 403
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 [self drawInteriorWithFrame:innerFrame inView:controlView]; 485 [self drawInteriorWithFrame:innerFrame inView:controlView];
486 486
487 // For the default theme, draw the status text on top of the (opaque) button 487 // For the default theme, draw the status text on top of the (opaque) button
488 // gradient. 488 // gradient.
489 if (drawStatusOnTop) 489 if (drawStatusOnTop)
490 [self drawSecondaryTitleInRect:innerFrame]; 490 [self drawSecondaryTitleInRect:innerFrame];
491 } 491 }
492 492
493 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 493 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
494 // Draw title 494 // Draw title
495 CGFloat textWidth = cellFrame.size.width - 495 CGFloat textWidth = NSWidth(cellFrame) -
496 (kTextPosLeft + kTextPaddingRight + kDropdownAreaWidth); 496 (kTextPosLeft + kTextPaddingRight + kDropdownAreaWidth);
497 [self setTitle:[self elideTitle:textWidth]]; 497 [self setTitle:[self elideTitle:textWidth]];
498 498
499 NSColor* color = [self titleColorForPart:kDownloadItemMouseOverButtonPart]; 499 NSColor* color = [self titleColorForPart:kDownloadItemMouseOverButtonPart];
500 NSString* primaryText = [self title]; 500 NSString* primaryText = [self title];
501 501
502 NSDictionary* primaryTextAttributes = 502 NSDictionary* primaryTextAttributes =
503 [NSDictionary dictionaryWithObjectsAndKeys: 503 [NSDictionary dictionaryWithObjectsAndKeys:
504 color, NSForegroundColorAttributeName, 504 color, NSForegroundColorAttributeName,
505 [self font], NSFontAttributeName, 505 [self font], NSFontAttributeName,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } 686 }
687 return self; 687 return self;
688 } 688 }
689 689
690 - (void)setCurrentProgress:(NSAnimationProgress)progress { 690 - (void)setCurrentProgress:(NSAnimationProgress)progress {
691 [super setCurrentProgress:progress]; 691 [super setCurrentProgress:progress];
692 [cell_ animation:self progressed:progress]; 692 [cell_ animation:self progressed:progress];
693 } 693 }
694 694
695 @end 695 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/dock_icon.mm ('k') | chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698