Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_drag_controller.h |
| diff --git a/chrome/browser/ui/panels/panel_drag_controller.h b/chrome/browser/ui/panels/panel_drag_controller.h |
| index a58b7644077813d31c2cd5fda3a5ed3d4ede0079..44dec1afaca53ed2cbdff5125ad90de81cca1f05 100644 |
| --- a/chrome/browser/ui/panels/panel_drag_controller.h |
| +++ b/chrome/browser/ui/panels/panel_drag_controller.h |
| @@ -11,16 +11,20 @@ |
| #include "ui/gfx/point.h" |
| class Panel; |
| +class PanelManager; |
| +class PanelStrip; |
| // Responsible for handling drags initiated for all panels, including both |
| // intra-strip and inter-strip drags. |
| class PanelDragController { |
| public: |
| - PanelDragController(); |
| + explicit PanelDragController(PanelManager* panel_manager); |
| ~PanelDragController(); |
| - void StartDragging(Panel* panel); |
| - void Drag(int delta_x, int delta_y); |
| + // Drags the given panel. |
| + // |mouse_location| is in screen coordinate system. |
| + void StartDragging(Panel* panel, const gfx::Point& mouse_location); |
| + void Drag(const gfx::Point& mouse_location); |
| void EndDragging(bool cancelled); |
| // Asynchronous confirmation of panel having been closed. |
| @@ -29,18 +33,47 @@ class PanelDragController { |
| bool IsDragging() const { return dragging_panel_ != NULL; } |
| Panel* dragging_panel() const { return dragging_panel_; } |
| - gfx::Point dragging_panel_original_position() const { |
| - return dragging_panel_original_position_; |
| + |
| +#ifdef UNIT_TEST |
| + static int GetDetachDockedPanelThreshold() { |
| + return kDetachDockedPanelThreshold; |
| + } |
| + |
| + static int GetDockDetachedPanelThreshold() { |
| + return kDockDetachedPanelThreshold; |
| } |
| +#endif |
| private: |
| + // Used to figure out if the panel can be dragged to other strip. |
| + PanelStrip* ComputeDragTagetStrip( |
| + const gfx::Point& mouse_location, gfx::Point* new_panel_position) const; |
| + bool CanDragToDockedStrip( |
| + const gfx::Point& mouse_location, gfx::Point* new_panel_position) const; |
| + bool CanDragToDetachedStrip( |
| + const gfx::Point& mouse_location, gfx::Point* new_panel_position) const; |
| + |
| + PanelManager* panel_manager_; // Weak, owns us. |
| + |
| // Panel currently being dragged. |
| Panel* dragging_panel_; |
| - // Original position, in screen coordinate system, of the panel being dragged. |
| - // This is used to get back to the original position when we cancel the |
| - // dragging. |
| - gfx::Point dragging_panel_original_position_; |
| + // The original panel strip that the drag is initiated. |
|
jennb
2012/03/03 02:19:33
Fix grammar.
jianli
2012/03/07 19:14:31
Done.
|
| + PanelStrip* dragging_panel_original_strip_; |
| + |
| + // The mouse location, in screen coordinates, when mouse press/drag event is |
| + // received last time. |
|
jennb
2012/03/03 02:19:33
'last time' ?
jianli
2012/03/07 19:14:31
Done.
|
| + gfx::Point last_mouse_location_; |
| + |
| + // The mouse location, in screen coordinates, when the drag starts at the |
| + // docked strip. |
| + gfx::Point mouse_location_on_docked_; |
| + |
| + // The threshold to detach a docked panel to make it free-floating. |
|
jennb
2012/03/03 02:19:33
These comments simply repeat the var name. Explain
jianli
2012/03/07 19:14:31
Done.
|
| + static const int kDetachDockedPanelThreshold; |
| + |
| + // The threshold to dock a detached panel. |
| + static const int kDockDetachedPanelThreshold; |
| DISALLOW_COPY_AND_ASSIGN(PanelDragController); |
| }; |