VelocityTracker.h 907 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * VelocityTracker.h
  3. *
  4. * Created on: Jul 19, 2017
  5. * Author: guoxs
  6. */
  7. #ifndef _UTILS_VELOCITY_TRACKER_H_
  8. #define _UTILS_VELOCITY_TRACKER_H_
  9. #include "control/Common.h"
  10. //typedef struct _POINT_
  11. //{
  12. // /**
  13. // * The x coordinate of the point.
  14. // */
  15. // int x;
  16. // /**
  17. // * The y coordinate of the point.
  18. // */
  19. // int y;
  20. //}POINT;
  21. typedef struct _POINT
  22. {
  23. /**
  24. * The x coordinate of the point.
  25. */
  26. int x;
  27. /**
  28. * The y coordinate of the point.
  29. */
  30. int y;
  31. } POINT;
  32. #define ID_SCROLLWINDOW_ROLL_TIMER 208
  33. class VelocityTracker {
  34. public:
  35. VelocityTracker();
  36. virtual ~VelocityTracker();
  37. void addMovement(const MotionEvent &ev);
  38. void reset();
  39. float getXVelocity() const;
  40. float getYVelocity() const;
  41. private:
  42. bool canComputeVelocity() const;
  43. private:
  44. int mCurIndex;
  45. MotionEvent mEvents[2];
  46. };
  47. #endif /* _UTILS_VELOCITY_TRACKER_H_ */