| 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/system/tray/tray_image_item.h" | 5 #include "ash/system/tray/tray_image_item.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/wm_shelf_util.h" | 7 #include "ash/common/shelf/wm_shelf_util.h" |
| 8 #include "ash/shelf/shelf_util.h" | 8 #include "ash/shelf/shelf_util.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/tray_item_view.h" | 10 #include "ash/system/tray/tray_item_view.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 void TrayImageItem::SetImageFromResourceId(int resource_id) { | 31 void TrayImageItem::SetImageFromResourceId(int resource_id) { |
| 32 resource_id_ = resource_id; | 32 resource_id_ = resource_id; |
| 33 if (!tray_view_) | 33 if (!tray_view_) |
| 34 return; | 34 return; |
| 35 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). | 35 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). |
| 36 GetImageNamed(resource_id_).ToImageSkia()); | 36 GetImageNamed(resource_id_).ToImageSkia()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 views::View* TrayImageItem::CreateTrayView(user::LoginStatus status) { | 39 views::View* TrayImageItem::CreateTrayView(LoginStatus status) { |
| 40 CHECK(tray_view_ == NULL); | 40 CHECK(tray_view_ == NULL); |
| 41 tray_view_ = new TrayItemView(this); | 41 tray_view_ = new TrayItemView(this); |
| 42 tray_view_->CreateImageView(); | 42 tray_view_->CreateImageView(); |
| 43 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). | 43 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). |
| 44 GetImageNamed(resource_id_).ToImageSkia()); | 44 GetImageNamed(resource_id_).ToImageSkia()); |
| 45 tray_view_->SetVisible(GetInitialVisibility()); | 45 tray_view_->SetVisible(GetInitialVisibility()); |
| 46 SetItemAlignment(system_tray()->shelf_alignment()); | 46 SetItemAlignment(system_tray()->shelf_alignment()); |
| 47 return tray_view_; | 47 return tray_view_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 views::View* TrayImageItem::CreateDefaultView(user::LoginStatus status) { | 50 views::View* TrayImageItem::CreateDefaultView(LoginStatus status) { |
| 51 return NULL; | 51 return nullptr; |
| 52 } | 52 } |
| 53 | 53 |
| 54 views::View* TrayImageItem::CreateDetailedView(user::LoginStatus status) { | 54 views::View* TrayImageItem::CreateDetailedView(LoginStatus status) { |
| 55 return NULL; | 55 return nullptr; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void TrayImageItem::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 58 void TrayImageItem::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 59 } | |
| 60 | 59 |
| 61 void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 60 void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 62 SetTrayImageItemBorder(tray_view_, alignment); | 61 SetTrayImageItemBorder(tray_view_, alignment); |
| 63 SetItemAlignment(alignment); | 62 SetItemAlignment(alignment); |
| 64 } | 63 } |
| 65 | 64 |
| 66 void TrayImageItem::DestroyTrayView() { | 65 void TrayImageItem::DestroyTrayView() { |
| 67 tray_view_ = NULL; | 66 tray_view_ = NULL; |
| 68 } | 67 } |
| 69 | 68 |
| 70 void TrayImageItem::DestroyDefaultView() { | 69 void TrayImageItem::DestroyDefaultView() { |
| 71 } | 70 } |
| 72 | 71 |
| 73 void TrayImageItem::DestroyDetailedView() { | 72 void TrayImageItem::DestroyDetailedView() { |
| 74 } | 73 } |
| 75 | 74 |
| 76 void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) { | 75 void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) { |
| 77 // Center the item dependent on the orientation of the shelf. | 76 // Center the item dependent on the orientation of the shelf. |
| 78 views::BoxLayout::Orientation layout = IsHorizontalAlignment(alignment) | 77 views::BoxLayout::Orientation layout = IsHorizontalAlignment(alignment) |
| 79 ? views::BoxLayout::kHorizontal | 78 ? views::BoxLayout::kHorizontal |
| 80 : views::BoxLayout::kVertical; | 79 : views::BoxLayout::kVertical; |
| 81 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); | 80 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); |
| 82 tray_view_->Layout(); | 81 tray_view_->Layout(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 } // namespace ash | 84 } // namespace ash |
| OLD | NEW |