diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-09 03:06:39 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-09 03:06:39 +0000 |
commit | ddc34494cda418b16651afbf2f1d52773611c0d3 (patch) | |
tree | 81132bdd5345a40b953fffe48d552c1b63687d13 /ash | |
parent | 57a04b7939468de6b16756ffc01bf3439bf4ed95 (diff) | |
download | chromium_src-ddc34494cda418b16651afbf2f1d52773611c0d3.zip chromium_src-ddc34494cda418b16651afbf2f1d52773611c0d3.tar.gz chromium_src-ddc34494cda418b16651afbf2f1d52773611c0d3.tar.bz2 |
ash: Make sure the uber-tray extends to the right and bottom edges of the screen.
This makes the bottom-right corner a click target for the tray. want.
BUG=110130
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9633008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125782 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/system/tray/system_tray.cc | 31 | ||||
-rw-r--r-- | ash/system/tray/system_tray.h | 3 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.cc | 7 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager_unittest.cc | 2 |
4 files changed, 28 insertions, 15 deletions
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 3d98d24..667f3c8 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -31,6 +31,9 @@ namespace ash { namespace { +const int kPaddingFromRightEdgeOfScreen = 10; +const int kPaddingFromBottomOfScreen = 10; + const int kAnimationDurationForPopupMS = 200; const int kArrowHeight = 10; @@ -185,9 +188,10 @@ namespace internal { class SystemTrayBubble : public views::BubbleDelegateView { public: SystemTrayBubble(ash::SystemTray* tray, + views::View* anchor, std::vector<ash::SystemTrayItem*>& items, bool detailed) - : views::BubbleDelegateView(tray, views::BubbleBorder::BOTTOM_RIGHT), + : views::BubbleDelegateView(anchor, views::BubbleBorder::BOTTOM_RIGHT), tray_(tray), items_(items), detailed_(detailed), @@ -272,10 +276,15 @@ SystemTray::SystemTray() : items_(), bubble_(NULL), popup_(NULL) { - SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, - 5, 0, 3)); - set_background(new SystemTrayBackground); + container_ = new views::View; + container_->SetLayoutManager(new views::BoxLayout( + views::BoxLayout::kHorizontal, 5, 0, 3)); + container_->set_background(new SystemTrayBackground); + set_border(views::Border::CreateEmptyBorder(0, 0, + kPaddingFromBottomOfScreen, kPaddingFromRightEdgeOfScreen)); set_notify_enter_exit_on_child(true); + SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); + AddChildView(container_); } SystemTray::~SystemTray() { @@ -294,7 +303,7 @@ void SystemTray::AddTrayItem(SystemTrayItem* item) { SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); if (tray_item) { - AddChildViewAt(tray_item, 0); + container_->AddChildViewAt(tray_item, 0); PreferredSizeChanged(); } } @@ -324,14 +333,14 @@ void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { ++it) { (*it)->DestroyTrayView(); } - RemoveAllChildViews(true); + container_->RemoveAllChildViews(true); for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); it != items_.end(); ++it) { views::View* view = (*it)->CreateTrayView(login_status); if (view) - AddChildViewAt(view, 0); + container_->AddChildViewAt(view, 0); } PreferredSizeChanged(); } @@ -339,7 +348,7 @@ void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) { CHECK(!popup_); CHECK(!bubble_); - bubble_ = new internal::SystemTrayBubble(this, items, detailed); + bubble_ = new internal::SystemTrayBubble(this, container_, items, detailed); popup_ = views::BubbleDelegateView::CreateBubble(bubble_); bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); popup_->non_client_view()->frame_view()->set_background(NULL); @@ -367,12 +376,14 @@ bool SystemTray::OnMousePressed(const views::MouseEvent& event) { } void SystemTray::OnMouseEntered(const views::MouseEvent& event) { - static_cast<SystemTrayBackground*>(background())->set_hovering(true); + static_cast<SystemTrayBackground*>(container_->background())-> + set_hovering(true); SchedulePaint(); } void SystemTray::OnMouseExited(const views::MouseEvent& event) { - static_cast<SystemTrayBackground*>(background())->set_hovering(false); + static_cast<SystemTrayBackground*>(container_->background())-> + set_hovering(false); SchedulePaint(); } diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h index 9aac138..bc4b400 100644 --- a/ash/system/tray/system_tray.h +++ b/ash/system/tray/system_tray.h @@ -56,6 +56,9 @@ class ASH_EXPORT SystemTray : public views::View, std::vector<SystemTrayItem*> items_; + // The container for all the tray views of the items. + views::View* container_; + // The popup widget and the delegate. internal::SystemTrayBubble* bubble_; views::Widget* popup_; diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 322f184..6b37e3f 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -20,8 +20,6 @@ namespace internal { namespace { -const int kSystemTrayPadding = 10; - ui::Layer* GetLayer(views::Widget* widget) { return widget->GetNativeView()->layer(); } @@ -135,9 +133,10 @@ void ShelfLayoutManager::CalculateTargetBounds(bool visible, const gfx::Rect& available_bounds(Shell::GetRootWindow()->bounds()); int y = available_bounds.bottom() - (visible ? max_height_ : 0); gfx::Rect status_bounds(status_->GetWindowScreenBounds()); + // The status widget should extend to the bottom and right edges. target_bounds->status_bounds = gfx::Rect( - available_bounds.right() - status_bounds.width() - kSystemTrayPadding, - y + (max_height_ - status_bounds.height()) / 2, + available_bounds.right() - status_bounds.width(), + y + max_height_ - status_bounds.height(), status_bounds.width(), status_bounds.height()); gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds()); target_bounds->launcher_bounds = gfx::Rect( diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index 8333903..8a83cb0 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -86,7 +86,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { bottom + (shelf->max_height() - launcher_bounds.height()) / 2); gfx::Rect status_bounds(shelf->status()->GetNativeView()->bounds()); EXPECT_EQ(status_bounds.y(), - bottom + (shelf->max_height() - status_bounds.height()) / 2); + bottom + shelf->max_height() - status_bounds.height()); } // Makes sure LayoutShelf invoked while animating cleans things up. |