diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 07:32:38 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 07:32:38 +0000 |
commit | ca5c4e5bd40a8f2f59c53f5a29bcde2591633ee8 (patch) | |
tree | 8082eab2dadce68986de0804e3933cd8fdb6c0cb /chrome/browser | |
parent | ce1fd4bfd4849008598d679a40ac23082e93b156 (diff) | |
download | chromium_src-ca5c4e5bd40a8f2f59c53f5a29bcde2591633ee8.zip chromium_src-ca5c4e5bd40a8f2f59c53f5a29bcde2591633ee8.tar.gz chromium_src-ca5c4e5bd40a8f2f59c53f5a29bcde2591633ee8.tar.bz2 |
Make the bookmark buttons follow theme changes correctly.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/160092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 44 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.h | 6 |
2 files changed, 36 insertions, 14 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index f4039282..7ea968a 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -89,9 +89,6 @@ static SkBitmap* kFolderIcon = NULL; // Border colors for the BookmarBarView. static const SkColor kTopBorderColor = SkColorSetRGB(222, 234, 248); -// Border color for the 'new tab' style bookmarks bar. -static const SkColor kNewtabBorderColor = SkColorSetRGB(195, 206, 224); - // How round the 'new tab' style bookmarks bar is. static const int kNewtabBarRoundness = 5; @@ -642,8 +639,10 @@ void BookmarkBarView::Paint(gfx::Canvas* canvas) { // Draw border SkPaint border_paint; - border_paint.setColor(kNewtabBorderColor); + border_paint.setColor( + GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION)); border_paint.setStyle(SkPaint::kStroke_Style); + border_paint.setAlpha(96); border_paint.setAntiAlias(true); canvas->drawRoundRect(rect, @@ -1045,7 +1044,12 @@ void BookmarkBarView::Init() { instructions_ = new views::Label( l10n_util::GetString(IDS_BOOKMARKS_NO_ITEMS), rb.GetFont(ResourceBundle::BaseFont)); - instructions_->SetColor(kInstructionsColor); + + if (GetThemeProvider()) { + instructions_->SetColor(GetThemeProvider()->GetColor( + BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); + } + AddChildView(instructions_); SetContextMenuController(this); @@ -1100,15 +1104,7 @@ void BookmarkBarView::Loaded(BookmarkModel* model) { // Create a button for each of the children on the bookmark bar. for (int i = 0, child_count = node->GetChildCount(); i < child_count; ++i) AddChildView(i, CreateBookmarkButton(node->GetChild(i))); - - // This button is normally created too early to get access to the theme - // provider, so we change its color here; this also makes color changes from - // profile swaps work. - if (GetThemeProvider()) { - other_bookmarked_button_->SetEnabledColor(GetThemeProvider()-> - GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); - } - + UpdateButtonColors(); other_bookmarked_button_->SetEnabled(true); Layout(); @@ -1155,6 +1151,7 @@ void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model, } DCHECK(index >= 0 && index <= GetBookmarkButtonCount()); AddChildView(index, CreateBookmarkButton(parent->GetChild(index))); + UpdateButtonColors(); Layout(); SchedulePaint(); } @@ -1230,6 +1227,7 @@ void BookmarkBarView::BookmarkNodeChildrenReordered(BookmarkModel* model, // Create the new buttons. for (int i = 0, child_count = node->GetChildCount(); i < child_count; ++i) AddChildView(i, CreateBookmarkButton(node->GetChild(i))); + UpdateButtonColors(); Layout(); SchedulePaint(); @@ -1489,6 +1487,10 @@ void BookmarkBarView::Observe(NotificationType type, } } +void BookmarkBarView::ThemeChanged() { + UpdateButtonColors(); +} + void BookmarkBarView::NotifyModelChanged() { if (model_changed_listener_) model_changed_listener_->ModelChanged(); @@ -1749,3 +1751,17 @@ void BookmarkBarView::StopThrobbing(bool immediate) { throbbing_view_->StartThrobbing(immediate ? 0 : 4); throbbing_view_ = NULL; } + +void BookmarkBarView::UpdateButtonColors() { + // We don't always have a theme provider (ui tests, for example). + if (GetThemeProvider()) { + for (int i = 0; i < GetBookmarkButtonCount(); i++) { + views::TextButton* button = GetBookmarkButton(i); + button->SetEnabledColor(GetThemeProvider()->GetColor( + BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); + } + other_bookmarked_button()->SetEnabledColor(GetThemeProvider()->GetColor( + BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); + } +} + diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h index f1a9b30..cac9b9f 100644 --- a/chrome/browser/views/bookmark_bar_view.h +++ b/chrome/browser/views/bookmark_bar_view.h @@ -343,6 +343,9 @@ class BookmarkBarView : public views::View, const NotificationSource& source, const NotificationDetails& details); + // Overridden from views::View. + virtual void ThemeChanged(); + // If the ModelChangedListener is non-null, ModelChanged is invoked on it. void NotifyModelChanged(); @@ -377,6 +380,9 @@ class BookmarkBarView : public views::View, // throbs. void StopThrobbing(bool immediate); + // Updates the colors for all the buttons in the bookmarks bar. + void UpdateButtonColors(); + NotificationRegistrar registrar_; Profile* profile_; |