fix: WCO transparent background (#38693)

* fix: WCO transparency

* doc: wco color transparency

* fix: transparent buttons when calling setTitleBarOverlay
This commit is contained in:
Samuel Maddock 2023-06-09 12:57:57 -04:00 committed by GitHub
parent d95ae19edf
commit e8fd5fd3a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 10 deletions

View file

@ -13,6 +13,7 @@
#include "shell/browser/ui/views/win_caption_button.h"
#include "shell/browser/ui/views/win_frame_view.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
#include "ui/views/layout/flex_layout.h"
@ -129,9 +130,7 @@ void WinCaptionButtonContainer::AddedToWidget() {
UpdateButtons();
if (frame_view_->window()->IsWindowControlsOverlayEnabled()) {
SetBackground(views::CreateSolidBackground(
frame_view_->window()->overlay_button_color()));
SetPaintToLayer();
UpdateBackground();
}
}
@ -146,6 +145,16 @@ void WinCaptionButtonContainer::OnWidgetBoundsChanged(
UpdateButtons();
}
void WinCaptionButtonContainer::UpdateBackground() {
const SkColor bg_color = frame_view_->window()->overlay_button_color();
const SkAlpha theme_alpha = SkColorGetA(bg_color);
SetBackground(views::CreateSolidBackground(bg_color));
SetPaintToLayer();
if (theme_alpha < SK_AlphaOPAQUE)
layer()->SetFillsBoundsOpaquely(false);
}
void WinCaptionButtonContainer::UpdateButtons() {
const bool is_maximized = frame_view_->frame()->IsMaximized();
restore_button_->SetVisible(is_maximized);

View file

@ -41,6 +41,9 @@ class WinCaptionButtonContainer : public views::View,
gfx::Size GetButtonSize() const;
void SetButtonSize(gfx::Size size);
// Sets caption button container background color.
void UpdateBackground();
// Sets caption button visibility and enabled state based on window state.
// Only one of maximize or restore button should ever be visible at the same
// time, and both are disabled in tablet UI mode.

View file

@ -59,8 +59,7 @@ void WinFrameView::InvalidateCaptionButtons() {
if (!caption_button_container_)
return;
caption_button_container_->SetBackground(
views::CreateSolidBackground(window()->overlay_button_color()));
caption_button_container_->UpdateBackground();
caption_button_container_->InvalidateLayout();
caption_button_container_->SchedulePaint();
}