summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 02:31:20 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 02:31:20 +0000
commit198d0468712f48b7d02a5366cfa03989061ed147 (patch)
treef5e9166965cfaafba50f9532ab1049147c7b9710
parent6e853c3ad131fe6713ce8efbac2270fee26ab5b2 (diff)
downloadchromium_src-198d0468712f48b7d02a5366cfa03989061ed147.zip
chromium_src-198d0468712f48b7d02a5366cfa03989061ed147.tar.gz
chromium_src-198d0468712f48b7d02a5366cfa03989061ed147.tar.bz2
Reland of r17500:
Theme our bookmark bar buttons. BUG=12467 TEST=Apply a theme and verify that bookmark bar text colors changes. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17587 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc21
-rw-r--r--views/controls/button/text_button.cc27
-rw-r--r--views/controls/button/text_button.h12
3 files changed, 54 insertions, 6 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index f151625..ba966593 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -381,11 +381,10 @@ BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser)
Init();
SetProfile(profile);
- if (IsAlwaysShown()) {
+ if (IsAlwaysShown())
size_animation_->Reset(1);
- } else {
+ else
size_animation_->Reset(0);
- }
}
BookmarkBarView::~BookmarkBarView() {
@@ -935,6 +934,15 @@ void BookmarkBarView::Loaded(BookmarkModel* model) {
// Create a button for each of the children on the bookmark bar.
for (int i = 0; i < node->GetChildCount(); ++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));
+ }
+
other_bookmarked_button_->SetEnabled(true);
Layout();
@@ -1248,6 +1256,13 @@ views::View* BookmarkBarView::CreateBookmarkButton(BookmarkNode* node) {
void BookmarkBarView::ConfigureButton(BookmarkNode* node,
views::TextButton* button) {
button->SetText(node->GetTitle());
+
+ // We don't always have a theme provider (ui tests, for example).
+ if (GetThemeProvider()) {
+ button->SetEnabledColor(GetThemeProvider()->GetColor(
+ BrowserThemeProvider::COLOR_BOOKMARK_TEXT));
+ }
+
button->ClearMaxTextSize();
button->SetContextMenuController(this);
button->SetDragController(this);
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index e468e9e..cc8eb08 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -156,6 +156,9 @@ TextButton::TextButton(ButtonListener* listener, const std::wstring& text)
font_(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::BaseFont)),
color_(kEnabledColor),
+ color_enabled_(kEnabledColor),
+ color_disabled_(kDisabledColor),
+ color_highlight_(kHighlightColor),
max_width_(0) {
SetText(text);
set_border(new TextButtonBorder);
@@ -178,6 +181,20 @@ void TextButton::SetIcon(const SkBitmap& icon) {
icon_ = icon;
}
+void TextButton::SetEnabledColor(SkColor color) {
+ color_enabled_ = color;
+ UpdateColor();
+}
+
+void TextButton::SetDisabledColor(SkColor color) {
+ color_disabled_ = color;
+ UpdateColor();
+}
+
+void TextButton::SetHighlightColor(SkColor color) {
+ color_highlight_ = color;
+}
+
void TextButton::ClearMaxTextSize() {
max_text_size_ = text_size_;
}
@@ -245,7 +262,7 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
#if defined(OS_WIN)
// TODO(erg): Either port DrawStringWithHalo to linux or find an
// alternative here.
- canvas->DrawStringWithHalo(text_, font_, color_, kHighlightColor,
+ canvas->DrawStringWithHalo(text_, font_, color_, color_highlight_,
text_bounds.x(),
text_bounds.y(),
text_bounds.width(),
@@ -256,7 +273,7 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
// Draw bevel highlight
canvas->DrawStringInt(text_,
font_,
- kHighlightColor,
+ color_highlight_,
text_bounds.x() + 1,
text_bounds.y() + 1,
text_bounds.width(),
@@ -282,6 +299,10 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
}
}
+void TextButton::UpdateColor() {
+ color_ = IsEnabled() ? color_enabled_ : color_disabled_;
+}
+
////////////////////////////////////////////////////////////////////////////////
// TextButton, View overrides:
@@ -310,7 +331,7 @@ void TextButton::SetEnabled(bool enabled) {
if (enabled == IsEnabled())
return;
CustomButton::SetEnabled(enabled);
- color_ = enabled ? kEnabledColor : kDisabledColor;
+ UpdateColor();
SchedulePaint();
}
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index 1a8134e..e18ef59 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -89,6 +89,9 @@ class TextButton : public CustomButton {
void ClearMaxTextSize();
void set_max_width(int max_width) { max_width_ = max_width; }
+ void SetEnabledColor(SkColor color);
+ void SetDisabledColor(SkColor color);
+ void SetHighlightColor(SkColor color);
// Paint the button into the specified canvas. If |for_drag| is true, the
// function paints a drag image representation into the canvas.
@@ -103,6 +106,10 @@ class TextButton : public CustomButton {
virtual bool OnMousePressed(const MouseEvent& e);
virtual void Paint(gfx::Canvas* canvas);
+ // Called when enabled or disabled state changes, or the colors for those
+ // states change.
+ virtual void UpdateColor();
+
private:
// The text string that is displayed in the button.
std::wstring text_;
@@ -123,6 +130,11 @@ class TextButton : public CustomButton {
// Text color.
SkColor color_;
+ // State colors.
+ SkColor color_enabled_;
+ SkColor color_disabled_;
+ SkColor color_highlight_;
+
// An icon displayed with the text.
SkBitmap icon_;