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/resources/vector_icons/vector_icons.h" | 11 #include "ash/resources/vector_icons/vector_icons.h" |
12 #include "grit/ash_resources.h" | 12 #include "grit/ash_resources.h" |
13 #include "ui/accessibility/ax_view_state.h" | 13 #include "ui/accessibility/ax_view_state.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
16 #include "ui/gfx/paint_vector_icon.h" | 16 #include "ui/gfx/paint_vector_icon.h" |
17 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
18 #include "ui/views/controls/label.h" | 18 #include "ui/views/controls/label.h" |
19 #include "ui/views/layout/box_layout.h" | 19 #include "ui/views/layout/box_layout.h" |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 | 22 |
23 TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more) | 23 TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more) |
24 : owner_(owner), | 24 : owner_(owner), |
25 show_more_(show_more), | 25 show_more_(show_more), |
26 icon_(NULL), | 26 icon_(nullptr), |
27 label_(NULL), | 27 label_(nullptr), |
28 more_(NULL) { | 28 more_(nullptr) { |
29 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 29 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
30 kTrayPopupPaddingHorizontal, 0, | 30 kTrayPopupPaddingHorizontal, 0, |
31 kTrayPopupPaddingBetweenItems)); | 31 kTrayPopupPaddingBetweenItems)); |
32 | 32 |
33 icon_ = new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 33 icon_ = new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
34 AddChildView(icon_); | 34 AddChildView(icon_); |
35 | 35 |
36 label_ = new views::Label; | 36 label_ = new views::Label; |
37 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 37 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
38 AddChildView(label_); | 38 AddChildView(label_); |
(...skipping 23 matching lines...) Expand all Loading... |
62 | 62 |
63 void TrayItemMore::SetImage(const gfx::ImageSkia& image_skia) { | 63 void TrayItemMore::SetImage(const gfx::ImageSkia& image_skia) { |
64 icon_->SetImage(image_skia); | 64 icon_->SetImage(image_skia); |
65 SchedulePaint(); | 65 SchedulePaint(); |
66 } | 66 } |
67 | 67 |
68 void TrayItemMore::SetAccessibleName(const base::string16& name) { | 68 void TrayItemMore::SetAccessibleName(const base::string16& name) { |
69 accessible_name_ = name; | 69 accessible_name_ = name; |
70 } | 70 } |
71 | 71 |
72 void TrayItemMore::ReplaceIcon(views::View* view) { | |
73 delete icon_; | |
74 icon_ = NULL; | |
75 AddChildViewAt(view, 0); | |
76 } | |
77 | |
78 bool TrayItemMore::PerformAction(const ui::Event& event) { | 72 bool TrayItemMore::PerformAction(const ui::Event& event) { |
79 if (!show_more_) | 73 if (!show_more_) |
80 return false; | 74 return false; |
81 | 75 |
82 owner()->TransitionDetailedView(); | 76 owner()->TransitionDetailedView(); |
83 return true; | 77 return true; |
84 } | 78 } |
85 | 79 |
86 void TrayItemMore::Layout() { | 80 void TrayItemMore::Layout() { |
87 // Let the box-layout do the layout first. Then move the '>' arrow to right | 81 // Let the box-layout do the layout first. Then move the '>' arrow to right |
(...skipping 18 matching lines...) Expand all Loading... |
106 } | 100 } |
107 } | 101 } |
108 | 102 |
109 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { | 103 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { |
110 ActionableView::GetAccessibleState(state); | 104 ActionableView::GetAccessibleState(state); |
111 if (!accessible_name_.empty()) | 105 if (!accessible_name_.empty()) |
112 state->name = accessible_name_; | 106 state->name = accessible_name_; |
113 } | 107 } |
114 | 108 |
115 } // namespace ash | 109 } // namespace ash |
OLD | NEW |