touch_delegate.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 COMPONENTS_EXO_TOUCH_DELEGATE_H_
  5. #define COMPONENTS_EXO_TOUCH_DELEGATE_H_
  6. #include "base/time/time.h"
  7. namespace gfx {
  8. class PointF;
  9. }
  10. namespace exo {
  11. class Surface;
  12. class Touch;
  13. // Handles events on touch devices in context-specific ways.
  14. class TouchDelegate {
  15. public:
  16. // Called at the top of the touch device's destructor, to give observers a
  17. // chance to remove themselves.
  18. virtual void OnTouchDestroying(Touch* touch) = 0;
  19. // This should return true if |surface| is a valid target for this touch
  20. // device. E.g. the surface is owned by the same client as the touch device.
  21. virtual bool CanAcceptTouchEventsForSurface(Surface* surface) const = 0;
  22. // Called when a new touch point has appeared on the surface. This touch
  23. // point is assigned a unique ID. Future events from this touch point
  24. // reference this ID. |location| is the initial location of touch point
  25. // relative to the origin of the surface.
  26. virtual void OnTouchDown(Surface* surface,
  27. base::TimeTicks time_stamp,
  28. int id,
  29. const gfx::PointF& location) = 0;
  30. // Called when a touch point has disappeared. No further events will be sent
  31. // for this touch point.
  32. virtual void OnTouchUp(base::TimeTicks time_stamp, int id) = 0;
  33. // Called when a touch point has changed coordinates.
  34. virtual void OnTouchMotion(base::TimeTicks time_stamp,
  35. int id,
  36. const gfx::PointF& location) = 0;
  37. // Called when a touch point has changed its shape.
  38. virtual void OnTouchShape(int id, float major, float minor) = 0;
  39. // Called when the client should apply all updated touches.
  40. virtual void OnTouchFrame() = 0;
  41. // Called when the touch session has been canceled. Touch cancellation
  42. // applies to all touch points currently active.
  43. virtual void OnTouchCancel() = 0;
  44. protected:
  45. virtual ~TouchDelegate() {}
  46. };
  47. } // namespace exo
  48. #endif // COMPONENTS_EXO_TOUCH_DELEGATE_H_