Commit 4044e751 authored by minch's avatar minch Committed by Commit Bot

dark_mode: Dark mode for power menu and system toast.

Bug: 1128763, 1107058
Change-Id: Iba395be1240214924279dc3c928991b6a513d09f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419918Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809001}
parent c0453c6a
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "ash/system/power/power_button_menu_item_view.h" #include "ash/system/power/power_button_menu_item_view.h"
#include "ash/style/ash_color_provider.h" #include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/font.h" #include "ui/gfx/font.h"
...@@ -49,15 +48,13 @@ PowerButtonMenuItemView::PowerButtonMenuItemView( ...@@ -49,15 +48,13 @@ PowerButtonMenuItemView::PowerButtonMenuItemView(
const AshColorProvider* color_provider = AshColorProvider::Get(); const AshColorProvider* color_provider = AshColorProvider::Get();
icon_view_->SetImage(gfx::CreateVectorIcon( icon_view_->SetImage(gfx::CreateVectorIcon(
icon, color_provider->DeprecatedGetContentLayerColor( icon, color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary, AshColorProvider::ContentLayerType::kIconColorPrimary)));
kPowerButtonMenuItemIconColor)));
AddChildView(icon_view_); AddChildView(icon_view_);
title_->SetBackgroundColor(SK_ColorTRANSPARENT); title_->SetBackgroundColor(SK_ColorTRANSPARENT);
title_->SetEnabledColor(color_provider->DeprecatedGetContentLayerColor( title_->SetEnabledColor(color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary, AshColorProvider::ContentLayerType::kTextColorPrimary));
kPowerButtonMenuItemTitleColor));
title_->SetText(title_text); title_->SetText(title_text);
title_->SetVerticalAlignment(gfx::ALIGN_TOP); title_->SetVerticalAlignment(gfx::ALIGN_TOP);
title_->SetLineHeight(kLineHeight); title_->SetLineHeight(kLineHeight);
...@@ -123,9 +120,8 @@ void PowerButtonMenuItemView::PaintButtonContents(gfx::Canvas* canvas) { ...@@ -123,9 +120,8 @@ void PowerButtonMenuItemView::PaintButtonContents(gfx::Canvas* canvas) {
gfx::Rect bounds = GetLocalBounds(); gfx::Rect bounds = GetLocalBounds();
bounds.Inset(gfx::Insets(kItemBorderThickness)); bounds.Inset(gfx::Insets(kItemBorderThickness));
// Stroke. // Stroke.
flags.setColor(AshColorProvider::Get()->DeprecatedGetControlsLayerColor( flags.setColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor, AshColorProvider::ControlsLayerType::kFocusRingColor));
kPowerButtonMenuItemFocusColor));
flags.setStrokeWidth(kItemBorderThickness); flags.setStrokeWidth(kItemBorderThickness);
flags.setStyle(cc::PaintFlags::Style::kStroke_Style); flags.setStyle(cc::PaintFlags::Style::kStroke_Style);
canvas->DrawRoundRect(bounds, kFocusedItemRoundRectRadiusDp, flags); canvas->DrawRoundRect(bounds, kFocusedItemRoundRectRadiusDp, flags);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/style/ash_color_provider.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_metrics_type.h"
#include "ash/system/power/power_button_menu_view.h" #include "ash/system/power/power_button_menu_view.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
...@@ -26,7 +25,7 @@ constexpr int PowerButtonMenuView::kMenuViewTransformDistanceDp; ...@@ -26,7 +25,7 @@ constexpr int PowerButtonMenuView::kMenuViewTransformDistanceDp;
namespace { namespace {
// Opacity of the power button menu fullscreen background shield. // Opacity of the power button menu fullscreen background shield.
constexpr float kPowerButtonMenuOpacity = 0.6f; constexpr float kPowerButtonMenuOpacity = 0.4f;
// TODO(minch): Get the internal display size instead if needed. // TODO(minch): Get the internal display size instead if needed.
// Gets the landscape size of the primary display. For landscape orientation, // Gets the landscape size of the primary display. For landscape orientation,
...@@ -64,9 +63,8 @@ class PowerButtonMenuScreenView::PowerButtonMenuBackgroundView ...@@ -64,9 +63,8 @@ class PowerButtonMenuScreenView::PowerButtonMenuBackgroundView
PowerButtonMenuBackgroundView(base::RepeatingClosure show_animation_done) PowerButtonMenuBackgroundView(base::RepeatingClosure show_animation_done)
: show_animation_done_(show_animation_done) { : show_animation_done_(show_animation_done) {
SetPaintToLayer(ui::LAYER_SOLID_COLOR); SetPaintToLayer(ui::LAYER_SOLID_COLOR);
layer()->SetColor(AshColorProvider::Get()->DeprecatedGetShieldLayerColor( layer()->SetColor(AshColorProvider::Get()->GetShieldLayerColor(
AshColorProvider::ShieldLayerType::kShield60, AshColorProvider::ShieldLayerType::kShield40));
kPowerButtonMenuFullscreenShieldColor));
layer()->SetOpacity(0.f); layer()->SetOpacity(0.f);
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.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_item_view.h"
#include "ash/system/power/power_button_menu_metrics_type.h" #include "ash/system/power/power_button_menu_metrics_type.h"
#include "ash/system/user/login_status.h" #include "ash/system/user/login_status.h"
...@@ -24,9 +23,9 @@ ...@@ -24,9 +23,9 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer_animator.h" #include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "ui/views/accessibility/view_accessibility.h" #include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
namespace ash { namespace ash {
...@@ -37,19 +36,11 @@ constexpr int kMenuItemHorizontalPadding = 16; ...@@ -37,19 +36,11 @@ constexpr int kMenuItemHorizontalPadding = 16;
constexpr int kMenuItemVerticalPadding = 16; constexpr int kMenuItemVerticalPadding = 16;
// The amount of rounding applied to the corners of the menu view. // The amount of rounding applied to the corners of the menu view.
constexpr int kMenuViewRoundRectRadiusDp = 16; constexpr gfx::RoundedCornersF kMenuViewRoundRectRadiusDp{16.f};
// Horizontal padding between two menu items. // Horizontal padding between two menu items.
constexpr int kPaddingBetweenMenuItems = 8; constexpr int kPaddingBetweenMenuItems = 8;
SkColor GetMenuBackgroundColor() {
return AshColorProvider::Get()->DeprecatedGetBaseLayerColor(
features::IsBackgroundBlurEnabled()
? AshColorProvider::BaseLayerType::kTransparent80
: AshColorProvider::BaseLayerType::kTransparent90,
kPowerButtonMenuBackgroundColor);
}
} // namespace } // namespace
using PowerButtonPosition = PowerButtonController::PowerButtonPosition; using PowerButtonPosition = PowerButtonController::PowerButtonPosition;
...@@ -61,8 +52,15 @@ PowerButtonMenuView::PowerButtonMenuView( ...@@ -61,8 +52,15 @@ PowerButtonMenuView::PowerButtonMenuView(
: power_button_position_(power_button_position) { : power_button_position_(power_button_position) {
SetFocusBehavior(FocusBehavior::ALWAYS); SetFocusBehavior(FocusBehavior::ALWAYS);
SetPaintToLayer(); SetPaintToLayer();
SetBackground(
views::CreateSolidBackground(AshColorProvider::Get()->GetBaseLayerColor(
features::IsBackgroundBlurEnabled()
? AshColorProvider::BaseLayerType::kTransparent80
: AshColorProvider::BaseLayerType::kTransparent90)));
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
layer()->SetOpacity(0.f); layer()->SetRoundedCornerRadius(kMenuViewRoundRectRadiusDp);
layer()->SetBackgroundBlur(
static_cast<float>(AshColorProvider::LayerBlurSigma::kBlurDefault));
GetViewAccessibility().OverrideRole(ax::mojom::Role::kMenu); GetViewAccessibility().OverrideRole(ax::mojom::Role::kMenu);
GetViewAccessibility().OverrideName( GetViewAccessibility().OverrideName(
l10n_util::GetStringUTF16(IDS_ASH_POWER_BUTTON_MENU_ACCESSIBLE)); l10n_util::GetStringUTF16(IDS_ASH_POWER_BUTTON_MENU_ACCESSIBLE));
...@@ -232,19 +230,6 @@ void PowerButtonMenuView::Layout() { ...@@ -232,19 +230,6 @@ void PowerButtonMenuView::Layout() {
} }
} }
void PowerButtonMenuView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);
// Clip into a rounded rectangle.
constexpr SkScalar radius = SkIntToScalar(kMenuViewRoundRectRadiusDp);
constexpr SkScalar kRadius[8] = {radius, radius, radius, radius,
radius, radius, radius, radius};
SkPath path;
path.addRoundRect(gfx::RectToSkRect(gfx::Rect(size())), kRadius);
canvas->ClipPath(path, true);
canvas->DrawColor(GetMenuBackgroundColor());
}
gfx::Size PowerButtonMenuView::CalculatePreferredSize() const { gfx::Size PowerButtonMenuView::CalculatePreferredSize() const {
gfx::Size menu_size; gfx::Size menu_size;
DCHECK(power_off_item_); DCHECK(power_off_item_);
......
...@@ -74,7 +74,6 @@ class ASH_EXPORT PowerButtonMenuView : public views::View, ...@@ -74,7 +74,6 @@ class ASH_EXPORT PowerButtonMenuView : public views::View,
private: private:
// views::View: // views::View:
void Layout() override; void Layout() override;
void OnPaint(gfx::Canvas* canvas) override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
// views::ButtonListener: // views::ButtonListener:
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h" #include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ash/wm/work_area_insets.h" #include "ash/wm/work_area_insets.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -25,6 +24,7 @@ ...@@ -25,6 +24,7 @@
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/views/animation/ink_drop_highlight.h" #include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/background.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/highlight_path_generator.h" #include "ui/views/controls/highlight_path_generator.h"
...@@ -42,9 +42,6 @@ namespace { ...@@ -42,9 +42,6 @@ namespace {
// Duration of slide animation when overlay is shown or hidden. // Duration of slide animation when overlay is shown or hidden.
constexpr int kSlideAnimationDurationMs = 100; constexpr int kSlideAnimationDurationMs = 100;
// Colors for the dismiss button.
constexpr SkColor kButtonTextColor = SkColorSetARGB(0xFF, 0xD2, 0xE3, 0xFC);
// These values are in DIP. // These values are in DIP.
constexpr int kToastCornerRounding = 16; constexpr int kToastCornerRounding = 16;
constexpr int kToastHeight = 32; constexpr int kToastHeight = 32;
...@@ -70,9 +67,8 @@ class ToastOverlayLabel : public views::Label { ...@@ -70,9 +67,8 @@ class ToastOverlayLabel : public views::Label {
SetAutoColorReadabilityEnabled(false); SetAutoColorReadabilityEnabled(false);
SetMultiLine(true); SetMultiLine(true);
SetMaxLines(2); SetMaxLines(2);
SetEnabledColor(AshColorProvider::Get()->DeprecatedGetContentLayerColor( SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary, AshColorProvider::ContentLayerType::kTextColorPrimary));
kToastLabelColor));
SetSubpixelRenderingEnabled(false); SetSubpixelRenderingEnabled(false);
int vertical_spacing = int vertical_spacing =
...@@ -121,11 +117,11 @@ class ToastOverlayButton : public views::LabelButton { ...@@ -121,11 +117,11 @@ class ToastOverlayButton : public views::LabelButton {
: views::LabelButton(listener, text, CONTEXT_TOAST_OVERLAY) { : views::LabelButton(listener, text, CONTEXT_TOAST_OVERLAY) {
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true); set_has_ink_drop_action_on_click(true);
set_ink_drop_base_color(AshColorProvider::Get() const auto* color_provider = AshColorProvider::Get();
->GetRippleAttributes(toast_backgrond_color) set_ink_drop_base_color(
.base_color); color_provider->GetRippleAttributes(toast_backgrond_color).base_color);
SetEnabledTextColors(color_provider->GetContentLayerColor(
SetEnabledTextColors(kButtonTextColor); AshColorProvider::ContentLayerType::kButtonLabelColorBlue));
// Treat the space below the baseline as a margin. // Treat the space below the baseline as a margin.
int vertical_spacing = int vertical_spacing =
...@@ -162,52 +158,47 @@ class ToastOverlayView : public views::View, public views::ButtonListener { ...@@ -162,52 +158,47 @@ class ToastOverlayView : public views::View, public views::ButtonListener {
const base::string16& text, const base::string16& text,
const base::Optional<base::string16>& dismiss_text) const base::Optional<base::string16>& dismiss_text)
: overlay_(overlay) { : overlay_(overlay) {
background_color_ = AshColorProvider::Get()->DeprecatedGetBaseLayerColor( SetPaintToLayer();
background_color_ = AshColorProvider::Get()->GetBaseLayerColor(
features::IsBackgroundBlurEnabled() features::IsBackgroundBlurEnabled()
? AshColorProvider::BaseLayerType::kTransparent80 ? AshColorProvider::BaseLayerType::kTransparent80
: AshColorProvider::BaseLayerType::kTransparent90, : AshColorProvider::BaseLayerType::kTransparent90);
kToastBackgroundColor); SetBackground(views::CreateSolidBackground(background_color_));
layer()->SetFillsBoundsOpaquely(false);
layer()->SetRoundedCornerRadius(gfx::RoundedCornersF(kToastCornerRounding));
layer()->SetBackgroundBlur(
static_cast<float>(AshColorProvider::LayerBlurSigma::kBlurDefault));
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>( auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal)); views::BoxLayout::Orientation::kHorizontal));
auto* label = new ToastOverlayLabel(text);
AddChildView(label);
label->SetMaximumWidth(GetMaximumSize().width());
layout->SetFlexForView(label, 1);
if (!dismiss_text.has_value())
return;
if (dismiss_text.has_value()) {
button_ = new ToastOverlayButton( button_ = new ToastOverlayButton(
this, this,
dismiss_text.value().empty() dismiss_text.value().empty()
? l10n_util::GetStringUTF16(IDS_ASH_TOAST_DISMISS_BUTTON) ? l10n_util::GetStringUTF16(IDS_ASH_TOAST_DISMISS_BUTTON)
: dismiss_text.value(), : dismiss_text.value(),
background_color_); background_color_);
}
auto* label = new ToastOverlayLabel(text); const int button_width =
AddChildView(label); std::min(button_->GetPreferredSize().width(), kToastButtonMaximumWidth);
label->SetMaximumWidth(GetMaximumSize().width());
layout->SetFlexForView(label, 1);
if (button_) {
int button_width = std::min(button_->GetPreferredSize().width(),
kToastButtonMaximumWidth);
button_->SetMaxSize(gfx::Size(button_width, GetMaximumSize().height())); button_->SetMaxSize(gfx::Size(button_width, GetMaximumSize().height()));
label->SetMaximumWidth(GetMaximumSize().width() - button_width - label->SetMaximumWidth(GetMaximumSize().width() - button_width -
kToastHorizontalSpacing * 2 - kToastHorizontalSpacing * 2 -
kToastHorizontalSpacing * 2); kToastHorizontalSpacing * 2);
AddChildView(button_); AddChildView(button_);
} }
}
~ToastOverlayView() override = default; ~ToastOverlayView() override = default;
ToastOverlayButton* button() { return button_; } ToastOverlayButton* button() { return button_; }
// views::View:
void OnPaint(gfx::Canvas* canvas) override {
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(background_color_);
canvas->DrawRoundRect(GetLocalBounds(), kToastCornerRounding, flags);
views::View::OnPaint(canvas);
}
private: private:
// views::View: // views::View:
gfx::Size GetMinimumSize() const override { gfx::Size GetMinimumSize() const override {
......
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