summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 14:54:27 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 14:54:27 +0000
commitb255f7504155f2aefff31fb3003b1b8a5a40f0c9 (patch)
treecf0bf2590b9ce80a8bf79d242da4ef990ce68d57 /chrome/browser
parent60c671ca9dc52bb7c6a0bac0773d526d9060e87a (diff)
downloadchromium_src-b255f7504155f2aefff31fb3003b1b8a5a40f0c9.zip
chromium_src-b255f7504155f2aefff31fb3003b1b8a5a40f0c9.tar.gz
chromium_src-b255f7504155f2aefff31fb3003b1b8a5a40f0c9.tar.bz2
Final tweaks to download item look on OS X. It now looks pretty much like on windows and linux, but is drawn nearly completely with vectors.
Also fix the SkColor->NSColor conversion in the mac theme provider. Also let status bubble text color be influenced by current theme. BUG=18902,18438 TEST=Download items now look like on windows. Color of the main download item text should change with the theme. Also, the status bubble text now adapts to the theme, and themes that specify text colors can now successfully change the color of e.g. the text in tabs. Also check that the status text ("104.0/110 MB, 1 h 45 secs left") is elided at the right when it's too long. Review URL: http://codereview.chromium.org/192033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_theme_provider_mac.mm10
-rw-r--r--chrome/browser/cocoa/download_item_cell.mm79
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm2
-rw-r--r--chrome/browser/cocoa/status_bubble_mac.mm1
4 files changed, 70 insertions, 22 deletions
diff --git a/chrome/browser/browser_theme_provider_mac.mm b/chrome/browser/browser_theme_provider_mac.mm
index 45bebc8..063ec25 100644
--- a/chrome/browser/browser_theme_provider_mac.mm
+++ b/chrome/browser/browser_theme_provider_mac.mm
@@ -79,10 +79,12 @@ NSColor* BrowserThemeProvider::GetNSColor(int id) {
if (color_iter != colors_.end()) {
const SkColor& sk_color = color_iter->second;
- NSColor* color = [NSColor colorWithCalibratedRed:SkColorGetR(sk_color)
- green:SkColorGetG(sk_color)
- blue:SkColorGetB(sk_color)
- alpha:SkColorGetA(sk_color)];
+
+ NSColor* color = [NSColor
+ colorWithCalibratedRed:SkColorGetR(sk_color)/255.0
+ green:SkColorGetG(sk_color)/255.0
+ blue:SkColorGetB(sk_color)/255.0
+ alpha:SkColorGetA(sk_color)/255.0];
// We loaded successfully. Cache the color.
if (color) {
diff --git a/chrome/browser/cocoa/download_item_cell.mm b/chrome/browser/cocoa/download_item_cell.mm
index 3890807..d5758ca 100644
--- a/chrome/browser/cocoa/download_item_cell.mm
+++ b/chrome/browser/cocoa/download_item_cell.mm
@@ -21,7 +21,7 @@ namespace {
const CGFloat kImagePaddingTop = 7;
// Distance from left border to icon
-const CGFloat kImagePaddingLeft = 8;
+const CGFloat kImagePaddingLeft = 9;
// Width of icon
const CGFloat kImageWidth = 16;
@@ -38,14 +38,17 @@ const CGFloat kTextPaddingRight = 3;
// y coordinate of download name string, in view coords, when status message
// is visible
-const CGFloat kPrimaryTextPosTop = 5;
+const CGFloat kPrimaryTextPosTop = 3;
// y coordinate of download name string, in view coords, when status message
// is not visible
const CGFloat kPrimaryTextOnlyPosTop = 10;
// y coordinate of status message, in view coords
-const CGFloat kSecondaryTextPosTop = 17;
+const CGFloat kSecondaryTextPosTop = 18;
+
+// Grey value of status text
+const CGFloat kSecondaryTextColor = 0.5;
// Width of dropdown area on the right (includes 1px for the border on each
// side).
@@ -57,6 +60,9 @@ const CGFloat kDropdownArrowWidth = 5;
// Height of dropdown arrow
const CGFloat kDropdownArrowHeight = 3;
+// Vertical displacement of dropdown area, relative to the "centered" position.
+const CGFloat kDropdownAreaY = -2;
+
// Duration of the two-lines-to-one-line animation, in seconds
NSTimeInterval kHideStatusDuration = 0.3;
@@ -79,6 +85,8 @@ const int kCompleteAnimationDuration = 2.5;
- (void)hideSecondaryTitle;
- (void)animation:(NSAnimation*)animation
progressed:(NSAnimationProgress)progress;
+- (NSString*)elideTitle:(int)availableWidth;
+- (NSString*)elideStatus:(int)availableWidth;
@end
@implementation DownloadItemCell
@@ -94,7 +102,7 @@ const int kCompleteAnimationDuration = 2.5;
[self setFont:[NSFont systemFontOfSize:
[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
[self setSecondaryFont:[NSFont systemFontOfSize:
- [NSFont systemFontSizeForControlSize:NSMiniControlSize]]];
+ [NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
[self updateTrackingAreas:self];
[[NSNotificationCenter defaultCenter]
@@ -285,19 +293,29 @@ const int kCompleteAnimationDuration = 2.5;
toPoint:topLeft
radius:radius];
[path lineToPoint:topLeft];
- [path closePath]; // Right path is closed
return path;
}
-- (void)elideTitle:(int)availableWidth {
+- (NSString*)elideTitle:(int)availableWidth {
NSFont* font = [self font];
gfx::Font font_chr =
gfx::Font::CreateFont(base::SysNSStringToWide([font fontName]),
[font pointSize]);
- NSString* titleString = base::SysWideToNSString(
+ return base::SysWideToNSString(
ElideFilename(downloadPath_, font_chr, availableWidth));
- [self setTitle:titleString];
+}
+
+- (NSString*)elideStatus:(int)availableWidth {
+ NSFont* font = [self secondaryFont];
+ gfx::Font font_chr =
+ gfx::Font::CreateFont(base::SysNSStringToWide([font fontName]),
+ [font pointSize]);
+
+ return base::SysWideToNSString(ElideText(
+ base::SysNSStringToWide([self secondaryTitle]),
+ font_chr,
+ availableWidth));
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
@@ -354,11 +372,16 @@ const int kCompleteAnimationDuration = 2.5;
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
// Draw title
- [self elideTitle:cellFrame.size.width -
- (kTextPosLeft + kTextPaddingRight + kDropdownAreaWidth)];
+ CGFloat textWidth = cellFrame.size.width -
+ (kTextPosLeft + kTextPaddingRight + kDropdownAreaWidth);
+ [self setTitle:[self elideTitle:textWidth]];
+
+ NSColor* themeTextColor = [[[self controlView] gtm_theme]
+ textColorForStyle:GTMThemeStyleBookmarksBarButton
+ state:GTMThemeStateActiveWindow];
NSColor* color = [self isButtonPartPressed]
- ? [NSColor alternateSelectedControlTextColor] : [NSColor textColor];
+ ? [NSColor alternateSelectedControlTextColor] : themeTextColor;
NSString* primaryText = [self title];
NSDictionary* primaryTextAttributes = [NSDictionary
@@ -374,8 +397,9 @@ const int kCompleteAnimationDuration = 2.5;
// Draw secondary title, if any
if ([self secondaryTitle] != nil && statusAlpha_ > 0) {
- NSString* secondaryText = [self secondaryTitle];
- NSColor* secondaryColor = [color colorWithAlphaComponent:statusAlpha_];
+ NSString* secondaryText = [self elideStatus:textWidth];
+ NSColor* secondaryColor = [NSColor colorWithDeviceWhite:kSecondaryTextColor
+ alpha:statusAlpha_];
NSDictionary* secondaryTextAttributes = [NSDictionary
dictionaryWithObjectsAndKeys:
secondaryColor, NSForegroundColorAttributeName,
@@ -430,25 +454,46 @@ const int kCompleteAnimationDuration = 2.5;
operation:NSCompositeSourceOver
fraction:[self isEnabled] ? 1.0 : 0.5];
+ // Separator between button and popup parts
+ CGFloat lx = NSMaxX(cellFrame) - kDropdownAreaWidth + 0.5;
+ [[NSColor colorWithDeviceWhite:0.0 alpha:0.1] set];
+ [NSBezierPath strokeLineFromPoint:NSMakePoint(lx, NSMinY(cellFrame) + 1)
+ toPoint:NSMakePoint(lx, NSMaxY(cellFrame) - 1)];
+ [[NSColor colorWithDeviceWhite:1.0 alpha:0.1] set];
+ [NSBezierPath strokeLineFromPoint:NSMakePoint(lx + 1, NSMinY(cellFrame) + 1)
+ toPoint:NSMakePoint(lx + 1, NSMaxY(cellFrame) - 1)];
+
// Popup arrow. Put center of mass of the arrow in the center of the
// dropdown area.
CGFloat cx = NSMaxX(cellFrame) - kDropdownAreaWidth/2 + 0.5;
CGFloat cy = NSMidY(cellFrame);
NSPoint p1 = NSMakePoint(cx - kDropdownArrowWidth/2,
- cy - kDropdownArrowHeight/3);
+ cy - kDropdownArrowHeight/3 + kDropdownAreaY);
NSPoint p2 = NSMakePoint(cx + kDropdownArrowWidth/2,
- cy - kDropdownArrowHeight/3);
- NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3);
+ cy - kDropdownArrowHeight/3 + kDropdownAreaY);
+ NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3 + kDropdownAreaY);
NSBezierPath *triangle = [NSBezierPath bezierPath];
[triangle moveToPoint:p1];
[triangle lineToPoint:p2];
[triangle lineToPoint:p3];
[triangle closePath];
+ NSGraphicsContext* context = [NSGraphicsContext currentContext];
+ [context saveGraphicsState];
+
+ scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
+ [shadow setShadowColor:[NSColor whiteColor]];
+ [shadow setShadowOffset:NSMakeSize(0, -1)];
+ [shadow setShadowBlurRadius:0.0];
+ [shadow set];
+
NSColor* fill = [self isDropdownPartPressed]
- ? [NSColor alternateSelectedControlTextColor] : [NSColor textColor];
+ ? [NSColor alternateSelectedControlTextColor] : themeTextColor;
[fill setFill];
+
[triangle fill];
+
+ [context restoreGraphicsState];
}
- (NSRect)imageRectForBounds:(NSRect)cellFrame {
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index 16fc0c7..cab11ae 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -23,7 +23,7 @@ namespace {
const size_t kMaxDownloadItemCount = 16;
// Horizontal padding between two download items.
-const int kDownloadItemPadding = 2;
+const int kDownloadItemPadding = 0;
// Duration for the open-new-leftmost-item animation, in seconds.
const NSTimeInterval kDownloadItemOpenDuration = 0.8;
diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm
index 3a3dc68..2db160f 100644
--- a/chrome/browser/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/cocoa/status_bubble_mac.mm
@@ -355,6 +355,7 @@ void StatusBubbleMac::FadeOut() {
[textShadow setShadowOffset:NSMakeSize(0.0f, -1.0f)];
NSDictionary* textDict = [NSDictionary dictionaryWithObjectsAndKeys:
+ textColor, NSForegroundColorAttributeName,
textFont, NSFontAttributeName,
textShadow, NSShadowAttributeName,
nil];