| 1 |
/* |
| 2 |
* Copyright (C) 2013-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 "input/touch/ITouchActionHandler.h" |
| 12 |
|
| 13 |
#include <stdlib.h> |
| 14 |
|
| 15 |
/*! |
| 16 |
* \ingroup touch |
| 17 |
* \brief Convenience interface implementing ITouchActionHandler with an |
| 18 |
* implementation that forwards any ITouchActionHandler-related calls |
| 19 |
* to a previously registered ITouchActionHandler |
| 20 |
* |
| 21 |
* \sa ITouchActionHandler |
| 22 |
*/ |
| 23 |
class ITouchInputHandling : protected ITouchActionHandler |
| 24 |
{ |
| 25 |
public: |
| 26 |
ITouchInputHandling() : m_handler(NULL) {} |
| 27 |
~ITouchInputHandling() override = default; |
| 28 |
|
| 29 |
/*! |
| 30 |
* \brief Register a touch input handler |
| 31 |
* |
| 32 |
* There can only be one touch input handler. |
| 33 |
* |
| 34 |
* \param touchHandler An instance of a touch handler implementing the |
| 35 |
* ITouchActionHandler interface |
| 36 |
* |
| 37 |
* \sa UnregisterHandler |
| 38 |
*/ |
| 39 |
void RegisterHandler(ITouchActionHandler* touchHandler); |
| 40 |
/*! |
| 41 |
* \brief Unregister the previously registered touch handler |
| 42 |
* |
| 43 |
* \sa RegisterHandler |
| 44 |
*/ |
| 45 |
void UnregisterHandler(); |
| 46 |
|
| 47 |
protected: |
| 48 |
// implementation of ITouchActionHandler |
| 49 |
void OnTouchAbort() override; |
| 50 |
|
| 51 |
bool OnSingleTouchStart(float x, float y) override; |
| 52 |
bool OnSingleTouchHold(float x, float y) override; |
| 53 |
bool OnSingleTouchMove( |
| 54 |
float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override; |
| 55 |
bool OnSingleTouchEnd(float x, float y) override; |
| 56 |
|
| 57 |
bool OnMultiTouchDown(float x, float y, int32_t pointer) override; |
| 58 |
bool OnMultiTouchHold(float x, float y, int32_t pointers = 2) override; |
| 59 |
bool OnMultiTouchMove(float x, |
| 60 |
float y, |
| 61 |
float offsetX, |
| 62 |
float offsetY, |
| 63 |
float velocityX, |
| 64 |
float velocityY, |
| 65 |
int32_t pointer) override; |
| 66 |
bool OnMultiTouchUp(float x, float y, int32_t pointer) override; |
| 67 |
|
| 68 |
bool OnTouchGestureStart(float x, float y) override; |
| 69 |
bool OnTouchGesturePan( |
| 70 |
float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override; |
| 71 |
bool OnTouchGestureEnd( |
| 72 |
float x, float y, float offsetX, float offsetY, float velocityX, float velocityY) override; |
| 73 |
|
| 74 |
// convenience events |
| 75 |
void OnTap(float x, float y, int32_t pointers = 1) override; |
| 76 |
void OnLongPress(float x, float y, int32_t pointers = 1) override; |
| 77 |
void OnSwipe(TouchMoveDirection direction, |
| 78 |
float xDown, |
| 79 |
float yDown, |
| 80 |
float xUp, |
| 81 |
float yUp, |
| 82 |
float velocityX, |
| 83 |
float velocityY, |
| 84 |
int32_t pointers = 1) override; |
| 85 |
void OnZoomPinch(float centerX, float centerY, float zoomFactor) override; |
| 86 |
void OnRotate(float centerX, float centerY, float angle) override; |
| 87 |
|
| 88 |
private: |
| 89 |
ITouchActionHandler* m_handler; |
| 90 |
}; |