| 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 "chrome/browser/ui/panels/panel_drag_controller.h" | 5 #include "chrome/browser/ui/panels/panel_drag_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/panels/detached_panel_strip.h" | 8 #include "chrome/browser/ui/panels/detached_panel_strip.h" |
| 9 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 9 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
| 10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 const gfx::Point& mouse_location) const { | 29 const gfx::Point& mouse_location) const { |
| 30 return mouse_location.Subtract(offset_from_mouse_location_on_drag_start_); | 30 return mouse_location.Subtract(offset_from_mouse_location_on_drag_start_); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void PanelDragController::StartDragging(Panel* panel, | 33 void PanelDragController::StartDragging(Panel* panel, |
| 34 const gfx::Point& mouse_location) { | 34 const gfx::Point& mouse_location) { |
| 35 DCHECK(!dragging_panel_); | 35 DCHECK(!dragging_panel_); |
| 36 | 36 |
| 37 last_mouse_location_ = mouse_location; | 37 last_mouse_location_ = mouse_location; |
| 38 offset_from_mouse_location_on_drag_start_ = | 38 offset_from_mouse_location_on_drag_start_ = |
| 39 mouse_location.Subtract(panel->GetBounds().origin()); | 39 mouse_location.DistanceFrom(panel->GetBounds().origin()); |
| 40 | 40 |
| 41 dragging_panel_ = panel; | 41 dragging_panel_ = panel; |
| 42 dragging_panel_->SetPreviewMode(true); | 42 dragging_panel_->SetPreviewMode(true); |
| 43 | 43 |
| 44 // Keep track of original strip and placement for the case that the drag is | 44 // Keep track of original strip and placement for the case that the drag is |
| 45 // cancelled. | 45 // cancelled. |
| 46 dragging_panel_original_strip_ = dragging_panel_->panel_strip(); | 46 dragging_panel_original_strip_ = dragging_panel_->panel_strip(); |
| 47 dragging_panel_original_strip_->SavePanelPlacement(dragging_panel_); | 47 dragging_panel_original_strip_->SavePanelPlacement(dragging_panel_); |
| 48 | 48 |
| 49 dragging_panel_original_strip_->StartDraggingPanelWithinStrip( | 49 dragging_panel_original_strip_->StartDraggingPanelWithinStrip( |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 if (dragging_panel_ == panel) { | 217 if (dragging_panel_ == panel) { |
| 218 // The saved placement is no longer needed. | 218 // The saved placement is no longer needed. |
| 219 dragging_panel_original_strip_->DiscardSavedPanelPlacement(); | 219 dragging_panel_original_strip_->DiscardSavedPanelPlacement(); |
| 220 | 220 |
| 221 // Clear the dragging state. | 221 // Clear the dragging state. |
| 222 dragging_panel_->panel_strip()->ClearDraggingStateWhenPanelClosed(); | 222 dragging_panel_->panel_strip()->ClearDraggingStateWhenPanelClosed(); |
| 223 | 223 |
| 224 dragging_panel_ = NULL; | 224 dragging_panel_ = NULL; |
| 225 } | 225 } |
| 226 } | 226 } |
| OLD | NEW |