Commit 789ae7c9 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Fix dark mode color for checkboxes used in system tray

Bug: 960116
Change-Id: I2e6868f2ec1873273614cfe1ae902714dd882df8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015572
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734558}
parent 319c9b41
......@@ -276,6 +276,21 @@ class EmptyNotifierView : public views::View {
DISALLOW_COPY_AND_ASSIGN(EmptyNotifierView);
};
class NotifierViewCheckbox : public views::Checkbox {
public:
using views::Checkbox::Checkbox;
private:
// views::Checkbox:
SkColor GetIconImageColor(int icon_state) const override {
if (icon_state & IconState::CHECKED) {
return AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kProminentIconButton, AshColorMode::kDark);
}
return views::Checkbox::GetIconImageColor(icon_state);
}
};
} // namespace
// NotifierSettingsView::NotifierButton ---------------------------------------
......@@ -288,8 +303,8 @@ NotifierSettingsView::NotifierButton::NotifierButton(
: views::Button(listener), notifier_id_(notifier.notifier_id) {
auto icon_view = std::make_unique<views::ImageView>();
auto name_view = std::make_unique<views::Label>(notifier.name);
auto checkbox =
std::make_unique<views::Checkbox>(base::string16(), this /* listener */);
auto checkbox = std::make_unique<NotifierViewCheckbox>(base::string16(),
this /* listener */);
name_view->SetAutoColorReadabilityEnabled(false);
name_view->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kTextPrimary, AshColorMode::kDark));
......
......@@ -179,10 +179,6 @@ SkPath Checkbox::GetFocusRingPath() const {
return path;
}
const gfx::VectorIcon& Checkbox::GetVectorIcon() const {
return GetChecked() ? kCheckboxActiveIcon : kCheckboxNormalIcon;
}
SkColor Checkbox::GetIconImageColor(int icon_state) const {
const SkColor active_color = GetNativeTheme()->GetSystemColor(
(icon_state & IconState::CHECKED)
......@@ -194,6 +190,10 @@ SkColor Checkbox::GetIconImageColor(int icon_state) const {
gfx::kDisabledControlAlpha);
}
const gfx::VectorIcon& Checkbox::GetVectorIcon() const {
return GetChecked() ? kCheckboxActiveIcon : kCheckboxNormalIcon;
}
void Checkbox::NotifyClick(const ui::Event& event) {
SetChecked(!GetChecked());
LabelButton::NotifyClick(event);
......
......@@ -48,6 +48,9 @@ class VIEWS_EXPORT Checkbox : public LabelButton {
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
protected:
// Bitmask constants for GetIconImageColor.
enum IconState { CHECKED = 0b1, ENABLED = 0b10 };
// LabelButton:
void OnThemeChanged() override;
std::unique_ptr<InkDrop> CreateInkDrop() override;
......@@ -57,20 +60,17 @@ class VIEWS_EXPORT Checkbox : public LabelButton {
gfx::ImageSkia GetImage(ButtonState for_state) const override;
std::unique_ptr<LabelButtonBorder> CreateDefaultBorder() const override;
// Gets the vector icon to use based on the current state of |checked_|.
virtual const gfx::VectorIcon& GetVectorIcon() const;
// Returns the path to draw the focus ring around for this Checkbox.
virtual SkPath GetFocusRingPath() const;
private:
class FocusRingHighlightPathGenerator;
// |icon_state| is a bitmask using the IconState enum.
virtual SkColor GetIconImageColor(int icon_state) const;
// Bitmask constants for GetIconImageColor.
enum IconState { CHECKED = 0b1, ENABLED = 0b10 };
// Gets the vector icon to use based on the current state of |checked_|.
virtual const gfx::VectorIcon& GetVectorIcon() const;
// |icon_state| is a bitmask using the IconState enum.
SkColor GetIconImageColor(int icon_state) const;
private:
class FocusRingHighlightPathGenerator;
// Button:
void NotifyClick(const ui::Event& event) 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