Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: ash/system/tray/tray_image_item.cc

Issue 2063813002: mash: Move SystemTrayImage and TrayImageItem to //ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wmnotifier
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/system/tray/tray_image_item.h"
6
7 #include "ash/common/shelf/wm_shelf_util.h"
8 #include "ash/shelf/shelf_util.h"
9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray/tray_item_view.h"
11 #include "ash/system/tray/tray_utils.h"
12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/image/image.h"
14 #include "ui/views/controls/image_view.h"
15 #include "ui/views/layout/box_layout.h"
16
17 namespace ash {
18
19 TrayImageItem::TrayImageItem(SystemTray* system_tray, int resource_id)
20 : SystemTrayItem(system_tray),
21 resource_id_(resource_id),
22 tray_view_(NULL) {
23 }
24
25 TrayImageItem::~TrayImageItem() {}
26
27 views::View* TrayImageItem::tray_view() {
28 return tray_view_;
29 }
30
31 void TrayImageItem::SetImageFromResourceId(int resource_id) {
32 resource_id_ = resource_id;
33 if (!tray_view_)
34 return;
35 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance().
36 GetImageNamed(resource_id_).ToImageSkia());
37 }
38
39 views::View* TrayImageItem::CreateTrayView(LoginStatus status) {
40 CHECK(tray_view_ == NULL);
41 tray_view_ = new TrayItemView(this);
42 tray_view_->CreateImageView();
43 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance().
44 GetImageNamed(resource_id_).ToImageSkia());
45 tray_view_->SetVisible(GetInitialVisibility());
46 SetItemAlignment(system_tray()->shelf_alignment());
47 return tray_view_;
48 }
49
50 views::View* TrayImageItem::CreateDefaultView(LoginStatus status) {
51 return nullptr;
52 }
53
54 views::View* TrayImageItem::CreateDetailedView(LoginStatus status) {
55 return nullptr;
56 }
57
58 void TrayImageItem::UpdateAfterLoginStatusChange(LoginStatus status) {}
59
60 void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
61 SetTrayImageItemBorder(tray_view_, alignment);
62 SetItemAlignment(alignment);
63 }
64
65 void TrayImageItem::DestroyTrayView() {
66 tray_view_ = NULL;
67 }
68
69 void TrayImageItem::DestroyDefaultView() {
70 }
71
72 void TrayImageItem::DestroyDetailedView() {
73 }
74
75 void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) {
76 // Center the item dependent on the orientation of the shelf.
77 views::BoxLayout::Orientation layout = IsHorizontalAlignment(alignment)
78 ? views::BoxLayout::kHorizontal
79 : views::BoxLayout::kVertical;
80 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0));
81 tray_view_->Layout();
82 }
83
84 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698