Index: ash/system/tray/system_tray.cc |
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc |
index 99113877940e6d3bc69b85922abe487b6f55ce1f..7334a6071927cd6546346c17b2b505da53288d9e 100644 |
--- a/ash/system/tray/system_tray.cc |
+++ b/ash/system/tray/system_tray.cc |
@@ -168,6 +168,7 @@ SystemTray::SystemTray() |
widget_(NULL), |
background_(new internal::SystemTrayBackground), |
should_show_launcher_(false), |
+ shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |
ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this, |
0, kTrayBackgroundAlpha)), |
ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this, |
@@ -179,7 +180,8 @@ SystemTray::SystemTray() |
tray_container_->set_border( |
views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
set_border(views::Border::CreateEmptyBorder(0, 0, |
- kPaddingFromBottomOfScreen, kPaddingFromRightEdgeOfScreen)); |
+ kPaddingFromBottomOfScreenBottomAlignment, |
+ kPaddingFromRightEdgeOfScreenBottomAlignment)); |
set_notify_enter_exit_on_child(true); |
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
AddChildView(tray_container_); |
@@ -478,6 +480,22 @@ void SystemTray::UpdateNotificationAnchor() { |
notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
} |
+void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { |
+ if (alignment == shelf_alignment_) |
+ return; |
+ |
+ if (alignment == SHELF_ALIGNMENT_BOTTOM){ |
+ tray_container_->SetLayoutManager(new views::BoxLayout( |
+ views::BoxLayout::kHorizontal, 0, 0, 0)); |
+ } else if (alignment == SHELF_ALIGNMENT_LEFT || |
sadrul
2012/05/17 23:30:29
two many spaces here
jennyz
2012/05/18 00:00:42
Done.
|
+ alignment == SHELF_ALIGNMENT_RIGHT) { |
+ if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM) |
+ tray_container_->SetLayoutManager(new views::BoxLayout( |
+ views::BoxLayout::kVertical, 0, 0, 0)); |
+ } |
sadrul
2012/05/17 23:30:29
I think this could just be:
tray_container_->Set
jennyz
2012/05/18 00:00:42
Done. I was trying to save a little for switching
|
+ shelf_alignment_ = alignment; |
+} |
+ |
bool SystemTray::PerformAction(const views::Event& event) { |
// If we're already showing the default view, hide it; otherwise, show it |
// (and hide any popup that's currently shown). |
@@ -489,8 +507,11 @@ bool SystemTray::PerformAction(const views::Event& event) { |
if (event.IsMouseEvent() || event.IsTouchEvent()) { |
const views::LocatedEvent& located_event = |
static_cast<const views::LocatedEvent&>(event); |
- arrow_offset = base::i18n::IsRTL() ? |
- located_event.x() : tray_container_->width() - located_event.x(); |
+ if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) |
+ arrow_offset = base::i18n::IsRTL() ? |
+ located_event.x() : tray_container_->width() - located_event.x(); |
+ else |
+ arrow_offset = tray_container_->height() - located_event.y(); |
} |
ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset); |
} |