Commit cb2fcc39 authored by John Smith's avatar John Smith Committed by Commit Bot

Add a button color colorid

This cleans up the double mapping for kColorId_DialogBackground in the
color pipeline as well as adds a new kColorId explicitly for button.
The new colorid is hooked up as appropriate for button cases and returns
the same colors as it did with DialogBackground. Having it be separate
would be helpful for cases like high contrast where the button may need
greater differentiation from the background and for any downstream
consumers who use a different color even in regular modes.

Bug: 1067359
Change-Id: I966bb0446c85ba08d8fe9d844544ccd06aff7b24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135385Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: John Smith <johnsm@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#757527}
parent 497fbc9b
......@@ -28,7 +28,7 @@
E(kColorBubbleBackground, NativeTheme::kColorId_BubbleBackground) \
E(kColorBubbleFooterBackground, \
NativeTheme::kColorId_BubbleFooterBackground) \
E(kColorButtonBackground, NativeTheme::kColorId_DialogBackground) \
E(kColorButtonBackground, NativeTheme::kColorId_ButtonColor) \
E(kColorButtonBorder, NativeTheme::kColorId_ButtonBorderColor) \
E(kColorButtonDisabledForeground, NativeTheme::kColorId_ButtonDisabledColor) \
E(kColorButtonForeground, NativeTheme::kColorId_ButtonEnabledColor) \
......
......@@ -219,6 +219,8 @@ base::Optional<SkColor> SkColorFromColorId(
return GetSeparatorColor("GtkSeparator#separator.horizontal");
// Button
case ui::NativeTheme::kColorId_ButtonColor:
return GetBgColor("GtkButton#button");
case ui::NativeTheme::kColorId_ButtonEnabledColor:
case ui::NativeTheme::kColorId_ButtonUncheckedColor:
return GetFgColor("GtkButton#button.text-button GtkLabel");
......
......@@ -47,6 +47,7 @@ base::Optional<SkColor> GetDarkSchemeColor(NativeTheme::ColorId color_id) {
switch (color_id) {
// Dialogs
case NativeTheme::kColorId_WindowBackground:
case NativeTheme::kColorId_ButtonColor:
case NativeTheme::kColorId_DialogBackground:
case NativeTheme::kColorId_BubbleBackground:
return color_utils::AlphaBlend(SK_ColorWHITE, gfx::kGoogleGrey900, 0.04f);
......@@ -211,6 +212,7 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
switch (color_id) {
// Dialogs
case NativeTheme::kColorId_WindowBackground:
case NativeTheme::kColorId_ButtonColor:
case NativeTheme::kColorId_DialogBackground:
case NativeTheme::kColorId_BubbleBackground:
return SK_ColorWHITE;
......@@ -252,7 +254,7 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
return gfx::kGoogleGrey700;
case NativeTheme::kColorId_ButtonDisabledColor: {
const SkColor bg = base_theme->GetSystemColor(
NativeTheme::kColorId_DialogBackground, color_scheme);
NativeTheme::kColorId_ButtonColor, color_scheme);
const SkColor fg = base_theme->GetSystemColor(
NativeTheme::kColorId_LabelEnabledColor, color_scheme);
return color_utils::BlendForMinContrast(gfx::kGoogleGrey600, bg, fg)
......@@ -260,7 +262,7 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
}
case NativeTheme::kColorId_ProminentButtonDisabledColor: {
const SkColor bg = base_theme->GetSystemColor(
NativeTheme::kColorId_DialogBackground, color_scheme);
NativeTheme::kColorId_ButtonColor, color_scheme);
return color_utils::BlendForMinContrast(bg, bg, base::nullopt, 1.2f)
.color;
}
......
......@@ -39,7 +39,7 @@ NativeThemeColorIdToColorIdMap() {
{NTCID::kColorId_BubbleBackground, kColorBubbleBackground},
{NTCID::kColorId_BubbleFooterBackground,
kColorBubbleFooterBackground},
{NTCID::kColorId_DialogBackground, kColorButtonBackground},
{NTCID::kColorId_ButtonColor, kColorButtonBackground},
{NTCID::kColorId_ButtonBorderColor, kColorButtonBorder},
{NTCID::kColorId_ButtonDisabledColor, kColorButtonDisabledForeground},
{NTCID::kColorId_ButtonEnabledColor, kColorButtonForeground},
......
......@@ -20,6 +20,7 @@
OP(kColorId_FocusedBorderColor), \
OP(kColorId_UnfocusedBorderColor), \
/* Button */ \
OP(kColorId_ButtonColor), \
OP(kColorId_ButtonBorderColor), \
OP(kColorId_ButtonEnabledColor), \
OP(kColorId_ButtonDisabledColor), \
......
......@@ -642,6 +642,7 @@ SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const {
return system_colors_[SystemThemeColor::kGrayText];
// Button Background
case kColorId_ButtonColor:
case kColorId_MenuBackgroundColor:
case kColorId_HighlightedMenuItemBackgroundColor:
case kColorId_TextfieldDefaultBackground:
......
......@@ -259,7 +259,7 @@ void MdTextButton::UpdateColors() {
ui::NativeTheme* theme = GetNativeTheme();
SkColor bg_color =
theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonColor);
if (bg_color_override_) {
bg_color = *bg_color_override_;
......
......@@ -96,7 +96,7 @@ class ToggleButton::ThumbView : public InkDropHostView {
const SkColor thumb_on_color = thumb_on_color_.value_or(
theme->GetSystemColor(ui::NativeTheme::kColorId_ProminentButtonColor));
const SkColor thumb_off_color = thumb_off_color_.value_or(
theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground));
theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonColor));
thumb_flags.setColor(
color_utils::AlphaBlend(thumb_on_color, thumb_off_color, color_ratio_));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment