| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/system/tray/tray_item_more.h" | 5 #include "ash/common/system/tray/tray_item_more.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/system/tray/fixed_sized_image_view.h" | 8 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 9 #include "ash/common/system/tray/system_tray_item.h" | 9 #include "ash/common/system/tray/system_tray_item.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| 11 #include "ash/common/system/tray/tray_popup_item_style.h" | 11 #include "ash/common/system/tray/tray_popup_item_style.h" |
| 12 #include "ash/resources/vector_icons/vector_icons.h" | 12 #include "ash/resources/vector_icons/vector_icons.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "grit/ash_resources.h" | 14 #include "grit/ash_resources.h" |
| 14 #include "ui/accessibility/ax_view_state.h" | 15 #include "ui/accessibility/ax_view_state.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 17 #include "ui/gfx/paint_vector_icon.h" | 18 #include "ui/gfx/paint_vector_icon.h" |
| 18 #include "ui/views/controls/image_view.h" | 19 #include "ui/views/controls/image_view.h" |
| 19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/layout/box_layout.h" | 21 #include "ui/views/layout/box_layout.h" |
| 21 | 22 |
| 22 namespace ash { | 23 namespace ash { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 icon_ = new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 35 icon_ = new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| 35 AddChildView(icon_); | 36 AddChildView(icon_); |
| 36 | 37 |
| 37 label_ = new views::Label; | 38 label_ = new views::Label; |
| 38 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 39 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 39 AddChildView(label_); | 40 AddChildView(label_); |
| 40 | 41 |
| 41 if (show_more) { | 42 if (show_more) { |
| 42 more_ = new views::ImageView; | 43 more_ = new views::ImageView; |
| 43 more_->EnableCanvasFlippingForRTLUI(true); | 44 more_->EnableCanvasFlippingForRTLUI(true); |
| 44 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 45 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 45 more_->SetImage( | 46 // The icon doesn't change in non-md. |
| 46 gfx::CreateVectorIcon(kSystemMenuArrowRightIcon, kMenuIconColor)); | |
| 47 } else { | |
| 48 more_->SetImage(ui::ResourceBundle::GetSharedInstance() | 47 more_->SetImage(ui::ResourceBundle::GetSharedInstance() |
| 49 .GetImageNamed(IDR_AURA_UBER_TRAY_MORE) | 48 .GetImageNamed(IDR_AURA_UBER_TRAY_MORE) |
| 50 .ToImageSkia()); | 49 .ToImageSkia()); |
| 51 } | 50 } |
| 52 AddChildView(more_); | 51 AddChildView(more_); |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 | 54 |
| 56 TrayItemMore::~TrayItemMore() {} | 55 TrayItemMore::~TrayItemMore() {} |
| 57 | 56 |
| 58 void TrayItemMore::SetLabel(const base::string16& label) { | 57 void TrayItemMore::SetLabel(const base::string16& label) { |
| 59 label_->SetText(label); | 58 label_->SetText(label); |
| 60 Layout(); | 59 Layout(); |
| 61 SchedulePaint(); | 60 SchedulePaint(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 void TrayItemMore::SetImage(const gfx::ImageSkia& image_skia) { | 63 void TrayItemMore::SetImage(const gfx::ImageSkia& image_skia) { |
| 65 icon_->SetImage(image_skia); | 64 icon_->SetImage(image_skia); |
| 66 SchedulePaint(); | 65 SchedulePaint(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void TrayItemMore::SetAccessibleName(const base::string16& name) { | 68 void TrayItemMore::SetAccessibleName(const base::string16& name) { |
| 70 accessible_name_ = name; | 69 accessible_name_ = name; |
| 71 } | 70 } |
| 72 | 71 |
| 72 std::unique_ptr<TrayPopupItemStyle> TrayItemMore::CreateStyle() const { |
| 73 return base::MakeUnique<TrayPopupItemStyle>( |
| 74 GetNativeTheme(), TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 75 } |
| 76 |
| 73 void TrayItemMore::UpdateStyle() { | 77 void TrayItemMore::UpdateStyle() { |
| 74 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | 78 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 75 return; | 79 return; |
| 80 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle(); |
| 81 style->SetupLabel(label_); |
| 76 | 82 |
| 77 TrayPopupItemStyle style(GetNativeTheme(), | 83 if (more_) { |
| 78 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | 84 more_->SetImage(gfx::CreateVectorIcon(kSystemMenuArrowRightIcon, |
| 79 style.SetupLabel(label_); | 85 style->GetForegroundColor())); |
| 86 } |
| 80 } | 87 } |
| 81 | 88 |
| 82 bool TrayItemMore::PerformAction(const ui::Event& event) { | 89 bool TrayItemMore::PerformAction(const ui::Event& event) { |
| 83 if (!show_more_) | 90 if (!show_more_) |
| 84 return false; | 91 return false; |
| 85 | 92 |
| 86 owner()->TransitionDetailedView(); | 93 owner()->TransitionDetailedView(); |
| 87 return true; | 94 return true; |
| 88 } | 95 } |
| 89 | 96 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 115 if (!accessible_name_.empty()) | 122 if (!accessible_name_.empty()) |
| 116 state->name = accessible_name_; | 123 state->name = accessible_name_; |
| 117 } | 124 } |
| 118 | 125 |
| 119 void TrayItemMore::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 126 void TrayItemMore::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 120 ActionableView::OnNativeThemeChanged(theme); | 127 ActionableView::OnNativeThemeChanged(theme); |
| 121 UpdateStyle(); | 128 UpdateStyle(); |
| 122 } | 129 } |
| 123 | 130 |
| 124 } // namespace ash | 131 } // namespace ash |
| OLD | NEW |