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