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

Unified Diff: ash/wm/app_list_controller.cc

Issue 281523002: ChromeOS: The centered app list's top is now forced to be >= 10. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Skip AppListControllerTest if UpdateDisplay is not supported. Created 6 years, 7 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 | ash/wm/app_list_controller_unittest.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 45915c49ae1a7a95b52cf913843f787d38097a0e..6acf1aef33e2e868892ad2757babfeb9d190a142 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -44,6 +44,9 @@ const int kMaxOverScrollShift = 48;
// result of minimal bubble arrow sizes and offsets.
const int kMinimalAnchorPositionOffset = 57;
+// The minimal margin (in pixels) around the app list when in centered mode.
+const int kMinimalCenteredAppListMargin = 10;
+
ui::Layer* GetLayer(views::Widget* widget) {
return widget->GetNativeView()->layer();
}
@@ -115,8 +118,11 @@ gfx::Vector2d GetAnchorPositionOffsetToShelf(
}
// Gets the point at the center of the display that a particular view is on.
-// This calculation excludes the virtual keyboard area.
-gfx::Point GetCenterOfDisplayForView(const views::View* view) {
+// This calculation excludes the virtual keyboard area. If the height of the
+// display area is less than |minimum_height|, its bottom will be extended to
+// that height (so that the app list never starts above the top of the screen).
+gfx::Point GetCenterOfDisplayForView(const views::View* view,
+ int minimum_height) {
gfx::Rect bounds = Shell::GetScreen()->GetDisplayNearestWindow(
view->GetWidget()->GetNativeView()).bounds();
@@ -129,9 +135,18 @@ gfx::Point GetCenterOfDisplayForView(const views::View* view) {
if (keyboard_controller && keyboard_controller->keyboard_visible())
bounds.Subtract(keyboard_controller->current_keyboard_bounds());
+ // Apply the |minimum_height|.
+ if (bounds.height() < minimum_height)
+ bounds.set_height(minimum_height);
+
return bounds.CenterPoint();
}
+// Gets the minimum height of the rectangle to center the app list in.
+int GetMinimumBoundsHeightForAppList(const app_list::AppListView* app_list) {
+ return app_list->bounds().height() + 2 * kMinimalCenteredAppListMargin;
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -189,15 +204,19 @@ void AppListController::SetVisible(bool visible, aura::Window* window) {
Shelf::ForWindow(container)->GetAppListButtonView();
is_centered_ = view->ShouldCenterWindow();
if (is_centered_) {
- // The experimental app list is centered over the display of the app list
- // button that was pressed (if triggered via keyboard, this is the display
- // with the currently focused window).
+ // Note: We can't center the app list until we have its dimensions, so we
+ // init at (0, 0) and then reset its anchor point.
view->InitAsBubbleAtFixedLocation(
container,
pagination_model_.get(),
- GetCenterOfDisplayForView(applist_button),
+ gfx::Point(),
views::BubbleBorder::FLOAT,
true /* border_accepts_events */);
+ // The experimental app list is centered over the display of the app list
+ // button that was pressed (if triggered via keyboard, this is the display
+ // with the currently focused window).
+ view->SetAnchorPoint(GetCenterOfDisplayForView(
+ applist_button, GetMinimumBoundsHeightForAppList(view)));
} else {
gfx::Rect applist_button_bounds = applist_button->GetBoundsInScreen();
// We need the location of the button within the local screen.
@@ -340,7 +359,8 @@ void AppListController::UpdateBounds() {
view_->UpdateBounds();
if (is_centered_)
- view_->SetAnchorPoint(GetCenterOfDisplayForView(view_));
+ view_->SetAnchorPoint(GetCenterOfDisplayForView(
+ view_, GetMinimumBoundsHeightForAppList(view_)));
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « no previous file | ash/wm/app_list_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698