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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
72 void TrayItemMore::ReplaceIcon(views::View* view) { | 73 void TrayItemMore::ReplaceIcon(views::View* view) { |
73 delete icon_; | 74 delete icon_; |
74 icon_ = NULL; | 75 icon_ = NULL; |
75 AddChildViewAt(view, 0); | 76 AddChildViewAt(view, 0); |
76 } | 77 } |
77 | 78 |
| 79 void TrayItemMore::UpdateStyle() { |
| 80 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 81 return; |
| 82 |
| 83 TrayPopupItemStyle style(GetNativeTheme(), |
| 84 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 85 style.SetupLabel(label_); |
| 86 } |
| 87 |
78 bool TrayItemMore::PerformAction(const ui::Event& event) { | 88 bool TrayItemMore::PerformAction(const ui::Event& event) { |
79 if (!show_more_) | 89 if (!show_more_) |
80 return false; | 90 return false; |
81 | 91 |
82 owner()->TransitionDetailedView(); | 92 owner()->TransitionDetailedView(); |
83 return true; | 93 return true; |
84 } | 94 } |
85 | 95 |
86 void TrayItemMore::Layout() { | 96 void TrayItemMore::Layout() { |
87 // Let the box-layout do the layout first. Then move the '>' arrow to right | 97 // Let the box-layout do the layout first. Then move the '>' arrow to right |
(...skipping 17 matching lines...) Expand all Loading... |
105 label_->SetBoundsRect(bounds); | 115 label_->SetBoundsRect(bounds); |
106 } | 116 } |
107 } | 117 } |
108 | 118 |
109 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { | 119 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { |
110 ActionableView::GetAccessibleState(state); | 120 ActionableView::GetAccessibleState(state); |
111 if (!accessible_name_.empty()) | 121 if (!accessible_name_.empty()) |
112 state->name = accessible_name_; | 122 state->name = accessible_name_; |
113 } | 123 } |
114 | 124 |
| 125 void TrayItemMore::ViewHierarchyChanged( |
| 126 const ViewHierarchyChangedDetails& details) { |
| 127 ActionableView::ViewHierarchyChanged(details); |
| 128 |
| 129 if (details.is_add && details.child == this) |
| 130 UpdateStyle(); |
| 131 } |
| 132 |
| 133 void TrayItemMore::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 134 ActionableView::OnNativeThemeChanged(theme); |
| 135 UpdateStyle(); |
| 136 } |
| 137 |
115 } // namespace ash | 138 } // namespace ash |
OLD | NEW |