Commit 9f4dc13e authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Add support for dark/light mode in tray buttons

The shelf tray buttons do not currently change
color properly after login.

Bug: 1110762
Change-Id: Ic1f95c1ee0e4048633b0ecbff6f3a15951afaacd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2496742
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarMin Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826621}
parent decd1923
...@@ -22,7 +22,9 @@ StopRecordingButtonTray::StopRecordingButtonTray(Shelf* shelf) ...@@ -22,7 +22,9 @@ StopRecordingButtonTray::StopRecordingButtonTray(Shelf* shelf)
: TrayBackgroundView(shelf) { : TrayBackgroundView(shelf) {
auto image_view = std::make_unique<views::ImageView>(); auto image_view = std::make_unique<views::ImageView>();
image_view->SetImage(gfx::CreateVectorIcon( image_view->SetImage(gfx::CreateVectorIcon(
kCaptureModeCircleStopIcon, ShelfConfig::Get()->shelf_icon_color())); kCaptureModeCircleStopIcon,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
image_view->SetTooltipText(GetAccessibleNameForTray()); image_view->SetTooltipText(GetAccessibleNameForTray());
image_view->SetHorizontalAlignment(views::ImageView::Alignment::kCenter); image_view->SetHorizontalAlignment(views::ImageView::Alignment::kCenter);
image_view->SetVerticalAlignment(views::ImageView::Alignment::kCenter); image_view->SetVerticalAlignment(views::ImageView::Alignment::kCenter);
......
...@@ -188,8 +188,10 @@ class NoteActionLaunchButton::ActionButton : public views::ImageButton { ...@@ -188,8 +188,10 @@ class NoteActionLaunchButton::ActionButton : public views::ImageButton {
SetAccessibleName( SetAccessibleName(
l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_CREATE_NOTE_ACTION)); l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_CREATE_NOTE_ACTION));
SetImage(views::Button::STATE_NORMAL, SetImage(views::Button::STATE_NORMAL,
CreateVectorIcon(kTrayActionNewLockScreenNoteIcon, CreateVectorIcon(
ShelfConfig::Get()->shelf_icon_color())); kTrayActionNewLockScreenNoteIcon,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kButtonIconColor)));
SetFocusBehavior(views::View::FocusBehavior::ALWAYS); SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
SetFlipCanvasOnPaintForRTLUI(true); SetFlipCanvasOnPaintForRTLUI(true);
......
...@@ -131,9 +131,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver, ...@@ -131,9 +131,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// if the shelf visibility should change during a drag. // if the shelf visibility should change during a drag.
float drag_hide_ratio_threshold() const; float drag_hide_ratio_threshold() const;
SkColor shelf_control_permanent_highlight_background() const {
return shelf_control_permanent_highlight_background_;
}
SkColor shelf_focus_border_color() const { return shelf_focus_border_color_; } SkColor shelf_focus_border_color() const { return shelf_focus_border_color_; }
int workspace_area_visible_inset() const { int workspace_area_visible_inset() const {
return workspace_area_visible_inset_; return workspace_area_visible_inset_;
...@@ -144,7 +141,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver, ...@@ -144,7 +141,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
int hidden_shelf_in_screen_portion() const { int hidden_shelf_in_screen_portion() const {
return hidden_shelf_in_screen_portion_; return hidden_shelf_in_screen_portion_;
} }
SkColor shelf_icon_color() const { return shelf_icon_color_; }
int status_indicator_offset_from_shelf_edge() const { int status_indicator_offset_from_shelf_edge() const {
return status_indicator_offset_from_shelf_edge_; return status_indicator_offset_from_shelf_edge_;
} }
...@@ -282,8 +278,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver, ...@@ -282,8 +278,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
const int app_icon_group_margin_tablet_; const int app_icon_group_margin_tablet_;
const int app_icon_group_margin_clamshell_; const int app_icon_group_margin_clamshell_;
const SkColor shelf_control_permanent_highlight_background_;
const SkColor shelf_focus_border_color_; const SkColor shelf_focus_border_color_;
// We reserve a small area on the edge of the workspace area to ensure that // We reserve a small area on the edge of the workspace area to ensure that
...@@ -297,10 +291,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver, ...@@ -297,10 +291,6 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// Portion of the shelf that's within the screen bounds when auto-hidden. // Portion of the shelf that's within the screen bounds when auto-hidden.
const int hidden_shelf_in_screen_portion_; const int hidden_shelf_in_screen_portion_;
// The foreground color of the icons used in the shelf (launcher,
// notifications, etc).
const SkColor shelf_icon_color_;
// The distance between the edge of the shelf and the status indicators. // The distance between the edge of the shelf and the status indicators.
const int status_indicator_offset_from_shelf_edge_; const int status_indicator_offset_from_shelf_edge_;
......
...@@ -118,13 +118,10 @@ ShelfConfig::ShelfConfig() ...@@ -118,13 +118,10 @@ ShelfConfig::ShelfConfig()
shelf_status_area_hit_region_padding_dense_(2), shelf_status_area_hit_region_padding_dense_(2),
app_icon_group_margin_tablet_(16), app_icon_group_margin_tablet_(16),
app_icon_group_margin_clamshell_(12), app_icon_group_margin_clamshell_(12),
shelf_control_permanent_highlight_background_(
SkColorSetA(SK_ColorWHITE, 26)), // 10%
shelf_focus_border_color_(gfx::kGoogleBlue300), shelf_focus_border_color_(gfx::kGoogleBlue300),
workspace_area_visible_inset_(2), workspace_area_visible_inset_(2),
workspace_area_auto_hide_inset_(5), workspace_area_auto_hide_inset_(5),
hidden_shelf_in_screen_portion_(3), hidden_shelf_in_screen_portion_(3),
shelf_icon_color_(SK_ColorWHITE),
status_indicator_offset_from_shelf_edge_(1), status_indicator_offset_from_shelf_edge_(1),
scrollable_shelf_ripple_padding_(2), scrollable_shelf_ripple_padding_(2),
shelf_tooltip_preview_height_(128), shelf_tooltip_preview_height_(128),
...@@ -424,7 +421,8 @@ SkColor ShelfConfig::GetShelfControlButtonColor() const { ...@@ -424,7 +421,8 @@ SkColor ShelfConfig::GetShelfControlButtonColor() const {
} else if (session_state == session_manager::SessionState::OOBE) { } else if (session_state == session_manager::SessionState::OOBE) {
return SkColorSetA(SK_ColorBLACK, 16); // 6% opacity return SkColorSetA(SK_ColorBLACK, 16); // 6% opacity
} }
return shelf_control_permanent_highlight_background_; return AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive);
} }
SkColor ShelfConfig::GetShelfWithAppListColor() const { SkColor ShelfConfig::GetShelfWithAppListColor() const {
......
...@@ -92,8 +92,7 @@ void ShelfControlButton::PaintBackground(gfx::Canvas* canvas, ...@@ -92,8 +92,7 @@ void ShelfControlButton::PaintBackground(gfx::Canvas* canvas,
const gfx::Rect& bounds) { const gfx::Rect& bounds) {
cc::PaintFlags flags; cc::PaintFlags flags;
flags.setAntiAlias(true); flags.setAntiAlias(true);
flags.setColor( flags.setColor(ShelfConfig::Get()->GetShelfControlButtonColor());
ShelfConfig::Get()->shelf_control_permanent_highlight_background());
canvas->DrawRoundRect(bounds, ShelfConfig::Get()->control_border_radius(), canvas->DrawRoundRect(bounds, ShelfConfig::Get()->control_border_radius(),
flags); flags);
} }
......
...@@ -95,9 +95,10 @@ void HoldingSpaceTrayIcon::InitLayout() { ...@@ -95,9 +95,10 @@ void HoldingSpaceTrayIcon::InitLayout() {
// that tooltips will be retrieved from `this` instead. // that tooltips will be retrieved from `this` instead.
no_previews_image_view_ = AddChildView(std::make_unique<views::ImageView>()); no_previews_image_view_ = AddChildView(std::make_unique<views::ImageView>());
no_previews_image_view_->SetCanProcessEventsWithinSubtree(false); no_previews_image_view_->SetCanProcessEventsWithinSubtree(false);
no_previews_image_view_->SetImage( no_previews_image_view_->SetImage(gfx::CreateVectorIcon(
gfx::CreateVectorIcon(kHoldingSpaceIcon, kHoldingSpaceTrayIconSize, kHoldingSpaceIcon, kHoldingSpaceTrayIconSize,
ShelfConfig::Get()->shelf_icon_color())); AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
if (features::IsTemporaryHoldingSpacePreviewsEnabled()) { if (features::IsTemporaryHoldingSpacePreviewsEnabled()) {
// As holding space items are added to the model, child layers will be added // As holding space items are added to the model, child layers will be added
......
...@@ -401,6 +401,11 @@ bool ImeMenuTray::ShouldShowKeyboardToggle() const { ...@@ -401,6 +401,11 @@ bool ImeMenuTray::ShouldShowKeyboardToggle() const {
.enabled(); .enabled();
} }
void ImeMenuTray::OnThemeChanged() {
TrayBackgroundView::OnThemeChanged();
UpdateTrayLabel();
}
base::string16 ImeMenuTray::GetAccessibleNameForTray() { base::string16 ImeMenuTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
} }
...@@ -524,6 +529,10 @@ void ImeMenuTray::UpdateTrayLabel() { ...@@ -524,6 +529,10 @@ void ImeMenuTray::UpdateTrayLabel() {
// Updates the tray label based on the current input method. // Updates the tray label based on the current input method.
CreateLabel(); CreateLabel();
label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary));
if (current_ime.third_party) if (current_ime.third_party)
label_->SetText(current_ime.short_name + base::UTF8ToUTF16("*")); label_->SetText(current_ime.short_name + base::UTF8ToUTF16("*"));
else else
......
...@@ -50,6 +50,7 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView, ...@@ -50,6 +50,7 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
bool ShouldShowKeyboardToggle() const; bool ShouldShowKeyboardToggle() const;
// TrayBackgroundView: // TrayBackgroundView:
void OnThemeChanged() override;
base::string16 GetAccessibleNameForTray() override; base::string16 GetAccessibleNameForTray() override;
void HandleLocaleChange() override; void HandleLocaleChange() override;
void HideBubbleWithView(const TrayBubbleView* bubble_view) override; void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ash/system/palette/palette_tool_manager.h" #include "ash/system/palette/palette_tool_manager.h"
#include "ash/system/palette/palette_utils.h" #include "ash/system/palette/palette_utils.h"
#include "ash/system/palette/palette_welcome_bubble.h" #include "ash/system/palette/palette_welcome_bubble.h"
#include "ash/system/tray/tray_background_view.h"
#include "ash/system/tray/tray_bubble_wrapper.h" #include "ash/system/tray/tray_bubble_wrapper.h"
#include "ash/system/tray/tray_container.h" #include "ash/system/tray/tray_container.h"
#include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_popup_utils.h"
...@@ -289,6 +290,11 @@ void PaletteTray::ClickedOutsideBubble() { ...@@ -289,6 +290,11 @@ void PaletteTray::ClickedOutsideBubble() {
HidePalette(); HidePalette();
} }
void PaletteTray::OnThemeChanged() {
TrayBackgroundView::OnThemeChanged();
UpdateTrayIcon();
}
base::string16 PaletteTray::GetAccessibleNameForTray() { base::string16 PaletteTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE); return l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE);
} }
...@@ -560,7 +566,9 @@ void PaletteTray::UpdateTrayIcon() { ...@@ -560,7 +566,9 @@ void PaletteTray::UpdateTrayIcon() {
icon_->SetImage(CreateVectorIcon( icon_->SetImage(CreateVectorIcon(
palette_tool_manager_->GetActiveTrayIcon( palette_tool_manager_->GetActiveTrayIcon(
palette_tool_manager_->GetActiveTool(PaletteGroup::MODE)), palette_tool_manager_->GetActiveTool(PaletteGroup::MODE)),
kTrayIconSize, ShelfConfig::Get()->shelf_icon_color())); kTrayIconSize,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
} }
void PaletteTray::OnPaletteEnabledPrefChanged() { void PaletteTray::OnPaletteEnabledPrefChanged() {
......
...@@ -72,6 +72,7 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView, ...@@ -72,6 +72,7 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView,
// TrayBackgroundView: // TrayBackgroundView:
void ClickedOutsideBubble() override; void ClickedOutsideBubble() override;
void OnThemeChanged() override;
base::string16 GetAccessibleNameForTray() override; base::string16 GetAccessibleNameForTray() override;
void HandleLocaleChange() override; void HandleLocaleChange() override;
void HideBubbleWithView(const TrayBubbleView* bubble_view) override; void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
......
...@@ -85,7 +85,6 @@ void StatusAreaWidget::Initialize() { ...@@ -85,7 +85,6 @@ void StatusAreaWidget::Initialize() {
DCHECK(!initialized_); DCHECK(!initialized_);
// Create the child views, left to right. // Create the child views, left to right.
overflow_button_tray_ = overflow_button_tray_ =
std::make_unique<StatusAreaOverflowButtonTray>(shelf_); std::make_unique<StatusAreaOverflowButtonTray>(shelf_);
AddTrayButton(overflow_button_tray_.get()); AddTrayButton(overflow_button_tray_.get());
...@@ -506,10 +505,6 @@ void StatusAreaWidget::SchedulePaint() { ...@@ -506,10 +505,6 @@ void StatusAreaWidget::SchedulePaint() {
tray_button->SchedulePaint(); tray_button->SchedulePaint();
} }
const ui::NativeTheme* StatusAreaWidget::GetNativeTheme() const {
return ui::NativeTheme::GetInstanceForDarkUI();
}
bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
if (!Widget::OnNativeWidgetActivationChanged(active)) if (!Widget::OnNativeWidgetActivationChanged(active))
return false; return false;
......
...@@ -151,7 +151,6 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver, ...@@ -151,7 +151,6 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver,
void SchedulePaint(); void SchedulePaint();
// Overridden from views::Widget: // Overridden from views::Widget:
const ui::NativeTheme* GetNativeTheme() const override;
bool OnNativeWidgetActivationChanged(bool active) override; bool OnNativeWidgetActivationChanged(bool active) override;
// TODO(jamescook): Introduce a test API instead of these methods. // TODO(jamescook): Introduce a test API instead of these methods.
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "components/session_manager/session_manager_types.h" #include "components/session_manager/session_manager_types.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/gfx/shadow_value.h" #include "ui/gfx/shadow_value.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -49,7 +48,7 @@ class ASH_EXPORT TimeView : public ActionableView, public ClockObserver { ...@@ -49,7 +48,7 @@ class ASH_EXPORT TimeView : public ActionableView, public ClockObserver {
void UpdateClockLayout(ClockLayout clock_layout); void UpdateClockLayout(ClockLayout clock_layout);
// Updates the time text color. // Updates the time text color.
void SetTextColor(SkColor color, bool auto_color_readability_enabled = true); void SetTextColor(SkColor color, bool auto_color_readability_enabled = false);
// Updates the time text fontlist. // Updates the time text fontlist.
void SetTextFont(const gfx::FontList& font_list); void SetTextFont(const gfx::FontList& font_list);
......
...@@ -35,7 +35,9 @@ StatusAreaOverflowButtonTray::IconView::IconView() ...@@ -35,7 +35,9 @@ StatusAreaOverflowButtonTray::IconView::IconView()
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
gfx::ImageSkia image = gfx::CreateVectorIcon( gfx::ImageSkia image = gfx::CreateVectorIcon(
kOverflowShelfRightIcon, ShelfConfig::Get()->shelf_icon_color()); kOverflowShelfRightIcon,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary));
SetImage(image); SetImage(image);
const int vertical_padding = (kTrayHeight - image.height()) / 2; const int vertical_padding = (kTrayHeight - image.height()) / 2;
......
...@@ -20,6 +20,7 @@ void SetupLabelForTray(views::Label* label) { ...@@ -20,6 +20,7 @@ void SetupLabelForTray(views::Label* label) {
// The text is drawn on an transparent bg, so we must disable subpixel // The text is drawn on an transparent bg, so we must disable subpixel
// rendering. // rendering.
label->SetSubpixelRenderingEnabled(false); label->SetSubpixelRenderingEnabled(false);
label->SetAutoColorReadabilityEnabled(false);
label->SetFontList(gfx::FontList().Derive( label->SetFontList(gfx::FontList().Derive(
kTrayTextFontSizeIncrease, gfx::Font::NORMAL, gfx::Font::Weight::MEDIUM)); kTrayTextFontSizeIncrease, gfx::Font::NORMAL, gfx::Font::Weight::MEDIUM));
} }
......
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