Index: ash/system/tray/tray_image_item.cc |
diff --git a/ash/system/tray/tray_image_item.cc b/ash/system/tray/tray_image_item.cc |
index d4ff9040adea7b678496b4560de274cd43f4a5f9..7c5e216c9428dbc68190657300cf87cbbe53fc79 100644 |
--- a/ash/system/tray/tray_image_item.cc |
+++ b/ash/system/tray/tray_image_item.cc |
@@ -4,12 +4,13 @@ |
#include "ash/system/tray/tray_image_item.h" |
+#include "ash/system/tray/system_tray.h" |
#include "ash/system/tray/tray_item_view.h" |
#include "ash/system/tray/tray_utils.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/image/image.h" |
#include "ui/views/controls/image_view.h" |
-#include "ui/views/layout/fill_layout.h" |
+#include "ui/views/layout/box_layout.h" |
namespace ash { |
namespace internal { |
@@ -41,6 +42,7 @@ views::View* TrayImageItem::CreateTrayView(user::LoginStatus status) { |
tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). |
GetImageNamed(resource_id_).ToImageSkia()); |
tray_view_->SetVisible(GetInitialVisibility()); |
+ SetItemAlignment(system_tray()->shelf_alignment()); |
return tray_view_; |
} |
@@ -57,6 +59,7 @@ void TrayImageItem::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
SetTrayImageItemBorder(tray_view_, alignment); |
+ SetItemAlignment(alignment); |
} |
void TrayImageItem::DestroyTrayView() { |
@@ -69,5 +72,22 @@ void TrayImageItem::DestroyDefaultView() { |
void TrayImageItem::DestroyDetailedView() { |
} |
+void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) { |
+ // Center the item dependent on the orientation of the shelf. |
+ views::BoxLayout::Orientation layout = views::BoxLayout::kHorizontal; |
+ switch (alignment) { |
+ case ash::SHELF_ALIGNMENT_BOTTOM: |
+ case ash::SHELF_ALIGNMENT_TOP: |
+ layout = views::BoxLayout::kHorizontal; |
+ break; |
+ case ash::SHELF_ALIGNMENT_LEFT: |
+ case ash::SHELF_ALIGNMENT_RIGHT: |
+ layout = views::BoxLayout::kVertical; |
+ break; |
+ } |
+ tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); |
+ tray_view_->Layout(); |
+} |
+ |
} // namespace internal |
} // namespace ash |