drag_controller.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_VIEWS_DRAG_CONTROLLER_H_
  5. #define UI_VIEWS_DRAG_CONTROLLER_H_
  6. #include "ui/views/views_export.h"
  7. namespace gfx {
  8. class Point;
  9. }
  10. namespace ui {
  11. class OSExchangeData;
  12. }
  13. namespace views {
  14. class View;
  15. // DragController is responsible for writing drag data for a view, as well as
  16. // supplying the supported drag operations. Use DragController if you don't
  17. // want to subclass.
  18. class VIEWS_EXPORT DragController {
  19. public:
  20. // Writes the data for the drag.
  21. virtual void WriteDragDataForView(View* sender,
  22. const gfx::Point& press_pt,
  23. ui::OSExchangeData* data) = 0;
  24. // Returns the supported drag operations (see DragDropTypes for possible
  25. // values). A drag is only started if this returns a non-zero value.
  26. virtual int GetDragOperationsForView(View* sender, const gfx::Point& p) = 0;
  27. // Returns true if a drag operation can be started.
  28. // |press_pt| represents the coordinates where the mouse was initially
  29. // pressed down. |p| is the current mouse coordinates.
  30. virtual bool CanStartDragForView(View* sender,
  31. const gfx::Point& press_pt,
  32. const gfx::Point& p) = 0;
  33. protected:
  34. virtual ~DragController() = default;
  35. };
  36. } // namespace views
  37. #endif // UI_VIEWS_DRAG_CONTROLLER_H_