touch_selection_draggable.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2015 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_TOUCH_SELECTION_TOUCH_SELECTION_DRAGGABLE_H_
  5. #define UI_TOUCH_SELECTION_TOUCH_SELECTION_DRAGGABLE_H_
  6. #include "ui/gfx/geometry/point_f.h"
  7. #include "ui/touch_selection/ui_touch_selection_export.h"
  8. namespace ui {
  9. class MotionEvent;
  10. class TouchSelectionDraggable;
  11. // Interface through which TouchSelectionDraggable manipulates the selection.
  12. class UI_TOUCH_SELECTION_EXPORT TouchSelectionDraggableClient {
  13. public:
  14. virtual ~TouchSelectionDraggableClient() {}
  15. virtual void OnDragBegin(const TouchSelectionDraggable& draggable,
  16. const gfx::PointF& start_position) = 0;
  17. virtual void OnDragUpdate(const TouchSelectionDraggable& draggable,
  18. const gfx::PointF& new_position) = 0;
  19. virtual void OnDragEnd(const TouchSelectionDraggable& draggable) = 0;
  20. virtual bool IsWithinTapSlop(const gfx::Vector2dF& delta) const = 0;
  21. };
  22. // Generic interface for entities that manipulate the selection via dragging.
  23. class UI_TOUCH_SELECTION_EXPORT TouchSelectionDraggable {
  24. public:
  25. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.touch_selection
  26. // GENERATED_JAVA_CLASS_NAME_OVERRIDE: TouchSelectionDraggableType
  27. enum class Type {
  28. kNone,
  29. kTouchHandle,
  30. kLongpress,
  31. };
  32. protected:
  33. virtual ~TouchSelectionDraggable() {}
  34. // Offers a touch sequence to the draggable target. Returns true if the event
  35. // was consumed, in which case the caller should cease further handling.
  36. virtual bool WillHandleTouchEvent(const ui::MotionEvent& event) = 0;
  37. // Whether a drag is active OR being detected for the current touch sequence.
  38. virtual bool IsActive() const = 0;
  39. };
  40. } // namespace ui
  41. #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_DRAGGABLE_H_