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

Side by Side Diff: chrome/browser/ui/app_list/app_list_service_mac.mm

Issue 93863002: Mac App Launcher is positioned on center of dock in certain cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a comment about when it is appropriate to animate the launcher. Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/app_list/app_list_service_mac.h" 5 #import "chrome/browser/ui/app_list/app_list_service_mac.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "apps/app_shim/app_shim_mac.h" 10 #include "apps/app_shim/app_shim_mac.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 // static 274 // static
275 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, 275 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size,
276 const gfx::Display& display, 276 const gfx::Display& display,
277 int primary_display_height, 277 int primary_display_height,
278 bool cursor_is_visible, 278 bool cursor_is_visible,
279 const gfx::Point& cursor, 279 const gfx::Point& cursor,
280 NSPoint* target_origin, 280 NSPoint* target_origin,
281 NSPoint* start_origin) { 281 NSPoint* start_origin) {
282 AppListPositioner positioner(display, window_size, 0); 282 AppListPositioner positioner(display, window_size, 0);
283 AppListPositioner::ScreenEdge dock_location = 283 AppListPositioner::ScreenEdge dock_location = DockLocationInDisplay(display);
284 AppListPositioner::SCREEN_EDGE_UNKNOWN; 284
285 gfx::Point anchor; 285 gfx::Point anchor;
286 if (!cursor_is_visible) { 286 // Snap to the dock edge. If the cursor is greater than the window
287 // width/height away or not visible, anchor to the center of the dock.
288 // Otherwise, anchor to the cursor position.
289 if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) {
287 anchor = positioner.GetAnchorPointForScreenCorner( 290 anchor = positioner.GetAnchorPointForScreenCorner(
288 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); 291 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT);
289 } else { 292 } else {
290 dock_location = DockLocationInDisplay(display); 293 int snap_distance =
291 294 dock_location == AppListPositioner::SCREEN_EDGE_BOTTOM ||
292 // Snap to the dock edge, anchored to the cursor position. 295 dock_location == AppListPositioner::SCREEN_EDGE_TOP ?
293 if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) { 296 window_size.height() :
294 anchor = positioner.GetAnchorPointForScreenCorner( 297 window_size.width();
295 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); 298 // Subtract the dock area since the display's default work_area will not
299 // subtract it if the dock is set to auto-hide, and the app list should
300 // never overlap the dock.
301 AdjustWorkAreaForDock(display, &positioner, dock_location);
302 if (!cursor_is_visible || positioner.GetCursorDistanceFromShelf(
303 dock_location, cursor) > snap_distance) {
304 anchor = positioner.GetAnchorPointForShelfCenter(dock_location);
296 } else { 305 } else {
297 // Subtract the dock area since the display's default work_area will not
298 // subtract it if the dock is set to auto-hide, and the app list should
299 // never overlap the dock.
300 AdjustWorkAreaForDock(display, &positioner, dock_location);
301 anchor = positioner.GetAnchorPointForShelfCursor(dock_location, cursor); 306 anchor = positioner.GetAnchorPointForShelfCursor(dock_location, cursor);
302 } 307 }
303 } 308 }
304 309
305 *target_origin = NSMakePoint( 310 *target_origin = NSMakePoint(
306 anchor.x() - window_size.width() / 2, 311 anchor.x() - window_size.width() / 2,
307 primary_display_height - anchor.y() - window_size.height() / 2); 312 primary_display_height - anchor.y() - window_size.height() / 2);
308 *start_origin = *target_origin; 313 *start_origin = *target_origin;
309 314
315 // If the launcher is anchored to the dock (regardless of whether the cursor
316 // is visible), animate in inwards from the edge of screen
310 switch (dock_location) { 317 switch (dock_location) {
311 case AppListPositioner::SCREEN_EDGE_UNKNOWN: 318 case AppListPositioner::SCREEN_EDGE_UNKNOWN:
312 break; 319 break;
313 case AppListPositioner::SCREEN_EDGE_LEFT: 320 case AppListPositioner::SCREEN_EDGE_LEFT:
314 start_origin->x -= kDistanceMovedOnShow; 321 start_origin->x -= kDistanceMovedOnShow;
315 break; 322 break;
316 case AppListPositioner::SCREEN_EDGE_RIGHT: 323 case AppListPositioner::SCREEN_EDGE_RIGHT:
317 start_origin->x += kDistanceMovedOnShow; 324 start_origin->x += kDistanceMovedOnShow;
318 break; 325 break;
319 case AppListPositioner::SCREEN_EDGE_TOP: 326 case AppListPositioner::SCREEN_EDGE_TOP:
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 550
544 - (void)animationDidEnd:(NSAnimation*)animation { 551 - (void)animationDidEnd:(NSAnimation*)animation {
545 [window_ close]; 552 [window_ close];
546 window_.reset(); 553 window_.reset();
547 animation_.reset(); 554 animation_.reset();
548 555
549 apps::AppShimHandler::MaybeTerminate(); 556 apps::AppShimHandler::MaybeTerminate();
550 } 557 }
551 558
552 @end 559 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698