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

Side by Side Diff: ash/wm/window_animations.cc

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ash/wm/window_animations.h" 5 #include "ash/wm/window_animations.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 459
460 // The launcher item is visible and has an icon. 460 // The launcher item is visible and has an icon.
461 if (!item_rect.IsEmpty()) 461 if (!item_rect.IsEmpty())
462 return item_rect; 462 return item_rect;
463 463
464 // If both the icon width and height are 0, then there is no icon in the 464 // If both the icon width and height are 0, then there is no icon in the
465 // launcher for |window|. If the launcher is auto hidden, one of the height or 465 // launcher for |window|. If the launcher is auto hidden, one of the height or
466 // width will be 0 but the position in the launcher and the major dimension 466 // width will be 0 but the position in the launcher and the major dimension
467 // are still reported correctly and the window can be animated to the launcher 467 // are still reported correctly and the window can be animated to the launcher
468 // item's light bar. 468 // item's light bar.
469 ShelfLayoutManager* layout_manager =
470 shelf->shelf_widget()->shelf_layout_manager();
471 if (item_rect.width() != 0 || item_rect.height() != 0) { 469 if (item_rect.width() != 0 || item_rect.height() != 0) {
472 if (layout_manager->visibility_state() == SHELF_AUTO_HIDE) { 470 if (shelf->shelf_layout_manager()->visibility_state() == SHELF_AUTO_HIDE) {
473 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); 471 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen();
474 switch (layout_manager->GetAlignment()) { 472 switch (shelf->alignment()) {
475 case SHELF_ALIGNMENT_BOTTOM: 473 case SHELF_ALIGNMENT_BOTTOM:
476 item_rect.set_y(shelf_bounds.y()); 474 item_rect.set_y(shelf_bounds.y());
477 break; 475 break;
478 case SHELF_ALIGNMENT_LEFT: 476 case SHELF_ALIGNMENT_LEFT:
479 item_rect.set_x(shelf_bounds.right()); 477 item_rect.set_x(shelf_bounds.right());
480 break; 478 break;
481 case SHELF_ALIGNMENT_RIGHT: 479 case SHELF_ALIGNMENT_RIGHT:
482 item_rect.set_x(shelf_bounds.x()); 480 item_rect.set_x(shelf_bounds.x());
483 break; 481 break;
484 case SHELF_ALIGNMENT_TOP: 482 case SHELF_ALIGNMENT_TOP:
485 item_rect.set_y(shelf_bounds.bottom()); 483 item_rect.set_y(shelf_bounds.bottom());
486 break; 484 break;
487 } 485 }
488 return item_rect; 486 return item_rect;
489 } 487 }
490 } 488 }
491 489
492 // Coming here, there is no visible icon of that shelf item and we zoom back 490 // Coming here, there is no visible icon of that shelf item and we zoom back
493 // to the location of the application launcher (which is fixed as first item 491 // to the location of the application launcher (which is fixed as first item
494 // of the shelf). 492 // of the shelf).
495 gfx::Rect work_area = 493 gfx::Rect work_area =
496 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); 494 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area();
497 int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x(); 495 int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x();
498 switch (layout_manager->GetAlignment()) { 496 return shelf->SelectValueForShelfAlignment(
499 case SHELF_ALIGNMENT_BOTTOM: 497 gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0),
500 return gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0); 498 gfx::Rect(work_area.x(), work_area.y(), 0, 0),
501 case SHELF_ALIGNMENT_TOP: 499 gfx::Rect(work_area.right(), work_area.y(), 0, 0),
502 return gfx::Rect(ltr_adjusted_x, work_area.y(), 0, 0); 500 gfx::Rect(ltr_adjusted_x, work_area.y(), 0, 0));
503 case SHELF_ALIGNMENT_LEFT:
504 return gfx::Rect(work_area.x(), work_area.y(), 0, 0);
505 case SHELF_ALIGNMENT_RIGHT:
506 return gfx::Rect(work_area.right(), work_area.y(), 0, 0);
507 }
508 NOTREACHED();
509 return gfx::Rect();
510 } 501 }
511 502
512 } // namespace ash 503 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_layout_manager_unittest.cc ('k') | ash/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698