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

Unified Diff: ui/views/controls/label.cc

Issue 2910153002: Remove views::Label::SetDisabledColor(). Replace with typography colors. (Closed)
Patch Set: rebase for r476345 Created 3 years, 7 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
Index: ui/views/controls/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index c5e3fc5e4d6f5994199fc13649b2d1f0b2d20efd..1db98e38acece6a602712d7867780a6365489096 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -53,13 +53,19 @@ Label::Label(const base::string16& text)
: Label(text, style::CONTEXT_LABEL, style::STYLE_PRIMARY) {}
Label::Label(const base::string16& text, int text_context, int text_style)
- : context_menu_contents_(this) {
+ : text_context_(text_context), context_menu_contents_(this) {
Init(text, style::GetFont(text_context, text_style));
SetLineHeight(style::GetLineHeight(text_context, text_style));
+
+ // If an explicit style is given, ignore color changes due to the NativeTheme.
+ if (text_style != style::STYLE_PRIMARY) {
+ SetEnabledColor(
+ style::GetColor(text_context, text_style, GetNativeTheme()));
+ }
}
Label::Label(const base::string16& text, const CustomFont& font)
- : context_menu_contents_(this) {
+ : text_context_(style::CONTEXT_LABEL), context_menu_contents_(this) {
Init(text, font.font_list);
}
@@ -103,7 +109,8 @@ void Label::SetEnabledColor(SkColor color) {
RecalculateColors();
}
-void Label::SetDisabledColor(SkColor color) {
+// TODO(tapted): Move this into a subclass used only by LabelButton.
+void Label::SetDisabledColorForLabelButton(SkColor color) {
if (disabled_color_set_ && requested_disabled_color_ == color)
return;
is_first_paint_text_ = true;
@@ -998,12 +1005,12 @@ void Label::ApplyTextColors() const {
void Label::UpdateColorsFromTheme(const ui::NativeTheme* theme) {
if (!enabled_color_set_) {
- requested_enabled_color_ = theme->GetSystemColor(
- ui::NativeTheme::kColorId_LabelEnabledColor);
+ requested_enabled_color_ =
+ style::GetColor(text_context_, style::STYLE_PRIMARY, theme);
}
if (!disabled_color_set_) {
- requested_disabled_color_ = theme->GetSystemColor(
- ui::NativeTheme::kColorId_LabelDisabledColor);
+ requested_disabled_color_ =
+ style::GetColor(text_context_, style::STYLE_DISABLED, theme);
}
if (!background_color_set_) {
background_color_ =

Powered by Google App Engine
This is Rietveld 408576698