Commit 7faddcc4 authored by minch's avatar minch Committed by Commit Bot

dark_mode: Live update under ash/system.

Live update for auto click menu, media controls in the system tray menu,
magnified device info etc.

Bug: 1131543
Change-Id: Ic5791723636fd9014bff021126b715ed703eba8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506836
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824280}
parent e1d559cf
......@@ -115,7 +115,9 @@ class AutoclickScrollButton : public CustomShapeButton,
const gfx::VectorIcon& icon,
int accessible_name_id,
AutoclickScrollView::ButtonId id)
: CustomShapeButton(PressedCallback(this, this)), action_(action) {
: CustomShapeButton(PressedCallback(this, this)),
action_(action),
icon_(icon) {
views::View::SetID(static_cast<int>(id));
SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id));
// Disable canvas flipping, as scroll left should always be left no matter
......@@ -127,10 +129,6 @@ class AutoclickScrollButton : public CustomShapeButton,
int64_t{AutoclickScrollView::kAutoclickScrollDelayMs}),
base::BindRepeating(&AutoclickScrollButton::DoScrollAction,
base::Unretained(this)));
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(
icon, AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kIconColorPrimary)));
if (action_ == AutoclickController::ScrollPadAction::kScrollLeft ||
action_ == AutoclickController::ScrollPadAction::kScrollRight) {
size_ = gfx::Size(kScrollPadButtonHypotenuseDips / 2,
......@@ -192,6 +190,15 @@ class AutoclickScrollButton : public CustomShapeButton,
return ComputePath(true /* all_edges */);
}
void OnThemeChanged() override {
CustomShapeButton::OnThemeChanged();
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(
icon_, AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kIconColorPrimary)));
SchedulePaint();
}
// Computes the path which is the outline of this button. If |all_edges|,
// returns a path which fully encloses the shape, otherwise just returns a
// path that can be used for drawing the edges but avoids overlap with
......@@ -315,6 +322,7 @@ class AutoclickScrollButton : public CustomShapeButton,
gfx::Size size_;
std::unique_ptr<base::RetainingOneShotTimer> scroll_hover_timer_;
bool active_ = false;
const gfx::VectorIcon& icon_;
DISALLOW_COPY_AND_ASSIGN(AutoclickScrollButton);
};
......
......@@ -21,10 +21,6 @@
namespace ash {
namespace {
const SkColor kFloatingMenuButtonIconColorActive = SkColorSetRGB(32, 33, 36);
}
FloatingMenuButton::FloatingMenuButton(views::ButtonListener* listener,
const gfx::VectorIcon& icon,
int accessible_name_id,
......@@ -55,10 +51,7 @@ FloatingMenuButton::FloatingMenuButton(views::ButtonListener* listener,
SetPreferredSize(gfx::Size(size_, size_));
TrayPopupUtils::ConfigureTrayPopupButton(this);
views::InstallCircleHighlightPathGenerator(this);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id));
UpdateImage();
}
FloatingMenuButton::~FloatingMenuButton() = default;
......@@ -126,21 +119,22 @@ FloatingMenuButton::CreateInkDropHighlight() const {
return TrayPopupUtils::CreateInkDropHighlight(this);
}
void FloatingMenuButton::OnThemeChanged() {
ImageButton::OnThemeChanged();
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
UpdateImage();
SchedulePaint();
}
void FloatingMenuButton::SetId(int id) {
views::View::SetID(id);
}
void FloatingMenuButton::UpdateImage() {
const SkColor icon_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(
*icon_, toggled_ ? kFloatingMenuButtonIconColorActive : icon_color));
SetImage(
views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(
*icon_, toggled_ ? kFloatingMenuButtonIconColorActive : icon_color));
DCHECK(icon_);
AshColorProvider::Get()->DecorateIconButton(
this, *icon_, toggled_, GetDefaultSizeOfVectorIcon(*icon_));
}
} // namespace ash
......@@ -50,6 +50,7 @@ class FloatingMenuButton : public views::ImageButton {
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override;
void OnThemeChanged() override;
// Used in tests.
void SetId(int id);
......
......@@ -6,7 +6,6 @@
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/system/audio/mic_gain_slider_controller.h"
#include "ash/system/tray/tray_constants.h"
#include "components/vector_icons/vector_icons.h"
......
......@@ -6,7 +6,6 @@
#include "ash/public/cpp/media_notification_provider.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/system/media/unified_media_controls_detailed_view.h"
#include "ash/system/tray/detailed_view_delegate.h"
#include "ash/system/tray/tray_constants.h"
......
......@@ -91,6 +91,11 @@ const gfx::VectorIcon& GetVectorIconForMediaAction(MediaSessionAction action) {
return gfx::kNoneIcon;
}
SkColor GetBackgroundColor() {
return AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive);
}
} // namespace
UnifiedMediaControlsView::MediaActionButton::MediaActionButton(
......@@ -105,7 +110,8 @@ UnifiedMediaControlsView::MediaActionButton::MediaActionButton(
media_message_center::GetActionFromButtonTag(*button));
},
controller,
this)) {
this)),
action_(action) {
SetImageHorizontalAlignment(views::ImageButton::ALIGN_CENTER);
SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE);
SetPreferredSize(kMediaButtonSize);
......@@ -113,27 +119,15 @@ UnifiedMediaControlsView::MediaActionButton::MediaActionButton(
TrayPopupUtils::ConfigureTrayPopupButton(this);
views::InstallCircleHighlightPathGenerator(this);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
}
void UnifiedMediaControlsView::MediaActionButton::SetAction(
MediaSessionAction action,
const base::string16& accessible_name) {
action_ = action;
set_tag(static_cast<int>(action));
SetTooltipText(accessible_name);
SetImage(views::Button::STATE_NORMAL,
CreateVectorIcon(
GetVectorIconForMediaAction(action), kMediaButtonIconSize,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
SetImage(views::Button::STATE_DISABLED,
CreateVectorIcon(
GetVectorIconForMediaAction(action), kMediaButtonIconSize,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorSecondary)));
UpdateVectorIcon();
}
std::unique_ptr<views::InkDrop>
......@@ -155,6 +149,19 @@ UnifiedMediaControlsView::MediaActionButton::CreateInkDropRipple() const {
GetInkDropCenterBasedOnLastEvent());
}
void UnifiedMediaControlsView::MediaActionButton::OnThemeChanged() {
views::ImageButton::OnThemeChanged();
UpdateVectorIcon();
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
}
void UnifiedMediaControlsView::MediaActionButton::UpdateVectorIcon() {
AshColorProvider::Get()->DecorateIconButton(
this, GetVectorIconForMediaAction(action_), /*toggled=*/false,
kMediaButtonIconSize);
}
UnifiedMediaControlsView::UnifiedMediaControlsView(
UnifiedMediaControlsController* controller)
: views::Button(base::BindRepeating(
......@@ -165,13 +172,8 @@ UnifiedMediaControlsView::UnifiedMediaControlsView(
this)),
controller_(controller) {
SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SetBackground(views::CreateRoundedRectBackground(
AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive),
kMediaControlsCornerRadius));
SetBackground(views::CreateRoundedRectBackground(GetBackgroundColor(),
kMediaControlsCornerRadius));
auto* box_layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, kMediaControlsViewInsets,
kMediaControlsViewPadding));
......@@ -199,30 +201,21 @@ UnifiedMediaControlsView::UnifiedMediaControlsView(
label->SetSubpixelRenderingEnabled(false);
};
auto title_label = std::make_unique<views::Label>();
config_label(title_label.get());
title_label->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary));
title_label->SetFontList(
title_label_ = title_row->AddChildView(std::make_unique<views::Label>());
config_label(title_label_);
title_label_->SetFontList(
views::Label::GetDefaultFontList().DeriveWithSizeDelta(
kTrackTitleFontSizeIncrease));
title_label_ = title_row->AddChildView(std::move(title_label));
auto drop_down_icon = std::make_unique<views::ImageView>();
drop_down_icon->SetPreferredSize(gfx::Size(kTitleRowHeight, kTitleRowHeight));
drop_down_icon->SetImage(CreateVectorIcon(
kUnifiedMenuMoreIcon,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
drop_down_icon_ = title_row->AddChildView(std::move(drop_down_icon));
drop_down_icon_ =
title_row->AddChildView(std::make_unique<views::ImageView>());
drop_down_icon_->SetPreferredSize(
gfx::Size(kTitleRowHeight, kTitleRowHeight));
track_column->AddChildView(std::move(title_row));
auto artist_label = std::make_unique<views::Label>();
config_label(artist_label.get());
artist_label->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary));
artist_label_ = track_column->AddChildView(std::move(artist_label));
artist_label_ = track_column->AddChildView(std::make_unique<views::Label>());
config_label(artist_label_);
box_layout->SetFlexForView(AddChildView(std::move(track_column)), 1);
......@@ -302,6 +295,22 @@ void UnifiedMediaControlsView::UpdateActionButtonAvailability(
button_row_->InvalidateLayout();
}
void UnifiedMediaControlsView::OnThemeChanged() {
views::Button::OnThemeChanged();
auto* color_provider = AshColorProvider::Get();
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
background()->SetNativeControlColor(GetBackgroundColor());
title_label_->SetEnabledColor(color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary));
drop_down_icon_->SetImage(CreateVectorIcon(
kUnifiedMenuMoreIcon,
color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
artist_label_->SetEnabledColor(color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary));
}
void UnifiedMediaControlsView::ShowEmptyState() {
is_in_empty_state_ = true;
......
......@@ -39,6 +39,9 @@ class ASH_EXPORT UnifiedMediaControlsView : public views::Button {
const base::flat_set<media_session::mojom::MediaSessionAction>&
enabled_actions);
// views::Button:
void OnThemeChanged() override;
// Show an empty state representing no media is playing.
void ShowEmptyState();
......@@ -66,6 +69,14 @@ class ASH_EXPORT UnifiedMediaControlsView : public views::Button {
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
void OnThemeChanged() override;
private:
void UpdateVectorIcon();
// Action that can be taken on the media through the button, it can be paly,
// pause or stop the media etc. See MediaSessionAction for all the actions.
media_session::mojom::MediaSessionAction action_;
};
SkPath GetArtworkClipPath(
......
......@@ -11,8 +11,6 @@
#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/style/default_colors.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_container.h"
#include "ash/wm/mru_window_tracker.h"
......@@ -40,9 +38,8 @@ OverviewButtonTray::OverviewButtonTray(Shelf* shelf)
scoped_session_observer_(this) {
gfx::ImageSkia image = gfx::CreateVectorIcon(
kShelfOverviewIcon,
DeprecatedGetContentLayerColor(
AshColorProvider::ContentLayerType::kButtonIconColor,
kShelfButtonColor));
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kButtonIconColor));
icon_->SetImage(image);
const int vertical_padding = (kTrayItemSize - image.height()) / 2;
const int horizontal_padding = (kTrayItemSize - image.width()) / 2;
......
......@@ -16,7 +16,6 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/label.h"
......
......@@ -40,7 +40,6 @@
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/stylus_state.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
......
......@@ -82,6 +82,11 @@ const char* PowerTrayView::GetClassName() const {
return "PowerTrayView";
}
void PowerTrayView::OnThemeChanged() {
TrayItemView::OnThemeChanged();
UpdateImage();
}
void PowerTrayView::HandleLocaleChange() {
UpdateStatus();
}
......
......@@ -30,6 +30,7 @@ class PowerTrayView : public TrayItemView,
views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
base::string16 GetTooltipText(const gfx::Point& p) const override;
const char* GetClassName() const override;
void OnThemeChanged() override;
// TrayItemView:
void HandleLocaleChange() override;
......
......@@ -24,7 +24,6 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/button/md_text_button.h"
......
......@@ -51,13 +51,8 @@ SystemMenuButton::SystemMenuButton(PressedCallback callback,
}
void SystemMenuButton::SetVectorIcon(const gfx::VectorIcon& icon) {
const SkColor icon_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(icon, icon_color));
SetImage(views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(
icon, AshColorProvider::GetDisabledColor(icon_color)));
AshColorProvider::Get()->DecorateIconButton(this, icon, /*toggled=*/false,
GetDefaultSizeOfVectorIcon(icon));
}
SystemMenuButton::~SystemMenuButton() = default;
......
......@@ -18,8 +18,6 @@
#include "ash/shelf/shelf_navigation_widget.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/style/default_color_constants.h"
#include "ash/style/default_colors.h"
#include "ash/system/model/system_tray_model.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/status_area_widget_delegate.h"
......@@ -161,9 +159,9 @@ TrayBackgroundView::TrayBackgroundView(Shelf* shelf)
DCHECK(shelf_);
SetNotifyEnterExitOnChild(true);
SetInkDropBaseColor(DeprecatedGetInkDropBaseColor(kDefaultShelfInkDropColor));
SetInkDropVisibleOpacity(
DeprecatedGetInkDropOpacity(kDefaultShelfInkDropOpacity));
auto ripple_attributes = AshColorProvider::Get()->GetRippleAttributes();
SetInkDropBaseColor(ripple_attributes.base_color);
SetInkDropVisibleOpacity(ripple_attributes.inkdrop_opacity);
SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
SetLayoutManager(std::make_unique<views::FillLayout>());
......
......@@ -39,8 +39,6 @@ CustomShapeButton::CustomShapeButton(PressedCallback callback)
TrayPopupUtils::ConfigureTrayPopupButton(this);
views::HighlightPathGenerator::Install(
this, std::make_unique<CustomShapeButtonHighlightPathGenerator>());
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
}
CustomShapeButton::~CustomShapeButton() = default;
......@@ -70,6 +68,13 @@ const char* CustomShapeButton::GetClassName() const {
return "CustomShapeButton";
}
void CustomShapeButton::OnThemeChanged() {
ImageButton::OnThemeChanged();
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SchedulePaint();
}
void CustomShapeButton::PaintCustomShapePath(gfx::Canvas* canvas) {
cc::PaintFlags flags;
flags.setAntiAlias(true);
......
......@@ -26,6 +26,7 @@ class CustomShapeButton : public views::ImageButton {
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override;
const char* GetClassName() const override;
void OnThemeChanged() override;
protected:
void PaintCustomShapePath(gfx::Canvas* canvas);
......
......@@ -47,8 +47,6 @@ UnifiedManagedDeviceView::UnifiedManagedDeviceView(
label_->SetAutoColorReadabilityEnabled(false);
label_->SetSubpixelRenderingEnabled(false);
label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary));
label_->SetID(VIEW_ID_TRAY_ENTERPRISE_LABEL);
AddChildView(label_);
......@@ -76,6 +74,13 @@ const char* UnifiedManagedDeviceView::GetClassName() const {
return "UnifiedManagedDeviceView";
}
void UnifiedManagedDeviceView::OnThemeChanged() {
views::Button::OnThemeChanged();
label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary));
Update();
}
void UnifiedManagedDeviceView::Update() {
SessionControllerImpl* session = Shell::Get()->session_controller();
EnterpriseDomainModel* model =
......
......@@ -34,8 +34,9 @@ class ASH_EXPORT UnifiedManagedDeviceView : public views::Button,
// EnterpriseDomainObserver:
void OnEnterpriseDomainChanged() override;
// views::TrayItemView:
// views::Button:
const char* GetClassName() const override;
void OnThemeChanged() override;
private:
void Update();
......
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