kodi
ITouchActionHandler.h
1 /*
2  * Copyright (C) 2012-2024 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <stdint.h>
12 
19 typedef enum
20 {
21  TouchMoveDirectionNone = 0x0,
22  TouchMoveDirectionLeft = 0x1,
23  TouchMoveDirectionRight = 0x2,
24  TouchMoveDirectionUp = 0x4,
25  TouchMoveDirectionDown = 0x8
27 
33 {
34 public:
35  virtual ~ITouchActionHandler() = default;
36 
40  virtual void OnTouchAbort() {}
41 
52  virtual bool OnSingleTouchStart(float x, float y) { return true; }
63  virtual bool OnSingleTouchHold(float x, float y) { return true; }
78  virtual bool OnSingleTouchMove(
79  float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
80  {
81  return true;
82  }
93  virtual bool OnSingleTouchEnd(float x, float y) { return true; }
94 
104  virtual bool OnMultiTouchDown(float x, float y, int32_t pointer) { return true; }
114  virtual bool OnMultiTouchHold(float x, float y, int32_t pointers = 2) { return true; }
128  virtual bool OnMultiTouchMove(float x,
129  float y,
130  float offsetX,
131  float offsetY,
132  float velocityX,
133  float velocityY,
134  int32_t pointer)
135  {
136  return true;
137  }
147  virtual bool OnMultiTouchUp(float x, float y, int32_t pointer) { return true; }
148 
157  virtual bool OnTouchGestureStart(float x, float y) { return true; }
170  virtual bool OnTouchGesturePan(
171  float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
172  {
173  return true;
174  }
187  virtual bool OnTouchGestureEnd(
188  float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
189  {
190  return true;
191  }
192 
193  // convenience events
203  virtual void OnTap(float x, float y, int32_t pointers = 1) {}
215  virtual void OnLongPress(float x, float y, int32_t pointers = 1) {}
230  virtual void OnSwipe(TouchMoveDirection direction,
231  float xDown,
232  float yDown,
233  float xUp,
234  float yUp,
235  float velocityX,
236  float velocityY,
237  int32_t pointers = 1)
238  {
239  }
250  virtual void OnZoomPinch(float centerX, float centerY, float zoomFactor) {}
260  virtual void OnRotate(float centerX, float centerY, float angle) {}
261 };
virtual bool OnMultiTouchDown(float x, float y, int32_t pointer)
An additional touch has been performed.
Definition: ITouchActionHandler.h:104
virtual bool OnSingleTouchHold(float x, float y)
A single touch has been held down for a certain amount of time.
Definition: ITouchActionHandler.h:63
virtual bool OnMultiTouchMove(float x, float y, float offsetX, float offsetY, float velocityX, float velocityY, int32_t pointer)
A touch has moved.
Definition: ITouchActionHandler.h:128
virtual bool OnTouchGesturePan(float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
A pan gesture with a single touch is in progress.
Definition: ITouchActionHandler.h:170
virtual bool OnTouchGestureEnd(float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
A pan gesture with a single touch has ended.
Definition: ITouchActionHandler.h:187
virtual void OnRotate(float centerX, float centerY, float angle)
Two simultaneous touches have been held down and moved to perform a rotating gesture.
Definition: ITouchActionHandler.h:260
virtual bool OnSingleTouchEnd(float x, float y)
A single touch has been lifted.
Definition: ITouchActionHandler.h:93
virtual void OnZoomPinch(float centerX, float centerY, float zoomFactor)
Two simultaneous touches have been held down and moved to perform a zooming/pinching gesture...
Definition: ITouchActionHandler.h:250
virtual void OnLongPress(float x, float y, int32_t pointers=1)
One or more touches have been held down for a certain amount of time.
Definition: ITouchActionHandler.h:215
virtual bool OnTouchGestureStart(float x, float y)
A pan gesture with a single touch has been started.
Definition: ITouchActionHandler.h:157
virtual void OnSwipe(TouchMoveDirection direction, float xDown, float yDown, float xUp, float yUp, float velocityX, float velocityY, int32_t pointers=1)
One or more touches has been moved quickly in a single direction in a short time. ...
Definition: ITouchActionHandler.h:230
virtual bool OnMultiTouchUp(float x, float y, int32_t pointer)
A touch has been lifted (but there are still active touches)
Definition: ITouchActionHandler.h:147
Interface defining all supported touch action events.
Definition: ITouchActionHandler.h:32
virtual bool OnSingleTouchMove(float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
A single touch has moved.
Definition: ITouchActionHandler.h:78
virtual void OnTouchAbort()
A touch action has been aborted.
Definition: ITouchActionHandler.h:40
TouchMoveDirection
Directions in which a touch can moved.
Definition: ITouchActionHandler.h:19
virtual void OnTap(float x, float y, int32_t pointers=1)
A tap with a one or more touches has been performed.
Definition: ITouchActionHandler.h:203
virtual bool OnMultiTouchHold(float x, float y, int32_t pointers=2)
Multiple simultaneous touches have been held down for a certain amount of time.
Definition: ITouchActionHandler.h:114
virtual bool OnSingleTouchStart(float x, float y)
A single touch has started.
Definition: ITouchActionHandler.h:52