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

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

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ShelfBrowserTest. 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/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 #include <utility> 9 #include <utility>
10 10
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 void PanelLayoutManager::FinishDragging() { 304 void PanelLayoutManager::FinishDragging() {
305 dragged_panel_ = NULL; 305 dragged_panel_ = NULL;
306 Relayout(); 306 Relayout();
307 } 307 }
308 308
309 void PanelLayoutManager::SetShelf(Shelf* shelf) { 309 void PanelLayoutManager::SetShelf(Shelf* shelf) {
310 DCHECK(!shelf_); 310 DCHECK(!shelf_);
311 DCHECK(!shelf_layout_manager_); 311 DCHECK(!shelf_layout_manager_);
312 shelf_ = shelf; 312 shelf_ = shelf;
313 shelf_->AddIconObserver(this); 313 shelf_->AddIconObserver(this);
314 if (shelf_->shelf_widget()) { 314 if (shelf_->shelf_layout_manager()) {
315 shelf_layout_manager_ = shelf_->shelf_widget()->shelf_layout_manager(); 315 shelf_layout_manager_ = shelf_->shelf_layout_manager();
316 WillChangeVisibilityState(shelf_layout_manager_->visibility_state()); 316 WillChangeVisibilityState(shelf_layout_manager_->visibility_state());
317 shelf_layout_manager_->AddObserver(this); 317 shelf_layout_manager_->AddObserver(this);
318 } 318 }
319 } 319 }
320 320
321 void PanelLayoutManager::ToggleMinimize(aura::Window* panel) { 321 void PanelLayoutManager::ToggleMinimize(aura::Window* panel) {
322 DCHECK(panel->parent() == panel_container_); 322 DCHECK(panel->parent() == panel_container_);
323 wm::WindowState* window_state = wm::GetWindowState(panel); 323 wm::WindowState* window_state = wm::GetWindowState(panel);
324 if (window_state->IsMinimized()) 324 if (window_state->IsMinimized())
325 window_state->Restore(); 325 window_state->Restore();
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 void PanelLayoutManager::MinimizePanel(aura::Window* panel) { 577 void PanelLayoutManager::MinimizePanel(aura::Window* panel) {
578 ::wm::SetWindowVisibilityAnimationType( 578 ::wm::SetWindowVisibilityAnimationType(
579 panel, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 579 panel, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
580 ui::Layer* layer = panel->layer(); 580 ui::Layer* layer = panel->layer();
581 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator()); 581 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator());
582 panel_slide_settings.SetPreemptionStrategy( 582 panel_slide_settings.SetPreemptionStrategy(
583 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 583 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
584 panel_slide_settings.SetTransitionDuration( 584 panel_slide_settings.SetTransitionDuration(
585 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds)); 585 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds));
586 gfx::Rect bounds(panel->bounds()); 586 gfx::Rect bounds(panel->bounds());
587 bounds.Offset(GetSlideInAnimationOffset( 587 bounds.Offset(GetSlideInAnimationOffset(shelf_->alignment()));
588 shelf_->shelf_widget()->GetAlignment()));
589 SetChildBoundsDirect(panel, bounds); 588 SetChildBoundsDirect(panel, bounds);
590 panel->Hide(); 589 panel->Hide();
591 layer->SetOpacity(0); 590 layer->SetOpacity(0);
592 if (wm::IsActiveWindow(panel)) 591 if (wm::IsActiveWindow(panel))
593 wm::DeactivateWindow(panel); 592 wm::DeactivateWindow(panel);
594 Relayout(); 593 Relayout();
595 } 594 }
596 595
597 void PanelLayoutManager::RestorePanel(aura::Window* panel) { 596 void PanelLayoutManager::RestorePanel(aura::Window* panel) {
598 PanelList::iterator found = 597 PanelList::iterator found =
(...skipping 12 matching lines...) Expand all
611 // when the WindowSelectorController is restoring minimized windows so that 610 // when the WindowSelectorController is restoring minimized windows so that
612 // they actually become visible. 611 // they actually become visible.
613 WindowSelectorController* window_selector_controller = 612 WindowSelectorController* window_selector_controller =
614 Shell::GetInstance()->window_selector_controller(); 613 Shell::GetInstance()->window_selector_controller();
615 if (in_layout_ || !window_selector_controller || 614 if (in_layout_ || !window_selector_controller ||
616 (window_selector_controller->IsSelecting() && 615 (window_selector_controller->IsSelecting() &&
617 !window_selector_controller->IsRestoringMinimizedWindows())) 616 !window_selector_controller->IsRestoringMinimizedWindows()))
618 return; 617 return;
619 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 618 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
620 619
621 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); 620 ShelfAlignment alignment = shelf_->alignment();
622 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || 621 bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
623 alignment == SHELF_ALIGNMENT_BOTTOM; 622 alignment == SHELF_ALIGNMENT_BOTTOM;
624 gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen( 623 gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen(
625 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); 624 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen());
626 int panel_start_bounds = kPanelIdealSpacing; 625 int panel_start_bounds = kPanelIdealSpacing;
627 int panel_end_bounds = horizontal ? 626 int panel_end_bounds = horizontal ?
628 panel_container_->bounds().width() - kPanelIdealSpacing : 627 panel_container_->bounds().width() - kPanelIdealSpacing :
629 panel_container_->bounds().height() - kPanelIdealSpacing; 628 panel_container_->bounds().height() - kPanelIdealSpacing;
630 aura::Window* active_panel = NULL; 629 aura::Window* active_panel = NULL;
631 std::vector<VisiblePanelPositionInfo> visible_panels; 630 std::vector<VisiblePanelPositionInfo> visible_panels;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 // Keyboard hidden, restore original bounds if they exist. 950 // Keyboard hidden, restore original bounds if they exist.
952 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen()); 951 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen());
953 } 952 }
954 } 953 }
955 // This bounds change will have caused a change to the Shelf which does not 954 // This bounds change will have caused a change to the Shelf which does not
956 // propogate automatically to this class, so manually recalculate bounds. 955 // propogate automatically to this class, so manually recalculate bounds.
957 OnWindowResized(); 956 OnWindowResized();
958 } 957 }
959 958
960 } // namespace ash 959 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698