Commit 565cc3bc authored by minch's avatar minch Committed by Commit Bot

dark_mode: Live update colors of system tray menu.

See recorded video at
https://drive.google.com/file/d/1hjHkN_gA7IMTTor6RehgF1mWMWkeLK9T/view?usp=sharing

This cl doesn't include all the elements in system tray menu, more
elements of it will be updated in follow up cls.

Bug: 1131543
Change-Id: I3a395e529764ab4e23a51ea5066e3e105a502552
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2486781Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820290}
parent e6e09c1c
...@@ -114,9 +114,8 @@ ClipboardHistoryItemView::DeleteButton::DeleteButton( ...@@ -114,9 +114,8 @@ ClipboardHistoryItemView::DeleteButton::DeleteButton(
SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE); SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE);
SetPreferredSize(gfx::Size(kDeleteButtonSizeDip, kDeleteButtonSizeDip)); SetPreferredSize(gfx::Size(kDeleteButtonSizeDip, kDeleteButtonSizeDip));
AshColorProvider::Get()->DecorateCloseButton( AshColorProvider::Get()->DecorateCloseButton(this, kDeleteButtonSizeDip,
this, AshColorProvider::ButtonType::kCloseButtonWithSmallBase, kCloseButtonIcon);
kDeleteButtonSizeDip, kCloseButtonIcon);
} }
ClipboardHistoryItemView::DeleteButton::~DeleteButton() = default; ClipboardHistoryItemView::DeleteButton::~DeleteButton() = default;
......
...@@ -256,24 +256,23 @@ SkColor AshColorProvider::GetBackgroundColor() const { ...@@ -256,24 +256,23 @@ SkColor AshColorProvider::GetBackgroundColor() const {
} }
void AshColorProvider::DecoratePillButton(views::LabelButton* button, void AshColorProvider::DecoratePillButton(views::LabelButton* button,
ButtonType type, const gfx::VectorIcon* icon) {
const gfx::VectorIcon& icon) { if (icon) {
DCHECK_EQ(ButtonType::kPillButtonWithIcon, type); SkColor enabled_icon_color =
DCHECK(!icon.is_empty()); GetContentLayerColor(ContentLayerType::kButtonIconColor);
SkColor enabled_icon_color = button->SetImage(views::Button::STATE_NORMAL,
GetContentLayerColor(ContentLayerType::kButtonIconColor); gfx::CreateVectorIcon(*icon, enabled_icon_color));
button->SetImage(views::Button::STATE_NORMAL, button->SetImage(
gfx::CreateVectorIcon(icon, enabled_icon_color)); views::Button::STATE_DISABLED,
button->SetImage( gfx::CreateVectorIcon(*icon, GetDisabledColor(enabled_icon_color)));
views::Button::STATE_DISABLED, button->SetImageLabelSpacing(kPillButtonImageLabelSpacingDp);
gfx::CreateVectorIcon(icon, GetDisabledColor(enabled_icon_color))); }
SkColor enabled_text_color = SkColor enabled_text_color =
GetContentLayerColor(ContentLayerType::kButtonLabelColor); GetContentLayerColor(ContentLayerType::kButtonLabelColor);
button->SetEnabledTextColors(enabled_text_color); button->SetEnabledTextColors(enabled_text_color);
button->SetTextColor(views::Button::STATE_DISABLED, button->SetTextColor(views::Button::STATE_DISABLED,
GetDisabledColor(enabled_text_color)); GetDisabledColor(enabled_text_color));
button->SetImageLabelSpacing(kPillButtonImageLabelSpacingDp);
// TODO(sammiequon): Add a default rounded rect background. It should probably // TODO(sammiequon): Add a default rounded rect background. It should probably
// be optional as some buttons still require customization. At that point we // be optional as some buttons still require customization. At that point we
...@@ -281,10 +280,8 @@ void AshColorProvider::DecoratePillButton(views::LabelButton* button, ...@@ -281,10 +280,8 @@ void AshColorProvider::DecoratePillButton(views::LabelButton* button,
} }
void AshColorProvider::DecorateCloseButton(views::ImageButton* button, void AshColorProvider::DecorateCloseButton(views::ImageButton* button,
ButtonType type,
int button_size, int button_size,
const gfx::VectorIcon& icon) { const gfx::VectorIcon& icon) {
DCHECK_EQ(ButtonType::kCloseButtonWithSmallBase, type);
DCHECK(!icon.is_empty()); DCHECK(!icon.is_empty());
SkColor enabled_icon_color = SkColor enabled_icon_color =
GetContentLayerColor(ContentLayerType::kButtonIconColor); GetContentLayerColor(ContentLayerType::kButtonIconColor);
...@@ -295,17 +292,21 @@ void AshColorProvider::DecorateCloseButton(views::ImageButton* button, ...@@ -295,17 +292,21 @@ void AshColorProvider::DecorateCloseButton(views::ImageButton* button,
// it is a circle. // it is a circle.
SkColor icon_background_color = AshColorProvider::Get()->GetBaseLayerColor( SkColor icon_background_color = AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent80); AshColorProvider::BaseLayerType::kTransparent80);
button->SetBackground( button->SetBackground(views::CreateRoundedRectBackground(
CreateBackgroundFromPainter(views::Painter::CreateSolidRoundRectPainter( icon_background_color, button_size / 2));
icon_background_color, button_size / 2)));
// TODO(sammiequon): Add background blur as per spec. Background blur is quite // TODO(sammiequon): Add background blur as per spec. Background blur is quite
// heavy, and we may have many close buttons showing at a time. They'll be // heavy, and we may have many close buttons showing at a time. They'll be
// added separately so its easier to monitor performance. // added separately so its easier to monitor performance.
} }
void AshColorProvider::DecorateFloatingIconButton(views::ImageButton* button,
const gfx::VectorIcon& icon) {
DecorateIconButton(button, icon, /*toggled=*/false,
GetDefaultSizeOfVectorIcon(icon));
}
void AshColorProvider::DecorateIconButton(views::ImageButton* button, void AshColorProvider::DecorateIconButton(views::ImageButton* button,
ButtonType type,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
bool toggled, bool toggled,
int icon_size) { int icon_size) {
...@@ -333,7 +334,7 @@ void AshColorProvider::DecorateIconButton(views::ImageButton* button, ...@@ -333,7 +334,7 @@ void AshColorProvider::DecorateIconButton(views::ImageButton* button,
button->SetImage(views::Button::STATE_NORMAL, new_normal_image); button->SetImage(views::Button::STATE_NORMAL, new_normal_image);
button->SetImage( button->SetImage(
views::Button::STATE_DISABLED, views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, icon_size, GetDisabledColor(normal_color))); gfx::CreateVectorIcon(icon, icon_size, GetDisabledColor(icon_color)));
} }
void AshColorProvider::AddObserver(ColorModeObserver* observer) { void AshColorProvider::AddObserver(ColorModeObserver* observer) {
......
...@@ -122,13 +122,6 @@ class ASH_EXPORT AshColorProvider : public SessionObserver { ...@@ -122,13 +122,6 @@ class ASH_EXPORT AshColorProvider : public SessionObserver {
kRadioColorInactive, kRadioColorInactive,
}; };
// Types of ash styled buttons.
enum class ButtonType {
kPillButtonWithIcon,
kCloseButtonWithSmallBase,
kIconButtonSmallOrMedium,
};
// Attributes of ripple, includes the base color, opacity of inkdrop and // Attributes of ripple, includes the base color, opacity of inkdrop and
// highlight. // highlight.
struct RippleAttributes { struct RippleAttributes {
...@@ -181,21 +174,20 @@ class ASH_EXPORT AshColorProvider : public SessionObserver { ...@@ -181,21 +174,20 @@ class ASH_EXPORT AshColorProvider : public SessionObserver {
// |is_themed_|). // |is_themed_|).
SkColor GetBackgroundColor() const; SkColor GetBackgroundColor() const;
// Helpers to style buttons based on the desired |type| and theme. Depending // Helpers to style different types of buttons. Depending on the type may
// on the type may style text, icon and background colors for both enabled and // style text, icon and background colors for both enabled and disabled
// disabled states. May overwrite an prior styles on |button|. // states. May overwrite an prior styles on |button|.
void DecoratePillButton(views::LabelButton* button, void DecoratePillButton(views::LabelButton* button,
ButtonType type, const gfx::VectorIcon* icon);
const gfx::VectorIcon& icon);
void DecorateCloseButton(views::ImageButton* button, void DecorateCloseButton(views::ImageButton* button,
ButtonType type,
int button_size, int button_size,
const gfx::VectorIcon& icon); const gfx::VectorIcon& icon);
void DecorateIconButton(views::ImageButton* button, void DecorateIconButton(views::ImageButton* button,
ButtonType type,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
bool toggled, bool toggled,
int icon_size); int icon_size);
void DecorateFloatingIconButton(views::ImageButton* button,
const gfx::VectorIcon& icon);
void AddObserver(ColorModeObserver* observer); void AddObserver(ColorModeObserver* observer);
void RemoveObserver(ColorModeObserver* observer); void RemoveObserver(ColorModeObserver* observer);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ui/views/animation/ink_drop_highlight.h" #include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_impl.h" #include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/animation/ink_drop_mask.h" #include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/background.h"
#include "ui/views/controls/highlight_path_generator.h" #include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
...@@ -53,6 +54,11 @@ const gfx::VectorIcon& GetVolumeIconForLevel(float level) { ...@@ -53,6 +54,11 @@ const gfx::VectorIcon& GetVolumeIconForLevel(float level) {
return *kVolumeLevelIcons[index]; return *kVolumeLevelIcons[index];
} }
SkColor GetBackgroundColorOfMoreButton() {
return AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive);
}
class MoreButton : public views::Button { class MoreButton : public views::Button {
public: public:
explicit MoreButton(views::ButtonListener* listener) explicit MoreButton(views::ButtonListener* listener)
...@@ -64,48 +70,23 @@ class MoreButton : public views::Button { ...@@ -64,48 +70,23 @@ class MoreButton : public views::Button {
2), 2),
2)); 2));
auto* color_provider = AshColorProvider::Get();
const SkColor icon_color = color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
if (!features::IsSystemTrayMicGainSettingEnabled()) { if (!features::IsSystemTrayMicGainSettingEnabled()) {
auto* headset = new views::ImageView(); headset_image_ = AddChildView(std::make_unique<views::ImageView>());
headset->SetCanProcessEventsWithinSubtree(false); headset_image_->SetCanProcessEventsWithinSubtree(false);
headset->SetImage(
CreateVectorIcon(vector_icons::kHeadsetIcon, icon_color));
AddChildView(headset);
} }
auto* more = new views::ImageView(); more_image_ = AddChildView(std::make_unique<views::ImageView>());
more->SetCanProcessEventsWithinSubtree(false); more_image_->SetCanProcessEventsWithinSubtree(false);
auto icon_rotation = base::i18n::IsRTL()
? SkBitmapOperations::ROTATION_270_CW
: SkBitmapOperations::ROTATION_90_CW;
more->SetImage(gfx::ImageSkiaOperations::CreateRotatedImage(
CreateVectorIcon(kUnifiedMenuExpandIcon, icon_color), icon_rotation));
AddChildView(more);
SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO)); SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO));
TrayPopupUtils::ConfigureTrayPopupButton(this); TrayPopupUtils::ConfigureTrayPopupButton(this);
views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(), views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(),
kTrayItemCornerRadius); kTrayItemCornerRadius);
focus_ring()->SetColor(color_provider->GetControlsLayerColor( SetBackground(views::CreateRoundedRectBackground(
AshColorProvider::ControlsLayerType::kFocusRingColor)); GetBackgroundColorOfMoreButton(), kTrayItemCornerRadius));
} }
~MoreButton() override = default; ~MoreButton() override = default;
// views::Button:
void PaintButtonContents(gfx::Canvas* canvas) override {
gfx::RectF rect(GetContentsBounds());
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive));
flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawRoundRect(rect, kTrayItemCornerRadius, flags);
}
std::unique_ptr<views::InkDrop> CreateInkDrop() override { std::unique_ptr<views::InkDrop> CreateInkDrop() override {
return TrayPopupUtils::CreateInkDrop(this); return TrayPopupUtils::CreateInkDrop(this);
} }
...@@ -123,7 +104,30 @@ class MoreButton : public views::Button { ...@@ -123,7 +104,30 @@ class MoreButton : public views::Button {
const char* GetClassName() const override { return "MoreButton"; } const char* GetClassName() const override { return "MoreButton"; }
void OnThemeChanged() override {
views::Button::OnThemeChanged();
auto* color_provider = AshColorProvider::Get();
const SkColor icon_color = color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
if (headset_image_) {
headset_image_->SetImage(
CreateVectorIcon(vector_icons::kHeadsetIcon, icon_color));
}
DCHECK(more_image_);
auto icon_rotation = base::i18n::IsRTL()
? SkBitmapOperations::ROTATION_270_CW
: SkBitmapOperations::ROTATION_90_CW;
more_image_->SetImage(gfx::ImageSkiaOperations::CreateRotatedImage(
CreateVectorIcon(kUnifiedMenuExpandIcon, icon_color), icon_rotation));
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
background()->SetNativeControlColor(GetBackgroundColorOfMoreButton());
}
private: private:
views::ImageView* headset_image_ = nullptr;
views::ImageView* more_image_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(MoreButton); DISALLOW_COPY_AND_ASSIGN(MoreButton);
}; };
......
...@@ -15,13 +15,7 @@ ...@@ -15,13 +15,7 @@
namespace ash { namespace ash {
CollapseButton::CollapseButton(views::ButtonListener* listener) CollapseButton::CollapseButton(views::ButtonListener* listener)
: CustomShapeButton(listener) { : CustomShapeButton(listener) {}
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(
kUnifiedMenuExpandIcon,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
}
CollapseButton::~CollapseButton() = default; CollapseButton::~CollapseButton() = default;
...@@ -62,4 +56,10 @@ const char* CollapseButton::GetClassName() const { ...@@ -62,4 +56,10 @@ const char* CollapseButton::GetClassName() const {
return "CollapseButton"; return "CollapseButton";
} }
void CollapseButton::OnThemeChanged() {
CustomShapeButton::OnThemeChanged();
AshColorProvider::Get()->DecorateFloatingIconButton(this,
kUnifiedMenuExpandIcon);
}
} // namespace ash } // namespace ash
...@@ -26,6 +26,7 @@ class CollapseButton : public CustomShapeButton { ...@@ -26,6 +26,7 @@ class CollapseButton : public CustomShapeButton {
SkPath CreateCustomShapePath(const gfx::Rect& bounds) const override; SkPath CreateCustomShapePath(const gfx::Rect& bounds) const override;
void PaintButtonContents(gfx::Canvas* canvas) override; void PaintButtonContents(gfx::Canvas* canvas) override;
const char* GetClassName() const override; const char* GetClassName() const override;
void OnThemeChanged() override;
private: private:
double expanded_amount_ = 1.0; double expanded_amount_ = 1.0;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
namespace ash { namespace ash {
using ContentLayerType = AshColorProvider::ContentLayerType; using ContentLayerType = AshColorProvider::ContentLayerType;
using ControlsLayerType = AshColorProvider::ControlsLayerType;
namespace { namespace {
...@@ -61,8 +62,6 @@ FeaturePodIconButton::FeaturePodIconButton(views::ButtonListener* listener, ...@@ -61,8 +62,6 @@ FeaturePodIconButton::FeaturePodIconButton(views::ButtonListener* listener,
// Focus ring is around the whole view's bounds, but the ink drop should be // Focus ring is around the whole view's bounds, but the ink drop should be
// the same size as the content. // the same size as the content.
TrayPopupUtils::ConfigureTrayPopupButton(this); TrayPopupUtils::ConfigureTrayPopupButton(this);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
focus_ring()->SetPathGenerator( focus_ring()->SetPathGenerator(
std::make_unique<views::CircleHighlightPathGenerator>(gfx::Insets())); std::make_unique<views::CircleHighlightPathGenerator>(gfx::Insets()));
views::InstallCircleHighlightPathGenerator(this, views::InstallCircleHighlightPathGenerator(this,
...@@ -91,11 +90,11 @@ void FeaturePodIconButton::PaintButtonContents(gfx::Canvas* canvas) { ...@@ -91,11 +90,11 @@ void FeaturePodIconButton::PaintButtonContents(gfx::Canvas* canvas) {
const AshColorProvider* color_provider = AshColorProvider::Get(); const AshColorProvider* color_provider = AshColorProvider::Get();
SkColor color = color_provider->GetControlsLayerColor( SkColor color = color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive); ControlsLayerType::kControlBackgroundColorInactive);
if (GetEnabled()) { if (GetEnabled()) {
if (toggled_) { if (toggled_) {
color = color_provider->GetControlsLayerColor( color = color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorActive); ControlsLayerType::kControlBackgroundColorActive);
} }
} else { } else {
color = AshColorProvider::GetDisabledColor(color); color = AshColorProvider::GetDisabledColor(color);
...@@ -140,13 +139,20 @@ const char* FeaturePodIconButton::GetClassName() const { ...@@ -140,13 +139,20 @@ const char* FeaturePodIconButton::GetClassName() const {
return "FeaturePodIconButton"; return "FeaturePodIconButton";
} }
void FeaturePodIconButton::OnThemeChanged() {
views::ImageButton::OnThemeChanged();
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
ControlsLayerType::kFocusRingColor));
UpdateVectorIcon();
SchedulePaint();
}
void FeaturePodIconButton::UpdateVectorIcon() { void FeaturePodIconButton::UpdateVectorIcon() {
if (!icon_) if (!icon_)
return; return;
AshColorProvider::Get()->DecorateIconButton( AshColorProvider::Get()->DecorateIconButton(this, *icon_, toggled_,
this, AshColorProvider::ButtonType::kIconButtonSmallOrMedium, *icon_, kUnifiedFeaturePodVectorIconSize);
toggled_, kUnifiedFeaturePodVectorIconSize);
} }
FeaturePodLabelButton::FeaturePodLabelButton(views::ButtonListener* listener) FeaturePodLabelButton::FeaturePodLabelButton(views::ButtonListener* listener)
...@@ -167,8 +173,6 @@ FeaturePodLabelButton::FeaturePodLabelButton(views::ButtonListener* listener) ...@@ -167,8 +173,6 @@ FeaturePodLabelButton::FeaturePodLabelButton(views::ButtonListener* listener)
detailed_view_arrow_->SetCanProcessEventsWithinSubtree(false); detailed_view_arrow_->SetCanProcessEventsWithinSubtree(false);
detailed_view_arrow_->SetVisible(false); detailed_view_arrow_->SetVisible(false);
OnEnabledChanged();
AddChildView(label_); AddChildView(label_);
AddChildView(detailed_view_arrow_); AddChildView(detailed_view_arrow_);
AddChildView(sub_label_); AddChildView(sub_label_);
...@@ -179,7 +183,7 @@ FeaturePodLabelButton::FeaturePodLabelButton(views::ButtonListener* listener) ...@@ -179,7 +183,7 @@ FeaturePodLabelButton::FeaturePodLabelButton(views::ButtonListener* listener)
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor( focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor)); ControlsLayerType::kFocusRingColor));
views::InstallRoundRectHighlightPathGenerator( views::InstallRoundRectHighlightPathGenerator(
this, gfx::Insets(), kUnifiedFeaturePodHoverCornerRadius); this, gfx::Insets(), kUnifiedFeaturePodHoverCornerRadius);
} }
...@@ -256,6 +260,11 @@ const char* FeaturePodLabelButton::GetClassName() const { ...@@ -256,6 +260,11 @@ const char* FeaturePodLabelButton::GetClassName() const {
return "FeaturePodLabelButton"; return "FeaturePodLabelButton";
} }
void FeaturePodLabelButton::OnThemeChanged() {
views::Button::OnThemeChanged();
OnEnabledChanged();
}
void FeaturePodLabelButton::SetLabel(const base::string16& label) { void FeaturePodLabelButton::SetLabel(const base::string16& label) {
label_->SetText(label); label_->SetText(label);
InvalidateLayout(); InvalidateLayout();
......
...@@ -40,6 +40,7 @@ class FeaturePodIconButton : public views::ImageButton { ...@@ -40,6 +40,7 @@ class FeaturePodIconButton : public views::ImageButton {
const override; const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
const char* GetClassName() const override; const char* GetClassName() const override;
void OnThemeChanged() override;
bool toggled() const { return toggled_; } bool toggled() const { return toggled_; }
...@@ -86,6 +87,7 @@ class FeaturePodLabelButton : public views::Button { ...@@ -86,6 +87,7 @@ class FeaturePodLabelButton : public views::Button {
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override; const override;
const char* GetClassName() const override; const char* GetClassName() const override;
void OnThemeChanged() override;
private: private:
// Layout |child| in horizontal center with its vertical origin set to |y|. // Layout |child| in horizontal center with its vertical origin set to |y|.
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/animation/throb_animation.h" #include "ui/gfx/animation/throb_animation.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
...@@ -47,19 +46,11 @@ constexpr int kInkDropRadius = 3 * kUnifiedPageIndicatorButtonRadius; ...@@ -47,19 +46,11 @@ constexpr int kInkDropRadius = 3 * kUnifiedPageIndicatorButtonRadius;
class PageIndicatorView::PageIndicatorButton : public views::Button, class PageIndicatorView::PageIndicatorButton : public views::Button,
public views::ButtonListener { public views::ButtonListener {
public: public:
explicit PageIndicatorButton(UnifiedSystemTrayController* controller, PageIndicatorButton(UnifiedSystemTrayController* controller, int page)
int page)
: views::Button(this), controller_(controller), page_number_(page) { : views::Button(this), controller_(controller), page_number_(page) {
DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior()); DCHECK_EQ(views::View::FocusBehavior::ACCESSIBLE_ONLY, GetFocusBehavior());
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY); SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY);
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
const AshColorProvider::RippleAttributes ripple_attributes =
AshColorProvider::Get()->GetRippleAttributes();
ripple_base_color_ = ripple_attributes.base_color;
highlight_opacity_ = ripple_attributes.highlight_opacity;
inkdrop_opacity_ = ripple_attributes.inkdrop_opacity;
views::InstallFixedSizeCircleHighlightPathGenerator(this, kInkDropRadius); views::InstallFixedSizeCircleHighlightPathGenerator(this, kInkDropRadius);
} }
...@@ -100,6 +91,16 @@ class PageIndicatorView::PageIndicatorButton : public views::Button, ...@@ -100,6 +91,16 @@ class PageIndicatorView::PageIndicatorButton : public views::Button,
flags); flags);
} }
// views::Button:
void OnThemeChanged() override {
views::Button::OnThemeChanged();
auto ripple_attributes = AshColorProvider::Get()->GetRippleAttributes();
ripple_base_color_ = ripple_attributes.base_color;
highlight_opacity_ = ripple_attributes.highlight_opacity;
inkdrop_opacity_ = ripple_attributes.inkdrop_opacity;
SchedulePaint();
}
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override { void ButtonPressed(views::Button* sender, const ui::Event& event) override {
DCHECK(controller_); DCHECK(controller_);
......
...@@ -10,17 +10,23 @@ ...@@ -10,17 +10,23 @@
#include "ui/views/animation/ink_drop.h" #include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_highlight.h" #include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_ripple.h" #include "ui/views/animation/ink_drop_ripple.h"
#include "ui/views/background.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/highlight_path_generator.h" #include "ui/views/controls/highlight_path_generator.h"
namespace ash { namespace ash {
namespace {
SkColor GetBackgroundColor() {
return AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive);
}
} // namespace
RoundedLabelButton::RoundedLabelButton(views::ButtonListener* listener, RoundedLabelButton::RoundedLabelButton(views::ButtonListener* listener,
const base::string16& text) const base::string16& text)
: views::LabelButton(listener, text) { : views::LabelButton(listener, text) {
auto* color_provider = AshColorProvider::Get();
SetEnabledTextColors(color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary));
SetHorizontalAlignment(gfx::ALIGN_CENTER); SetHorizontalAlignment(gfx::ALIGN_CENTER);
SetBorder(views::CreateEmptyBorder(gfx::Insets())); SetBorder(views::CreateEmptyBorder(gfx::Insets()));
label()->SetElideBehavior(gfx::NO_ELIDE); label()->SetElideBehavior(gfx::NO_ELIDE);
...@@ -30,9 +36,17 @@ RoundedLabelButton::RoundedLabelButton(views::ButtonListener* listener, ...@@ -30,9 +36,17 @@ RoundedLabelButton::RoundedLabelButton(views::ButtonListener* listener,
TrayPopupUtils::ConfigureTrayPopupButton(this); TrayPopupUtils::ConfigureTrayPopupButton(this);
views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(), views::InstallRoundRectHighlightPathGenerator(this, gfx::Insets(),
kTrayItemSize / 2.f); kTrayItemSize / 2.f);
SetBackground(views::CreateRoundedRectBackground(GetBackgroundColor(),
kTrayItemCornerRadius));
}
void RoundedLabelButton::OnThemeChanged() {
views::LabelButton::OnThemeChanged();
auto* color_provider = AshColorProvider::Get();
color_provider->DecoratePillButton(this, /*icon=*/nullptr);
focus_ring()->SetColor(color_provider->GetControlsLayerColor( focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor)); AshColorProvider::ControlsLayerType::kFocusRingColor));
background()->SetNativeControlColor(GetBackgroundColor());
} }
RoundedLabelButton::~RoundedLabelButton() = default; RoundedLabelButton::~RoundedLabelButton() = default;
...@@ -46,18 +60,6 @@ int RoundedLabelButton::GetHeightForWidth(int width) const { ...@@ -46,18 +60,6 @@ int RoundedLabelButton::GetHeightForWidth(int width) const {
return kTrayItemSize; return kTrayItemSize;
} }
void RoundedLabelButton::PaintButtonContents(gfx::Canvas* canvas) {
gfx::RectF rect(GetContentsBounds());
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive));
flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawRoundRect(rect, kTrayItemCornerRadius, flags);
views::LabelButton::PaintButtonContents(canvas);
}
std::unique_ptr<views::InkDrop> RoundedLabelButton::CreateInkDrop() { std::unique_ptr<views::InkDrop> RoundedLabelButton::CreateInkDrop() {
return TrayPopupUtils::CreateInkDrop(this); return TrayPopupUtils::CreateInkDrop(this);
} }
......
...@@ -25,12 +25,12 @@ class RoundedLabelButton : public views::LabelButton { ...@@ -25,12 +25,12 @@ class RoundedLabelButton : public views::LabelButton {
// views::LabelButton: // views::LabelButton:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
int GetHeightForWidth(int width) const override; int GetHeightForWidth(int width) const override;
void PaintButtonContents(gfx::Canvas* canvas) override;
std::unique_ptr<views::InkDrop> CreateInkDrop() override; std::unique_ptr<views::InkDrop> CreateInkDrop() override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override; const override;
const char* GetClassName() const override; const char* GetClassName() const override;
void OnThemeChanged() override;
private: private:
DISALLOW_COPY_AND_ASSIGN(RoundedLabelButton); DISALLOW_COPY_AND_ASSIGN(RoundedLabelButton);
......
...@@ -21,26 +21,13 @@ namespace ash { ...@@ -21,26 +21,13 @@ namespace ash {
TopShortcutButton::TopShortcutButton(views::ButtonListener* listener, TopShortcutButton::TopShortcutButton(views::ButtonListener* listener,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
int accessible_name_id) int accessible_name_id)
: views::ImageButton(listener) { : views::ImageButton(listener), icon_(icon) {
SetImageHorizontalAlignment(ALIGN_CENTER); SetImageHorizontalAlignment(ALIGN_CENTER);
SetImageVerticalAlignment(ALIGN_MIDDLE); SetImageVerticalAlignment(ALIGN_MIDDLE);
if (accessible_name_id) if (accessible_name_id)
SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id));
TrayPopupUtils::ConfigureTrayPopupButton(this); TrayPopupUtils::ConfigureTrayPopupButton(this);
views::InstallCircleHighlightPathGenerator(this); views::InstallCircleHighlightPathGenerator(this);
auto* color_provider = AshColorProvider::Get();
const SkColor icon_color = color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(icon, kTrayTopShortcutButtonIconSize, icon_color));
SetImage(
views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, kTrayTopShortcutButtonIconSize,
AshColorProvider::GetDisabledColor(icon_color)));
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
} }
TopShortcutButton::~TopShortcutButton() = default; TopShortcutButton::~TopShortcutButton() = default;
...@@ -80,4 +67,15 @@ const char* TopShortcutButton::GetClassName() const { ...@@ -80,4 +67,15 @@ const char* TopShortcutButton::GetClassName() const {
return "TopShortcutButton"; return "TopShortcutButton";
} }
void TopShortcutButton::OnThemeChanged() {
views::ImageButton::OnThemeChanged();
auto* color_provider = AshColorProvider::Get();
color_provider->DecorateIconButton(this, icon_,
/*toggled_=*/false,
kTrayTopShortcutButtonIconSize);
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SchedulePaint();
}
} // namespace ash } // namespace ash
...@@ -30,8 +30,11 @@ class TopShortcutButton : public views::ImageButton { ...@@ -30,8 +30,11 @@ class TopShortcutButton : public views::ImageButton {
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override; const override;
const char* GetClassName() const override; const char* GetClassName() const override;
void OnThemeChanged() override;
private: private:
const gfx::VectorIcon& icon_;
DISALLOW_COPY_AND_ASSIGN(TopShortcutButton); DISALLOW_COPY_AND_ASSIGN(TopShortcutButton);
}; };
......
...@@ -98,8 +98,6 @@ UnifiedSliderButton::UnifiedSliderButton(views::ButtonListener* listener, ...@@ -98,8 +98,6 @@ UnifiedSliderButton::UnifiedSliderButton(views::ButtonListener* listener,
// Focus ring is around the whole view's bounds, but the ink drop should be // Focus ring is around the whole view's bounds, but the ink drop should be
// the same size as the content. // the same size as the content.
TrayPopupUtils::ConfigureTrayPopupButton(this); TrayPopupUtils::ConfigureTrayPopupButton(this);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
focus_ring()->SetPathGenerator( focus_ring()->SetPathGenerator(
std::make_unique<views::CircleHighlightPathGenerator>(gfx::Insets())); std::make_unique<views::CircleHighlightPathGenerator>(gfx::Insets()));
views::InstallCircleHighlightPathGenerator( views::InstallCircleHighlightPathGenerator(
...@@ -108,15 +106,6 @@ UnifiedSliderButton::UnifiedSliderButton(views::ButtonListener* listener, ...@@ -108,15 +106,6 @@ UnifiedSliderButton::UnifiedSliderButton(views::ButtonListener* listener,
UnifiedSliderButton::~UnifiedSliderButton() = default; UnifiedSliderButton::~UnifiedSliderButton() = default;
gfx::Size UnifiedSliderButton::CalculatePreferredSize() const {
return gfx::Size(kTrayItemSize + kUnifiedCircularButtonFocusPadding.width(),
kTrayItemSize + kUnifiedCircularButtonFocusPadding.height());
}
const char* UnifiedSliderButton::GetClassName() const {
return "UnifiedSliderButton";
}
void UnifiedSliderButton::SetVectorIcon(const gfx::VectorIcon& icon) { void UnifiedSliderButton::SetVectorIcon(const gfx::VectorIcon& icon) {
icon_ = &icon; icon_ = &icon;
UpdateVectorIcon(); UpdateVectorIcon();
...@@ -168,13 +157,29 @@ void UnifiedSliderButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -168,13 +157,29 @@ void UnifiedSliderButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
: ax::mojom::CheckedState::kFalse); : ax::mojom::CheckedState::kFalse);
} }
const char* UnifiedSliderButton::GetClassName() const {
return "UnifiedSliderButton";
}
gfx::Size UnifiedSliderButton::CalculatePreferredSize() const {
return gfx::Size(kTrayItemSize + kUnifiedCircularButtonFocusPadding.width(),
kTrayItemSize + kUnifiedCircularButtonFocusPadding.height());
}
void UnifiedSliderButton::OnThemeChanged() {
views::ImageButton::OnThemeChanged();
UpdateVectorIcon();
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SchedulePaint();
}
void UnifiedSliderButton::UpdateVectorIcon() { void UnifiedSliderButton::UpdateVectorIcon() {
if (!icon_) if (!icon_)
return; return;
AshColorProvider::Get()->DecorateIconButton( AshColorProvider::Get()->DecorateIconButton(
this, AshColorProvider::ButtonType::kIconButtonSmallOrMedium, *icon_, this, *icon_, toggled_, GetDefaultSizeOfVectorIcon(*icon_));
toggled_, GetDefaultSizeOfVectorIcon(*icon_));
} }
UnifiedSliderView::UnifiedSliderView(UnifiedSliderListener* listener, UnifiedSliderView::UnifiedSliderView(UnifiedSliderListener* listener,
......
...@@ -37,20 +37,16 @@ class UnifiedSliderButton : public views::ImageButton { ...@@ -37,20 +37,16 @@ class UnifiedSliderButton : public views::ImageButton {
// Change the toggle state. // Change the toggle state.
void SetToggled(bool toggled); void SetToggled(bool toggled);
// views::View:
gfx::Size CalculatePreferredSize() const override;
// views::Button:
const char* GetClassName() const override;
// views::ImageButton: // views::ImageButton:
std::unique_ptr<views::InkDrop> CreateInkDrop() override; std::unique_ptr<views::InkDrop> CreateInkDrop() override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override; const override;
void PaintButtonContents(gfx::Canvas* canvas) override; void PaintButtonContents(gfx::Canvas* canvas) override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
const char* GetClassName() const override;
gfx::Size CalculatePreferredSize() const override;
void OnThemeChanged() override;
private: private:
void UpdateVectorIcon(); void UpdateVectorIcon();
......
...@@ -67,6 +67,7 @@ class DateView : public views::Button, ...@@ -67,6 +67,7 @@ class DateView : public views::Button,
// views::Button: // views::Button:
const char* GetClassName() const override { return "DateView"; } const char* GetClassName() const override { return "DateView"; }
void OnThemeChanged() override;
private: private:
void Update(); void Update();
...@@ -90,26 +91,17 @@ class DateView : public views::Button, ...@@ -90,26 +91,17 @@ class DateView : public views::Button,
}; };
DateView::DateView(UnifiedSystemTrayController* controller) DateView::DateView(UnifiedSystemTrayController* controller)
: Button(this), controller_(controller), label_(new views::Label) { : Button(this), controller_(controller) {
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
AddChildView(label_); label_ = AddChildView(std::make_unique<views::Label>());
auto* color_provider = AshColorProvider::Get();
label_->SetAutoColorReadabilityEnabled(false); label_->SetAutoColorReadabilityEnabled(false);
label_->SetSubpixelRenderingEnabled(false); label_->SetSubpixelRenderingEnabled(false);
label_->SetEnabledColor(color_provider->GetContentLayerColor(
ContentLayerType::kTextColorPrimary));
Update(); Update();
Shell::Get()->system_tray_model()->clock()->AddObserver(this); Shell::Get()->system_tray_model()->clock()->AddObserver(this);
SetEnabled(Shell::Get()->system_tray_model()->clock()->IsSettingsAvailable()); SetEnabled(Shell::Get()->system_tray_model()->clock()->IsSettingsAvailable());
SetInstallFocusRingOnFocus(true); SetInstallFocusRingOnFocus(true);
SetFocusForPlatform(); SetFocusForPlatform();
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SetInkDropMode(views::InkDropHostView::InkDropMode::OFF); SetInkDropMode(views::InkDropHostView::InkDropMode::OFF);
} }
...@@ -117,6 +109,15 @@ DateView::~DateView() { ...@@ -117,6 +109,15 @@ DateView::~DateView() {
Shell::Get()->system_tray_model()->clock()->RemoveObserver(this); Shell::Get()->system_tray_model()->clock()->RemoveObserver(this);
} }
void DateView::OnThemeChanged() {
views::Button::OnThemeChanged();
auto* color_provider = AshColorProvider::Get();
label_->SetEnabledColor(color_provider->GetContentLayerColor(
ContentLayerType::kTextColorPrimary));
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
}
void DateView::ButtonPressed(views::Button* sender, const ui::Event& event) { void DateView::ButtonPressed(views::Button* sender, const ui::Event& event) {
controller_->HandleOpenDateTimeSettingsAction(); controller_->HandleOpenDateTimeSettingsAction();
} }
...@@ -158,6 +159,7 @@ class BatteryView : public views::View, public PowerStatus::Observer { ...@@ -158,6 +159,7 @@ class BatteryView : public views::View, public PowerStatus::Observer {
void ChildPreferredSizeChanged(views::View* child) override; void ChildPreferredSizeChanged(views::View* child) override;
void ChildVisibilityChanged(views::View* child) override; void ChildVisibilityChanged(views::View* child) override;
const char* GetClassName() const override { return "BatteryView"; } const char* GetClassName() const override { return "BatteryView"; }
void OnThemeChanged() override;
// PowerStatus::Observer: // PowerStatus::Observer:
void OnPowerStatusChanged() override; void OnPowerStatusChanged() override;
...@@ -174,26 +176,16 @@ class BatteryView : public views::View, public PowerStatus::Observer { ...@@ -174,26 +176,16 @@ class BatteryView : public views::View, public PowerStatus::Observer {
DISALLOW_COPY_AND_ASSIGN(BatteryView); DISALLOW_COPY_AND_ASSIGN(BatteryView);
}; };
BatteryView::BatteryView() BatteryView::BatteryView() {
: percentage_(new views::Label),
separator_(new views::Label),
status_(new views::Label) {
PowerStatus::Get()->AddObserver(this); PowerStatus::Get()->AddObserver(this);
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal)); views::BoxLayout::Orientation::kHorizontal));
percentage_ = AddChildView(std::make_unique<views::Label>());
separator_ = AddChildView(std::make_unique<views::Label>());
status_ = AddChildView(std::make_unique<views::Label>());
separator_->SetText( separator_->SetText(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_STATUS_SEPARATOR)); l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_STATUS_SEPARATOR));
ConfigureLabel(percentage_);
ConfigureLabel(separator_);
ConfigureLabel(status_);
AddChildView(percentage_);
AddChildView(separator_);
AddChildView(status_);
Update(); Update();
} }
...@@ -214,6 +206,13 @@ void BatteryView::ChildVisibilityChanged(views::View* child) { ...@@ -214,6 +206,13 @@ void BatteryView::ChildVisibilityChanged(views::View* child) {
PreferredSizeChanged(); PreferredSizeChanged();
} }
void BatteryView::OnThemeChanged() {
views::View::OnThemeChanged();
ConfigureLabel(percentage_);
ConfigureLabel(separator_);
ConfigureLabel(status_);
}
void BatteryView::OnPowerStatusChanged() { void BatteryView::OnPowerStatusChanged() {
Update(); Update();
} }
...@@ -250,6 +249,7 @@ class ManagedStateView : public views::Button { ...@@ -250,6 +249,7 @@ class ManagedStateView : public views::Button {
// views::Button: // views::Button:
const char* GetClassName() const override { return "ManagedStateView"; } const char* GetClassName() const override { return "ManagedStateView"; }
void OnThemeChanged() override;
protected: protected:
ManagedStateView(views::ButtonListener* listener, ManagedStateView(views::ButtonListener* listener,
...@@ -257,39 +257,44 @@ class ManagedStateView : public views::Button { ...@@ -257,39 +257,44 @@ class ManagedStateView : public views::Button {
const gfx::VectorIcon& icon); const gfx::VectorIcon& icon);
private: private:
views::Label* label_ = nullptr;
views::ImageView* image_ = nullptr;
const gfx::VectorIcon& icon_;
DISALLOW_COPY_AND_ASSIGN(ManagedStateView); DISALLOW_COPY_AND_ASSIGN(ManagedStateView);
}; };
void ManagedStateView::OnThemeChanged() {
views::Button::OnThemeChanged();
auto* color_provider = AshColorProvider::Get();
label_->SetEnabledColor(color_provider->GetContentLayerColor(
ContentLayerType::kTextColorSecondary));
image_->SetImage(
gfx::CreateVectorIcon(icon_, color_provider->GetContentLayerColor(
ContentLayerType::kIconColorSecondary)));
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
}
ManagedStateView::ManagedStateView(views::ButtonListener* listener, ManagedStateView::ManagedStateView(views::ButtonListener* listener,
int label_id, int label_id,
const gfx::VectorIcon& icon) const gfx::VectorIcon& icon)
: Button(listener) { : Button(listener), icon_(icon) {
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, gfx::Insets(), views::BoxLayout::Orientation::kHorizontal, gfx::Insets(),
kUnifiedSystemInfoSpacing)); kUnifiedSystemInfoSpacing));
auto* color_provider = AshColorProvider::Get(); label_ = AddChildView(std::make_unique<views::Label>());
auto* label = new views::Label; label_->SetAutoColorReadabilityEnabled(false);
label->SetAutoColorReadabilityEnabled(false); label_->SetSubpixelRenderingEnabled(false);
label->SetSubpixelRenderingEnabled(false); label_->SetText(l10n_util::GetStringUTF16(label_id));
label->SetEnabledColor(color_provider->GetContentLayerColor(
ContentLayerType::kTextColorSecondary)); image_ = AddChildView(std::make_unique<views::ImageView>());
label->SetText(l10n_util::GetStringUTF16(label_id)); image_->SetPreferredSize(
AddChildView(label);
auto* image = new views::ImageView;
image->SetImage(
gfx::CreateVectorIcon(icon, color_provider->GetContentLayerColor(
ContentLayerType::kIconColorSecondary)));
image->SetPreferredSize(
gfx::Size(kUnifiedSystemInfoHeight, kUnifiedSystemInfoHeight)); gfx::Size(kUnifiedSystemInfoHeight, kUnifiedSystemInfoHeight));
AddChildView(image);
SetInstallFocusRingOnFocus(true); SetInstallFocusRingOnFocus(true);
SetFocusForPlatform(); SetFocusForPlatform();
focus_ring()->SetColor(color_provider->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SetInkDropMode(views::InkDropHostView::InkDropMode::OFF); SetInkDropMode(views::InkDropHostView::InkDropMode::OFF);
} }
...@@ -410,28 +415,22 @@ UnifiedSystemInfoView::UnifiedSystemInfoView( ...@@ -410,28 +415,22 @@ UnifiedSystemInfoView::UnifiedSystemInfoView(
layout->set_cross_axis_alignment( layout->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter); views::BoxLayout::CrossAxisAlignment::kCenter);
AddChildView(new DateView(controller)); AddChildView(std::make_unique<DateView>(controller));
if (PowerStatus::Get()->IsBatteryPresent()) { if (PowerStatus::Get()->IsBatteryPresent()) {
auto* separator = new views::Separator(); separator_ = AddChildView(std::make_unique<views::Separator>());
separator->SetColor(AshColorProvider::Get()->GetContentLayerColor( separator_->SetPreferredHeight(kUnifiedSystemInfoHeight);
ContentLayerType::kSeparatorColor)); AddChildView(std::make_unique<BatteryView>());
separator->SetPreferredHeight(kUnifiedSystemInfoHeight);
AddChildView(separator);
AddChildView(new BatteryView());
} }
auto* spacing = new views::View; auto* spacing = AddChildView(std::make_unique<views::View>());
AddChildView(spacing);
layout->SetFlexForView(spacing, 1); layout->SetFlexForView(spacing, 1);
if (!features::IsManagedDeviceUIRedesignEnabled()) { if (!features::IsManagedDeviceUIRedesignEnabled()) {
// UnifiedManagedDeviceView is shown instead. // UnifiedManagedDeviceView is shown instead.
enterprise_managed_ = new EnterpriseManagedView(controller); enterprise_managed_ =
supervised_ = new SupervisedUserView(); AddChildView(std::make_unique<EnterpriseManagedView>(controller));
AddChildView(enterprise_managed_); supervised_ = AddChildView(std::make_unique<SupervisedUserView>());
AddChildView(supervised_);
} }
} }
...@@ -449,4 +448,12 @@ const char* UnifiedSystemInfoView::GetClassName() const { ...@@ -449,4 +448,12 @@ const char* UnifiedSystemInfoView::GetClassName() const {
return "UnifiedSystemInfoView"; return "UnifiedSystemInfoView";
} }
void UnifiedSystemInfoView::OnThemeChanged() {
views::View::OnThemeChanged();
if (separator_) {
separator_->SetColor(AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kSeparatorColor));
}
}
} // namespace ash } // namespace ash
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_controller.h"
#include "ui/views/view.h" #include "ui/views/view.h"
namespace views {
class Separator;
} // namespace views
namespace ash { namespace ash {
// A view at the bottom of UnifiedSystemTray bubble that shows system // A view at the bottom of UnifiedSystemTray bubble that shows system
...@@ -23,6 +27,7 @@ class ASH_EXPORT UnifiedSystemInfoView : public views::View { ...@@ -23,6 +27,7 @@ class ASH_EXPORT UnifiedSystemInfoView : public views::View {
void ChildPreferredSizeChanged(views::View* child) override; void ChildPreferredSizeChanged(views::View* child) override;
void ChildVisibilityChanged(views::View* child) override; void ChildVisibilityChanged(views::View* child) override;
const char* GetClassName() const override; const char* GetClassName() const override;
void OnThemeChanged() override;
private: private:
FRIEND_TEST_ALL_PREFIXES(UnifiedSystemInfoViewTest, EnterpriseManagedVisible); FRIEND_TEST_ALL_PREFIXES(UnifiedSystemInfoViewTest, EnterpriseManagedVisible);
...@@ -38,6 +43,8 @@ class ASH_EXPORT UnifiedSystemInfoView : public views::View { ...@@ -38,6 +43,8 @@ class ASH_EXPORT UnifiedSystemInfoView : public views::View {
// kManagedDeviceUIRedesign is enabled. // kManagedDeviceUIRedesign is enabled.
views::View* supervised_ = nullptr; views::View* supervised_ = nullptr;
views::Separator* separator_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(UnifiedSystemInfoView); DISALLOW_COPY_AND_ASSIGN(UnifiedSystemInfoView);
}; };
......
...@@ -64,9 +64,7 @@ SkColor CloseDeskButton::GetInkDropBaseColor() const { ...@@ -64,9 +64,7 @@ SkColor CloseDeskButton::GetInkDropBaseColor() const {
void CloseDeskButton::OnThemeChanged() { void CloseDeskButton::OnThemeChanged() {
views::ImageButton::OnThemeChanged(); views::ImageButton::OnThemeChanged();
AshColorProvider* color_provider = AshColorProvider::Get(); AshColorProvider* color_provider = AshColorProvider::Get();
color_provider->DecorateCloseButton( color_provider->DecorateCloseButton(this, kCloseButtonSize, kCloseButtonIcon);
this, AshColorProvider::ButtonType::kCloseButtonWithSmallBase,
kCloseButtonSize, kCloseButtonIcon);
auto ripple_attributes = auto ripple_attributes =
color_provider->GetRippleAttributes(background()->get_color()); color_provider->GetRippleAttributes(background()->get_color());
......
...@@ -54,6 +54,8 @@ DeskNameView::DeskNameView() { ...@@ -54,6 +54,8 @@ DeskNameView::DeskNameView() {
SetCursorEnabled(true); SetCursorEnabled(true);
SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_CENTER); SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_CENTER);
SetBackground(views::CreateRoundedRectBackground(GetBackgroundColor(),
kDeskNameViewBorderRadius));
} }
DeskNameView::~DeskNameView() = default; DeskNameView::~DeskNameView() = default;
...@@ -127,10 +129,6 @@ void DeskNameView::OnMouseExited(const ui::MouseEvent& event) { ...@@ -127,10 +129,6 @@ void DeskNameView::OnMouseExited(const ui::MouseEvent& event) {
void DeskNameView::OnThemeChanged() { void DeskNameView::OnThemeChanged() {
Textfield::OnThemeChanged(); Textfield::OnThemeChanged();
SetBackground(views::CreateRoundedRectBackground(GetBackgroundColor(),
kDeskNameViewBorderRadius));
AshColorProvider* color_provider = AshColorProvider::Get(); AshColorProvider* color_provider = AshColorProvider::Get();
const SkColor text_color = color_provider->GetContentLayerColor( const SkColor text_color = color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary); AshColorProvider::ContentLayerType::kTextColorPrimary);
......
...@@ -167,9 +167,7 @@ std::unique_ptr<views::LabelButtonBorder> NewDeskButton::CreateDefaultBorder() ...@@ -167,9 +167,7 @@ std::unique_ptr<views::LabelButtonBorder> NewDeskButton::CreateDefaultBorder()
void NewDeskButton::OnThemeChanged() { void NewDeskButton::OnThemeChanged() {
LabelButton::OnThemeChanged(); LabelButton::OnThemeChanged();
AshColorProvider::Get()->DecoratePillButton( AshColorProvider::Get()->DecoratePillButton(this, &kDesksNewDeskButtonIcon);
this, AshColorProvider::ButtonType::kPillButtonWithIcon,
kDesksNewDeskButtonIcon);
UpdateButtonState(); UpdateButtonState();
} }
......
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