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

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

Issue 2315233002: views: support disabled color for CTA buttons (Closed)
Patch Set: get rid of CallToActionDisabled 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 44d111c80dff5219baba969b59ba615dc8a2cbe5..8f5e960fcf0ea44b91f125e84fd85be5f9288230 100644
--- a/ui/views/controls/button/md_text_button.cc
+++ b/ui/views/controls/button/md_text_button.cc
@@ -287,16 +287,24 @@ 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)
- : SK_ColorTRANSPARENT;
+ SkColor bg_color = SK_ColorTRANSPARENT;
+
+ 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 = SkColorSetA(bg_color, 0x61);
Evan Stade 2016/09/07 17:14:33 I know it's expressed as an alpha value in the spe
Elly Fong-Jones 2016/09/07 18:01:45 Done.
+ } else if (is_default()) {
+ bg_color = color_utils::BlendTowardOppositeLuma(text_color, 0xD8);
+ }
bg_color = PlatformStyle::BackgroundColorForMdButton(bg_color, state());
Evan Stade 2016/09/07 17:14:33 can we make it a todo to get rid of this? Color lo
Elly Fong-Jones 2016/09/07 17:43:50 Hm - I like this idea, but what would color_utils:
Elly Fong-Jones 2016/09/07 18:01:45 I ended up adding a TODO for this.
« 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