| OLD | NEW |
| 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 |
| 11 #include "ash/keyboard/keyboard_observer_register.h" | 11 #include "ash/keyboard/keyboard_observer_register.h" |
| 12 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
| 13 #include "ash/public/cpp/window_properties.h" | 13 #include "ash/public/cpp/window_properties.h" |
| 14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/shelf/wm_shelf.h" | 15 #include "ash/shelf/shelf.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_port.h" | 17 #include "ash/shell_port.h" |
| 18 #include "ash/wm/overview/window_selector_controller.h" | 18 #include "ash/wm/overview/window_selector_controller.h" |
| 19 #include "ash/wm/window_animation_types.h" | 19 #include "ash/wm/window_animation_types.h" |
| 20 #include "ash/wm/window_parenting_utils.h" | 20 #include "ash/wm/window_parenting_utils.h" |
| 21 #include "ash/wm/window_properties.h" | 21 #include "ash/wm/window_properties.h" |
| 22 #include "ash/wm/window_state.h" | 22 #include "ash/wm/window_state.h" |
| 23 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
| 24 #include "ash/wm_window.h" | 24 #include "ash/wm_window.h" |
| 25 #include "base/auto_reset.h" | 25 #include "base/auto_reset.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 } // namespace | 183 } // namespace |
| 184 | 184 |
| 185 class PanelCalloutWidget : public views::Widget { | 185 class PanelCalloutWidget : public views::Widget { |
| 186 public: | 186 public: |
| 187 explicit PanelCalloutWidget(Window* container) : background_(nullptr) { | 187 explicit PanelCalloutWidget(Window* container) : background_(nullptr) { |
| 188 InitWidget(container); | 188 InitWidget(container); |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Updates the bounds based on the shelf alignment. | 191 // Updates the bounds based on the shelf alignment. |
| 192 void UpdateBounds(WmShelf* shelf) { | 192 void UpdateBounds(Shelf* shelf) { |
| 193 Window* window = this->GetNativeWindow(); | 193 Window* window = this->GetNativeWindow(); |
| 194 gfx::Rect callout_bounds = window->bounds(); | 194 gfx::Rect callout_bounds = window->bounds(); |
| 195 if (shelf->IsHorizontalAlignment()) { | 195 if (shelf->IsHorizontalAlignment()) { |
| 196 callout_bounds.set_width(kArrowWidth); | 196 callout_bounds.set_width(kArrowWidth); |
| 197 callout_bounds.set_height(kArrowHeight); | 197 callout_bounds.set_height(kArrowHeight); |
| 198 } else { | 198 } else { |
| 199 callout_bounds.set_width(kArrowHeight); | 199 callout_bounds.set_width(kArrowHeight); |
| 200 callout_bounds.set_height(kArrowWidth); | 200 callout_bounds.set_height(kArrowWidth); |
| 201 } | 201 } |
| 202 Window* parent = window->parent(); | 202 Window* parent = window->parent(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 DCHECK(!dragged_panel_); | 298 DCHECK(!dragged_panel_); |
| 299 dragged_panel_ = panel; | 299 dragged_panel_ = panel; |
| 300 Relayout(); | 300 Relayout(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void PanelLayoutManager::FinishDragging() { | 303 void PanelLayoutManager::FinishDragging() { |
| 304 dragged_panel_ = nullptr; | 304 dragged_panel_ = nullptr; |
| 305 Relayout(); | 305 Relayout(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void PanelLayoutManager::SetShelf(WmShelf* shelf) { | 308 void PanelLayoutManager::SetShelf(Shelf* shelf) { |
| 309 DCHECK(!shelf_); | 309 DCHECK(!shelf_); |
| 310 shelf_ = shelf; | 310 shelf_ = shelf; |
| 311 shelf_->AddObserver(this); | 311 shelf_->AddObserver(this); |
| 312 WillChangeVisibilityState(shelf_->GetVisibilityState()); | 312 WillChangeVisibilityState(shelf_->GetVisibilityState()); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void PanelLayoutManager::ToggleMinimize(Window* panel) { | 315 void PanelLayoutManager::ToggleMinimize(Window* panel) { |
| 316 DCHECK(panel->parent() == panel_container_); | 316 DCHECK(panel->parent() == panel_container_); |
| 317 wm::WindowState* window_state = wm::GetWindowState(panel); | 317 wm::WindowState* window_state = wm::GetWindowState(panel); |
| 318 if (window_state->IsMinimized()) | 318 if (window_state->IsMinimized()) |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 577 |
| 578 ::wm::SetWindowVisibilityAnimationType( | 578 ::wm::SetWindowVisibilityAnimationType( |
| 579 panel, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); | 579 panel, wm::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(shelf_->GetAlignment())); | 587 bounds.Offset(GetSlideInAnimationOffset(shelf_->alignment())); |
| 588 SetChildBoundsDirect(panel, bounds); | 588 SetChildBoundsDirect(panel, bounds); |
| 589 panel->Hide(); | 589 panel->Hide(); |
| 590 layer->SetOpacity(0); | 590 layer->SetOpacity(0); |
| 591 if (::wm::IsActiveWindow(panel)) | 591 if (::wm::IsActiveWindow(panel)) |
| 592 ::wm::DeactivateWindow(panel); | 592 ::wm::DeactivateWindow(panel); |
| 593 Relayout(); | 593 Relayout(); |
| 594 } | 594 } |
| 595 | 595 |
| 596 void PanelLayoutManager::RestorePanel(Window* panel) { | 596 void PanelLayoutManager::RestorePanel(Window* panel) { |
| 597 PanelList::iterator found = | 597 PanelList::iterator found = |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 std::max(current_bounds.x() - callout_bounds.x(), | 851 std::max(current_bounds.x() - callout_bounds.x(), |
| 852 callout_bounds.right() - current_bounds.right()); | 852 callout_bounds.right() - current_bounds.right()); |
| 853 } else { | 853 } else { |
| 854 callout_bounds.set_y(icon_bounds.y() + | 854 callout_bounds.set_y(icon_bounds.y() + |
| 855 (icon_bounds.height() - callout_bounds.height()) / | 855 (icon_bounds.height() - callout_bounds.height()) / |
| 856 2); | 856 2); |
| 857 distance_until_over_panel = | 857 distance_until_over_panel = |
| 858 std::max(current_bounds.y() - callout_bounds.y(), | 858 std::max(current_bounds.y() - callout_bounds.y(), |
| 859 callout_bounds.bottom() - current_bounds.bottom()); | 859 callout_bounds.bottom() - current_bounds.bottom()); |
| 860 } | 860 } |
| 861 if (shelf_->GetAlignment() == SHELF_ALIGNMENT_LEFT) | 861 if (shelf_->alignment() == SHELF_ALIGNMENT_LEFT) |
| 862 callout_bounds.set_x(bounds.x() - callout_bounds.width()); | 862 callout_bounds.set_x(bounds.x() - callout_bounds.width()); |
| 863 else if (shelf_->GetAlignment() == SHELF_ALIGNMENT_RIGHT) | 863 else if (shelf_->alignment() == SHELF_ALIGNMENT_RIGHT) |
| 864 callout_bounds.set_x(bounds.right()); | 864 callout_bounds.set_x(bounds.right()); |
| 865 else | 865 else |
| 866 callout_bounds.set_y(bounds.bottom()); | 866 callout_bounds.set_y(bounds.bottom()); |
| 867 ::wm::ConvertRectFromScreen(callout_widget_window->parent(), | 867 ::wm::ConvertRectFromScreen(callout_widget_window->parent(), |
| 868 &callout_bounds); | 868 &callout_bounds); |
| 869 | 869 |
| 870 SetChildBoundsDirect(callout_widget_window, callout_bounds); | 870 SetChildBoundsDirect(callout_widget_window, callout_bounds); |
| 871 DCHECK_EQ(panel_container_, callout_widget_window->parent()); | 871 DCHECK_EQ(panel_container_, callout_widget_window->parent()); |
| 872 DCHECK_EQ(panel_container_, panel->parent()); | 872 DCHECK_EQ(panel_container_, panel->parent()); |
| 873 panel_container_->StackChildAbove(callout_widget_window, panel); | 873 panel_container_->StackChildAbove(callout_widget_window, panel); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 // This bounds change will have caused a change to the Shelf which does not | 937 // This bounds change will have caused a change to the Shelf which does not |
| 938 // propogate automatically to this class, so manually recalculate bounds. | 938 // propogate automatically to this class, so manually recalculate bounds. |
| 939 OnWindowResized(); | 939 OnWindowResized(); |
| 940 } | 940 } |
| 941 | 941 |
| 942 void PanelLayoutManager::OnKeyboardClosed() { | 942 void PanelLayoutManager::OnKeyboardClosed() { |
| 943 keyboard_observer_.RemoveAll(); | 943 keyboard_observer_.RemoveAll(); |
| 944 } | 944 } |
| 945 | 945 |
| 946 } // namespace ash | 946 } // namespace ash |
| OLD | NEW |