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 {
SystemTrayContainer() {}
virtual ~SystemTrayContainer() {}
void SetLayoutManager(views::LayoutManager* layout_manager) {
views::View::SetLayoutManager(layout_manager);
UpdateWidgetSize();
}
private:
void UpdateWidgetSize() {
if (GetWidget())
......@@ -171,6 +176,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,
......@@ -182,7 +188,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_);
......@@ -507,6 +514,17 @@ void SystemTray::UpdateNotificationAnchor() {
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) {
// If we're already showing the default view, hide it; otherwise, show it
// (and hide any popup that's currently shown).
......@@ -518,8 +536,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);
}
......
......@@ -10,6 +10,7 @@
#include "ash/ash_export.h"
#include "ash/system/tray/tray_views.h"
#include "ash/system/user/login_status.h"
#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
......@@ -40,6 +41,7 @@ class SystemTrayItem;
namespace internal {
class SystemTrayBackground;
class SystemTrayBubble;
class SystemTrayContainer;
class SystemTrayLayerAnimationObserver;
}
......@@ -151,6 +153,9 @@ class ASH_EXPORT SystemTray : public internal::ActionableView,
// Returns true if the bubble exists.
bool CloseBubbleForTest() const;
void SetShelfAlignment(ShelfAlignment alignment);
ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
private:
friend class internal::SystemTrayLayerAnimationObserver;
friend class internal::SystemTrayBubble;
......@@ -205,7 +210,7 @@ class ASH_EXPORT SystemTray : public internal::ActionableView,
std::vector<SystemTrayItem*> notification_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.
std::map<SystemTrayItem*, views::View*> tray_item_map_;
......@@ -240,6 +245,9 @@ class ASH_EXPORT SystemTray : public internal::ActionableView,
// See description agove getter.
bool should_show_launcher_;
// Shelf alignment.
ShelfAlignment shelf_alignment_;
internal::BackgroundAnimator hide_background_animator_;
internal::BackgroundAnimator hover_background_animator_;
scoped_ptr<internal::SystemTrayLayerAnimationObserver>
......
This diff is collapsed.
......@@ -27,6 +27,7 @@ class SystemTrayBubble;
class SystemTrayBubbleView : public views::BubbleDelegateView {
public:
SystemTrayBubbleView(views::View* anchor,
views::BubbleBorder::ArrowLocation arrow_location,
SystemTrayBubble* host,
bool can_activate);
virtual ~SystemTrayBubbleView();
......
......@@ -8,8 +8,11 @@
namespace ash {
const int kPaddingFromRightEdgeOfScreen = 15;
const int kPaddingFromBottomOfScreen = 10;
const int kPaddingFromRightEdgeOfScreenBottomAlignment = 15;
const int kPaddingFromBottomOfScreenBottomAlignment = 10;
const int kPaddingFromLeftEdgeOfScreenLeftAlignment = 13;
const int kPaddingFromRightEdgeOfScreenRightAlignment = 2;
const int kPaddingFromBottomOfScreenVerticalAlignment = 9;
const int kTrayPopupAutoCloseDelayInSeconds = 2;
const int kTrayPopupAutoCloseDelayForTextInSeconds = 5;
......
......@@ -10,8 +10,11 @@ typedef unsigned int SkColor;
namespace ash {
extern const int kPaddingFromRightEdgeOfScreen;
extern const int kPaddingFromBottomOfScreen;
extern const int kPaddingFromRightEdgeOfScreenBottomAlignment;
extern const int kPaddingFromBottomOfScreenBottomAlignment;
extern const int kPaddingFromLeftEdgeOfScreenLeftAlignment;
extern const int kPaddingFromRightEdgeOfScreenRightAlignment;
extern const int kPaddingFromBottomOfScreenVerticalAlignment;
extern const int kTrayPopupAutoCloseDelayInSeconds;
extern const int kTrayPopupAutoCloseDelayForTextInSeconds;
......
......@@ -193,6 +193,8 @@ void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) {
alignment_ = alignment;
if (launcher_)
launcher_->SetAlignment(alignment);
if (Shell::GetInstance()->tray())
Shell::GetInstance()->tray()->SetShelfAlignment(alignment);
LayoutShelf();
}
......@@ -395,12 +397,10 @@ void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
gfx::Rect status_bounds(status_->GetWindowScreenBounds());
gfx::Size launcher_size = launcher_ ?
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());
} else {
// TODO: include status when supports alignment.
*width = launcher_size.width();
}
else
*width = std::max(launcher_size.width(), status_bounds.width());
}
void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset,
......
......@@ -10,6 +10,7 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray.h"
#include "ash/test/ash_test_base.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
......@@ -507,6 +508,11 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
EXPECT_GE(
launcher_bounds.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(),
monitor.GetWorkAreaInsets().left());
EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
......@@ -516,7 +522,6 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y());
EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height());
shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds();
monitor = manager->GetMonitorNearestWindow(Shell::GetRootWindow());
......@@ -526,6 +531,11 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
EXPECT_GE(
launcher_bounds.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(),
monitor.GetWorkAreaInsets().right());
EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
......
......@@ -56,7 +56,7 @@ void StatusAreaLayoutManager::SetChildBounds(
// If the size matches, no need to do anything. We don't check the location as
// that is managed by the shelf.
if (requested_bounds.size() == child->bounds().size())
if (requested_bounds == child->bounds())
return;
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