summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 23:10:15 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 23:10:15 +0000
commit3eaa3a801feb0e1ae28a866ec5256c51b2daed6b (patch)
treec035cf72afd8cf53741b4c831f8ac882679ae6eb /views
parentafbf65f026465e65136bb4de4d6b9946b4ec1c19 (diff)
downloadchromium_src-3eaa3a801feb0e1ae28a866ec5256c51b2daed6b.zip
chromium_src-3eaa3a801feb0e1ae28a866ec5256c51b2daed6b.tar.gz
chromium_src-3eaa3a801feb0e1ae28a866ec5256c51b2daed6b.tar.bz2
views: Pull out DragController class into its own header file.
BUG=72040 TEST=None R=ben@chromium.org Review URL: http://codereview.chromium.org/7202015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/textfield/native_textfield_views.cc2
-rw-r--r--views/controls/textfield/native_textfield_views.h1
-rw-r--r--views/drag_controller.h48
-rw-r--r--views/view.cc9
-rw-r--r--views/view.h36
-rw-r--r--views/views.gyp1
6 files changed, 57 insertions, 40 deletions
diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc
index 423b6eb..472a5cb 100644
--- a/views/controls/textfield/native_textfield_views.cc
+++ b/views/controls/textfield/native_textfield_views.cc
@@ -80,7 +80,7 @@ NativeTextfieldViews::NativeTextfieldViews(Textfield* parent)
DCHECK_NE(parent->style(), Textfield::STYLE_LOWERCASE);
SetContextMenuController(this);
- SetDragController(this);
+ set_drag_controller(this);
}
NativeTextfieldViews::~NativeTextfieldViews() {
diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h
index d7edfd5..4da13dd 100644
--- a/views/controls/textfield/native_textfield_views.h
+++ b/views/controls/textfield/native_textfield_views.h
@@ -13,6 +13,7 @@
#include "views/border.h"
#include "views/controls/textfield/native_textfield_wrapper.h"
#include "views/controls/textfield/textfield_views_model.h"
+#include "views/drag_controller.h"
#include "views/ime/text_input_client.h"
#include "views/view.h"
diff --git a/views/drag_controller.h b/views/drag_controller.h
new file mode 100644
index 0000000..c7012d8
--- /dev/null
+++ b/views/drag_controller.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 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_EVENTS_DRAG_CONTROLLER_H_
+#define VIEWS_EVENTS_DRAG_CONTROLLER_H_
+#pragma once
+
+namespace gfx {
+class Point;
+}
+
+namespace ui {
+class OSExchangeData;
+}
+
+namespace views {
+class View;
+
+// DragController is responsible for writing drag data for a view, as well as
+// supplying the supported drag operations. Use DragController if you don't
+// want to subclass.
+class DragController {
+ public:
+ // Writes the data for the drag.
+ virtual void WriteDragDataForView(View* sender,
+ const gfx::Point& press_pt,
+ OSExchangeData* data) = 0;
+
+ // Returns the supported drag operations (see DragDropTypes for possible
+ // values). A drag is only started if this returns a non-zero value.
+ virtual int GetDragOperationsForView(View* sender,
+ const gfx::Point& p) = 0;
+
+ // Returns true if a drag operation can be started.
+ // |press_pt| represents the coordinates where the mouse was initially
+ // pressed down. |p| is the current mouse coordinates.
+ virtual bool CanStartDragForView(View* sender,
+ const gfx::Point& press_pt,
+ const gfx::Point& p) = 0;
+
+ protected:
+ virtual ~DragController() {}
+};
+
+} // namespace views
+
+#endif // VIEWS_EVENTS_DRAG_CONTROLLER_H_
diff --git a/views/view.cc b/views/view.cc
index dd24927..ad6609f 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -19,6 +19,7 @@
#include "ui/gfx/path.h"
#include "ui/gfx/transform.h"
#include "views/background.h"
+#include "views/drag_controller.h"
#include "views/layout/layout_manager.h"
#include "views/views_delegate.h"
#include "views/widget/native_widget_private.h"
@@ -1010,14 +1011,6 @@ void View::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
// Drag and drop ---------------------------------------------------------------
-void View::SetDragController(DragController* drag_controller) {
- drag_controller_ = drag_controller;
-}
-
-DragController* View::GetDragController() {
- return drag_controller_;
-}
-
bool View::GetDropFormats(
int* formats,
std::set<OSExchangeData::CustomFormat>* custom_formats) {
diff --git a/views/view.h b/views/view.h
index f909ba4..8b32bb6 100644
--- a/views/view.h
+++ b/views/view.h
@@ -49,6 +49,7 @@ namespace views {
class Background;
class Border;
+class DragController;
class FocusManager;
class FocusTraversable;
class InputMethod;
@@ -89,33 +90,6 @@ class ContextMenuController {
virtual ~ContextMenuController() {}
};
-// DragController is responsible for writing drag data for a view, as well as
-// supplying the supported drag operations. Use DragController if you don't
-// want to subclass.
-
-class DragController {
- public:
- // Writes the data for the drag.
- virtual void WriteDragDataForView(View* sender,
- const gfx::Point& press_pt,
- OSExchangeData* data) = 0;
-
- // Returns the supported drag operations (see DragDropTypes for possible
- // values). A drag is only started if this returns a non-zero value.
- virtual int GetDragOperationsForView(View* sender,
- const gfx::Point& p) = 0;
-
- // Returns true if a drag operation can be started.
- // |press_pt| represents the coordinates where the mouse was initially
- // pressed down. |p| is the current mouse coordinates.
- virtual bool CanStartDragForView(View* sender,
- const gfx::Point& press_pt,
- const gfx::Point& p) = 0;
-
- protected:
- virtual ~DragController() {}
-};
-
/////////////////////////////////////////////////////////////////////////////
//
// View class
@@ -791,10 +765,10 @@ class View : public AcceleratorTarget {
// Drag and drop -------------------------------------------------------------
- // Set/get the DragController. See description of DragController for more
- // information.
- void SetDragController(DragController* drag_controller);
- DragController* GetDragController();
+ DragController* drag_controller() { return drag_controller_; }
+ void set_drag_controller(DragController* drag_controller) {
+ drag_controller_ = drag_controller;
+ }
// During a drag and drop session when the mouse moves the view under the
// mouse is queried for the drop types it supports by way of the
diff --git a/views/views.gyp b/views/views.gyp
index edb1804..1f84df7 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -259,6 +259,7 @@
'controls/tree/tree_view.h',
#'debug_utils.cc',
#'debug_utils.h',
+ 'drag_controller.h',
'drag_utils.cc',
'drag_utils.h',
'drag_utils_gtk.cc',