Chromium Code Reviews| 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 d9b8244db6f8c4e154b69976ac10f34f6b6a8f58..d9cc7b1d73957eb07a7ca4d98f0fa8c50af0f0ce 100644 |
| --- a/ash/common/system/tray/tray_item_more.cc |
| +++ b/ash/common/system/tray/tray_item_more.cc |
| @@ -14,6 +14,7 @@ |
| #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 +24,11 @@ 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), |
| + style_(new TrayPopupItemStyle(GetNativeTheme(), |
| + TrayPopupItemStyle::FontStyle::TITLE)) { |
| SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| kTrayPopupPaddingHorizontal, 0, |
| kTrayPopupPaddingBetweenItems)); |
| @@ -37,22 +40,12 @@ 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( |
| - gfx::VectorIconId::SYSTEM_MENU_ARROW_RIGHT, kMenuIconColor)); |
| - } else { |
| - more_->SetImage(ui::ResourceBundle::GetSharedInstance() |
| - .GetImageNamed(IDR_AURA_UBER_TRAY_MORE) |
| - .ToImageSkia()); |
| - } |
| - AddChildView(more_); |
| - } |
| + UpdateChildren(); |
| } |
| -TrayItemMore::~TrayItemMore() {} |
| +TrayItemMore::~TrayItemMore() { |
| + style_->RemoveObserver(this); |
| +} |
| void TrayItemMore::SetLabel(const base::string16& label) { |
| label_->SetText(label); |
| @@ -69,10 +62,43 @@ 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(style); |
| + style_->RemoveObserver(this); |
| + style_ = std::move(style); |
| + style_->AddObserver(this); |
| + OnTrayPopupItemStyleChanged(); |
| +} |
| + |
| +void TrayItemMore::OnTrayPopupItemStyleChanged() { |
| + SetEnabled(style_->color_style() != TrayPopupItemStyle::ColorStyle::DISABLED); |
| + UpdateChildren(); |
| +} |
| + |
| +void TrayItemMore::UpdateChildren() { |
| + if (more_) { |
| + delete more_; |
| + more_ = nullptr; |
| + } |
| + |
| + if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| + style()->SetupLabel(label_); |
|
tdanderson
2016/09/08 16:11:02
I wonder if it would be better to invoke this when
bruthig
2016/09/12 13:45:34
I'm not sure I follow 100%. The style will need t
tdanderson
2016/09/12 18:51:46
Ah, disregard my comment then - in my first skim t
|
| + |
| + if (show_more_) { |
| + more_ = new views::ImageView; |
| + more_->EnableCanvasFlippingForRTLUI(true); |
| + |
| + if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| + more_->SetImage( |
| + gfx::CreateVectorIcon(gfx::VectorIconId::SYSTEM_MENU_ARROW_RIGHT, |
| + 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 +138,8 @@ void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { |
| state->name = accessible_name_; |
| } |
| +void TrayItemMore::OnThemeChanged() { |
| + style_->SetTheme(GetNativeTheme()); |
| +} |
| + |
| } // namespace ash |