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

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: Patch to land 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..8f9db2818db73333379529e0704ebfb9d507dce0 100644
--- a/chrome/browser/ui/panels/panel_drag_controller.h
+++ b/chrome/browser/ui/panels/panel_drag_controller.h
@@ -11,12 +11,17 @@
#include "ui/gfx/point.h"
class Panel;
+class PanelManager;
+class PanelStrip;
+namespace gfx {
+class Rect;
+}
// 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 +36,52 @@ 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:
+ // Helper methods to figure out if the panel can be dragged to other strip.
+ // Returns target strip/boolean flag, and |new_panel_bounds| if the panel
+ // can enter other strip at |mouse_location|.
+ PanelStrip* ComputeDragTargetStrip(
+ const gfx::Point& mouse_location, gfx::Rect* new_panel_bounds) const;
+ bool CanDragToDockedStrip(
+ const gfx::Point& mouse_location, gfx::Rect* new_panel_bounds) const;
+ bool CanDragToDetachedStrip(
+ const gfx::Point& mouse_location, gfx::Rect* new_panel_bounds) 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 offset from mouse location to the panel position when the drag
+ // starts.
+ gfx::Point offset_from_mouse_location_on_drag_start_;
+
+ // The minimum distance that the docked panel gets dragged up in order to
+ // make it free-floating.
+ 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;
+
DISALLOW_COPY_AND_ASSIGN(PanelDragController);
};
« no previous file with comments | « chrome/browser/ui/panels/panel_drag_browsertest.cc ('k') | chrome/browser/ui/panels/panel_drag_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698