Commit 70208163 authored by Bret Sepulveda's avatar Bret Sepulveda Committed by Commit Bot

Fix popup window title color always being black with custom titlebar.

This patch changes the window title color when the titlebar is painted.
This ensures that the proper contrasting color is picked for both active
and inactive states. The color is also made partially transparent when
the window is inactive.

The end result is that the window title should always be the same color
as the window caption button symbols (unless a theme uses a button
background with the opposite luma of the titlebar).

Bug: 821980
Change-Id: Ib84edf0b9d2bb9415cd293d3683915b9d64b40be
Reviewed-on: https://chromium-review.googlesource.com/979035
Commit-Queue: Bret Sepulveda <bsep@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545933}
parent d9ec3a6d
......@@ -669,6 +669,15 @@ void GlassBrowserFrameView::PaintTitlebar(gfx::Canvas* canvas) const {
titlebar_rect.y(), frame_overlay_image.width() * scale,
frame_overlay_image.height() * scale, true);
}
if (ShowCustomTitle()) {
const SkAlpha title_alpha =
ShouldPaintAsActive() ? SK_AlphaOPAQUE : kInactiveTitlebarFeatureAlpha;
const SkColor title_color = SkColorSetA(
color_utils::BlendTowardOppositeLuma(titlebar_color, SK_AlphaOPAQUE),
title_alpha);
window_title_->SetEnabledColor(title_color);
}
}
void GlassBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) const {
......@@ -804,6 +813,7 @@ void GlassBrowserFrameView::LayoutTitleBar() {
const int max_text_width = std::max(0, MinimizeButtonX() - x);
window_title_->SetBounds(x, window_icon_bounds.y(), max_text_width,
window_icon_bounds.height());
window_title_->SetAutoColorReadabilityEnabled(false);
}
}
......
......@@ -26,6 +26,10 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
public TabIconViewModel,
public TabStripObserver {
public:
// Alpha to use for features in the titlebar (the window title and caption
// buttons) when the window is inactive. They are opaque when active.
static constexpr SkAlpha kInactiveTitlebarFeatureAlpha = 0x65;
// Constructs a non-client view for an BrowserFrame.
GlassBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
~GlassBrowserFrameView() override;
......
......@@ -131,7 +131,8 @@ void Windows10CaptionButton::PaintSymbol(gfx::Canvas* canvas) {
SkColor symbol_color = GetBaseColor();
if (!frame_view_->ShouldPaintAsActive() && state() != STATE_HOVERED &&
state() != STATE_PRESSED) {
symbol_color = SkColorSetA(symbol_color, 0x65);
symbol_color = SkColorSetA(
symbol_color, GlassBrowserFrameView::kInactiveTitlebarFeatureAlpha);
} else if (button_type_ == VIEW_ID_CLOSE_BUTTON &&
hover_animation().is_animating()) {
symbol_color = gfx::Tween::ColorValueBetween(
......
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