Commit 85bbe281 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Make tooltips match the window color scheme instead of opposing it.

Previously, light-mode tooltips were light-on-dark, and dark-mode were
dark-on-light.  This reverses that, since opposite-scheme tooltips stick out
oddly and look buggy.  For example, on CrOS, hovering a tab gave a dark-on-light
"tooltip" (preview), but hovering the new tab button was light-on-dark.

Since translucent tooltips will now stand out less, this adds a border, just as
non-translucent tooltips have.  This also makes non-translucent tooltips more
closely resemble translucent ones by using GetResultingPaintColor() instead of
simply clamping opacity.

Bug: 1024091
Change-Id: Ie6cda816b285423446d8d8f119288683b913d3dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931756
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718723}
parent 531f6250
...@@ -77,10 +77,8 @@ void AddUiColorMixers(ColorProvider* provider) { ...@@ -77,10 +77,8 @@ void AddUiColorMixers(ColorProvider* provider) {
mixer[kColorTextfieldSelectionBackground] = {kColorTextSelectionBackground}; mixer[kColorTextfieldSelectionBackground] = {kColorTextSelectionBackground};
mixer[kColorTextfieldSelectionForeground] = {kColorTextfieldForeground}; mixer[kColorTextfieldSelectionForeground] = {kColorTextfieldForeground};
mixer[kColorThrobber] = {kColorAccent}; mixer[kColorThrobber] = {kColorAccent};
mixer[kColorTooltipBackground] = mixer[kColorTooltipBackground] = SetAlpha(kColorPrimaryBackground, 0xCC);
SetAlpha(GetColorWithMaxContrast(kColorPrimaryBackground), 0xE9); mixer[kColorTooltipForeground] = SetAlpha(kColorPrimaryForeground, 0xDE);
mixer[kColorTooltipForeground] =
SetAlpha(GetColorWithMaxContrast(kColorTooltipBackground), 0xDE);
mixer[kColorTreeBackground] = {kColorPrimaryBackground}; mixer[kColorTreeBackground] = {kColorPrimaryBackground};
mixer[kColorTreeNodeForeground] = {kColorPrimaryForeground}; mixer[kColorTreeNodeForeground] = {kColorPrimaryForeground};
mixer[kColorTreeNodeSelectedFocusedBackground] = { mixer[kColorTreeNodeSelectedFocusedBackground] = {
......
...@@ -139,6 +139,10 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id, ...@@ -139,6 +139,10 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
case NativeTheme::kColorId_TextfieldSelectionBackgroundFocused: case NativeTheme::kColorId_TextfieldSelectionBackgroundFocused:
return gfx::kGoogleBlue800; return gfx::kGoogleBlue800;
// Tooltip
case NativeTheme::kColorId_TooltipText:
return SkColorSetA(gfx::kGoogleGrey200, 0xDE);
// Tree // Tree
case NativeTheme::kColorId_TreeBackground: case NativeTheme::kColorId_TreeBackground:
return color_utils::AlphaBlend(SK_ColorWHITE, gfx::kGoogleGrey900, return color_utils::AlphaBlend(SK_ColorWHITE, gfx::kGoogleGrey900,
...@@ -311,13 +315,10 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id, ...@@ -311,13 +315,10 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
case NativeTheme::kColorId_TooltipBackground: { case NativeTheme::kColorId_TooltipBackground: {
const SkColor bg = base_theme->GetSystemColor( const SkColor bg = base_theme->GetSystemColor(
NativeTheme::kColorId_WindowBackground, color_scheme); NativeTheme::kColorId_WindowBackground, color_scheme);
return SkColorSetA(color_utils::GetColorWithMaxContrast(bg), 0xE9); return SkColorSetA(bg, 0xCC);
}
case NativeTheme::kColorId_TooltipText: {
const SkColor bg = base_theme->GetSystemColor(
NativeTheme::kColorId_TooltipBackground, color_scheme);
return SkColorSetA(color_utils::GetColorWithMaxContrast(bg), 0xDE);
} }
case NativeTheme::kColorId_TooltipText:
return SkColorSetA(kPrimaryTextColor, 0xDE);
// Tree // Tree
case NativeTheme::kColorId_TreeBackground: case NativeTheme::kColorId_TreeBackground:
......
...@@ -135,18 +135,16 @@ class TooltipAura::TooltipView : public views::View { ...@@ -135,18 +135,16 @@ class TooltipAura::TooltipView : public views::View {
render_text_->SetColor(color); render_text_->SetColor(color);
} }
void SetBackgroundColor(SkColor background_color) { void SetBackgroundColor(SkColor background_color, SkColor border_color) {
if (CanUseTranslucentTooltipWidget()) { if (CanUseTranslucentTooltipWidget()) {
// Corner radius of tooltip background. // Corner radius of tooltip background.
const float kTooltipCornerRadius = 2.f; const float kTooltipCornerRadius = 2.f;
SetBackground(views::CreateBackgroundFromPainter( SetBackground(views::CreateBackgroundFromPainter(
views::Painter::CreateSolidRoundRectPainter(background_color, views::Painter::CreateRoundRectWith1PxBorderPainter(
kTooltipCornerRadius))); background_color, border_color, kTooltipCornerRadius)));
} else { } else {
SetBackground(views::CreateSolidBackground(background_color)); SetBackground(views::CreateSolidBackground(background_color));
auto border_color =
color_utils::GetColorWithMaxContrast(background_color);
SetBorder(views::CreatePaddedBorder( SetBorder(views::CreatePaddedBorder(
views::CreateSolidBorder(1, border_color), views::CreateSolidBorder(1, border_color),
gfx::Insets(kVerticalPaddingTop - 1, kHorizontalPadding - 1, gfx::Insets(kVerticalPaddingTop - 1, kHorizontalPadding - 1,
...@@ -254,13 +252,17 @@ void TooltipAura::SetText(aura::Window* window, ...@@ -254,13 +252,17 @@ void TooltipAura::SetText(aura::Window* window,
ui::NativeTheme* native_theme = widget_->GetNativeTheme(); ui::NativeTheme* native_theme = widget_->GetNativeTheme();
auto background_color = auto background_color =
native_theme->GetSystemColor(ui::NativeTheme::kColorId_TooltipBackground); native_theme->GetSystemColor(ui::NativeTheme::kColorId_TooltipBackground);
if (!CanUseTranslucentTooltipWidget()) if (!CanUseTranslucentTooltipWidget()) {
background_color = SkColorSetA(background_color, 0xFF); background_color = color_utils::GetResultingPaintColor(
tooltip_view_->SetBackgroundColor(background_color); background_color, native_theme->GetSystemColor(
ui::NativeTheme::kColorId_WindowBackground));
}
auto foreground_color = auto foreground_color =
native_theme->GetSystemColor(ui::NativeTheme::kColorId_TooltipText); native_theme->GetSystemColor(ui::NativeTheme::kColorId_TooltipText);
if (!CanUseTranslucentTooltipWidget()) if (!CanUseTranslucentTooltipWidget())
foreground_color = SkColorSetA(foreground_color, 0xFF); foreground_color =
color_utils::GetResultingPaintColor(foreground_color, background_color);
tooltip_view_->SetBackgroundColor(background_color, foreground_color);
tooltip_view_->SetForegroundColor(foreground_color); tooltip_view_->SetForegroundColor(foreground_color);
} }
......
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