diff options
author | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 17:24:00 +0000 |
---|---|---|
committer | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 17:24:00 +0000 |
commit | 99afaa77ff54c0ce39b6e3032a362aeade8aac4f (patch) | |
tree | be480bc954d52396408fec468f01766786a2ecab | |
parent | d0af0e41aa9f536bc9bc47872117eb65979cd015 (diff) | |
download | chromium_src-99afaa77ff54c0ce39b6e3032a362aeade8aac4f.zip chromium_src-99afaa77ff54c0ce39b6e3032a362aeade8aac4f.tar.gz chromium_src-99afaa77ff54c0ce39b6e3032a362aeade8aac4f.tar.bz2 |
Revert 43041 - Remove the themeing from the folder menu background, text in the folder menu items, and no longer needed calls.
I found an easier, simpler change.
BUG=39428
TEST=Pop up a folder menu and insure that the background does not adopt any theme settings.
Review URL: http://codereview.chromium.org/1548003
TBR=mrossetti@chromium.org
Review URL: http://codereview.chromium.org/1596001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43096 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 54 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_folder_controller.mm b/chrome/browser/cocoa/bookmark_bar_folder_controller.mm index c525e88..c334ff8 100644 --- a/chrome/browser/cocoa/bookmark_bar_folder_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_folder_controller.mm @@ -49,6 +49,14 @@ const CGFloat kBookmarkBarFolderScrollAmount = parentController_.reset([controller retain]); buttons_.reset([[NSMutableArray alloc] init]); folderTarget_.reset([[BookmarkFolderTarget alloc] initWithController:self]); + + // Register for theme changes. + NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; + [defaultCenter addObserver:self + selector:@selector(themeDidChangeNotification:) + name:kBrowserThemeDidChangeNotification + object:nil]; + [self configureWindow]; [self addScrollTracking]; } @@ -73,6 +81,26 @@ const CGFloat kBookmarkBarFolderScrollAmount = [super showWindow:sender]; } +// Update theme information for all our buttons. +- (void)updateTheme:(ThemeProvider*)themeProvider { + if (!themeProvider) + return; + NSColor* color = + themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + true); + for (BookmarkButton* button in buttons_.get()) { + BookmarkButtonCell* cell = [button cell]; + [cell setTextColor:color]; + } +} + +// Called after the current theme has changed. +- (void)themeDidChangeNotification:(NSNotification*)aNotification { + ThemeProvider* themeProvider = + static_cast<ThemeProvider*>([[aNotification object] pointerValue]); + [self updateTheme:themeProvider]; +} + // Redirect bookmark button cell creation to our parent to allow a // single implementation. - (NSCell*)cellForBookmarkNode:(const BookmarkNode*)child { @@ -239,6 +267,7 @@ const CGFloat kBookmarkBarFolderScrollAmount = buttonsOuterFrame.origin.y -= bookmarks::kBookmarkBarHeight; } } + [self updateTheme:[self themeProvider]]; // Now that we have all our buttons we can determine the real size // of our window. @@ -386,7 +415,6 @@ const CGFloat kBookmarkBarFolderScrollAmount = } - (ThemeProvider*)themeProvider { - // Note that the theme is ignored for the menu and its buttons. return [parentController_ themeProvider]; } diff --git a/chrome/browser/cocoa/bookmark_bar_folder_view.h b/chrome/browser/cocoa/bookmark_bar_folder_view.h index d100425..a8fe85b 100644 --- a/chrome/browser/cocoa/bookmark_bar_folder_view.h +++ b/chrome/browser/cocoa/bookmark_bar_folder_view.h @@ -9,7 +9,7 @@ // Main content view for a bookmark bar folder "menu" window. This is // logically similar to a BookmarkBarView but is oriented vertically. -@interface BookmarkBarFolderView : NSView { +@interface BookmarkBarFolderView : BackgroundGradientView { @private BOOL inDrag_; // Are we in the middle of a drag? BOOL dropIndicatorShown_; diff --git a/chrome/browser/cocoa/bookmark_bar_folder_view.mm b/chrome/browser/cocoa/bookmark_bar_folder_view.mm index cbbd5a2..9ede01b 100644 --- a/chrome/browser/cocoa/bookmark_bar_folder_view.mm +++ b/chrome/browser/cocoa/bookmark_bar_folder_view.mm @@ -4,6 +4,7 @@ #import "chrome/browser/cocoa/bookmark_bar_folder_view.h" +#import "chrome/browser/browser_theme_provider.h" #import "chrome/browser/cocoa/bookmark_bar_controller.h" @implementation BookmarkBarFolderView @@ -13,6 +14,12 @@ } - (void)awakeFromNib { + [super awakeFromNib]; + + // BackgroundGradientView's awakeFromNib does a |showsDivider_ = YES|. + // Make sure we turn it off. + [self setShowsDivider:NO]; + NSArray* types = [NSArray arrayWithObject:kBookmarkButtonDragType]; [self registerForDraggedTypes:types]; } @@ -23,6 +30,8 @@ } - (void)drawRect:(NSRect)rect { + [self drawBackground]; + // TODO(jrg): copied from bookmark_bar_view but orientation changed. // Code dup sucks but I'm not sure I can take 16 lines and make it // generic for horiz vs vertical while keeping things simple. @@ -40,9 +49,14 @@ NSMakeRect(kBarHorizPad, dropIndicatorPosition_, NSWidth([self bounds]) - 2*kBarHorizPad, kBarHeight); - NSColor* uglyBlackBarColor = [NSColor blackColor]; - [[uglyBlackBarColor colorWithAlphaComponent:kBarOpacity] setFill]; - [[NSBezierPath bezierPathWithRect:uglyBlackBar] fill]; + // themeProvider is nil in unit tests. + ThemeProvider* themeProvider = [[self controller] themeProvider]; + if (themeProvider) { + NSColor* uglyBlackBarColor = themeProvider-> + GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, true); + [[uglyBlackBarColor colorWithAlphaComponent:kBarOpacity] setFill]; + [[NSBezierPath bezierPathWithRect:uglyBlackBar] fill]; + } } } diff --git a/chrome/browser/cocoa/bookmark_bar_folder_view_unittest.mm b/chrome/browser/cocoa/bookmark_bar_folder_view_unittest.mm index 27e7d98..2cf339e 100644 --- a/chrome/browser/cocoa/bookmark_bar_folder_view_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_folder_view_unittest.mm @@ -132,6 +132,9 @@ TEST_F(BookmarkBarFolderViewTest, Basics) { [view_ awakeFromNib]; [[test_window() contentView] addSubview:view_]; + // Confirm an assumption made in our awakeFromNib + EXPECT_FALSE([view_ showsDivider]); + // Make sure we're set up for DnD NSArray* types = [view_ registeredDraggedTypes]; EXPECT_TRUE([types containsObject:kBookmarkButtonDragType]); diff --git a/chrome/browser/cocoa/bookmark_bar_folder_window.mm b/chrome/browser/cocoa/bookmark_bar_folder_window.mm index 8c2a56d..9d056f5 100644 --- a/chrome/browser/cocoa/bookmark_bar_folder_window.mm +++ b/chrome/browser/cocoa/bookmark_bar_folder_window.mm @@ -19,4 +19,8 @@ defer:deferCreation]; } +- (ThemeProvider*)themeProvider { + return [[self windowController] themeProvider]; +} + @end |