diff options
author | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-24 20:12:13 +0000 |
---|---|---|
committer | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-24 20:12:13 +0000 |
commit | 1609ebc02a548740c83c859e54a7c1bfd4b8c3df (patch) | |
tree | 4d0d1c26b9b54fb4d8a02745a7aae4c1111c741c /ash/wm | |
parent | 81c7affb49bcad9243d115e2f21027c8624e64c7 (diff) | |
download | chromium_src-1609ebc02a548740c83c859e54a7c1bfd4b8c3df.zip chromium_src-1609ebc02a548740c83c859e54a7c1bfd4b8c3df.tar.gz chromium_src-1609ebc02a548740c83c859e54a7c1bfd4b8c3df.tar.bz2 |
The new alternate shelf requests that all tray / message bubbles / application launcher will be flush with the shelf
There is one edge case left for a rotated shelf: Messages are slightly offsetted from the system menu (if existent). Beside that everything seems to work now as expected.
BUG=259029
TEST=visual with L/R languages and with different shelf alignments
Review URL: https://chromiumcodereview.appspot.com/19771021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213500 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r-- | ash/wm/app_list_controller.cc | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index 7685993..68845b0 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -38,6 +38,16 @@ const int kAnimationOffset = 8; // The maximum shift in pixels when over-scroll happens. const int kMaxOverScrollShift = 48; +// The alternate shelf style adjusts the bubble to be flush with the shelf +// when there is no bubble-tip. This is the tip height which needs to be +// offsetted. +const int kArrowTipHeight = 10; + +// The minimal anchor position offset to make sure that the bubble is still on +// the screen with 8 pixels spacing on the left / right. This constant is a +// result of minimal bubble arrow sizes and offsets. +const int kMinimalAnchorPositionOffset = 60; + ui::Layer* GetLayer(views::Widget* widget) { return widget->GetNativeView()->layer(); } @@ -77,6 +87,44 @@ gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect, views::Widget* widget) { return offseted; } +// Using |button_bounds|, determine the anchor so that the bubble gets shown +// above the shelf (used for the alternate shelf theme). +gfx::Point GetAdjustAnchorPositionToShelf( + const gfx::Rect& button_bounds, views::Widget* widget) { + DCHECK(Shell::HasInstance()); + ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( + widget->GetNativeView()->GetRootWindow()); + gfx::Point anchor(button_bounds.CenterPoint()); + switch (shelf_alignment) { + case SHELF_ALIGNMENT_TOP: + case SHELF_ALIGNMENT_BOTTOM: + { + if (base::i18n::IsRTL()) { + int screen_width = widget->GetWorkAreaBoundsInScreen().width(); + anchor.set_x(std::min(screen_width - kMinimalAnchorPositionOffset, + anchor.x())); + } else { + anchor.set_x(std::max(kMinimalAnchorPositionOffset, anchor.x())); + } + int offset = button_bounds.height() / 2 - kArrowTipHeight; + if (shelf_alignment == SHELF_ALIGNMENT_TOP) + offset = -offset; + anchor.set_y(anchor.y() - offset); + } + break; + case SHELF_ALIGNMENT_LEFT: + anchor.set_x(button_bounds.right() - kArrowTipHeight); + anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y())); + break; + case SHELF_ALIGNMENT_RIGHT: + anchor.set_x(button_bounds.x() + kArrowTipHeight); + anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y())); + break; + } + + return anchor; +} + } // namespace //////////////////////////////////////////////////////////////////////////////// @@ -121,22 +169,19 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); aura::Window* container = GetRootWindowController(window->GetRootWindow())-> GetContainer(kShellWindowId_AppListContainer); - // TODO(harrym): find a better solution for this. if (ash::switches::UseAlternateShelfLayout()) { gfx::Rect applist_button_bounds = Launcher::ForWindow(container)-> GetAppListButtonView()->GetBoundsInScreen(); - gfx::Point anchor = applist_button_bounds.origin(); - if (anchor.x() == 0) - anchor.set_x(applist_button_bounds.right()); - if (anchor.y() == 0) - anchor.set_y(applist_button_bounds.bottom()); view->InitAsBubble( container, pagination_model_.get(), NULL, - anchor, + GetAdjustAnchorPositionToShelf(applist_button_bounds, + Launcher::ForWindow(container)->GetAppListButtonView()-> + GetWidget()), GetBubbleArrow(container), true /* border_accepts_events */); + view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); } else { view->InitAsBubble( container, @@ -146,8 +191,6 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { GetBubbleArrow(container), true /* border_accepts_events */); } - if (ash::switches::UseAlternateShelfLayout()) - view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); SetView(view); } } |