Commit 86edf477 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Add themed color support for system menu

Bug: 1035361
Change-Id: Ib39b48c2798262c98ded9a2beb796d8f359da925
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006370
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732952}
parent b5acf97f
......@@ -163,6 +163,11 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// Gets the shelf color when a window is maximized.
SkColor GetMaximizedShelfColor() const;
// Calculates a themed color for shelf and system menu based on the wallpaper.
// Uses alpha value from the provided base_color, returns base_color unchanged
// if the wallpaper can not be used to generate a themed color.
SkColor GetThemedColorFromWallpaper(SkColor base_color) const;
// Gets the default shelf color, calculated using the wallpaper color if
// available.
SkColor GetDefaultShelfColor() const;
......
......@@ -273,21 +273,9 @@ SkColor ShelfConfig::GetMaximizedShelfColor() const {
return SkColorSetA(GetDefaultShelfColor(), 254); // ~100% opacity
}
SkColor ShelfConfig::GetDefaultShelfColor() const {
if (!features::IsBackgroundBlurEnabled()) {
return AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent90,
AshColorProvider::AshColorMode::kDark);
}
SkColor final_color = AshColorProvider::Get()->GetBaseLayerColor(
IsTabletMode() ? AshColorProvider::BaseLayerType::kTransparent60
: AshColorProvider::BaseLayerType::kTransparent74,
AshColorProvider::AshColorMode::kDark);
int final_alpha = SkColorGetA(final_color);
SkColor ShelfConfig::GetThemedColorFromWallpaper(SkColor base_color) const {
if (!Shell::Get()->wallpaper_controller())
return final_color;
return base_color;
SkColor dark_muted_color =
Shell::Get()->wallpaper_controller()->GetProminentColor(
......@@ -295,13 +283,29 @@ SkColor ShelfConfig::GetDefaultShelfColor() const {
color_utils::SaturationRange::MUTED));
if (dark_muted_color == kInvalidWallpaperColor)
return final_color;
return base_color;
int base_alpha = SkColorGetA(base_color);
// Combine SK_ColorBLACK at 50% opacity with |dark_muted_color|.
final_color = color_utils::GetResultingPaintColor(
base_color = color_utils::GetResultingPaintColor(
SkColorSetA(SK_ColorBLACK, 127), dark_muted_color);
return SkColorSetA(final_color, final_alpha);
return SkColorSetA(base_color, base_alpha);
}
SkColor ShelfConfig::GetDefaultShelfColor() const {
if (!features::IsBackgroundBlurEnabled()) {
return AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent90,
AshColorProvider::AshColorMode::kDark);
}
SkColor final_color = AshColorProvider::Get()->GetBaseLayerColor(
IsTabletMode() ? AshColorProvider::BaseLayerType::kTransparent60
: AshColorProvider::BaseLayerType::kTransparent74,
AshColorProvider::AshColorMode::kDark);
return GetThemedColorFromWallpaper(final_color);
}
int ShelfConfig::GetShelfControlButtonBlurRadius() const {
......
......@@ -26,6 +26,7 @@
#include "ash/system/unified/unified_system_info_view.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "ash/system/unified/unified_system_tray_model.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/message_center/message_center.h"
......@@ -230,20 +231,30 @@ class UnifiedSystemTrayView::FocusSearch : public views::FocusSearch {
// static
SkColor UnifiedSystemTrayView::GetBackgroundColor() {
if (features::IsBackgroundBlurEnabled()) {
AshColorProvider::BaseLayerType layer_type =
Shelf::ForWindow(Shell::GetPrimaryRootWindow())
->shelf_widget()
->GetBackgroundType() == ShelfBackgroundType::kHomeLauncher
? AshColorProvider::BaseLayerType::kTransparent60
: AshColorProvider::BaseLayerType::kTransparent74;
return AshColorProvider::Get()->GetBaseLayerColor(
layer_type, AshColorProvider::AshColorMode::kDark);
if (!features::IsBackgroundBlurEnabled()) {
return AshColorProvider::Get()->DeprecatedGetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent90,
kUnifiedMenuBackgroundColor);
}
return AshColorProvider::Get()->DeprecatedGetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent90,
kUnifiedMenuBackgroundColor);
AshColorProvider::BaseLayerType layer_type =
(Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode())
? AshColorProvider::BaseLayerType::kTransparent60
: AshColorProvider::BaseLayerType::kTransparent74;
auto background_type = Shelf::ForWindow(Shell::GetPrimaryRootWindow())
->shelf_widget()
->GetBackgroundType();
if (background_type == ShelfBackgroundType::kMaximized ||
background_type == ShelfBackgroundType::kInApp) {
layer_type = AshColorProvider::BaseLayerType::kTransparent90;
}
SkColor background_color = AshColorProvider::Get()->GetBaseLayerColor(
layer_type, AshColorProvider::AshColorMode::kDark);
return ShelfConfig::Get()->GetThemedColorFromWallpaper(background_color);
}
// static
......
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