Index: ash/common/system/tray/tray_item_more.cc |
diff --git a/ash/common/system/tray/tray_item_more.cc b/ash/common/system/tray/tray_item_more.cc |
index 6d4fe55191bcf428fd06a196cbcf24986915adac..735b23018a032bcba3afc3b28d9fe919144372d2 100644 |
--- a/ash/common/system/tray/tray_item_more.cc |
+++ b/ash/common/system/tray/tray_item_more.cc |
@@ -14,6 +14,8 @@ |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/image/image.h" |
#include "ui/gfx/paint_vector_icon.h" |
+#include "ui/gfx/vector_icons_public.h" |
+#include "ui/native_theme/native_theme.h" |
#include "ui/views/controls/image_view.h" |
#include "ui/views/controls/label.h" |
#include "ui/views/layout/box_layout.h" |
@@ -23,9 +25,15 @@ namespace ash { |
TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more) |
: owner_(owner), |
show_more_(show_more), |
- icon_(NULL), |
- label_(NULL), |
- more_(NULL) { |
+ icon_(nullptr), |
+ label_(nullptr), |
+ more_(nullptr) { |
+ if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
+ style_.reset(new TrayPopupItemStyle(GetNativeTheme(), |
+ TrayPopupItemStyle::FontStyle::TITLE)); |
+ style_->AddObserver(this); |
+ } |
+ |
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
kTrayPopupPaddingHorizontal, 0, |
kTrayPopupPaddingBetweenItems)); |
@@ -37,22 +45,13 @@ TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more) |
label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
AddChildView(label_); |
- if (show_more) { |
- more_ = new views::ImageView; |
- more_->EnableCanvasFlippingForRTLUI(true); |
- if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
- more_->SetImage( |
- gfx::CreateVectorIcon(kSystemMenuArrowRightIcon, kMenuIconColor)); |
- } else { |
- more_->SetImage(ui::ResourceBundle::GetSharedInstance() |
- .GetImageNamed(IDR_AURA_UBER_TRAY_MORE) |
- .ToImageSkia()); |
- } |
- AddChildView(more_); |
- } |
+ UpdateContent(); |
tdanderson
2016/09/12 18:51:47
If I'm not mistaken, this call to UpdateContent()
|
} |
-TrayItemMore::~TrayItemMore() {} |
+TrayItemMore::~TrayItemMore() { |
+ if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
+ style_->RemoveObserver(this); |
+} |
void TrayItemMore::SetLabel(const base::string16& label) { |
label_->SetText(label); |
@@ -69,10 +68,41 @@ void TrayItemMore::SetAccessibleName(const base::string16& name) { |
accessible_name_ = name; |
} |
-void TrayItemMore::ReplaceIcon(views::View* view) { |
- delete icon_; |
- icon_ = NULL; |
- AddChildViewAt(view, 0); |
+void TrayItemMore::SetStyle(std::unique_ptr<TrayPopupItemStyle> style) { |
+ DCHECK(MaterialDesignController::IsSystemTrayMenuMaterial() && style); |
+ style_ = std::move(style); |
+ style_->AddObserver(this); |
+ OnTrayPopupItemStyleUpdated(); |
+} |
+ |
+void TrayItemMore::OnTrayPopupItemStyleUpdated() { |
+ SetEnabled(style_->color_style() != TrayPopupItemStyle::ColorStyle::DISABLED); |
+ UpdateContent(); |
+} |
+ |
+void TrayItemMore::UpdateContent() { |
+ if (more_) { |
+ delete more_; |
+ more_ = nullptr; |
+ } |
+ |
+ if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
+ style()->SetupLabel(label_); |
+ |
+ if (show_more_) { |
+ more_ = new views::ImageView; |
+ more_->EnableCanvasFlippingForRTLUI(true); |
+ |
+ if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
+ more_->SetImage(gfx::CreateVectorIcon(kSystemMenuArrowRightIcon, |
+ style()->GetForegroundColor())); |
+ } else { |
+ more_->SetImage(ui::ResourceBundle::GetSharedInstance() |
+ .GetImageNamed(IDR_AURA_UBER_TRAY_MORE) |
+ .ToImageSkia()); |
+ } |
+ AddChildView(more_); |
+ } |
} |
bool TrayItemMore::PerformAction(const ui::Event& event) { |
@@ -112,4 +142,9 @@ void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { |
state->name = accessible_name_; |
} |
+void TrayItemMore::OnThemeChanged() { |
+ if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
+ style_->SetTheme(GetNativeTheme()); |
+} |
+ |
} // namespace ash |