summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvarkha <varkha@chromium.org>2015-10-21 16:39:15 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-21 23:41:50 +0000
commit70dd5863813a50a6f0ba47e0ef3ae6b89cb802e8 (patch)
tree78a00bc88965c00192f3a5c644f754885696360b
parentfc6c19336079e27e6fbf194076723c9acfada681 (diff)
downloadchromium_src-70dd5863813a50a6f0ba47e0ef3ae6b89cb802e8.zip
chromium_src-70dd5863813a50a6f0ba47e0ef3ae6b89cb802e8.tar.gz
chromium_src-70dd5863813a50a6f0ba47e0ef3ae6b89cb802e8.tar.bz2
Uses theme's bookmark text color for all states
This CL adds an API to LabelButton that sets a text color for all non-disabled button states. This API is then used to set bookmark buttons text color based on ThemeProperties::COLOR_BOOKMARK_TEXT. BUG=545003 TEST=Use a dark theme with white bookmark bar text color Test that this color is applied to normal, hover and pressed states. Switch theme back and test that all three colors are updated. Review URL: https://codereview.chromium.org/1417553003 Cr-Commit-Position: refs/heads/master@{#355436}
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc14
-rw-r--r--ui/views/controls/button/label_button.cc6
-rw-r--r--ui/views/controls/button/label_button.h27
3 files changed, 27 insertions, 20 deletions
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index d354428..4cc26fc 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -1721,8 +1721,7 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node,
button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT);
// We don't always have a theme provider (ui tests, for example).
if (GetThemeProvider()) {
- button->SetTextColor(
- views::Button::STATE_NORMAL,
+ button->SetEnabledTextColors(
GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT));
}
@@ -2035,13 +2034,12 @@ void BookmarkBarView::UpdateColors() {
SkColor color =
theme_provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT);
for (int i = 0; i < GetBookmarkButtonCount(); ++i)
- GetBookmarkButton(i)->SetTextColor(views::Button::STATE_NORMAL, color);
- other_bookmarks_button_->SetTextColor(views::Button::STATE_NORMAL, color);
- managed_bookmarks_button_->SetTextColor(views::Button::STATE_NORMAL, color);
- supervised_bookmarks_button_->SetTextColor(views::Button::STATE_NORMAL,
- color);
+ GetBookmarkButton(i)->SetEnabledTextColors(color);
+ other_bookmarks_button_->SetEnabledTextColors(color);
+ managed_bookmarks_button_->SetEnabledTextColors(color);
+ supervised_bookmarks_button_->SetEnabledTextColors(color);
if (apps_page_shortcut_->visible())
- apps_page_shortcut_->SetTextColor(views::Button::STATE_NORMAL, color);
+ apps_page_shortcut_->SetEnabledTextColors(color);
overflow_button_->SetImage(
views::Button::STATE_NORMAL,
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
index bf96747..983d118 100644
--- a/ui/views/controls/button/label_button.cc
+++ b/ui/views/controls/button/label_button.cc
@@ -116,6 +116,12 @@ void LabelButton::SetTextColor(ButtonState for_state, SkColor color) {
explicitly_set_colors_[for_state] = true;
}
+void LabelButton::SetEnabledTextColors(SkColor color) {
+ ButtonState states[] = {STATE_NORMAL, STATE_HOVERED, STATE_PRESSED};
+ for (auto state : states)
+ SetTextColor(state, color);
+}
+
void LabelButton::SetTextShadows(const gfx::ShadowValues& shadows) {
label_->SetShadows(shadows);
}
diff --git a/ui/views/controls/button/label_button.h b/ui/views/controls/button/label_button.h
index 96c226c..b26c0a7 100644
--- a/ui/views/controls/button/label_button.h
+++ b/ui/views/controls/button/label_button.h
@@ -32,36 +32,39 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
LabelButton(ButtonListener* listener, const base::string16& text);
~LabelButton() override;
- // Get or set the image shown for the specified button state.
+ // Gets or sets the image shown for the specified button state.
// GetImage returns the image for STATE_NORMAL if the state's image is empty.
virtual const gfx::ImageSkia& GetImage(ButtonState for_state);
void SetImage(ButtonState for_state, const gfx::ImageSkia& image);
- // Get or set the text shown on the button.
+ // Gets or sets the text shown on the button.
const base::string16& GetText() const;
void SetText(const base::string16& text);
- // Set the text color shown for the specified button state.
+ // Sets the text color shown for the specified button |for_state| to |color|.
void SetTextColor(ButtonState for_state, SkColor color);
- // Set drop shadows underneath the text.
+ // Sets the text colors shown for the non-disabled states to |color|.
+ void SetEnabledTextColors(SkColor color);
+
+ // Sets drop shadows underneath the text.
void SetTextShadows(const gfx::ShadowValues& shadows);
// Sets whether subpixel rendering is used on the label.
void SetTextSubpixelRenderingEnabled(bool enabled);
- // Get or set the text's multi-line property to break on '\n', etc.
+ // Gets or sets the text's multi-line property to break on '\n', etc.
bool GetTextMultiLine() const;
void SetTextMultiLine(bool text_multi_line);
- // Get or set the font list used by this button.
+ // Gets or sets the font list used by this button.
const gfx::FontList& GetFontList() const;
void SetFontList(const gfx::FontList& font_list);
- // Set the elide behavior of this button.
+ // Sets the elide behavior of this button.
void SetElideBehavior(gfx::ElideBehavior elide_behavior);
- // Get or set the horizontal alignment used for the button; reversed in RTL.
+ // Gets or sets the horizontal alignment used for the button; reversed in RTL.
// The optional image will lead the text, unless the button is right-aligned.
gfx::HorizontalAlignment GetHorizontalAlignment() const;
void SetHorizontalAlignment(gfx::HorizontalAlignment alignment);
@@ -70,15 +73,15 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
void SetMinSize(const gfx::Size& min_size);
void SetMaxSize(const gfx::Size& max_size);
- // Get or set the option to handle the return key; false by default.
+ // Gets or sets the option to handle the return key; false by default.
bool is_default() const { return is_default_; }
void SetIsDefault(bool is_default);
- // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|.
+ // Gets or sets the button's overall style; the default is |STYLE_TEXTBUTTON|.
ButtonStyle style() const { return style_; }
void SetStyle(ButtonStyle style);
- // Set the spacing between the image and the text. Shrinking the spacing
+ // Sets the spacing between the image and the text. Shrinking the spacing
// will not shrink the overall button size, as it is monotonically increasing.
// Call SetMinSize(gfx::Size()) to clear the size if needed.
void SetImageLabelSpacing(int spacing);
@@ -115,7 +118,7 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
// CustomButton:
void StateChanged() override;
- // Fill |params| with information about the button.
+ // Fills |params| with information about the button.
virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const;
// Resets colors from the NativeTheme, explicitly set colors are unchanged.