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, ...@@ -163,6 +163,11 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// Gets the shelf color when a window is maximized. // Gets the shelf color when a window is maximized.
SkColor GetMaximizedShelfColor() const; 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 // Gets the default shelf color, calculated using the wallpaper color if
// available. // available.
SkColor GetDefaultShelfColor() const; SkColor GetDefaultShelfColor() const;
......
...@@ -273,21 +273,9 @@ SkColor ShelfConfig::GetMaximizedShelfColor() const { ...@@ -273,21 +273,9 @@ SkColor ShelfConfig::GetMaximizedShelfColor() const {
return SkColorSetA(GetDefaultShelfColor(), 254); // ~100% opacity return SkColorSetA(GetDefaultShelfColor(), 254); // ~100% opacity
} }
SkColor ShelfConfig::GetDefaultShelfColor() const { SkColor ShelfConfig::GetThemedColorFromWallpaper(SkColor base_color) 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);
if (!Shell::Get()->wallpaper_controller()) if (!Shell::Get()->wallpaper_controller())
return final_color; return base_color;
SkColor dark_muted_color = SkColor dark_muted_color =
Shell::Get()->wallpaper_controller()->GetProminentColor( Shell::Get()->wallpaper_controller()->GetProminentColor(
...@@ -295,13 +283,29 @@ SkColor ShelfConfig::GetDefaultShelfColor() const { ...@@ -295,13 +283,29 @@ SkColor ShelfConfig::GetDefaultShelfColor() const {
color_utils::SaturationRange::MUTED)); color_utils::SaturationRange::MUTED));
if (dark_muted_color == kInvalidWallpaperColor) 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|. // 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); 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 { int ShelfConfig::GetShelfControlButtonBlurRadius() const {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "ash/system/unified/unified_system_info_view.h" #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_controller.h"
#include "ash/system/unified/unified_system_tray_model.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/canvas.h"
#include "ui/gfx/scoped_canvas.h" #include "ui/gfx/scoped_canvas.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
...@@ -230,20 +231,30 @@ class UnifiedSystemTrayView::FocusSearch : public views::FocusSearch { ...@@ -230,20 +231,30 @@ class UnifiedSystemTrayView::FocusSearch : public views::FocusSearch {
// static // static
SkColor UnifiedSystemTrayView::GetBackgroundColor() { SkColor UnifiedSystemTrayView::GetBackgroundColor() {
if (features::IsBackgroundBlurEnabled()) { if (!features::IsBackgroundBlurEnabled()) {
AshColorProvider::BaseLayerType layer_type = return AshColorProvider::Get()->DeprecatedGetBaseLayerColor(
Shelf::ForWindow(Shell::GetPrimaryRootWindow()) AshColorProvider::BaseLayerType::kTransparent90,
->shelf_widget() kUnifiedMenuBackgroundColor);
->GetBackgroundType() == ShelfBackgroundType::kHomeLauncher
? AshColorProvider::BaseLayerType::kTransparent60
: AshColorProvider::BaseLayerType::kTransparent74;
return AshColorProvider::Get()->GetBaseLayerColor(
layer_type, AshColorProvider::AshColorMode::kDark);
} }
return AshColorProvider::Get()->DeprecatedGetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent90, AshColorProvider::BaseLayerType layer_type =
kUnifiedMenuBackgroundColor); (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 // 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