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

Unified Diff: ui/views/controls/button/md_text_button.cc

Issue 2315233002: views: support disabled color for CTA buttons (Closed)
Patch Set: rebase Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/md_text_button.cc
diff --git a/ui/views/controls/button/md_text_button.cc b/ui/views/controls/button/md_text_button.cc
index 037ce0e788770d13a243871a1c93d0f17c870e85..9e8e5104fe57436d337997a8d6e2d5b758745fe3 100644
--- a/ui/views/controls/button/md_text_button.cc
+++ b/ui/views/controls/button/md_text_button.cc
@@ -292,18 +292,28 @@ void MdTextButton::UpdateColors() {
if (!explicitly_set_normal_color())
LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id));
+ // CTA buttons keep their enabled text color; disabled state is conveyed by
+ // shading the background instead.
+ if (is_cta_)
+ SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id));
+
SkColor text_color = label()->enabled_color();
SkColor bg_color =
- bg_color_override_
- ? *bg_color_override_
- : is_cta_
- ? theme->GetSystemColor(
- ui::NativeTheme::kColorId_CallToActionColor)
- : is_default()
- ? color_utils::BlendTowardOppositeLuma(text_color, 0xD8)
- : theme->GetSystemColor(
- ui::NativeTheme::kColorId_DialogBackground);
+ theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
+
+ if (bg_color_override_) {
+ bg_color = *bg_color_override_;
+ } else if (is_cta_) {
+ bg_color = theme->GetSystemColor(
+ ui::NativeTheme::kColorId_CallToActionColor);
+ if (state() == STATE_DISABLED)
+ bg_color = color_utils::BlendTowardOppositeLuma(bg_color, 0x61);
+ } else if (is_default()) {
+ bg_color = color_utils::BlendTowardOppositeLuma(text_color, 0xD8);
+ }
+ // TODO(ellyjones): Excise this, in favor of a helper function wrapping
+ // |color_utils::AlphaBlend| and a new NativeTheme color constant.
bg_color = PlatformStyle::BackgroundColorForMdButton(bg_color, state());
const SkAlpha kStrokeOpacity = 0x1A;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698