Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: ash/wm/app_list_controller.cc

Issue 23622020: Fixing the dynamic positioning (move with anchor) for the app launcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit test Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/app_list/views/app_list_view.h » ('j') | ui/app_list/views/app_list_view.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/app_list_controller.cc
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index ea5e4f4ce906b51952f53786cc45a77f1f97dc56..cf97dee01c76205237e5c5096bc1bd38fc67dbcb 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -39,11 +39,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;
James Cook 2013/09/05 20:05:17 Nice that you found this thing to clean up.
Mr4D (OOO till 08-26) 2013/09/05 20:52:00 Sure thing!
-
// 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.
@@ -88,9 +83,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::Point GetAnchorPositionOffsetToShelf(
const gfx::Rect& button_bounds, views::Widget* widget) {
DCHECK(Shell::HasInstance());
ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment(
@@ -102,24 +97,22 @@ gfx::Point GetAdjustAnchorPositionToShelf(
{
if (base::i18n::IsRTL()) {
int screen_width = widget->GetWorkAreaBoundsInScreen().width();
- anchor.set_x(std::min(screen_width - kMinimalAnchorPositionOffset,
- anchor.x()));
+ anchor.set_x(
+ std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(),
+ 0));
} else {
- anchor.set_x(std::max(kMinimalAnchorPositionOffset, anchor.x()));
+ anchor.set_x(std::max(kMinimalAnchorPositionOffset - anchor.x(), 0));
}
- int offset = button_bounds.height() / 2 - kArrowTipHeight;
- if (shelf_alignment == SHELF_ALIGNMENT_TOP)
- offset = -offset;
- anchor.set_y(anchor.y() - offset);
+ anchor.set_y(0);
}
break;
case SHELF_ALIGNMENT_LEFT:
- anchor.set_x(button_bounds.right() - kArrowTipHeight);
- anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y()));
+ anchor.set_x(0);
+ anchor.set_y(std::max(kMinimalAnchorPositionOffset - anchor.y(), 0));
break;
case SHELF_ALIGNMENT_RIGHT:
- anchor.set_x(button_bounds.x() + kArrowTipHeight);
- anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y()));
+ anchor.set_x(0);
+ anchor.set_y(std::max(kMinimalAnchorPositionOffset - anchor.y(), 0));
break;
}
@@ -176,8 +169,8 @@ void AppListController::SetVisible(bool visible, aura::Window* window) {
view->InitAsBubble(
container,
pagination_model_.get(),
- NULL,
- GetAdjustAnchorPositionToShelf(applist_button_bounds,
+ Launcher::ForWindow(container)->GetAppListButtonView(),
+ GetAnchorPositionOffsetToShelf(applist_button_bounds,
Launcher::ForWindow(container)->GetAppListButtonView()->
GetWidget()),
GetBubbleArrow(container),
« no previous file with comments | « no previous file | ui/app_list/views/app_list_view.h » ('j') | ui/app_list/views/app_list_view.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698