Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3609)

Unified Diff: chrome/browser/ui/panels/panel_drag_controller.h

Issue 9546001: Support detaching/attaching panels via inter-strip drags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fix per feedback Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 df944a586e685d5958d7d40e9d3f160d675f9d53..d91bddb4ed614192143b8ef2c99f07fcbcd0d425 100644
--- a/chrome/browser/ui/panels/panel_drag_controller.h
+++ b/chrome/browser/ui/panels/panel_drag_controller.h
@@ -11,12 +11,14 @@
#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();
// Drags the given panel.
@@ -31,23 +33,50 @@ 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 when the drag is started.
+ PanelStrip* dragging_panel_original_strip_;
// The mouse location, in screen coordinates, when StartDragging or Drag was
// pveviously called.
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 minimum distance that the docked panel gets dragged up in order to
+ // make it free-floating.
Andrei 2012/03/07 22:55:13 Could we formulate the condition for detaching in
jianli 2012/03/08 01:18:26 Done.
+ static const int kDetachDockedPanelThreshold;
+
+ // Indicates how close the bottom of the detached panel is to the bottom of
+ // the docked area such that the detached panel becomes docked.
+ static const int kDockDetachedPanelThreshold;
Andrei 2012/03/07 22:55:13 Why do they start with a "k"? I thought "k" was re
jianli 2012/03/08 01:18:26 Per coding style guide, we tend to prefix any cons
+
DISALLOW_COPY_AND_ASSIGN(PanelDragController);
};

Powered by Google App Engine
This is Rietveld 408576698