| 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/resources/vector_icons/vector_icons.h" | 12 #include "ash/resources/vector_icons/vector_icons.h" |
| 12 #include "grit/ash_resources.h" | 13 #include "grit/ash_resources.h" |
| 13 #include "ui/accessibility/ax_view_state.h" | 14 #include "ui/accessibility/ax_view_state.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
| 16 #include "ui/gfx/paint_vector_icon.h" | 17 #include "ui/gfx/paint_vector_icon.h" |
| 17 #include "ui/views/controls/image_view.h" | 18 #include "ui/views/controls/image_view.h" |
| 18 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/layout/box_layout.h" | 20 #include "ui/views/layout/box_layout.h" |
| 20 | 21 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 63 |
| 63 void TrayItemMore::SetImage(const gfx::ImageSkia& image_skia) { | 64 void TrayItemMore::SetImage(const gfx::ImageSkia& image_skia) { |
| 64 icon_->SetImage(image_skia); | 65 icon_->SetImage(image_skia); |
| 65 SchedulePaint(); | 66 SchedulePaint(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void TrayItemMore::SetAccessibleName(const base::string16& name) { | 69 void TrayItemMore::SetAccessibleName(const base::string16& name) { |
| 69 accessible_name_ = name; | 70 accessible_name_ = name; |
| 70 } | 71 } |
| 71 | 72 |
| 73 void TrayItemMore::UpdateStyle() { |
| 74 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 75 return; |
| 76 |
| 77 TrayPopupItemStyle style(GetNativeTheme(), |
| 78 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 79 style.SetupLabel(label_); |
| 80 } |
| 81 |
| 72 bool TrayItemMore::PerformAction(const ui::Event& event) { | 82 bool TrayItemMore::PerformAction(const ui::Event& event) { |
| 73 if (!show_more_) | 83 if (!show_more_) |
| 74 return false; | 84 return false; |
| 75 | 85 |
| 76 owner()->TransitionDetailedView(); | 86 owner()->TransitionDetailedView(); |
| 77 return true; | 87 return true; |
| 78 } | 88 } |
| 79 | 89 |
| 80 void TrayItemMore::Layout() { | 90 void TrayItemMore::Layout() { |
| 81 // Let the box-layout do the layout first. Then move the '>' arrow to right | 91 // Let the box-layout do the layout first. Then move the '>' arrow to right |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 label_->SetBoundsRect(bounds); | 109 label_->SetBoundsRect(bounds); |
| 100 } | 110 } |
| 101 } | 111 } |
| 102 | 112 |
| 103 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { | 113 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { |
| 104 ActionableView::GetAccessibleState(state); | 114 ActionableView::GetAccessibleState(state); |
| 105 if (!accessible_name_.empty()) | 115 if (!accessible_name_.empty()) |
| 106 state->name = accessible_name_; | 116 state->name = accessible_name_; |
| 107 } | 117 } |
| 108 | 118 |
| 119 void TrayItemMore::ViewHierarchyChanged( |
| 120 const ViewHierarchyChangedDetails& details) { |
| 121 ActionableView::ViewHierarchyChanged(details); |
| 122 |
| 123 if (details.is_add && details.child == this) |
| 124 UpdateStyle(); |
| 125 } |
| 126 |
| 127 void TrayItemMore::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 128 ActionableView::OnNativeThemeChanged(theme); |
| 129 UpdateStyle(); |
| 130 } |
| 131 |
| 109 } // namespace ash | 132 } // namespace ash |
| OLD | NEW |