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

Side by Side Diff: ash/wm/panels/panel_layout_manager.cc

Issue 115113006: Rename Launcher to Shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes 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
« no previous file with comments | « ash/wm/panels/panel_layout_manager.h ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/panels/panel_layout_manager.h" 5 #include "ash/wm/panels/panel_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "ash/launcher/launcher.h"
11 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
11 #include "ash/shelf/shelf.h"
12 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
13 #include "ash/shelf/shelf_types.h" 13 #include "ash/shelf/shelf_types.h"
14 #include "ash/shelf/shelf_widget.h" 14 #include "ash/shelf/shelf_widget.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/shell_window_ids.h" 16 #include "ash/shell_window_ids.h"
17 #include "ash/wm/window_animations.h" 17 #include "ash/wm/window_animations.h"
18 #include "ash/wm/window_state.h" 18 #include "ash/wm/window_state.h"
19 #include "ash/wm/window_util.h" 19 #include "ash/wm/window_util.h"
20 #include "base/auto_reset.h" 20 #include "base/auto_reset.h"
21 #include "base/bind.h" 21 #include "base/bind.h"
(...skipping 20 matching lines...) Expand all
42 namespace { 42 namespace {
43 const int kPanelIdealSpacing = 4; 43 const int kPanelIdealSpacing = 4;
44 44
45 const float kMaxHeightFactor = .80f; 45 const float kMaxHeightFactor = .80f;
46 const float kMaxWidthFactor = .50f; 46 const float kMaxWidthFactor = .50f;
47 47
48 // Duration for panel animations. 48 // Duration for panel animations.
49 const int kPanelSlideDurationMilliseconds = 50; 49 const int kPanelSlideDurationMilliseconds = 50;
50 const int kCalloutFadeDurationMilliseconds = 50; 50 const int kCalloutFadeDurationMilliseconds = 50;
51 51
52 // Offset used when sliding panel in/out of the launcher. Used for minimizing, 52 // Offset used when sliding panel in/out of the shelf. Used for minimizing,
53 // restoring and the initial showing of a panel. 53 // restoring and the initial showing of a panel.
54 const int kPanelSlideInOffset = 20; 54 const int kPanelSlideInOffset = 20;
55 55
56 // Callout arrow dimensions. 56 // Callout arrow dimensions.
57 const int kArrowWidth = 18; 57 const int kArrowWidth = 18;
58 const int kArrowHeight = 9; 58 const int kArrowHeight = 9;
59 59
60 class CalloutWidgetBackground : public views::Background { 60 class CalloutWidgetBackground : public views::Background {
61 public: 61 public:
62 CalloutWidgetBackground() : alignment_(SHELF_ALIGNMENT_BOTTOM) { 62 CalloutWidgetBackground() : alignment_(SHELF_ALIGNMENT_BOTTOM) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 DISALLOW_COPY_AND_ASSIGN(PanelCalloutWidget); 252 DISALLOW_COPY_AND_ASSIGN(PanelCalloutWidget);
253 }; 253 };
254 254
255 //////////////////////////////////////////////////////////////////////////////// 255 ////////////////////////////////////////////////////////////////////////////////
256 // PanelLayoutManager public implementation: 256 // PanelLayoutManager public implementation:
257 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) 257 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container)
258 : panel_container_(panel_container), 258 : panel_container_(panel_container),
259 in_add_window_(false), 259 in_add_window_(false),
260 in_layout_(false), 260 in_layout_(false),
261 dragged_panel_(NULL), 261 dragged_panel_(NULL),
262 launcher_(NULL), 262 shelf_(NULL),
263 shelf_layout_manager_(NULL), 263 shelf_layout_manager_(NULL),
264 last_active_panel_(NULL), 264 last_active_panel_(NULL),
265 weak_factory_(this) { 265 weak_factory_(this) {
266 DCHECK(panel_container); 266 DCHECK(panel_container);
267 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 267 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
268 AddObserver(this); 268 AddObserver(this);
269 Shell::GetInstance()->display_controller()->AddObserver(this); 269 Shell::GetInstance()->display_controller()->AddObserver(this);
270 Shell::GetInstance()->AddShellObserver(this); 270 Shell::GetInstance()->AddShellObserver(this);
271 } 271 }
272 272
273 PanelLayoutManager::~PanelLayoutManager() { 273 PanelLayoutManager::~PanelLayoutManager() {
274 Shutdown(); 274 Shutdown();
275 } 275 }
276 276
277 void PanelLayoutManager::Shutdown() { 277 void PanelLayoutManager::Shutdown() {
278 if (shelf_layout_manager_) 278 if (shelf_layout_manager_)
279 shelf_layout_manager_->RemoveObserver(this); 279 shelf_layout_manager_->RemoveObserver(this);
280 shelf_layout_manager_ = NULL; 280 shelf_layout_manager_ = NULL;
281 for (PanelList::iterator iter = panel_windows_.begin(); 281 for (PanelList::iterator iter = panel_windows_.begin();
282 iter != panel_windows_.end(); ++iter) { 282 iter != panel_windows_.end(); ++iter) {
283 delete iter->callout_widget; 283 delete iter->callout_widget;
284 } 284 }
285 panel_windows_.clear(); 285 panel_windows_.clear();
286 if (launcher_) 286 if (shelf_)
287 launcher_->RemoveIconObserver(this); 287 shelf_->RemoveIconObserver(this);
288 launcher_ = NULL; 288 shelf_ = NULL;
289 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 289 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
290 RemoveObserver(this); 290 RemoveObserver(this);
291 Shell::GetInstance()->display_controller()->RemoveObserver(this); 291 Shell::GetInstance()->display_controller()->RemoveObserver(this);
292 Shell::GetInstance()->RemoveShellObserver(this); 292 Shell::GetInstance()->RemoveShellObserver(this);
293 } 293 }
294 294
295 void PanelLayoutManager::StartDragging(aura::Window* panel) { 295 void PanelLayoutManager::StartDragging(aura::Window* panel) {
296 DCHECK(!dragged_panel_); 296 DCHECK(!dragged_panel_);
297 dragged_panel_ = panel; 297 dragged_panel_ = panel;
298 Relayout(); 298 Relayout();
299 } 299 }
300 300
301 void PanelLayoutManager::FinishDragging() { 301 void PanelLayoutManager::FinishDragging() {
302 dragged_panel_ = NULL; 302 dragged_panel_ = NULL;
303 Relayout(); 303 Relayout();
304 } 304 }
305 305
306 void PanelLayoutManager::SetLauncher(ash::Launcher* launcher) { 306 void PanelLayoutManager::SetShelf(Shelf* shelf) {
307 DCHECK(!launcher_); 307 DCHECK(!shelf_);
308 DCHECK(!shelf_layout_manager_); 308 DCHECK(!shelf_layout_manager_);
309 launcher_ = launcher; 309 shelf_ = shelf;
310 launcher_->AddIconObserver(this); 310 shelf_->AddIconObserver(this);
311 if (launcher_->shelf_widget()) { 311 if (shelf_->shelf_widget()) {
312 shelf_layout_manager_ = ash::internal::ShelfLayoutManager::ForLauncher( 312 shelf_layout_manager_ = ash::internal::ShelfLayoutManager::ForShelf(
313 launcher_->shelf_widget()->GetNativeWindow()); 313 shelf_->shelf_widget()->GetNativeWindow());
314 WillChangeVisibilityState(shelf_layout_manager_->visibility_state()); 314 WillChangeVisibilityState(shelf_layout_manager_->visibility_state());
315 shelf_layout_manager_->AddObserver(this); 315 shelf_layout_manager_->AddObserver(this);
316 } 316 }
317 } 317 }
318 318
319 void PanelLayoutManager::ToggleMinimize(aura::Window* panel) { 319 void PanelLayoutManager::ToggleMinimize(aura::Window* panel) {
320 DCHECK(panel->parent() == panel_container_); 320 DCHECK(panel->parent() == panel_container_);
321 wm::WindowState* window_state = wm::GetWindowState(panel); 321 wm::WindowState* window_state = wm::GetWindowState(panel);
322 if (window_state->IsMinimized()) 322 if (window_state->IsMinimized())
323 window_state->Restore(); 323 window_state->Restore();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 views::corewm::SetWindowVisibilityAnimationType( 549 views::corewm::SetWindowVisibilityAnimationType(
550 panel, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 550 panel, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
551 ui::Layer* layer = panel->layer(); 551 ui::Layer* layer = panel->layer();
552 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator()); 552 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator());
553 panel_slide_settings.SetPreemptionStrategy( 553 panel_slide_settings.SetPreemptionStrategy(
554 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 554 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
555 panel_slide_settings.SetTransitionDuration( 555 panel_slide_settings.SetTransitionDuration(
556 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds)); 556 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds));
557 gfx::Rect bounds(panel->bounds()); 557 gfx::Rect bounds(panel->bounds());
558 bounds.Offset(GetSlideInAnimationOffset( 558 bounds.Offset(GetSlideInAnimationOffset(
559 launcher_->shelf_widget()->GetAlignment())); 559 shelf_->shelf_widget()->GetAlignment()));
560 SetChildBoundsDirect(panel, bounds); 560 SetChildBoundsDirect(panel, bounds);
561 panel->Hide(); 561 panel->Hide();
562 PanelList::iterator found = 562 PanelList::iterator found =
563 std::find(panel_windows_.begin(), panel_windows_.end(), panel); 563 std::find(panel_windows_.begin(), panel_windows_.end(), panel);
564 if (found != panel_windows_.end()) { 564 if (found != panel_windows_.end()) {
565 layer->SetOpacity(0); 565 layer->SetOpacity(0);
566 // The next time the window is visible it should slide into place. 566 // The next time the window is visible it should slide into place.
567 found->slide_in = true; 567 found->slide_in = true;
568 } 568 }
569 if (wm::IsActiveWindow(panel)) 569 if (wm::IsActiveWindow(panel))
570 wm::DeactivateWindow(panel); 570 wm::DeactivateWindow(panel);
571 Relayout(); 571 Relayout();
572 } 572 }
573 573
574 void PanelLayoutManager::RestorePanel(aura::Window* panel) { 574 void PanelLayoutManager::RestorePanel(aura::Window* panel) {
575 panel->Show(); 575 panel->Show();
576 Relayout(); 576 Relayout();
577 } 577 }
578 578
579 void PanelLayoutManager::Relayout() { 579 void PanelLayoutManager::Relayout() {
580 if (!launcher_ || !launcher_->shelf_widget()) 580 if (!shelf_ || !shelf_->shelf_widget())
581 return; 581 return;
582 582
583 if (in_layout_) 583 if (in_layout_)
584 return; 584 return;
585 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 585 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
586 586
587 ShelfAlignment alignment = launcher_->shelf_widget()->GetAlignment(); 587 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment();
588 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || 588 bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
589 alignment == SHELF_ALIGNMENT_BOTTOM; 589 alignment == SHELF_ALIGNMENT_BOTTOM;
590 gfx::Rect launcher_bounds = ash::ScreenAsh::ConvertRectFromScreen( 590 gfx::Rect shelf_bounds = ash::ScreenAsh::ConvertRectFromScreen(
591 panel_container_, launcher_->shelf_widget()->GetWindowBoundsInScreen()); 591 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen());
592 int panel_start_bounds = kPanelIdealSpacing; 592 int panel_start_bounds = kPanelIdealSpacing;
593 int panel_end_bounds = horizontal ? 593 int panel_end_bounds = horizontal ?
594 panel_container_->bounds().width() - kPanelIdealSpacing : 594 panel_container_->bounds().width() - kPanelIdealSpacing :
595 panel_container_->bounds().height() - kPanelIdealSpacing; 595 panel_container_->bounds().height() - kPanelIdealSpacing;
596 aura::Window* active_panel = NULL; 596 aura::Window* active_panel = NULL;
597 std::vector<VisiblePanelPositionInfo> visible_panels; 597 std::vector<VisiblePanelPositionInfo> visible_panels;
598 for (PanelList::iterator iter = panel_windows_.begin(); 598 for (PanelList::iterator iter = panel_windows_.begin();
599 iter != panel_windows_.end(); ++iter) { 599 iter != panel_windows_.end(); ++iter) {
600 aura::Window* panel = iter->window; 600 aura::Window* panel = iter->window;
601 iter->callout_widget->SetAlignment(alignment); 601 iter->callout_widget->SetAlignment(alignment);
602 602
603 // Consider the dragged panel as part of the layout as long as it is 603 // Consider the dragged panel as part of the layout as long as it is
604 // touching the launcher. 604 // touching the shelf.
605 if (!panel->IsVisible() || 605 if (!panel->IsVisible() ||
606 (panel == dragged_panel_ && 606 (panel == dragged_panel_ &&
607 !BoundsAdjacent(panel->bounds(), launcher_bounds))) { 607 !BoundsAdjacent(panel->bounds(), shelf_bounds))) {
608 continue; 608 continue;
609 } 609 }
610 610
611 // If the shelf is currently hidden (full-screen mode), minimize panel until 611 // If the shelf is currently hidden (full-screen mode), minimize panel until
612 // full-screen mode is exited. 612 // full-screen mode is exited.
613 if (restore_windows_on_shelf_visible_) { 613 if (restore_windows_on_shelf_visible_) {
614 wm::GetWindowState(panel)->Minimize(); 614 wm::GetWindowState(panel)->Minimize();
615 restore_windows_on_shelf_visible_->Add(panel); 615 restore_windows_on_shelf_visible_->Add(panel);
616 continue; 616 continue;
617 } 617 }
618 618
619 gfx::Rect icon_bounds = 619 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
620 launcher_->GetScreenBoundsOfItemIconForWindow(panel);
621 620
622 // If both the icon width and height are 0 then there is no icon in the 621 // If both the icon width and height are 0 then there is no icon in the
623 // launcher. If the launcher is hidden, one of the height or width will be 622 // shelf. If the shelf is hidden, one of the height or width will be
624 // 0 but the position in the launcher and major dimension is still reported 623 // 0 but the position in the shelf and major dimension is still reported
625 // correctly and the panel can be aligned above where the hidden icon is. 624 // correctly and the panel can be aligned above where the hidden icon is.
626 if (icon_bounds.width() == 0 && icon_bounds.height() == 0) 625 if (icon_bounds.width() == 0 && icon_bounds.height() == 0)
627 continue; 626 continue;
628 627
629 if (panel->HasFocus() || 628 if (panel->HasFocus() ||
630 panel->Contains( 629 panel->Contains(
631 aura::client::GetFocusClient(panel)->GetFocusedWindow())) { 630 aura::client::GetFocusClient(panel)->GetFocusedWindow())) {
632 DCHECK(!active_panel); 631 DCHECK(!active_panel);
633 active_panel = panel; 632 active_panel = panel;
634 } 633 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 FanOutPanels(visible_panels.begin() + first_overlapping_panel, 672 FanOutPanels(visible_panels.begin() + first_overlapping_panel,
674 visible_panels.end()); 673 visible_panels.end());
675 674
676 for (size_t i = 0; i < visible_panels.size(); ++i) { 675 for (size_t i = 0; i < visible_panels.size(); ++i) {
677 if (visible_panels[i].window == dragged_panel_) 676 if (visible_panels[i].window == dragged_panel_)
678 continue; 677 continue;
679 bool slide_in = visible_panels[i].slide_in; 678 bool slide_in = visible_panels[i].slide_in;
680 gfx::Rect bounds = visible_panels[i].window->GetTargetBounds(); 679 gfx::Rect bounds = visible_panels[i].window->GetTargetBounds();
681 switch (alignment) { 680 switch (alignment) {
682 case SHELF_ALIGNMENT_BOTTOM: 681 case SHELF_ALIGNMENT_BOTTOM:
683 bounds.set_y(launcher_bounds.y() - bounds.height()); 682 bounds.set_y(shelf_bounds.y() - bounds.height());
684 break; 683 break;
685 case SHELF_ALIGNMENT_LEFT: 684 case SHELF_ALIGNMENT_LEFT:
686 bounds.set_x(launcher_bounds.right()); 685 bounds.set_x(shelf_bounds.right());
687 break; 686 break;
688 case SHELF_ALIGNMENT_RIGHT: 687 case SHELF_ALIGNMENT_RIGHT:
689 bounds.set_x(launcher_bounds.x() - bounds.width()); 688 bounds.set_x(shelf_bounds.x() - bounds.width());
690 break; 689 break;
691 case SHELF_ALIGNMENT_TOP: 690 case SHELF_ALIGNMENT_TOP:
692 bounds.set_y(launcher_bounds.bottom()); 691 bounds.set_y(shelf_bounds.bottom());
693 break; 692 break;
694 } 693 }
695 bool on_launcher = visible_panels[i].window->GetTargetBounds() == bounds; 694 bool on_shelf = visible_panels[i].window->GetTargetBounds() == bounds;
696 695
697 if (horizontal) { 696 if (horizontal) {
698 bounds.set_x(visible_panels[i].major_pos - 697 bounds.set_x(visible_panels[i].major_pos -
699 visible_panels[i].major_length / 2); 698 visible_panels[i].major_length / 2);
700 } else { 699 } else {
701 bounds.set_y(visible_panels[i].major_pos - 700 bounds.set_y(visible_panels[i].major_pos -
702 visible_panels[i].major_length / 2); 701 visible_panels[i].major_length / 2);
703 } 702 }
704 703
705 ui::Layer* layer = visible_panels[i].window->layer(); 704 ui::Layer* layer = visible_panels[i].window->layer();
706 if (slide_in) { 705 if (slide_in) {
707 // New windows shift up from the launcher into position. 706 // New windows shift up from the shelf into position.
708 gfx::Rect initial_bounds(bounds); 707 gfx::Rect initial_bounds(bounds);
709 initial_bounds.Offset(GetSlideInAnimationOffset(alignment)); 708 initial_bounds.Offset(GetSlideInAnimationOffset(alignment));
710 SetChildBoundsDirect(visible_panels[i].window, initial_bounds); 709 SetChildBoundsDirect(visible_panels[i].window, initial_bounds);
711 // Set on launcher so that the panel animates into its target position. 710 // Set on shelf so that the panel animates into its target position.
712 on_launcher = true; 711 on_shelf = true;
713 } 712 }
714 713
715 if (on_launcher) { 714 if (on_shelf) {
716 ui::ScopedLayerAnimationSettings panel_slide_settings( 715 ui::ScopedLayerAnimationSettings panel_slide_settings(
717 layer->GetAnimator()); 716 layer->GetAnimator());
718 panel_slide_settings.SetPreemptionStrategy( 717 panel_slide_settings.SetPreemptionStrategy(
719 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 718 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
720 panel_slide_settings.SetTransitionDuration( 719 panel_slide_settings.SetTransitionDuration(
721 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds)); 720 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds));
722 SetChildBoundsDirect(visible_panels[i].window, bounds); 721 SetChildBoundsDirect(visible_panels[i].window, bounds);
723 if (slide_in) 722 if (slide_in)
724 layer->SetOpacity(1); 723 layer->SetOpacity(1);
725 } else { 724 } else {
726 // If the launcher moved don't animate, move immediately to the new 725 // If the shelf moved don't animate, move immediately to the new
727 // target location. 726 // target location.
728 SetChildBoundsDirect(visible_panels[i].window, bounds); 727 SetChildBoundsDirect(visible_panels[i].window, bounds);
729 } 728 }
730 } 729 }
731 730
732 UpdateStacking(active_panel); 731 UpdateStacking(active_panel);
733 UpdateCallouts(); 732 UpdateCallouts();
734 } 733 }
735 734
736 void PanelLayoutManager::UpdateStacking(aura::Window* active_panel) { 735 void PanelLayoutManager::UpdateStacking(aura::Window* active_panel) {
737 if (!active_panel) { 736 if (!active_panel) {
738 if (!last_active_panel_) 737 if (!last_active_panel_)
739 return; 738 return;
740 active_panel = last_active_panel_; 739 active_panel = last_active_panel_;
741 } 740 }
742 741
743 ShelfAlignment alignment = launcher_->alignment(); 742 ShelfAlignment alignment = shelf_->alignment();
744 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || 743 bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
745 alignment == SHELF_ALIGNMENT_BOTTOM; 744 alignment == SHELF_ALIGNMENT_BOTTOM;
746 745
747 // We want to to stack the panels like a deck of cards: 746 // We want to to stack the panels like a deck of cards:
748 // ,--,--,--,-------.--.--. 747 // ,--,--,--,-------.--.--.
749 // | | | | | | | 748 // | | | | | | |
750 // | | | | | | | 749 // | | | | | | |
751 // 750 //
752 // We use the middle of each panel to figure out how to stack the panels. This 751 // We use the middle of each panel to figure out how to stack the panels. This
753 // allows us to update the stacking when a panel is being dragged around by 752 // allows us to update the stacking when a panel is being dragged around by
754 // the titlebar--even though it doesn't update the launcher icon positions, we 753 // the titlebar--even though it doesn't update the shelf icon positions, we
755 // still want the visual effect. 754 // still want the visual effect.
756 std::map<int, aura::Window*> window_ordering; 755 std::map<int, aura::Window*> window_ordering;
757 for (PanelList::const_iterator it = panel_windows_.begin(); 756 for (PanelList::const_iterator it = panel_windows_.begin();
758 it != panel_windows_.end(); ++it) { 757 it != panel_windows_.end(); ++it) {
759 gfx::Rect bounds = it->window->bounds(); 758 gfx::Rect bounds = it->window->bounds();
760 window_ordering.insert(std::make_pair(horizontal ? 759 window_ordering.insert(std::make_pair(horizontal ?
761 bounds.x() + bounds.width() / 2 : 760 bounds.x() + bounds.width() / 2 :
762 bounds.y() + bounds.height() / 2, 761 bounds.y() + bounds.height() / 2,
763 it->window)); 762 it->window));
764 } 763 }
(...skipping 16 matching lines...) Expand all
781 previous_panel = it->second; 780 previous_panel = it->second;
782 } 781 }
783 782
784 panel_container_->StackChildAtTop(active_panel); 783 panel_container_->StackChildAtTop(active_panel);
785 if (dragged_panel_ && dragged_panel_->parent() == panel_container_) 784 if (dragged_panel_ && dragged_panel_->parent() == panel_container_)
786 panel_container_->StackChildAtTop(dragged_panel_); 785 panel_container_->StackChildAtTop(dragged_panel_);
787 last_active_panel_ = active_panel; 786 last_active_panel_ = active_panel;
788 } 787 }
789 788
790 void PanelLayoutManager::UpdateCallouts() { 789 void PanelLayoutManager::UpdateCallouts() {
791 ShelfAlignment alignment = launcher_->alignment(); 790 ShelfAlignment alignment = shelf_->alignment();
792 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || 791 bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
793 alignment == SHELF_ALIGNMENT_BOTTOM; 792 alignment == SHELF_ALIGNMENT_BOTTOM;
794 793
795 for (PanelList::iterator iter = panel_windows_.begin(); 794 for (PanelList::iterator iter = panel_windows_.begin();
796 iter != panel_windows_.end(); ++iter) { 795 iter != panel_windows_.end(); ++iter) {
797 aura::Window* panel = iter->window; 796 aura::Window* panel = iter->window;
798 views::Widget* callout_widget = iter->callout_widget; 797 views::Widget* callout_widget = iter->callout_widget;
799 798
800 gfx::Rect current_bounds = panel->GetBoundsInScreen(); 799 gfx::Rect current_bounds = panel->GetBoundsInScreen();
801 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen(panel->parent(), 800 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen(panel->parent(),
802 panel->GetTargetBounds()); 801 panel->GetTargetBounds());
803 gfx::Rect icon_bounds = 802 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
804 launcher_->GetScreenBoundsOfItemIconForWindow(panel);
805 if (icon_bounds.IsEmpty() || !panel->layer()->GetTargetVisibility() || 803 if (icon_bounds.IsEmpty() || !panel->layer()->GetTargetVisibility() ||
806 panel == dragged_panel_) { 804 panel == dragged_panel_) {
807 callout_widget->Hide(); 805 callout_widget->Hide();
808 callout_widget->GetNativeWindow()->layer()->SetOpacity(0); 806 callout_widget->GetNativeWindow()->layer()->SetOpacity(0);
809 continue; 807 continue;
810 } 808 }
811 809
812 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen(); 810 gfx::Rect callout_bounds = callout_widget->GetWindowBoundsInScreen();
813 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin(); 811 gfx::Vector2d slide_vector = bounds.origin() - current_bounds.origin();
814 int slide_distance = horizontal ? slide_vector.x() : slide_vector.y(); 812 int slide_distance = horizontal ? slide_vector.x() : slide_vector.y();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 884
887 void PanelLayoutManager::OnKeyboardBoundsChanging( 885 void PanelLayoutManager::OnKeyboardBoundsChanging(
888 const gfx::Rect& keyboard_bounds) { 886 const gfx::Rect& keyboard_bounds) {
889 // This bounds change will have caused a change to the Shelf which does not 887 // This bounds change will have caused a change to the Shelf which does not
890 // propogate automatically to this class, so manually recalculate bounds. 888 // propogate automatically to this class, so manually recalculate bounds.
891 OnWindowResized(); 889 OnWindowResized();
892 } 890 }
893 891
894 } // namespace internal 892 } // namespace internal
895 } // namespace ash 893 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_layout_manager.h ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698