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

Unified Diff: chrome/browser/cocoa/tab_controller.mm

Issue 260009: Several background pattern fixes on the Mac.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/tab_controller.h ('k') | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/tab_controller.mm
===================================================================
--- chrome/browser/cocoa/tab_controller.mm (revision 28537)
+++ chrome/browser/cocoa/tab_controller.mm (working copy)
@@ -33,11 +33,15 @@
self = [super initWithNibName:@"TabView" bundle:mac_util::MainAppBundle()];
if (self != nil) {
isIconShowing_ = YES;
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(viewResized:)
- name:NSViewFrameDidChangeNotification
- object:[self view]];
+ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
+ [defaultCenter addObserver:self
+ selector:@selector(viewResized:)
+ name:NSViewFrameDidChangeNotification
+ object:[self view]];
+ [defaultCenter addObserver:self
+ selector:@selector(themeChangedNotification:)
+ name:kGTMThemeDidChangeNotification
+ object:nil];
}
return self;
}
@@ -52,9 +56,10 @@
// mark ourselves as needing a redraw.
- (void)internalSetSelected:(BOOL)selected {
selected_ = selected;
- [(TabView *)[self view] setState:selected];
+ TabView* tabView = static_cast<TabView*>([self view]);
+ [tabView setState:selected];
[self updateVisibility];
- [self applyTheme];
+ [self updateTitleColor];
}
// Called when the tab's nib is done loading and all outlets are hooked up.
@@ -71,9 +76,6 @@
iconTitleXOffset_ = NSMinX(titleFrame) - NSMinX(originalIconFrame_);
titleCloseWidthOffset_ = NSMaxX([closeButton_ frame]) - NSMaxX(titleFrame);
- // Ensure we don't show favicon if the tab is already too small to begin with.
- [self updateVisibility];
-
[self internalSetSelected:selected_];
}
@@ -100,7 +102,7 @@
return [[self target] isCommandEnabled:command forController:self];
}
-- (void)setTitle:(NSString *)title {
+- (void)setTitle:(NSString*)title {
[[self view] setToolTip:title];
[super setTitle:title];
}
@@ -131,7 +133,7 @@
return iconView_;
}
-- (NSString *)toolTip {
+- (NSString*)toolTip {
return [[self view] toolTip];
}
@@ -212,6 +214,21 @@
[titleView_ setFrame:titleFrame];
}
+- (void)updateTitleColor {
+ NSColor* titleColor = nil;
+ GTMTheme* theme = [[self view] gtm_theme];
+ if (![self selected]) {
+ titleColor = [theme textColorForStyle:GTMThemeStyleTabBarDeselected
+ state:GTMThemeStateActiveWindow];
+ }
+ // Default to the selected text color unless told otherwise.
+ if (!titleColor) {
+ titleColor = [theme textColorForStyle:GTMThemeStyleTabBarSelected
+ state:GTMThemeStateActiveWindow];
+ }
+ [titleView_ setTextColor:titleColor ? titleColor : [NSColor textColor]];
+}
+
// Called when our view is resized. If it gets too small, start by hiding
// the close button and only show it if tab is selected. Eventually, hide the
// icon as well. We know that this is for our view because we only registered
@@ -220,21 +237,12 @@
[self updateVisibility];
}
-- (void)applyTheme {
- GTMTheme* theme = [[self view] gtm_theme];
- NSColor* color = nil;
- if (!selected_) {
- color = [theme textColorForStyle:GTMThemeStyleTabBarDeselected
- state:GTMThemeStateActiveWindow];
+- (void)themeChangedNotification:(NSNotification*)notification {
+ GTMTheme* theme = [notification object];
+ NSView* view = [self view];
+ if ([theme isEqual:[view gtm_theme]]) {
+ [self updateTitleColor];
}
- // Default to the selected text color unless told otherwise.
- if (!color) {
- color = [theme textColorForStyle:GTMThemeStyleToolBar
- state:GTMThemeStateActiveWindow];
- }
-
- [titleView_ setTextColor:color ? color : [NSColor textColor]];
- [[self view] setNeedsDisplay:YES];
}
// Called by the tabs to determine whether we are in rapid (tab) closure mode.
« no previous file with comments | « chrome/browser/cocoa/tab_controller.h ('k') | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698