Chromium Code Reviews| 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 // Drags the given panel. | 24 // Drags the given panel. |
| 23 // |mouse_location| is in screen coordinate system. | 25 // |mouse_location| is in screen coordinate system. |
| 24 void StartDragging(Panel* panel, const gfx::Point& mouse_location); | 26 void StartDragging(Panel* panel, const gfx::Point& mouse_location); |
| 25 void Drag(const gfx::Point& mouse_location); | 27 void Drag(const gfx::Point& mouse_location); |
| 26 void EndDragging(bool cancelled); | 28 void EndDragging(bool cancelled); |
| 27 | 29 |
| 28 // Asynchronous confirmation of panel having been closed. | 30 // Asynchronous confirmation of panel having been closed. |
| 29 void OnPanelClosed(Panel* panel); | 31 void OnPanelClosed(Panel* panel); |
| 30 | 32 |
| 31 bool IsDragging() const { return dragging_panel_ != NULL; } | 33 bool IsDragging() const { return dragging_panel_ != NULL; } |
| 32 | 34 |
| 33 Panel* dragging_panel() const { return dragging_panel_; } | 35 Panel* dragging_panel() const { return dragging_panel_; } |
| 34 gfx::Point dragging_panel_original_position() const { | 36 |
| 35 return dragging_panel_original_position_; | 37 #ifdef UNIT_TEST |
| 38 static int GetDetachDockedPanelThreshold() { | |
| 39 return kDetachDockedPanelThreshold; | |
| 36 } | 40 } |
| 37 | 41 |
| 42 static int GetDockDetachedPanelThreshold() { | |
| 43 return kDockDetachedPanelThreshold; | |
| 44 } | |
| 45 #endif | |
| 46 | |
| 38 private: | 47 private: |
| 48 // Used to figure out if the panel can be dragged to other strip. | |
|
jennb
2012/03/08 23:41:09
Comment what the params and return values mean.
jianli
2012/03/09 21:48:58
Done.
| |
| 49 PanelStrip* ComputeDragTagetStrip( | |
|
jennb
2012/03/08 23:41:09
typo: Taget
jianli
2012/03/09 21:48:58
Done.
| |
| 50 const gfx::Point& mouse_location, gfx::Point* new_panel_position) const; | |
| 51 bool CanDragToDockedStrip( | |
| 52 const gfx::Point& mouse_location, gfx::Point* new_panel_position) const; | |
| 53 bool CanDragToDetachedStrip( | |
| 54 const gfx::Point& mouse_location, gfx::Point* new_panel_position) const; | |
| 55 | |
| 56 int GetOffsetToDockedAreaBottom( | |
|
jennb
2012/03/08 23:41:09
Needs comment. Unclear what this is.
jianli
2012/03/09 21:48:58
Removed since it is not needed now.
| |
| 57 const gfx::Point& target_panel_position) const; | |
| 58 | |
| 59 PanelManager* panel_manager_; // Weak, owns us. | |
| 60 | |
| 39 // Panel currently being dragged. | 61 // Panel currently being dragged. |
| 40 Panel* dragging_panel_; | 62 Panel* dragging_panel_; |
| 41 | 63 |
| 42 // Original position, in screen coordinate system, of the panel being dragged. | 64 // The original panel strip when the drag is started. |
| 43 // This is used to get back to the original position when we cancel the | 65 PanelStrip* dragging_panel_original_strip_; |
| 44 // dragging. | |
| 45 gfx::Point dragging_panel_original_position_; | |
| 46 | 66 |
| 47 // The mouse location, in screen coordinates, when StartDragging or Drag was | 67 // The mouse location, in screen coordinates, when StartDragging or Drag was |
| 48 // pveviously called. | 68 // pveviously called. |
| 49 gfx::Point last_mouse_location_; | 69 gfx::Point last_mouse_location_; |
| 50 | 70 |
| 71 // The offset from mouse location to the panel position when the drag | |
| 72 // starts. | |
| 73 gfx::Point offset_from_mouse_location_on_drag_start_; | |
|
jennb
2012/03/08 23:41:09
This is a delta of some sort? I don't understand t
jianli
2012/03/09 21:48:58
Comment updated.
| |
| 74 | |
| 75 // The minimum distance that the docked panel gets dragged up in order to | |
| 76 // make it free-floating. | |
| 77 static const int kDetachDockedPanelThreshold; | |
| 78 | |
| 79 // Indicates how close the bottom of the detached panel is to the bottom of | |
| 80 // the docked area such that the detached panel becomes docked. | |
| 81 static const int kDockDetachedPanelThreshold; | |
| 82 | |
| 51 DISALLOW_COPY_AND_ASSIGN(PanelDragController); | 83 DISALLOW_COPY_AND_ASSIGN(PanelDragController); |
| 52 }; | 84 }; |
| 53 | 85 |
| 54 #endif // CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ | 86 #endif // CHROME_BROWSER_UI_PANELS_PANEL_DRAG_CONTROLLER_H_ |
| OLD | NEW |