| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "base/scoped_nsobject.h" | |
| 6 #import "chrome/browser/cocoa/tab_cell.h" | |
| 7 #import "third_party/GTM/AppKit/GTMTheme.h" | |
| 8 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" | |
| 9 | |
| 10 | |
| 11 @implementation TabCell | |
| 12 | |
| 13 - (id)initTextCell:(NSString *)aString { | |
| 14 self = [super initTextCell:aString]; | |
| 15 if (self != nil) { | |
| 16 // nothing for now... | |
| 17 } | |
| 18 return self; | |
| 19 } | |
| 20 | |
| 21 - (NSBackgroundStyle)interiorBackgroundStyle { | |
| 22 return [[[self controlView] gtm_theme] | |
| 23 interiorBackgroundStyleForStyle:GTMThemeStyleToolBar | |
| 24 state:GTMThemeStateActiveWindow]; | |
| 25 } | |
| 26 | |
| 27 // Override drawing the button so that it looks like a Chromium tab instead | |
| 28 // of just a normal MacOS button. | |
| 29 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { | |
| 30 // Inset where the text is drawn to keep it away from the sloping edges of the | |
| 31 // tab, the close box, and the icon view. These constants are derived | |
| 32 // empirically as the cell doesn't know about the surrounding view objects. | |
| 33 // TODO(pinkerton/alcor): Fix this somehow? | |
| 34 const int kIconXOffset = 28; | |
| 35 const int kCloseBoxXOffset = 21; | |
| 36 NSRect frame = NSOffsetRect(cellFrame, kIconXOffset, 0); | |
| 37 frame.size.width -= kCloseBoxXOffset + kIconXOffset; | |
| 38 [self drawInteriorWithFrame:frame | |
| 39 inView:controlView]; | |
| 40 } | |
| 41 | |
| 42 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { | |
| 43 GTMTheme* theme = [[self controlView] gtm_theme]; | |
| 44 NSColor* textColor = [theme textColorForStyle:GTMThemeStyleToolBar | |
| 45 state:[self isHighlighted]]; | |
| 46 | |
| 47 scoped_nsobject<NSShadow> textShadow([[NSShadow alloc] init]); | |
| 48 [textShadow setShadowBlurRadius:0.0f]; | |
| 49 [textShadow.get() setShadowColor:[textColor gtm_legibleTextColor]]; | |
| 50 [textShadow.get() setShadowOffset:NSMakeSize(0.0f, -1.0f)]; | |
| 51 | |
| 52 NSDictionary* attributes = | |
| 53 [NSDictionary dictionaryWithObjectsAndKeys: | |
| 54 [self font], NSFontAttributeName, | |
| 55 textColor, NSForegroundColorAttributeName, | |
| 56 textShadow.get(), NSShadowAttributeName, | |
| 57 nil]; | |
| 58 | |
| 59 [[self title] drawInRect:[self titleRectForBounds:cellFrame] | |
| 60 withAttributes:attributes]; | |
| 61 | |
| 62 NSRect imageBounds = NSZeroRect; | |
| 63 imageBounds.size = [[self image] size]; | |
| 64 [[self image] drawInRect:[self imageRectForBounds:cellFrame] | |
| 65 fromRect:imageBounds | |
| 66 operation:NSCompositeSourceOver | |
| 67 fraction:1.0]; | |
| 68 } | |
| 69 | |
| 70 - (void)highlight:(BOOL)flag | |
| 71 withFrame:(NSRect)cellFrame | |
| 72 inView:(NSView *)controlView { | |
| 73 // Don't do normal highlighting | |
| 74 } | |
| 75 | |
| 76 @end | |
| OLD | NEW |