| 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_window_resizer.h" | 5 #include "ash/wm/panels/panel_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/shelf/shelf.h" | 7 #include "ash/wm/common/shelf/wm_shelf.h" |
| 8 #include "ash/shelf/shelf_types.h" | |
| 9 #include "ash/shelf/shelf_widget.h" | |
| 10 #include "ash/shell_window_ids.h" | |
| 11 #include "ash/wm/aura/wm_window_aura.h" | |
| 12 #include "ash/wm/common/window_parenting_utils.h" | 8 #include "ash/wm/common/window_parenting_utils.h" |
| 13 #include "ash/wm/common/window_state.h" | 9 #include "ash/wm/common/window_state.h" |
| 14 #include "ash/wm/common/wm_root_window_controller.h" | 10 #include "ash/wm/common/wm_root_window_controller.h" |
| 11 #include "ash/wm/common/wm_shell_window_ids.h" |
| 15 #include "ash/wm/common/wm_window.h" | 12 #include "ash/wm/common/wm_window.h" |
| 16 #include "ash/wm/panels/panel_layout_manager.h" | 13 #include "ash/wm/panels/panel_layout_manager.h" |
| 17 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
| 18 #include "ui/base/ui_base_types.h" | 15 #include "ui/base/ui_base_types.h" |
| 19 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
| 20 #include "ui/views/widget/widget.h" | |
| 21 | 17 |
| 22 namespace ash { | 18 namespace ash { |
| 23 | 19 |
| 24 namespace { | 20 namespace { |
| 25 | 21 |
| 26 const int kPanelSnapToLauncherDistance = 30; | 22 const int kPanelSnapToLauncherDistance = 30; |
| 27 | 23 |
| 28 } // namespace | 24 } // namespace |
| 29 | 25 |
| 30 PanelWindowResizer::~PanelWindowResizer() { | 26 PanelWindowResizer::~PanelWindowResizer() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 initial_panel_container_ = panel_container_; | 111 initial_panel_container_ = panel_container_; |
| 116 } | 112 } |
| 117 | 113 |
| 118 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, | 114 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, |
| 119 gfx::Point* offset) { | 115 gfx::Point* offset) { |
| 120 bool should_attach = false; | 116 bool should_attach = false; |
| 121 if (panel_container_) { | 117 if (panel_container_) { |
| 122 PanelLayoutManager* panel_layout_manager = | 118 PanelLayoutManager* panel_layout_manager = |
| 123 PanelLayoutManager::Get(panel_container_); | 119 PanelLayoutManager::Get(panel_container_); |
| 124 gfx::Rect launcher_bounds = GetTarget()->GetParent()->ConvertRectFromScreen( | 120 gfx::Rect launcher_bounds = GetTarget()->GetParent()->ConvertRectFromScreen( |
| 125 panel_layout_manager->shelf() | 121 panel_layout_manager->shelf()->GetWindow()->GetBoundsInScreen()); |
| 126 ->shelf_widget() | 122 switch (panel_layout_manager->shelf()->GetAlignment()) { |
| 127 ->GetWindowBoundsInScreen()); | |
| 128 switch (panel_layout_manager->shelf()->alignment()) { | |
| 129 case wm::SHELF_ALIGNMENT_BOTTOM: | 123 case wm::SHELF_ALIGNMENT_BOTTOM: |
| 130 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: | 124 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| 131 if (bounds.bottom() >= (launcher_bounds.y() - | 125 if (bounds.bottom() >= (launcher_bounds.y() - |
| 132 kPanelSnapToLauncherDistance)) { | 126 kPanelSnapToLauncherDistance)) { |
| 133 should_attach = true; | 127 should_attach = true; |
| 134 offset->set_y(launcher_bounds.y() - bounds.height() - bounds.y()); | 128 offset->set_y(launcher_bounds.y() - bounds.height() - bounds.y()); |
| 135 } | 129 } |
| 136 break; | 130 break; |
| 137 case wm::SHELF_ALIGNMENT_LEFT: | 131 case wm::SHELF_ALIGNMENT_LEFT: |
| 138 if (bounds.x() <= (launcher_bounds.right() + | 132 if (bounds.x() <= (launcher_bounds.right() + |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if (initial_panel_container_ != panel_container_) | 189 if (initial_panel_container_ != panel_container_) |
| 196 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); | 190 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); |
| 197 if (panel_container_) | 191 if (panel_container_) |
| 198 PanelLayoutManager::Get(panel_container_)->FinishDragging(); | 192 PanelLayoutManager::Get(panel_container_)->FinishDragging(); |
| 199 } | 193 } |
| 200 | 194 |
| 201 void PanelWindowResizer::UpdateLauncherPosition() { | 195 void PanelWindowResizer::UpdateLauncherPosition() { |
| 202 if (panel_container_) { | 196 if (panel_container_) { |
| 203 PanelLayoutManager::Get(panel_container_) | 197 PanelLayoutManager::Get(panel_container_) |
| 204 ->shelf() | 198 ->shelf() |
| 205 ->UpdateIconPositionForWindow( | 199 ->UpdateIconPositionForWindow(GetTarget()); |
| 206 wm::WmWindowAura::GetAuraWindow(GetTarget())); | |
| 207 } | 200 } |
| 208 } | 201 } |
| 209 | 202 |
| 210 } // namespace ash | 203 } // namespace ash |
| OLD | NEW |