mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: WCO transparent background (#38716)
* fix: WCO transparency Co-authored-by: samuelmaddock <samuel.maddock@gmail.com> * doc: wco color transparency Co-authored-by: samuelmaddock <samuel.maddock@gmail.com> * fix: transparent buttons when calling setTitleBarOverlay Co-authored-by: samuelmaddock <samuel.maddock@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: samuelmaddock <samuel.maddock@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user