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

Side by Side Diff: ui/views/controls/button/md_text_button.cc

Issue 2620453005: Material Design: Fix MdLabelButton not updating text colors on theme changes (Closed)
Patch Set: Refactor Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/button/md_text_button.h" 5 #include "ui/views/controls/button/md_text_button.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 SetBorder(CreateEmptyBorder(top_padding, kHorizontalPadding, bottom_padding, 244 SetBorder(CreateEmptyBorder(top_padding, kHorizontalPadding, bottom_padding,
245 kHorizontalPadding)); 245 kHorizontalPadding));
246 } 246 }
247 247
248 void MdTextButton::UpdateColors() { 248 void MdTextButton::UpdateColors() {
249 ui::NativeTheme::ColorId fg_color_id = 249 ui::NativeTheme::ColorId fg_color_id =
250 is_prominent_ ? ui::NativeTheme::kColorId_TextOnProminentButtonColor 250 is_prominent_ ? ui::NativeTheme::kColorId_TextOnProminentButtonColor
251 : ui::NativeTheme::kColorId_ButtonEnabledColor; 251 : ui::NativeTheme::kColorId_ButtonEnabledColor;
252 252
253 ui::NativeTheme* theme = GetNativeTheme(); 253 ui::NativeTheme* theme = GetNativeTheme();
254 if (!explicitly_set_normal_color()) 254 if (!explicitly_set_normal_color()) {
255 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); 255 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id));
256 LabelButton::ResetExplicitnessOfEnabledTextColors();
257 }
256 258
257 // Prominent buttons keep their enabled text color; disabled state is conveyed 259 // Prominent buttons keep their enabled text color; disabled state is conveyed
258 // by shading the background instead. 260 // by shading the background instead.
259 if (is_prominent_) 261 if (is_prominent_)
260 SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id)); 262 SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id));
261 263
262 SkColor text_color = label()->enabled_color(); 264 SkColor text_color = label()->enabled_color();
263 SkColor bg_color = 265 SkColor bg_color =
264 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); 266 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
265 267
(...skipping 28 matching lines...) Expand all
294 stroke_color, gfx::kDisabledControlAlpha); 296 stroke_color, gfx::kDisabledControlAlpha);
295 } 297 }
296 298
297 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); 299 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color)));
298 set_background(Background::CreateBackgroundPainter( 300 set_background(Background::CreateBackgroundPainter(
299 true, Painter::CreateRoundRectWith1PxBorderPainter( 301 true, Painter::CreateRoundRectWith1PxBorderPainter(
300 bg_color, stroke_color, kInkDropSmallCornerRadius))); 302 bg_color, stroke_color, kInkDropSmallCornerRadius)));
301 } 303 }
302 304
303 } // namespace views 305 } // namespace views
OLDNEW
« ui/views/controls/button/label_button.cc ('K') | « ui/views/controls/button/label_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698