touch_stylus_delegate.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2016 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_STYLUS_DELEGATE_H_
  5. #define COMPONENTS_EXO_TOUCH_STYLUS_DELEGATE_H_
  6. #include "base/time/time.h"
  7. #include "ui/events/event_constants.h"
  8. namespace gfx {
  9. class Vector2dF;
  10. }
  11. namespace exo {
  12. class Touch;
  13. // Handles stylus specific events as an extension to TouchDelegate.
  14. class TouchStylusDelegate {
  15. public:
  16. // Called at the top of the touch's destructor, to give observers a
  17. // chance to remove themselves.
  18. virtual void OnTouchDestroying(Touch* pointer) = 0;
  19. // Called to set the tool type of a touch. Only called once with the down
  20. // event. A tool type cannot change afterwards.
  21. virtual void OnTouchTool(int touch_id, ui::EventPointerType type) = 0;
  22. // Called when the force (pressure) of the touch changes.
  23. // Normalized to be [0, 1].
  24. virtual void OnTouchForce(base::TimeTicks time_stamp,
  25. int touch_id,
  26. float force) = 0;
  27. // Called when the tilt of a pen/stylus changes. Measured from surface normal
  28. // as plane angle in degrees, values lie in [-90,90]. A positive x is to the
  29. // right and a positive y is towards the user.
  30. virtual void OnTouchTilt(base::TimeTicks time_stamp,
  31. int touch_id,
  32. const gfx::Vector2dF& tilt) = 0;
  33. protected:
  34. virtual ~TouchStylusDelegate() {}
  35. };
  36. } // namespace exo
  37. #endif // COMPONENTS_EXO_TOUCH_STYLUS_DELEGATE_H_