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

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

Issue 248073005: Automatically call OnNativeThemeChanged when a widget is added to a hierarchy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review Created 6 years, 8 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
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 717d2e08a445b2af147a964653f10b86a80f5c81..f3175a62f250a004e0005440b999f76a2a02ab5d 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -378,14 +378,25 @@ void Label::OnPaint(gfx::Canvas* canvas) {
}
void Label::OnNativeThemeChanged(const ui::NativeTheme* theme) {
- UpdateColorsFromTheme(theme);
+ if (!enabled_color_set_) {
+ requested_enabled_color_ = theme->GetSystemColor(
+ ui::NativeTheme::kColorId_LabelEnabledColor);
+ }
+ if (!disabled_color_set_) {
+ requested_disabled_color_ = theme->GetSystemColor(
+ ui::NativeTheme::kColorId_LabelDisabledColor);
+ }
+ if (!background_color_set_) {
+ background_color_ = theme->GetSystemColor(
+ ui::NativeTheme::kColorId_LabelBackgroundColor);
+ }
+ RecalculateColors();
}
void Label::Init(const base::string16& text, const gfx::FontList& font_list) {
font_list_ = font_list;
enabled_color_set_ = disabled_color_set_ = background_color_set_ = false;
auto_color_readability_ = true;
- UpdateColorsFromTheme(ui::NativeTheme::instance());
horizontal_alignment_ = gfx::ALIGN_CENTER;
line_height_ = 0;
is_multi_line_ = false;
@@ -534,22 +545,6 @@ void Label::CalculateDrawStringParams(base::string16* paint_text,
*flags |= gfx::Canvas::NO_ELLIPSIS;
}
-void Label::UpdateColorsFromTheme(const ui::NativeTheme* theme) {
- if (!enabled_color_set_) {
- requested_enabled_color_ = theme->GetSystemColor(
- ui::NativeTheme::kColorId_LabelEnabledColor);
- }
- if (!disabled_color_set_) {
- requested_disabled_color_ = theme->GetSystemColor(
- ui::NativeTheme::kColorId_LabelDisabledColor);
- }
- if (!background_color_set_) {
- background_color_ = theme->GetSystemColor(
- ui::NativeTheme::kColorId_LabelBackgroundColor);
- }
- RecalculateColors();
-}
-
void Label::ResetCachedSize() {
text_size_valid_ = false;
cached_heights_cursor_ = 0;
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698