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

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

Issue 23112002: Fixing the gdrive sync item alignment to keep it centered. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reduced to only change the tray_image_item Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/tray_image_item.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/tray/system_tray.h"
7 #include "ash/system/tray/tray_item_view.h" 8 #include "ash/system/tray/tray_item_view.h"
8 #include "ash/system/tray/tray_utils.h" 9 #include "ash/system/tray/tray_utils.h"
9 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/image/image.h" 11 #include "ui/gfx/image/image.h"
11 #include "ui/views/controls/image_view.h" 12 #include "ui/views/controls/image_view.h"
12 #include "ui/views/layout/fill_layout.h" 13 #include "ui/views/layout/box_layout.h"
13 14
14 namespace ash { 15 namespace ash {
15 namespace internal { 16 namespace internal {
16 17
17 TrayImageItem::TrayImageItem(SystemTray* system_tray, int resource_id) 18 TrayImageItem::TrayImageItem(SystemTray* system_tray, int resource_id)
18 : SystemTrayItem(system_tray), 19 : SystemTrayItem(system_tray),
19 resource_id_(resource_id), 20 resource_id_(resource_id),
20 tray_view_(NULL) { 21 tray_view_(NULL) {
21 } 22 }
22 23
(...skipping 11 matching lines...) Expand all
34 GetImageNamed(resource_id_).ToImageSkia()); 35 GetImageNamed(resource_id_).ToImageSkia());
35 } 36 }
36 37
37 views::View* TrayImageItem::CreateTrayView(user::LoginStatus status) { 38 views::View* TrayImageItem::CreateTrayView(user::LoginStatus status) {
38 CHECK(tray_view_ == NULL); 39 CHECK(tray_view_ == NULL);
39 tray_view_ = new TrayItemView(this); 40 tray_view_ = new TrayItemView(this);
40 tray_view_->CreateImageView(); 41 tray_view_->CreateImageView();
41 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). 42 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance().
42 GetImageNamed(resource_id_).ToImageSkia()); 43 GetImageNamed(resource_id_).ToImageSkia());
43 tray_view_->SetVisible(GetInitialVisibility()); 44 tray_view_->SetVisible(GetInitialVisibility());
45 SetItemAlignment(system_tray()->shelf_alignment());
44 return tray_view_; 46 return tray_view_;
45 } 47 }
46 48
47 views::View* TrayImageItem::CreateDefaultView(user::LoginStatus status) { 49 views::View* TrayImageItem::CreateDefaultView(user::LoginStatus status) {
48 return NULL; 50 return NULL;
49 } 51 }
50 52
51 views::View* TrayImageItem::CreateDetailedView(user::LoginStatus status) { 53 views::View* TrayImageItem::CreateDetailedView(user::LoginStatus status) {
52 return NULL; 54 return NULL;
53 } 55 }
54 56
55 void TrayImageItem::UpdateAfterLoginStatusChange(user::LoginStatus status) { 57 void TrayImageItem::UpdateAfterLoginStatusChange(user::LoginStatus status) {
56 } 58 }
57 59
58 void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 60 void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
59 SetTrayImageItemBorder(tray_view_, alignment); 61 SetTrayImageItemBorder(tray_view_, alignment);
62 SetItemAlignment(alignment);
60 } 63 }
61 64
62 void TrayImageItem::DestroyTrayView() { 65 void TrayImageItem::DestroyTrayView() {
63 tray_view_ = NULL; 66 tray_view_ = NULL;
64 } 67 }
65 68
66 void TrayImageItem::DestroyDefaultView() { 69 void TrayImageItem::DestroyDefaultView() {
67 } 70 }
68 71
69 void TrayImageItem::DestroyDetailedView() { 72 void TrayImageItem::DestroyDetailedView() {
70 } 73 }
71 74
75 void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) {
76 // Center the item dependent on the orientation of the shelf.
77 views::BoxLayout::Orientation layout = views::BoxLayout::kHorizontal;
78 switch (alignment) {
79 case ash::SHELF_ALIGNMENT_BOTTOM:
80 case ash::SHELF_ALIGNMENT_TOP:
81 layout = views::BoxLayout::kHorizontal;
82 break;
83 case ash::SHELF_ALIGNMENT_LEFT:
84 case ash::SHELF_ALIGNMENT_RIGHT:
85 layout = views::BoxLayout::kVertical;
86 break;
87 }
88 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0));
89 tray_view_->Layout();
90 }
91
72 } // namespace internal 92 } // namespace internal
73 } // namespace ash 93 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_image_item.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698