xbmc
IGenericTouchGestureDetector.h
1 /*
2  * Copyright (C) 2013-2018 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/ITouchInputHandling.h"
12 #include "input/touch/TouchTypes.h"
13 
14 #include <array>
15 
21 {
22 public:
23  IGenericTouchGestureDetector(ITouchActionHandler* handler, float dpi) : m_done(false), m_dpi(dpi)
24  {
25  RegisterHandler(handler);
26  }
27  ~IGenericTouchGestureDetector() override = default;
28  static constexpr int MAX_POINTERS = 2;
29 
35  bool IsDone() { return m_done; }
36 
45  virtual bool OnTouchDown(unsigned int index, const Pointer& pointer) = 0;
57  virtual bool OnTouchUp(unsigned int index, const Pointer& pointer) { return false; }
66  virtual bool OnTouchMove(unsigned int index, const Pointer& pointer) { return false; }
76  virtual bool OnTouchUpdate(unsigned int index, const Pointer& pointer) { return false; }
77 
78 protected:
82  bool m_done;
86  float m_dpi;
90  std::array<Pointer, MAX_POINTERS> m_pointers;
91 };
virtual bool OnTouchDown(unsigned int index, const Pointer &pointer)=0
A new touch pointer has been recognised.
virtual bool OnTouchUpdate(unsigned int index, const Pointer &pointer)
An active touch pointer&#39;s values have been updated but no event has occurred.
Definition: IGenericTouchGestureDetector.h:76
bool IsDone()
Check whether the gesture recognition is finished or not.
Definition: IGenericTouchGestureDetector.h:35
bool m_done
Whether the gesture recognition is finished or not.
Definition: IGenericTouchGestureDetector.h:82
float m_dpi
DPI value of the touch screen.
Definition: IGenericTouchGestureDetector.h:86
Convenience interface implementing ITouchActionHandler with an implementation that forwards any ITouc...
Definition: ITouchInputHandling.h:23
std::array< Pointer, MAX_POINTERS > m_pointers
Local list of all known touch pointers.
Definition: IGenericTouchGestureDetector.h:90
Interface defining methods to perform gesture recognition.
Definition: IGenericTouchGestureDetector.h:20
Interface defining all supported touch action events.
Definition: ITouchActionHandler.h:32
virtual bool OnTouchMove(unsigned int index, const Pointer &pointer)
An active touch pointer has moved.
Definition: IGenericTouchGestureDetector.h:66
A class representing a touch pointer interaction consisting of an down touch, the last touch and the ...
Definition: TouchTypes.h:49
void RegisterHandler(ITouchActionHandler *touchHandler)
Register a touch input handler.
Definition: ITouchInputHandling.cpp:11
virtual bool OnTouchUp(unsigned int index, const Pointer &pointer)
An active touch pointer has vanished.
Definition: IGenericTouchGestureDetector.h:57