Chromium Code Reviews| Index: ash/system/tiles/tiles_default_view.cc |
| diff --git a/ash/system/tiles/tiles_default_view.cc b/ash/system/tiles/tiles_default_view.cc |
| index b67d34e8f7c7892197edd54d860fa00eb9eb8a08..12dd62d101475ebf25ef22ed8680b422c0b9e076 100644 |
| --- a/ash/system/tiles/tiles_default_view.cc |
| +++ b/ash/system/tiles/tiles_default_view.cc |
| @@ -17,12 +17,14 @@ |
| #include "ash/system/tray/system_tray_controller.h" |
| #include "ash/system/tray/system_tray_item.h" |
| #include "ash/system/tray/tray_constants.h" |
| +#include "ash/system/tray/tray_popup_item_style.h" |
| #include "ash/system/tray/tray_popup_utils.h" |
| #include "ash/wm/lock_state_controller.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/dbus/session_manager_client.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/gfx/geometry/insets.h" |
| +#include "ui/gfx/paint_vector_icon.h" |
| #include "ui/views/border.h" |
| #include "ui/views/controls/button/custom_button.h" |
| #include "ui/views/controls/separator.h" |
| @@ -36,10 +38,25 @@ namespace { |
| // not mirrored in this locale. |
| const char kHebrewLocale[] = "he"; |
| -const gfx::VectorIcon& GetNightLightButtonIcon() { |
| - return Shell::Get()->night_light_controller()->GetEnabled() |
| - ? kSystemMenuNightLightOnIcon |
| - : kSystemMenuNightLightOffIcon; |
| +// Updates the icon and its style of the NightLight toggle button based on the |
| +// status of NightLight. |
| +void UpdateNightLightButtonStyle(SystemMenuButton* night_light_button) { |
| + // Use the same icon theme used for inactive items in the tray when |
| + // NightLight is not active. |
| + SkColor normal_color = TrayPopupItemStyle::GetIconColor( |
| + TrayPopupItemStyle::ColorStyle::INACTIVE); |
| + const gfx::VectorIcon* icon = &kSystemMenuNightLightOffIcon; |
| + |
| + if (Shell::Get()->night_light_controller()->GetEnabled()) { |
| + normal_color = kMenuIconColor; |
| + icon = &kSystemMenuNightLightOnIcon; |
| + } |
| + |
| + night_light_button->SetImage(views::Button::STATE_NORMAL, |
| + gfx::CreateVectorIcon(*icon, normal_color)); |
| + night_light_button->SetImage( |
| + views::Button::STATE_DISABLED, |
| + gfx::CreateVectorIcon(*icon, kMenuIconColorDisabled)); |
|
James Cook
2017/05/25 02:08:45
I'm finding this hard to follow. How about creatin
afakhry
2017/05/25 03:17:54
Please take a look at the new code. I created a cl
|
| } |
| } // namespace |
| @@ -91,9 +108,13 @@ void TilesDefaultView::Init() { |
| AddChildView(help_button_); |
| AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
| + // Temporarily create the button with the "Off" icon. Calling |
| + // UpdateNightLightButtonStyle() below will set the correct icon and its theme |
| + // based on the current status of NightLight. |
| night_light_button_ = new SystemMenuButton( |
| - this, TrayPopupInkDropStyle::HOST_CENTERED, GetNightLightButtonIcon(), |
| + this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuNightLightOffIcon, |
| IDS_ASH_STATUS_TRAY_NIGHT_LIGHT); |
| + UpdateNightLightButtonStyle(night_light_button_); |
| night_light_button_->SetEnabled(can_show_web_ui); |
| AddChildView(night_light_button_); |
| AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
| @@ -130,7 +151,7 @@ void TilesDefaultView::ButtonPressed(views::Button* sender, |
| } else if (sender == night_light_button_) { |
| ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT); |
| Shell::Get()->night_light_controller()->Toggle(); |
| - night_light_button_->SetVectorIcon(GetNightLightButtonIcon()); |
| + UpdateNightLightButtonStyle(night_light_button_); |
| } else if (sender == lock_button_) { |
| ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); |
| chromeos::DBusThreadManager::Get() |