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

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

Issue 2094553002: MD - Fix coloring of buttons on DL shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compiling is always a plus Created 4 years, 6 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/button/md_text_button.h ('k') | 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 d5dfd009db3ee9d795a2794cc871b8f695a742bb..ec863e03dcd87c4d4f6cb45f36cb10c065543ca9 100644
--- a/ui/views/controls/button/md_text_button.cc
+++ b/ui/views/controls/button/md_text_button.cc
@@ -143,7 +143,7 @@ void MdTextButton::SetCallToAction(bool cta) {
is_cta_ = cta;
focus_ring_->set_thickness(cta ? kFocusBorderThicknessCta
: kFocusBorderThickness);
- UpdateColorsFromNativeTheme();
+ UpdateColors();
}
void MdTextButton::Layout() {
@@ -165,7 +165,7 @@ void MdTextButton::OnBlur() {
void MdTextButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
LabelButton::OnNativeThemeChanged(theme);
- UpdateColorsFromNativeTheme();
+ UpdateColors();
}
SkColor MdTextButton::GetInkDropBaseColor() const {
@@ -199,8 +199,13 @@ bool MdTextButton::ShouldShowInkDropForFocus() const {
return false;
}
+void MdTextButton::SetEnabledTextColors(SkColor color) {
+ LabelButton::SetEnabledTextColors(color);
+ UpdateColors();
+}
+
void MdTextButton::UpdateStyleToIndicateDefaultStatus() {
- UpdateColorsFromNativeTheme();
+ UpdateColors();
}
MdTextButton::MdTextButton(ButtonListener* listener)
@@ -242,7 +247,7 @@ MdTextButton::MdTextButton(ButtonListener* listener)
MdTextButton::~MdTextButton() {}
-void MdTextButton::UpdateColorsFromNativeTheme() {
+void MdTextButton::UpdateColors() {
ui::NativeTheme::ColorId fg_color_id =
is_cta_ ? ui::NativeTheme::kColorId_TextOnCallToActionColor
: ui::NativeTheme::kColorId_ButtonEnabledColor;
@@ -252,7 +257,7 @@ void MdTextButton::UpdateColorsFromNativeTheme() {
// specify a color.
ui::NativeTheme* theme = GetNativeTheme();
if (is_cta_ || !explicitly_set_normal_color())
- SetEnabledTextColors(theme->GetSystemColor(fg_color_id));
+ LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id));
SkColor text_color = label()->enabled_color();
SkColor bg_color =
@@ -261,7 +266,12 @@ void MdTextButton::UpdateColorsFromNativeTheme() {
: is_default()
? color_utils::BlendTowardOppositeLuma(text_color, 0xD8)
: SK_ColorTRANSPARENT;
- SkColor stroke_color = SkColorSetA(SK_ColorBLACK, 0x1A);
+
+ const SkAlpha kStrokeOpacity = 0x1A;
+ SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color))
+ ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity)
+ : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity);
+
set_background(Background::CreateBackgroundPainter(
true, Painter::CreateRoundRectWith1PxBorderPainter(
bg_color, stroke_color, kInkDropSmallCornerRadius)));
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698