Commit a4c22f31 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Change toggle button colors to match UX specs

Bug: 1145295
Change-Id: I8c3f2cb0a07895af16ac6c7ea24d3b4ae2f7c2b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545643Reviewed-by: default avatarMin Chen <minch@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829043}
parent 3b24e26c
...@@ -223,11 +223,20 @@ SkColor AshColorProvider::GetContentLayerColor(ContentLayerType type) const { ...@@ -223,11 +223,20 @@ SkColor AshColorProvider::GetContentLayerColor(ContentLayerType type) const {
case ContentLayerType::kSliderColorInactive: case ContentLayerType::kSliderColorInactive:
case ContentLayerType::kRadioColorInactive: case ContentLayerType::kRadioColorInactive:
return is_dark_mode ? gfx::kGoogleGrey200 : gfx::kGoogleGrey700; return is_dark_mode ? gfx::kGoogleGrey200 : gfx::kGoogleGrey700;
case ContentLayerType::kSwitchKnobColorInactive:
return is_dark_mode ? gfx::kGoogleGrey800 : SK_ColorWHITE;
case ContentLayerType::kSwitchTrackColorInactive:
return GetSecondToneColor(is_dark_mode ? gfx::kGoogleGrey200
: gfx::kGoogleGrey700);
case ContentLayerType::kButtonLabelColorBlue: case ContentLayerType::kButtonLabelColorBlue:
case ContentLayerType::kSliderColorActive: case ContentLayerType::kSliderColorActive:
case ContentLayerType::kRadioColorActive: case ContentLayerType::kRadioColorActive:
case ContentLayerType::kSwitchAccessInnerStrokeColor: case ContentLayerType::kSwitchAccessInnerStrokeColor:
case ContentLayerType::kSwitchKnobColorActive:
return is_dark_mode ? gfx::kGoogleBlue300 : gfx::kGoogleBlue600; return is_dark_mode ? gfx::kGoogleBlue300 : gfx::kGoogleBlue600;
case ContentLayerType::kSwitchTrackColorActive:
return GetSecondToneColor(
GetContentLayerColor(ContentLayerType::kSwitchKnobColorActive));
case ContentLayerType::kButtonLabelColorPrimary: case ContentLayerType::kButtonLabelColorPrimary:
case ContentLayerType::kButtonIconColorPrimary: case ContentLayerType::kButtonIconColorPrimary:
case ContentLayerType::kBatteryBadgeColor: case ContentLayerType::kBatteryBadgeColor:
......
...@@ -121,6 +121,12 @@ class ASH_EXPORT AshColorProvider : public SessionObserver { ...@@ -121,6 +121,12 @@ class ASH_EXPORT AshColorProvider : public SessionObserver {
kRadioColorActive, kRadioColorActive,
kRadioColorInactive, kRadioColorInactive,
// Color for toggle button.
kSwitchKnobColorActive,
kSwitchKnobColorInactive,
kSwitchTrackColorActive,
kSwitchTrackColorInactive,
// Color for current active desk's border. // Color for current active desk's border.
kCurrentDeskColor, kCurrentDeskColor,
......
...@@ -122,6 +122,7 @@ void DarkModeDetailedView::OnThemeChanged() { ...@@ -122,6 +122,7 @@ void DarkModeDetailedView::OnThemeChanged() {
TrayDetailedView::OnThemeChanged(); TrayDetailedView::OnThemeChanged();
themed_label_->SetEnabledColor(GetLabelColor()); themed_label_->SetEnabledColor(GetLabelColor());
neutral_label_->SetEnabledColor(GetLabelColor()); neutral_label_->SetEnabledColor(GetLabelColor());
TrayPopupUtils::UpdateToggleButtonColors(toggle_);
} }
void DarkModeDetailedView::UpdateToggleButton(bool dark_mode_enabled) { void DarkModeDetailedView::UpdateToggleButton(bool dark_mode_enabled) {
......
...@@ -219,15 +219,6 @@ views::ImageView* TrayPopupUtils::CreateMainImageView() { ...@@ -219,15 +219,6 @@ views::ImageView* TrayPopupUtils::CreateMainImageView() {
views::ToggleButton* TrayPopupUtils::CreateToggleButton( views::ToggleButton* TrayPopupUtils::CreateToggleButton(
views::Button::PressedCallback callback, views::Button::PressedCallback callback,
int accessible_name_id) { int accessible_name_id) {
constexpr SkColor kTrackAlpha = 0x66;
auto GetColor = [](bool is_on, SkAlpha alpha = SK_AlphaOPAQUE) {
AshColorProvider::ContentLayerType type =
is_on ? AshColorProvider::ContentLayerType::kIconColorProminent
: AshColorProvider::ContentLayerType::kTextColorPrimary;
return SkColorSetA(AshColorProvider::Get()->GetContentLayerColor(type),
alpha);
};
views::ToggleButton* toggle = new views::ToggleButton(std::move(callback)); views::ToggleButton* toggle = new views::ToggleButton(std::move(callback));
const gfx::Size toggle_size(toggle->GetPreferredSize()); const gfx::Size toggle_size(toggle->GetPreferredSize());
const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2; const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2;
...@@ -236,10 +227,7 @@ views::ToggleButton* TrayPopupUtils::CreateToggleButton( ...@@ -236,10 +227,7 @@ views::ToggleButton* TrayPopupUtils::CreateToggleButton(
toggle->SetBorder(views::CreateEmptyBorder( toggle->SetBorder(views::CreateEmptyBorder(
gfx::Insets(vertical_padding, horizontal_padding))); gfx::Insets(vertical_padding, horizontal_padding)));
toggle->SetAccessibleName(l10n_util::GetStringUTF16(accessible_name_id)); toggle->SetAccessibleName(l10n_util::GetStringUTF16(accessible_name_id));
toggle->SetThumbOnColor(GetColor(true)); UpdateToggleButtonColors(toggle);
toggle->SetThumbOffColor(GetColor(false));
toggle->SetTrackOnColor(GetColor(true, kTrackAlpha));
toggle->SetTrackOffColor(GetColor(false, kTrackAlpha));
return toggle; return toggle;
} }
...@@ -367,6 +355,18 @@ void TrayPopupUtils::UpdateCheckMarkVisibility(HoverHighlightView* container, ...@@ -367,6 +355,18 @@ void TrayPopupUtils::UpdateCheckMarkVisibility(HoverHighlightView* container,
: HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); : HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX);
} }
void TrayPopupUtils::UpdateToggleButtonColors(views::ToggleButton* toggle) {
auto* ash_color_provider = AshColorProvider::Get();
toggle->SetThumbOnColor(ash_color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSwitchKnobColorActive));
toggle->SetThumbOffColor(ash_color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSwitchKnobColorInactive));
toggle->SetTrackOnColor(ash_color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSwitchTrackColorActive));
toggle->SetTrackOffColor(ash_color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSwitchTrackColorInactive));
}
void TrayPopupUtils::SetLabelFontList(views::Label* label, FontStyle style) { void TrayPopupUtils::SetLabelFontList(views::Label* label, FontStyle style) {
label->SetAutoColorReadabilityEnabled(false); label->SetAutoColorReadabilityEnabled(false);
const gfx::FontList& base_font_list = views::Label::GetDefaultFontList(); const gfx::FontList& base_font_list = views::Label::GetDefaultFontList();
......
...@@ -201,6 +201,9 @@ class TrayPopupUtils { ...@@ -201,6 +201,9 @@ class TrayPopupUtils {
static void UpdateCheckMarkVisibility(HoverHighlightView* container, static void UpdateCheckMarkVisibility(HoverHighlightView* container,
bool visible); bool visible);
// Updates the toggle button colors based on the current color mode.
static void UpdateToggleButtonColors(views::ToggleButton* toggle);
// Sets the font list for |label| based on |style|. // Sets the font list for |label| based on |style|.
static void SetLabelFontList(views::Label* label, FontStyle style); static void SetLabelFontList(views::Label* label, FontStyle style);
......
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