summaryrefslogtreecommitdiffstats
path: root/views/widget/drop_helper.h
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 18:17:35 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 18:17:35 +0000
commit84ad47e975cb77a12881dc0c72053a22993950ca (patch)
tree343752188cf8571abc5533d9eb37efb1eab03ebd /views/widget/drop_helper.h
parent586cf35708db57b9013a12adc8d8513163e558de (diff)
downloadchromium_src-84ad47e975cb77a12881dc0c72053a22993950ca.zip
chromium_src-84ad47e975cb77a12881dc0c72053a22993950ca.tar.gz
chromium_src-84ad47e975cb77a12881dc0c72053a22993950ca.tar.bz2
Revert "views: Move widget/ directory to ui/views." properly.
Review URL: http://codereview.chromium.org/8562003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/drop_helper.h')
-rw-r--r--views/widget/drop_helper.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/views/widget/drop_helper.h b/views/widget/drop_helper.h
new file mode 100644
index 0000000..cc62bfc
--- /dev/null
+++ b/views/widget/drop_helper.h
@@ -0,0 +1,108 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef VIEWS_WIDGET_DROP_HELPER_H_
+#define VIEWS_WIDGET_DROP_HELPER_H_
+#pragma once
+
+#include "base/basictypes.h"
+
+namespace gfx {
+class Point;
+} // namespace gfx
+
+namespace ui {
+class OSExchangeData;
+} // namespace ui
+using ui::OSExchangeData;
+
+namespace views {
+
+class RootView;
+class View;
+
+// DropHelper provides support for managing the view a drop is going to occur
+// at during dnd as well as sending the view the appropriate dnd methods.
+// DropHelper is intended to be used by a class that interacts with the system
+// drag and drop. The system class invokes OnDragOver as the mouse moves,
+// then either OnDragExit or OnDrop when the drop is done.
+class DropHelper {
+ public:
+ explicit DropHelper(View* root_view);
+ ~DropHelper();
+
+ // Current view drop events are targeted at, may be NULL.
+ View* target_view() const { return target_view_; }
+
+ // Returns the RootView the DropHelper was created with.
+ View* root_view() const { return root_view_; }
+
+ // Resets the target_view_ to NULL if it equals view.
+ //
+ // This is invoked when a View is removed from the RootView to make sure
+ // we don't target a view that was removed during dnd.
+ void ResetTargetViewIfEquals(View* view);
+
+ // Invoked when a the mouse is dragged over the root view during a drag and
+ // drop operation. This method returns a bitmask of the types in DragDropTypes
+ // for the target view. If no view wants the drop, DRAG_NONE is returned.
+ int OnDragOver(const OSExchangeData& data,
+ const gfx::Point& root_view_location,
+ int drag_operation);
+
+ // Invoked when a the mouse is dragged out of the root view during a drag and
+ // drop operation.
+ void OnDragExit();
+
+ // Invoked when the user drops data on the root view during a drag and drop
+ // operation. See OnDragOver for details on return type.
+ //
+ // NOTE: implementations must invoke OnDragOver before invoking this,
+ // supplying the return value from OnDragOver as the drag_operation.
+ int OnDrop(const OSExchangeData& data,
+ const gfx::Point& root_view_location,
+ int drag_operation);
+
+ // Calculates the target view for a drop given the specified location in
+ // the coordinate system of the rootview. This tries to avoid continually
+ // querying CanDrop by returning target_view_ if the mouse is still over
+ // target_view_.
+ View* CalculateTargetView(const gfx::Point& root_view_location,
+ const OSExchangeData& data,
+ bool check_can_drop);
+
+ private:
+ // Implementation of CalculateTargetView. If |deepest_view| is non-NULL it is
+ // set to the deepest descendant of the RootView that contains the point
+ // |root_view_location|
+ View* CalculateTargetViewImpl(const gfx::Point& root_view_location,
+ const OSExchangeData& data,
+ bool check_can_drop,
+ View** deepest_view);
+
+ // Methods to send the appropriate drop notification to the targeted view.
+ // These do nothing if the target view is NULL.
+ void NotifyDragEntered(const OSExchangeData& data,
+ const gfx::Point& root_view_location,
+ int drag_operation);
+ int NotifyDragOver(const OSExchangeData& data,
+ const gfx::Point& root_view_location,
+ int drag_operation);
+ void NotifyDragExit();
+
+ // RootView we were created for.
+ View* root_view_;
+
+ // View we're targeting events at.
+ View* target_view_;
+
+ // The deepest view under the current drop coordinate.
+ View* deepest_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(DropHelper);
+};
+
+} // namespace views
+
+#endif // VIEWS_WIDGET_DROP_HELPER_H_