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

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

Issue 165499: Updates to clean up default theme and add hover states (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 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) 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 "base/scoped_nsobject.h"
5 #import "chrome/browser/cocoa/tab_cell.h" 6 #import "chrome/browser/cocoa/tab_cell.h"
6 #import "third_party/GTM/AppKit/GTMTheme.h" 7 #import "third_party/GTM/AppKit/GTMTheme.h"
7 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" 8 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h"
8 9
10
9 @implementation TabCell 11 @implementation TabCell
10 12
11 - (id)initTextCell:(NSString *)aString { 13 - (id)initTextCell:(NSString *)aString {
12 self = [super initTextCell:aString]; 14 self = [super initTextCell:aString];
13 if (self != nil) { 15 if (self != nil) {
14 // nothing for now... 16 // nothing for now...
15 } 17 }
16 return self; 18 return self;
17 } 19 }
18 20
19 - (NSBackgroundStyle)interiorBackgroundStyle { 21 - (NSBackgroundStyle)interiorBackgroundStyle {
20 return [[[self controlView] gtm_theme] 22 return [[[self controlView] gtm_theme]
21 interiorBackgroundStyleForStyle:GTMThemeStyleTabBarSelected 23 interiorBackgroundStyleForStyle:GTMThemeStyleToolBar
22 state:GTMThemeStateActiveWindow]; 24 state:GTMThemeStateActiveWindow];
23 } 25 }
24 26
25 // Override drawing the button so that it looks like a Chromium tab instead 27 // Override drawing the button so that it looks like a Chromium tab instead
26 // of just a normal MacOS button. 28 // of just a normal MacOS button.
27 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { 29 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
28 // Inset where the text is drawn to keep it away from the sloping edges of the 30 // Inset where the text is drawn to keep it away from the sloping edges of the
29 // tab, the close box, and the icon view. These constants are derived 31 // tab, the close box, and the icon view. These constants are derived
30 // empirically as the cell doesn't know about the surrounding view objects. 32 // empirically as the cell doesn't know about the surrounding view objects.
31 // TODO(pinkerton/alcor): Fix this somehow? 33 // TODO(pinkerton/alcor): Fix this somehow?
32 const int kIconXOffset = 28; 34 const int kIconXOffset = 28;
33 const int kCloseBoxXOffset = 21; 35 const int kCloseBoxXOffset = 21;
34 NSRect frame = NSOffsetRect(cellFrame, kIconXOffset, 0); 36 NSRect frame = NSOffsetRect(cellFrame, kIconXOffset, 0);
35 frame.size.width -= kCloseBoxXOffset + kIconXOffset; 37 frame.size.width -= kCloseBoxXOffset + kIconXOffset;
36 [self drawInteriorWithFrame:frame 38 [self drawInteriorWithFrame:frame
37 inView:controlView]; 39 inView:controlView];
38 } 40 }
39 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 setShadowColor:[textColor gtm_legibleTextColor]];
50 [textShadow 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
40 - (void)highlight:(BOOL)flag 70 - (void)highlight:(BOOL)flag
41 withFrame:(NSRect)cellFrame 71 withFrame:(NSRect)cellFrame
42 inView:(NSView *)controlView { 72 inView:(NSView *)controlView {
43 // Don't do normal highlighting 73 // Don't do normal highlighting
44 } 74 }
45 75
46 @end 76 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/status_bubble_mac_unittest.mm ('k') | chrome/browser/cocoa/tab_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698