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

Unified Diff: ash/wm/app_list_controller.cc

Issue 198063003: Revert of Shelf Cleanup (- binary files) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « ash/test/shelf_view_test_api.cc ('k') | chrome/browser/about_flags.cc » ('j') | no next file with comments »
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 b92f491012e711270ee519c4ac56a1ae13a4bd3b..550a9552f2ed350fac518d7943a08484dbca08e0 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -40,6 +40,11 @@
// The maximum shift in pixels when over-scroll happens.
const int kMaxOverScrollShift = 48;
+// 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 = 57;
+
ui::Layer* GetLayer(views::Widget* widget) {
return widget->GetNativeView()->layer();
}
@@ -77,6 +82,37 @@
}
return offseted;
+}
+
+// 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(
+ 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();
+ return gfx::Vector2d(
+ std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(),
+ 0), 0);
+ }
+ return gfx::Vector2d(
+ std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0);
+ case SHELF_ALIGNMENT_LEFT:
+ return gfx::Vector2d(
+ 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0));
+ case SHELF_ALIGNMENT_RIGHT:
+ return gfx::Vector2d(
+ 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0));
+ default:
+ NOTREACHED();
+ return gfx::Vector2d();
+ }
}
} // namespace
@@ -140,6 +176,23 @@
Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(),
views::BubbleBorder::FLOAT,
true /* border_accepts_events */);
+ } else if (ash::switches::UseAlternateShelfLayout()) {
+ gfx::Rect applist_button_bounds = Shelf::ForWindow(container)->
+ GetAppListButtonView()->GetBoundsInScreen();
+ // We need the location of the button within the local screen.
+ applist_button_bounds = ScreenUtil::ConvertRectFromScreen(
+ root_window,
+ applist_button_bounds);
+ view->InitAsBubbleAttachedToAnchor(
+ container,
+ pagination_model_.get(),
+ Shelf::ForWindow(container)->GetAppListButtonView(),
+ GetAnchorPositionOffsetToShelf(applist_button_bounds,
+ Shelf::ForWindow(container)->GetAppListButtonView()->
+ GetWidget()),
+ GetBubbleArrow(container),
+ true /* border_accepts_events */);
+ view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
} else {
view->InitAsBubbleAttachedToAnchor(
container,
« no previous file with comments | « ash/test/shelf_view_test_api.cc ('k') | chrome/browser/about_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698