Chromium Code Reviews| 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_image_item.h" | 5 #include "ash/common/system/tray/tray_image_item.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/shelf/wm_shelf_util.h" | 8 #include "ash/common/shelf/wm_shelf_util.h" |
| 9 #include "ash/common/system/tray/system_tray.h" | 9 #include "ash/common/system/tray/system_tray.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 views::View* TrayImageItem::CreateDetailedView(LoginStatus status) { | 84 views::View* TrayImageItem::CreateDetailedView(LoginStatus status) { |
| 85 return nullptr; | 85 return nullptr; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void TrayImageItem::UpdateAfterLoginStatusChange(LoginStatus status) {} | 88 void TrayImageItem::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 89 | 89 |
| 90 void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 90 void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 91 SetTrayImageItemBorder(tray_view_, alignment); | 91 SetTrayImageItemBorder(tray_view_, alignment); |
| 92 SetItemAlignment(alignment); | |
| 93 } | 92 } |
| 94 | 93 |
| 95 void TrayImageItem::DestroyTrayView() { | 94 void TrayImageItem::DestroyTrayView() { |
| 96 tray_view_ = nullptr; | 95 tray_view_ = nullptr; |
| 97 } | 96 } |
| 98 | 97 |
| 99 void TrayImageItem::DestroyDefaultView() {} | 98 void TrayImageItem::DestroyDefaultView() {} |
| 100 | 99 |
| 101 void TrayImageItem::DestroyDetailedView() {} | 100 void TrayImageItem::DestroyDetailedView() {} |
| 102 | 101 |
| 103 void TrayImageItem::SetIconColor(SkColor color) { | 102 void TrayImageItem::SetIconColor(SkColor color) { |
| 104 icon_color_ = color; | 103 icon_color_ = color; |
| 105 UpdateImageOnImageView(); | 104 UpdateImageOnImageView(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 void TrayImageItem::SetImageFromResourceId(int resource_id) { | 107 void TrayImageItem::SetImageFromResourceId(int resource_id) { |
| 109 resource_id_ = resource_id; | 108 resource_id_ = resource_id; |
| 110 UpdateImageOnImageView(); | 109 UpdateImageOnImageView(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) { | |
| 114 // Center the item dependent on the orientation of the shelf. | |
| 115 views::BoxLayout::Orientation layout = IsHorizontalAlignment(alignment) | |
| 116 ? views::BoxLayout::kHorizontal | |
|
Evan Stade
2016/10/27 19:05:30
use the TrayItemView's fill layout. ImageView alre
tdanderson
2016/10/27 19:28:00
Acknowledged.
| |
| 117 : views::BoxLayout::kVertical; | |
| 118 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); | |
| 119 tray_view_->Layout(); | |
| 120 } | |
| 121 | |
| 122 void TrayImageItem::UpdateImageOnImageView() { | 112 void TrayImageItem::UpdateImageOnImageView() { |
| 123 if (!tray_view_) | 113 if (!tray_view_) |
| 124 return; | 114 return; |
| 125 | 115 |
| 126 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { | 116 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
| 127 tray_view_->image_view()->SetImage(gfx::CreateVectorIcon( | 117 tray_view_->image_view()->SetImage(gfx::CreateVectorIcon( |
| 128 ResourceIdToVectorIcon(resource_id_), kTrayIconSize, icon_color_)); | 118 ResourceIdToVectorIcon(resource_id_), kTrayIconSize, icon_color_)); |
| 129 } else { | 119 } else { |
| 130 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance() | 120 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance() |
| 131 .GetImageNamed(resource_id_) | 121 .GetImageNamed(resource_id_) |
| 132 .ToImageSkia()); | 122 .ToImageSkia()); |
| 133 } | 123 } |
| 134 } | 124 } |
| 135 | 125 |
| 136 } // namespace ash | 126 } // namespace ash |
| OLD | NEW |