diff options
author | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 02:43:06 +0000 |
---|---|---|
committer | skuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 02:43:06 +0000 |
commit | 754b1c4b3c8fca1834b1833a78c4dd22542febc6 (patch) | |
tree | 4a4e4516f3554f373fbe9b5a3d6164afb4816e2a /ash/wm/app_list_controller.cc | |
parent | 60902e70a808b6cededa6ad1e5b060eb454800eb (diff) | |
download | chromium_src-754b1c4b3c8fca1834b1833a78c4dd22542febc6.zip chromium_src-754b1c4b3c8fca1834b1833a78c4dd22542febc6.tar.gz chromium_src-754b1c4b3c8fca1834b1833a78c4dd22542febc6.tar.bz2 |
Fixing the dynamic positioning (move with anchor) for the app launcher
The problem was that the positioning was done before it was shown and the move_with_anchor didn't work since there was no anchor. Changed it now to use an anchor offset.
BUG=284780
TEST=unittest (partial), visually [(RTL and LTR) x (left, right, bottom aligned) x (always visible, sliding into view, hidden)]
Review URL: https://chromiumcodereview.appspot.com/23622020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/app_list_controller.cc')
-rw-r--r-- | ash/wm/app_list_controller.cc | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index b142288..f05cdfc 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -38,11 +38,6 @@ 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. @@ -87,9 +82,9 @@ 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( +// Using |button_bounds|, determine the anchor offset so that the bubble gets +// shown above the shelf (used for the alternate shelf theme). +gfx::Vector2d GetAnchorPositionOffsetToShelf( const gfx::Rect& button_bounds, views::Widget* widget) { DCHECK(Shell::HasInstance()); ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( @@ -98,31 +93,24 @@ gfx::Point GetAdjustAnchorPositionToShelf( 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); + if (base::i18n::IsRTL()) { + int screen_width = widget->GetWorkAreaBoundsInScreen().width(); + return gfx::Vector2d( + std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), + 0), 0); } - break; + return gfx::Vector2d( + std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0); case SHELF_ALIGNMENT_LEFT: - anchor.set_x(button_bounds.right() - kArrowTipHeight); - anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y())); - break; + return gfx::Vector2d( + 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); case SHELF_ALIGNMENT_RIGHT: - anchor.set_x(button_bounds.x() + kArrowTipHeight); - anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y())); - break; + return gfx::Vector2d( + 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); + default: + NOTREACHED(); + return gfx::Vector2d(); } - - return anchor; } } // namespace @@ -172,22 +160,22 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { if (ash::switches::UseAlternateShelfLayout()) { gfx::Rect applist_button_bounds = Launcher::ForWindow(container)-> GetAppListButtonView()->GetBoundsInScreen(); - view->InitAsBubble( + view->InitAsBubbleAttachedToAnchor( container, pagination_model_.get(), - NULL, - GetAdjustAnchorPositionToShelf(applist_button_bounds, + Launcher::ForWindow(container)->GetAppListButtonView(), + GetAnchorPositionOffsetToShelf(applist_button_bounds, Launcher::ForWindow(container)->GetAppListButtonView()-> GetWidget()), GetBubbleArrow(container), true /* border_accepts_events */); view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); } else { - view->InitAsBubble( + view->InitAsBubbleAttachedToAnchor( container, pagination_model_.get(), Launcher::ForWindow(container)->GetAppListButtonView(), - gfx::Point(), + gfx::Vector2d(), GetBubbleArrow(container), true /* border_accepts_events */); } |