| 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/common/panels/panel_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/wm/common/panels/panel_layout_manager.h" |
| 7 #include "ash/wm/common/shelf/wm_shelf.h" | 8 #include "ash/wm/common/shelf/wm_shelf.h" |
| 8 #include "ash/wm/common/window_parenting_utils.h" | 9 #include "ash/wm/common/window_parenting_utils.h" |
| 9 #include "ash/wm/common/window_state.h" | 10 #include "ash/wm/common/window_state.h" |
| 10 #include "ash/wm/common/wm_root_window_controller.h" | 11 #include "ash/wm/common/wm_root_window_controller.h" |
| 11 #include "ash/wm/common/wm_shell_window_ids.h" | 12 #include "ash/wm/common/wm_shell_window_ids.h" |
| 12 #include "ash/wm/common/wm_window.h" | 13 #include "ash/wm/common/wm_window.h" |
| 13 #include "ash/wm/panels/panel_layout_manager.h" | |
| 14 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
| 15 #include "ui/base/ui_base_types.h" | 15 #include "ui/base/ui_base_types.h" |
| 16 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const int kPanelSnapToLauncherDistance = 30; | 22 const int kPanelSnapToLauncherDistance = 30; |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 PanelWindowResizer::~PanelWindowResizer() { | 26 PanelWindowResizer::~PanelWindowResizer() {} |
| 27 } | |
| 28 | 27 |
| 29 // static | 28 // static |
| 30 PanelWindowResizer* | 29 PanelWindowResizer* PanelWindowResizer::Create( |
| 31 PanelWindowResizer::Create(WindowResizer* next_window_resizer, | 30 WindowResizer* next_window_resizer, |
| 32 wm::WindowState* window_state) { | 31 wm::WindowState* window_state) { |
| 33 return new PanelWindowResizer(next_window_resizer, window_state); | 32 return new PanelWindowResizer(next_window_resizer, window_state); |
| 34 } | 33 } |
| 35 | 34 |
| 36 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 35 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 37 last_location_ = GetTarget()->GetParent()->ConvertPointToScreen(location); | 36 last_location_ = GetTarget()->GetParent()->ConvertPointToScreen(location); |
| 38 if (!did_move_or_resize_) { | 37 if (!did_move_or_resize_) { |
| 39 did_move_or_resize_ = true; | 38 did_move_or_resize_ = true; |
| 40 StartedDragging(); | 39 StartedDragging(); |
| 41 } | 40 } |
| 42 | 41 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 gfx::Point* offset) { | 114 gfx::Point* offset) { |
| 116 bool should_attach = false; | 115 bool should_attach = false; |
| 117 if (panel_container_) { | 116 if (panel_container_) { |
| 118 PanelLayoutManager* panel_layout_manager = | 117 PanelLayoutManager* panel_layout_manager = |
| 119 PanelLayoutManager::Get(panel_container_); | 118 PanelLayoutManager::Get(panel_container_); |
| 120 gfx::Rect launcher_bounds = GetTarget()->GetParent()->ConvertRectFromScreen( | 119 gfx::Rect launcher_bounds = GetTarget()->GetParent()->ConvertRectFromScreen( |
| 121 panel_layout_manager->shelf()->GetWindow()->GetBoundsInScreen()); | 120 panel_layout_manager->shelf()->GetWindow()->GetBoundsInScreen()); |
| 122 switch (panel_layout_manager->shelf()->GetAlignment()) { | 121 switch (panel_layout_manager->shelf()->GetAlignment()) { |
| 123 case wm::SHELF_ALIGNMENT_BOTTOM: | 122 case wm::SHELF_ALIGNMENT_BOTTOM: |
| 124 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: | 123 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| 125 if (bounds.bottom() >= (launcher_bounds.y() - | 124 if (bounds.bottom() >= |
| 126 kPanelSnapToLauncherDistance)) { | 125 (launcher_bounds.y() - kPanelSnapToLauncherDistance)) { |
| 127 should_attach = true; | 126 should_attach = true; |
| 128 offset->set_y(launcher_bounds.y() - bounds.height() - bounds.y()); | 127 offset->set_y(launcher_bounds.y() - bounds.height() - bounds.y()); |
| 129 } | 128 } |
| 130 break; | 129 break; |
| 131 case wm::SHELF_ALIGNMENT_LEFT: | 130 case wm::SHELF_ALIGNMENT_LEFT: |
| 132 if (bounds.x() <= (launcher_bounds.right() + | 131 if (bounds.x() <= |
| 133 kPanelSnapToLauncherDistance)) { | 132 (launcher_bounds.right() + kPanelSnapToLauncherDistance)) { |
| 134 should_attach = true; | 133 should_attach = true; |
| 135 offset->set_x(launcher_bounds.right() - bounds.x()); | 134 offset->set_x(launcher_bounds.right() - bounds.x()); |
| 136 } | 135 } |
| 137 break; | 136 break; |
| 138 case wm::SHELF_ALIGNMENT_RIGHT: | 137 case wm::SHELF_ALIGNMENT_RIGHT: |
| 139 if (bounds.right() >= (launcher_bounds.x() - | 138 if (bounds.right() >= |
| 140 kPanelSnapToLauncherDistance)) { | 139 (launcher_bounds.x() - kPanelSnapToLauncherDistance)) { |
| 141 should_attach = true; | 140 should_attach = true; |
| 142 offset->set_x(launcher_bounds.x() - bounds.width() - bounds.x()); | 141 offset->set_x(launcher_bounds.x() - bounds.width() - bounds.x()); |
| 143 } | 142 } |
| 144 break; | 143 break; |
| 145 } | 144 } |
| 146 } | 145 } |
| 147 return should_attach; | 146 return should_attach; |
| 148 } | 147 } |
| 149 | 148 |
| 150 void PanelWindowResizer::StartedDragging() { | 149 void PanelWindowResizer::StartedDragging() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 193 |
| 195 void PanelWindowResizer::UpdateLauncherPosition() { | 194 void PanelWindowResizer::UpdateLauncherPosition() { |
| 196 if (panel_container_) { | 195 if (panel_container_) { |
| 197 PanelLayoutManager::Get(panel_container_) | 196 PanelLayoutManager::Get(panel_container_) |
| 198 ->shelf() | 197 ->shelf() |
| 199 ->UpdateIconPositionForWindow(GetTarget()); | 198 ->UpdateIconPositionForWindow(GetTarget()); |
| 200 } | 199 } |
| 201 } | 200 } |
| 202 | 201 |
| 203 } // namespace ash | 202 } // namespace ash |
| OLD | NEW |