| 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 | 14 |
| 15 // Responsible for handling drags initiated for all panels, including both | 15 // Responsible for handling drags initiated for all panels, including both |
| 16 // intra-strip and inter-strip drags. | 16 // intra-strip and inter-strip drags. |
| 17 class PanelDragController { | 17 class PanelDragController { |
| 18 public: | 18 public: |
| 19 PanelDragController(); | 19 PanelDragController(); |
| 20 ~PanelDragController(); | 20 ~PanelDragController(); |
| 21 | 21 |
| 22 void StartDragging(Panel* panel); | 22 // Drags the given panel. |
| 23 void Drag(int delta_x, int delta_y); | 23 // |mouse_location| is in screen coordinate system. |
| 24 void StartDragging(Panel* panel, const gfx::Point& mouse_location); |
| 25 void Drag(const gfx::Point& mouse_location); |
| 24 void EndDragging(bool cancelled); | 26 void EndDragging(bool cancelled); |
| 25 | 27 |
| 26 // Asynchronous confirmation of panel having been closed. | 28 // Asynchronous confirmation of panel having been closed. |
| 27 void OnPanelClosed(Panel* panel); | 29 void OnPanelClosed(Panel* panel); |
| 28 | 30 |
| 29 bool IsDragging() const { return dragging_panel_ != NULL; } | 31 bool IsDragging() const { return dragging_panel_ != NULL; } |
| 30 | 32 |
| 31 Panel* dragging_panel() const { return dragging_panel_; } | 33 Panel* dragging_panel() const { return dragging_panel_; } |
| 32 gfx::Point dragging_panel_original_position() const { | 34 gfx::Point dragging_panel_original_position() const { |
| 33 return dragging_panel_original_position_; | 35 return dragging_panel_original_position_; |
| 34 } | 36 } |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 // Panel currently being dragged. | 39 // Panel currently being dragged. |
| 38 Panel* dragging_panel_; | 40 Panel* dragging_panel_; |
| 39 | 41 |
| 40 // Original position, in screen coordinate system, of the panel being dragged. | 42 // Original position, in screen coordinate system, of the panel being dragged. |
| 41 // This is used to get back to the original position when we cancel the | 43 // This is used to get back to the original position when we cancel the |
| 42 // dragging. | 44 // dragging. |
| 43 gfx::Point dragging_panel_original_position_; | 45 gfx::Point dragging_panel_original_position_; |
| 44 | 46 |
| 47 // The mouse location, in screen coordinates, when StartDragging or Drag is |
| 48 // called pveviously. |
| 49 gfx::Point last_mouse_location_; |
| 50 |
| 45 DISALLOW_COPY_AND_ASSIGN(PanelDragController); | 51 DISALLOW_COPY_AND_ASSIGN(PanelDragController); |
| 46 }; | 52 }; |
| 47 | 53 |
| 48 #endif // CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ | 54 #endif // CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ |
| OLD | NEW |