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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/tray_image_item.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« 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