| 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 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
| 12 | 12 |
| 13 class Panel; | 13 class Panel; |
| 14 class PanelManager; |
| 15 class PanelStrip; |
| 14 | 16 |
| 15 // Responsible for handling drags initiated for all panels, including both | 17 // Responsible for handling drags initiated for all panels, including both |
| 16 // intra-strip and inter-strip drags. | 18 // intra-strip and inter-strip drags. |
| 17 class PanelDragController { | 19 class PanelDragController { |
| 18 public: | 20 public: |
| 19 PanelDragController(); | 21 explicit PanelDragController(PanelManager* panel_manager); |
| 20 ~PanelDragController(); | 22 ~PanelDragController(); |
| 21 | 23 |
| 22 void StartDragging(Panel* panel); | 24 // Drags the given panel. |
| 23 void Drag(int delta_x, int delta_y); | 25 // |mouse_location| is in screen coordinate system. |
| 26 void StartDragging(Panel* panel, const gfx::Point& mouse_location); |
| 27 void Drag(const gfx::Point& mouse_location); |
| 24 void EndDragging(bool cancelled); | 28 void EndDragging(bool cancelled); |
| 25 | 29 |
| 26 // Asynchronous confirmation of panel having been closed. | 30 // Asynchronous confirmation of panel having been closed. |
| 27 void OnPanelClosed(Panel* panel); | 31 void OnPanelClosed(Panel* panel); |
| 28 | 32 |
| 29 bool IsDragging() const { return dragging_panel_ != NULL; } | 33 bool IsDragging() const { return dragging_panel_ != NULL; } |
| 30 | 34 |
| 31 Panel* dragging_panel() const { return dragging_panel_; } | 35 Panel* dragging_panel() const { return dragging_panel_; } |
| 32 gfx::Point dragging_panel_original_position() const { | 36 gfx::Point dragging_panel_original_position() const { |
| 33 return dragging_panel_original_position_; | 37 return dragging_panel_original_position_; |
| 34 } | 38 } |
| 39 bool has_dragged_to_other_strip() const { |
| 40 return has_dragged_to_other_strip_; |
| 41 } |
| 35 | 42 |
| 36 private: | 43 private: |
| 44 // Returns the panel strip to drag to. |
| 45 PanelStrip* CanDragToDockedStrip(const gfx::Point& mouse_location) const; |
| 46 PanelStrip* CanDragToDetachedStrip(const gfx::Point& mouse_location) const; |
| 47 |
| 48 // Helper method to transit the dragging panel to the new strip at the new |
| 49 // position. |
| 50 static void MoveToStrip(Panel* panel, |
| 51 PanelStrip* new_strip, |
| 52 const gfx::Point& new_position); |
| 53 |
| 54 PanelManager* panel_manager_; // Weak, owns us. |
| 55 |
| 37 // Panel currently being dragged. | 56 // Panel currently being dragged. |
| 38 Panel* dragging_panel_; | 57 Panel* dragging_panel_; |
| 39 | 58 |
| 40 // Original position, in screen coordinate system, of the panel being dragged. | 59 // The original panel strip that the drag is initiated. |
| 60 PanelStrip* dragging_panel_original_strip_; |
| 61 |
| 62 // Original position, in screen coordinates, of the panel being dragged. |
| 41 // This is used to get back to the original position when we cancel the | 63 // This is used to get back to the original position when we cancel the |
| 42 // dragging. | 64 // dragging. |
| 43 gfx::Point dragging_panel_original_position_; | 65 gfx::Point dragging_panel_original_position_; |
| 44 | 66 |
| 67 // The mouse location, in screen coordinates, when mouse press/drag event is |
| 68 // received last time. |
| 69 gfx::Point last_mouse_location_; |
| 70 |
| 71 // When the panel is dragged within the docked strip, y delta of the drag is |
| 72 // not applied to new panel position. We need to keep track of the total |
| 73 // omitted delta values so that the panel can jump immediately to the position |
| 74 // where the panel detach is triggered. |
| 75 int total_ommitted_delta_y_; |
| 76 |
| 77 // The flag that indicates if the dragging panel has ever been dragged into |
| 78 // other strip. |
| 79 bool has_dragged_to_other_strip_; |
| 80 |
| 45 DISALLOW_COPY_AND_ASSIGN(PanelDragController); | 81 DISALLOW_COPY_AND_ASSIGN(PanelDragController); |
| 46 }; | 82 }; |
| 47 | 83 |
| 48 #endif // CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ | 84 #endif // CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ |
| OLD | NEW |