Commit 0ab08e54 authored by jennyz@google.com's avatar jennyz@google.com

Add left/right launcher layout support for uber tray. The status area and uber...

Add left/right launcher layout support for uber tray. The status area and uber tray bubble will adjust for left/right launcher layout.

BUG=127577
TEST=Status area and uber tray bubble UI looks right for left/right launcher layout.

Review URL: https://chromiumcodereview.appspot.com/10384217

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137980 0039d316-1c4b-4281-b951-d872f2087c98
parent ad4ccccb
...@@ -94,6 +94,11 @@ class SystemTrayContainer : public views::View { ...@@ -94,6 +94,11 @@ class SystemTrayContainer : public views::View {
SystemTrayContainer() {} SystemTrayContainer() {}
virtual ~SystemTrayContainer() {} virtual ~SystemTrayContainer() {}
void SetLayoutManager(views::LayoutManager* layout_manager) {
views::View::SetLayoutManager(layout_manager);
UpdateWidgetSize();
}
private: private:
void UpdateWidgetSize() { void UpdateWidgetSize() {
if (GetWidget()) if (GetWidget())
...@@ -171,6 +176,7 @@ SystemTray::SystemTray() ...@@ -171,6 +176,7 @@ SystemTray::SystemTray()
widget_(NULL), widget_(NULL),
background_(new internal::SystemTrayBackground), background_(new internal::SystemTrayBackground),
should_show_launcher_(false), should_show_launcher_(false),
shelf_alignment_(SHELF_ALIGNMENT_BOTTOM),
ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this, ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this,
0, kTrayBackgroundAlpha)), 0, kTrayBackgroundAlpha)),
ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this, ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this,
...@@ -182,7 +188,8 @@ SystemTray::SystemTray() ...@@ -182,7 +188,8 @@ SystemTray::SystemTray()
tray_container_->set_border( tray_container_->set_border(
views::Border::CreateEmptyBorder(1, 1, 1, 1)); views::Border::CreateEmptyBorder(1, 1, 1, 1));
set_border(views::Border::CreateEmptyBorder(0, 0, set_border(views::Border::CreateEmptyBorder(0, 0,
kPaddingFromBottomOfScreen, kPaddingFromRightEdgeOfScreen)); kPaddingFromBottomOfScreenBottomAlignment,
kPaddingFromRightEdgeOfScreenBottomAlignment));
set_notify_enter_exit_on_child(true); set_notify_enter_exit_on_child(true);
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
AddChildView(tray_container_); AddChildView(tray_container_);
...@@ -507,6 +514,17 @@ void SystemTray::UpdateNotificationAnchor() { ...@@ -507,6 +514,17 @@ void SystemTray::UpdateNotificationAnchor() {
notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
} }
void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
if (alignment == shelf_alignment_)
return;
tray_container_->SetLayoutManager(new views::BoxLayout(
alignment == SHELF_ALIGNMENT_BOTTOM ?
views::BoxLayout::kHorizontal : views::BoxLayout::kVertical,
0, 0, 0));
shelf_alignment_ = alignment;
}
bool SystemTray::PerformAction(const views::Event& event) { bool SystemTray::PerformAction(const views::Event& event) {
// If we're already showing the default view, hide it; otherwise, show it // If we're already showing the default view, hide it; otherwise, show it
// (and hide any popup that's currently shown). // (and hide any popup that's currently shown).
...@@ -518,8 +536,11 @@ bool SystemTray::PerformAction(const views::Event& event) { ...@@ -518,8 +536,11 @@ bool SystemTray::PerformAction(const views::Event& event) {
if (event.IsMouseEvent() || event.IsTouchEvent()) { if (event.IsMouseEvent() || event.IsTouchEvent()) {
const views::LocatedEvent& located_event = const views::LocatedEvent& located_event =
static_cast<const views::LocatedEvent&>(event); static_cast<const views::LocatedEvent&>(event);
arrow_offset = base::i18n::IsRTL() ? if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM)
located_event.x() : tray_container_->width() - located_event.x(); 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); ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset);
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/tray/tray_views.h" #include "ash/system/tray/tray_views.h"
#include "ash/system/user/login_status.h" #include "ash/system/user/login_status.h"
#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -40,6 +41,7 @@ class SystemTrayItem; ...@@ -40,6 +41,7 @@ class SystemTrayItem;
namespace internal { namespace internal {
class SystemTrayBackground; class SystemTrayBackground;
class SystemTrayBubble; class SystemTrayBubble;
class SystemTrayContainer;
class SystemTrayLayerAnimationObserver; class SystemTrayLayerAnimationObserver;
} }
...@@ -151,6 +153,9 @@ class ASH_EXPORT SystemTray : public internal::ActionableView, ...@@ -151,6 +153,9 @@ class ASH_EXPORT SystemTray : public internal::ActionableView,
// Returns true if the bubble exists. // Returns true if the bubble exists.
bool CloseBubbleForTest() const; bool CloseBubbleForTest() const;
void SetShelfAlignment(ShelfAlignment alignment);
ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
private: private:
friend class internal::SystemTrayLayerAnimationObserver; friend class internal::SystemTrayLayerAnimationObserver;
friend class internal::SystemTrayBubble; friend class internal::SystemTrayBubble;
...@@ -205,7 +210,7 @@ class ASH_EXPORT SystemTray : public internal::ActionableView, ...@@ -205,7 +210,7 @@ class ASH_EXPORT SystemTray : public internal::ActionableView,
std::vector<SystemTrayItem*> notification_items_; std::vector<SystemTrayItem*> notification_items_;
// The container for all the tray views of the items. // The container for all the tray views of the items.
views::View* tray_container_; internal::SystemTrayContainer* tray_container_;
// Mappings of system tray item and it's view in the tray. // Mappings of system tray item and it's view in the tray.
std::map<SystemTrayItem*, views::View*> tray_item_map_; std::map<SystemTrayItem*, views::View*> tray_item_map_;
...@@ -240,6 +245,9 @@ class ASH_EXPORT SystemTray : public internal::ActionableView, ...@@ -240,6 +245,9 @@ class ASH_EXPORT SystemTray : public internal::ActionableView,
// See description agove getter. // See description agove getter.
bool should_show_launcher_; bool should_show_launcher_;
// Shelf alignment.
ShelfAlignment shelf_alignment_;
internal::BackgroundAnimator hide_background_animator_; internal::BackgroundAnimator hide_background_animator_;
internal::BackgroundAnimator hover_background_animator_; internal::BackgroundAnimator hover_background_animator_;
scoped_ptr<internal::SystemTrayLayerAnimationObserver> scoped_ptr<internal::SystemTrayLayerAnimationObserver>
......
This diff is collapsed.
...@@ -27,6 +27,7 @@ class SystemTrayBubble; ...@@ -27,6 +27,7 @@ class SystemTrayBubble;
class SystemTrayBubbleView : public views::BubbleDelegateView { class SystemTrayBubbleView : public views::BubbleDelegateView {
public: public:
SystemTrayBubbleView(views::View* anchor, SystemTrayBubbleView(views::View* anchor,
views::BubbleBorder::ArrowLocation arrow_location,
SystemTrayBubble* host, SystemTrayBubble* host,
bool can_activate); bool can_activate);
virtual ~SystemTrayBubbleView(); virtual ~SystemTrayBubbleView();
......
...@@ -8,8 +8,11 @@ ...@@ -8,8 +8,11 @@
namespace ash { namespace ash {
const int kPaddingFromRightEdgeOfScreen = 15; const int kPaddingFromRightEdgeOfScreenBottomAlignment = 15;
const int kPaddingFromBottomOfScreen = 10; const int kPaddingFromBottomOfScreenBottomAlignment = 10;
const int kPaddingFromLeftEdgeOfScreenLeftAlignment = 13;
const int kPaddingFromRightEdgeOfScreenRightAlignment = 2;
const int kPaddingFromBottomOfScreenVerticalAlignment = 9;
const int kTrayPopupAutoCloseDelayInSeconds = 2; const int kTrayPopupAutoCloseDelayInSeconds = 2;
const int kTrayPopupAutoCloseDelayForTextInSeconds = 5; const int kTrayPopupAutoCloseDelayForTextInSeconds = 5;
......
...@@ -10,8 +10,11 @@ typedef unsigned int SkColor; ...@@ -10,8 +10,11 @@ typedef unsigned int SkColor;
namespace ash { namespace ash {
extern const int kPaddingFromRightEdgeOfScreen; extern const int kPaddingFromRightEdgeOfScreenBottomAlignment;
extern const int kPaddingFromBottomOfScreen; extern const int kPaddingFromBottomOfScreenBottomAlignment;
extern const int kPaddingFromLeftEdgeOfScreenLeftAlignment;
extern const int kPaddingFromRightEdgeOfScreenRightAlignment;
extern const int kPaddingFromBottomOfScreenVerticalAlignment;
extern const int kTrayPopupAutoCloseDelayInSeconds; extern const int kTrayPopupAutoCloseDelayInSeconds;
extern const int kTrayPopupAutoCloseDelayForTextInSeconds; extern const int kTrayPopupAutoCloseDelayForTextInSeconds;
......
...@@ -193,6 +193,8 @@ void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { ...@@ -193,6 +193,8 @@ void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) {
alignment_ = alignment; alignment_ = alignment;
if (launcher_) if (launcher_)
launcher_->SetAlignment(alignment); launcher_->SetAlignment(alignment);
if (Shell::GetInstance()->tray())
Shell::GetInstance()->tray()->SetShelfAlignment(alignment);
LayoutShelf(); LayoutShelf();
} }
...@@ -395,12 +397,10 @@ void ShelfLayoutManager::GetShelfSize(int* width, int* height) { ...@@ -395,12 +397,10 @@ void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
gfx::Rect status_bounds(status_->GetWindowScreenBounds()); gfx::Rect status_bounds(status_->GetWindowScreenBounds());
gfx::Size launcher_size = launcher_ ? gfx::Size launcher_size = launcher_ ?
launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size();
if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { if (alignment_ == SHELF_ALIGNMENT_BOTTOM)
*height = std::max(launcher_size.height(), status_bounds.height()); *height = std::max(launcher_size.height(), status_bounds.height());
} else { else
// TODO: include status when supports alignment. *width = std::max(launcher_size.width(), status_bounds.width());
*width = launcher_size.width();
}
} }
void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -507,6 +508,11 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) { ...@@ -507,6 +508,11 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
EXPECT_GE( EXPECT_GE(
launcher_bounds.width(), launcher_bounds.width(),
shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
EXPECT_EQ(SHELF_ALIGNMENT_LEFT,
Shell::GetInstance()->tray()->shelf_alignment());
gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds());
EXPECT_GE(status_bounds.width(),
shelf->status()->GetContentsView()->GetPreferredSize().width());
EXPECT_EQ(shelf->GetIdealBounds().width(), EXPECT_EQ(shelf->GetIdealBounds().width(),
monitor.GetWorkAreaInsets().left()); monitor.GetWorkAreaInsets().left());
EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
...@@ -516,7 +522,6 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) { ...@@ -516,7 +522,6 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y()); EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y());
EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height()); EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height());
shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds(); launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds();
monitor = manager->GetMonitorNearestWindow(Shell::GetRootWindow()); monitor = manager->GetMonitorNearestWindow(Shell::GetRootWindow());
...@@ -526,6 +531,11 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) { ...@@ -526,6 +531,11 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
EXPECT_GE( EXPECT_GE(
launcher_bounds.width(), launcher_bounds.width(),
shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
EXPECT_EQ(SHELF_ALIGNMENT_RIGHT,
Shell::GetInstance()->tray()->shelf_alignment());
status_bounds = gfx::Rect(shelf->status()->GetWindowScreenBounds());
EXPECT_GE(status_bounds.width(),
shelf->status()->GetContentsView()->GetPreferredSize().width());
EXPECT_EQ(shelf->GetIdealBounds().width(), EXPECT_EQ(shelf->GetIdealBounds().width(),
monitor.GetWorkAreaInsets().right()); monitor.GetWorkAreaInsets().right());
EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
......
...@@ -56,7 +56,7 @@ void StatusAreaLayoutManager::SetChildBounds( ...@@ -56,7 +56,7 @@ void StatusAreaLayoutManager::SetChildBounds(
// If the size matches, no need to do anything. We don't check the location as // If the size matches, no need to do anything. We don't check the location as
// that is managed by the shelf. // that is managed by the shelf.
if (requested_bounds.size() == child->bounds().size()) if (requested_bounds == child->bounds())
return; return;
SetChildBoundsDirect(child, requested_bounds); SetChildBoundsDirect(child, requested_bounds);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment