Commit 686eb664 authored by minch's avatar minch Committed by Commit Bot

dark_mode: Gets power button menu's color from AshColorProvider.

See https://docs.google.com/document/d/1DFKZsXCU4GySB9Ry8Bhd8k8sB7pO5wOz0GBcFmAq5B4/edit?pli=1#heading=h.8xp39kibavgr
for details.

Bug: 982950
Change-Id: I2025ad188db3f72dae55a649d69fd97eaab8c59a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1779448
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692801}
parent eab9962a
......@@ -35,4 +35,12 @@ constexpr SkColor kToastBackgroundColor =
SkColorSetA(SK_ColorBLACK, 0xCC); // 80%
constexpr SkColor kToastLabelColor = SK_ColorWHITE;
// colors for power button menu.
constexpr SkColor kPowerButtonMenuItemIconColor = gfx::kGoogleGrey900;
constexpr SkColor kPowerButtonMenuItemTitleColor = gfx::kGoogleGrey700;
constexpr SkColor kPowerButtonMenuItemFocusColor =
SkColorSetA(gfx::kGoogleBlue600, 0x66); // 40%
constexpr SkColor kPowerButtonMenuBackgroundColor = SK_ColorWHITE;
constexpr SkColor kPowerButtonMenuFullscreenShieldColor = SK_ColorBLACK;
#endif // ASH_STYLE_DEFAULT_COLOR_CONSTANTS_H_
......@@ -4,9 +4,10 @@
#include "ash/system/power/power_button_menu_item_view.h"
#include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/font.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/accessibility/view_accessibility.h"
......@@ -18,12 +19,6 @@ namespace ash {
namespace {
// Color of the image icon.
constexpr SkColor kItemIconColor = SkColorSetARGB(0xFF, 0x20, 0x21, 0x24);
// Color of the title of the label.
constexpr SkColor kItemTitleColor = SkColorSetARGB(0xFF, 0x5F, 0x63, 0x68);
// Size of the image icon in pixels.
constexpr int kIconSize = 24;
......@@ -36,13 +31,6 @@ constexpr int kTitleTopPadding = 52;
// The amount of rounding applied to the corners of the focused menu item.
constexpr int kFocusedItemRoundRectRadiusDp = 8;
// Color of the focused menu item's border.
constexpr SkColor kFocusedItemBorderColor =
SkColorSetARGB(0x66, 0x1A, 0x73, 0xE8);
// Color of the focused menu item.
constexpr SkColor kFocusedItemColor = SkColorSetARGB(0x0A, 0x1A, 0x73, 0xE8);
} // namespace
PowerButtonMenuItemView::PowerButtonMenuItemView(
......@@ -55,11 +43,19 @@ PowerButtonMenuItemView::PowerButtonMenuItemView(
SetFocusBehavior(FocusBehavior::ALWAYS);
SetFocusPainter(nullptr);
SetPaintToLayer();
icon_view_->SetImage(gfx::CreateVectorIcon(icon, kItemIconColor));
layer()->SetFillsBoundsOpaquely(false);
const AshColorProvider* color_provider = AshColorProvider::Get();
icon_view_->SetImage(gfx::CreateVectorIcon(
icon, color_provider->DeprecatedGetContentLayerColor(
AshColorProvider::ContentLayerType::kIconPrimary,
kPowerButtonMenuItemIconColor)));
AddChildView(icon_view_);
title_->SetBackgroundColor(SK_ColorTRANSPARENT);
title_->SetEnabledColor(kItemTitleColor);
title_->SetEnabledColor(color_provider->DeprecatedGetContentLayerColor(
AshColorProvider::ContentLayerType::kTextPrimary,
kPowerButtonMenuItemTitleColor));
title_->SetText(title_text);
AddChildView(title_);
GetViewAccessibility().OverrideRole(ax::mojom::Role::kMenuItem);
......@@ -107,16 +103,27 @@ void PowerButtonMenuItemView::OnBlur() {
}
void PowerButtonMenuItemView::PaintButtonContents(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);
canvas->DrawColor(SK_ColorWHITE);
if (!HasFocus() || GetContentsBounds().IsEmpty())
cc::PaintFlags flags;
flags.setAntiAlias(true);
// Set the background color to SK_ColorTRANSPARENT here since the parent view
// PowerButtonMenuView has already set the background color.
flags.setColor(SK_ColorTRANSPARENT);
const gfx::Rect content_bounds = GetContentsBounds();
canvas->DrawRoundRect(content_bounds, kFocusedItemRoundRectRadiusDp, flags);
if (!HasFocus() || content_bounds.IsEmpty())
return;
SetBorder(views::CreateRoundedRectBorder(kItemBorderThickness,
kFocusedItemRoundRectRadiusDp,
kFocusedItemBorderColor));
canvas->FillRect(GetContentsBounds(), kFocusedItemColor);
views::View::OnPaintBorder(canvas);
// Border.
gfx::Rect bounds = GetLocalBounds();
bounds.Inset(gfx::Insets(kItemBorderThickness));
// Stroke.
flags.setColor(AshColorProvider::Get()->DeprecatedGetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRing,
kPowerButtonMenuItemFocusColor));
flags.setStrokeWidth(kItemBorderThickness);
flags.setStyle(cc::PaintFlags::Style::kStroke_Style);
canvas->DrawRoundRect(bounds, kFocusedItemRoundRectRadiusDp, flags);
}
} // namespace ash
......@@ -7,6 +7,8 @@
#include <utility>
#include "ash/shell.h"
#include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ash/system/power/power_button_menu_metrics_type.h"
#include "ash/system/power/power_button_menu_view.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
......@@ -23,9 +25,6 @@ constexpr int PowerButtonMenuView::kMenuViewTransformDistanceDp;
namespace {
// Color of the fullscreen background shield.
constexpr SkColor kShieldColor = SkColorSetARGB(0xFF, 0x00, 0x00, 0x00);
// Opacity of the power button menu fullscreen background shield.
constexpr float kPowerButtonMenuOpacity = 0.6f;
......@@ -65,7 +64,9 @@ class PowerButtonMenuScreenView::PowerButtonMenuBackgroundView
PowerButtonMenuBackgroundView(base::RepeatingClosure show_animation_done)
: show_animation_done_(show_animation_done) {
SetPaintToLayer(ui::LAYER_SOLID_COLOR);
layer()->SetColor(kShieldColor);
layer()->SetColor(AshColorProvider::Get()->DeprecatedGetShieldLayerColor(
AshColorProvider::ShieldLayerType::kAlpha60,
kPowerButtonMenuFullscreenShieldColor));
}
~PowerButtonMenuBackgroundView() override = default;
......
......@@ -5,11 +5,14 @@
#include "ash/system/power/power_button_menu_view.h"
#include "ash/display/screen_orientation_controller.h"
#include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/new_window_delegate.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ash/system/power/power_button_menu_item_view.h"
#include "ash/system/power/power_button_menu_metrics_type.h"
#include "ash/system/user/login_status.h"
......@@ -34,6 +37,14 @@ constexpr int kMenuViewRoundRectRadiusDp = 16;
// Horizontal padding between two menu items.
constexpr int kPaddingBetweenMenuItems = 8;
SkColor GetMenuBackgroundColor() {
return AshColorProvider::Get()->DeprecatedGetBaseLayerColor(
app_list_features::IsBackgroundBlurEnabled()
? AshColorProvider::BaseLayerType::kTransparentWithBlur
: AshColorProvider::BaseLayerType::kTransparentWithoutBlur,
kPowerButtonMenuBackgroundColor);
}
} // namespace
using PowerButtonPosition = PowerButtonController::PowerButtonPosition;
......@@ -220,7 +231,7 @@ void PowerButtonMenuView::OnPaint(gfx::Canvas* canvas) {
SkPath path;
path.addRoundRect(gfx::RectToSkRect(gfx::Rect(size())), kRadius);
canvas->ClipPath(path, true);
canvas->DrawColor(SK_ColorWHITE);
canvas->DrawColor(GetMenuBackgroundColor());
}
gfx::Size PowerButtonMenuView::CalculatePreferredSize() const {
......
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