LuciadCPillar 2023.1.03
|
This class generates high-level touch gesture events from low-level input events. More...
#include <luciad/input/touch/TouchGestureRecognizer.h>
Public Member Functions | |
TouchGestureRecognizer (std::shared_ptr< IInputEventCallback > callback, std::shared_ptr< ITaskScheduler > taskScheduler) | |
Creates a TouchGestureRecognizer The generated high level luciad::IInputEvent s are passed to the given callback on the UI thread. More... | |
~TouchGestureRecognizer () | |
double | getDisplayScale () const |
double | getDpi () const |
ScreenDistance | getDragThreshold () const |
size_t | getLongPressThreshold () const |
size_t | getMultiTapInterval () const noexcept |
ScreenDistance | getMultiTapThreshold () const |
void | onTouchEvent (const TouchPointEvent &touchPointEvent) |
Entry point for the touch events of the gesture recognizer. More... | |
void | setDisplayScale (double scale) |
Set the display scale factor. More... | |
void | setDpi (double dpi) |
Set the display pixel density in dots per inch. More... | |
void | setDragThreshold (ScreenDistance threshold) |
Sets the screen distance that is used as threshold to detect if a drag is performed while using touch inputs. More... | |
void | setLongPressThreshold (size_t longPressThreshold) |
Set the threshold, in milliseconds, to reach before a long press event is sent. More... | |
void | setMultiTapInterval (size_t interval) |
Set the interval used to detect multiple taps (default is 400 ms). More... | |
void | setMultiTapThreshold (ScreenDistance threshold) |
Set the screen distance threshold to detect multiple taps. More... | |
This class generates high-level touch gesture events from low-level input events.
High level events are subclasses of luciad::IInputEvent
such as luciad::TouchTapEvent
. Sequences of low level events are used to create those high level events.
For example, a touch press + movement of the touch point (possibly multiple times) sequence is recognized as a touch drag gesture. A touch press + a touch release sequence is recognized as a touch tap gesture. This class is useful when adding integration with a platform that does not provide these more high-level events.
A typical use of such a class is to wire it to a UI framework specific class (such as Qt , see QQuickMapObject in the sample code) and make the controller react to the high level event instead of every low level event the framework can fire.
The use of the TouchGestureRecognizer is optional. A controller implementation can use custom conversion code if needed, for example if you want to manage the low level events yourself and create other high level luciad::IInputEvent
instances.
The events passed to this class are expected to be defined in device independent pixels.
luciad::TouchGestureRecognizer::TouchGestureRecognizer | ( | std::shared_ptr< IInputEventCallback > | callback, |
std::shared_ptr< ITaskScheduler > | taskScheduler | ||
) |
Creates a TouchGestureRecognizer The generated high level luciad::IInputEvent
s are passed to the given callback on the UI thread.
For certain events, like for example a long press, an internal timer is used to determine when an IInputEvent needs to be sent. Due to the use of a timer, it is possible that some work is done on a different thread than the UI thread. The task scheduler can be used to apply the result of the timer on the UI thread.
callback | the callback that receive generated luciad::IInputEvent s. Can not be nullptr . |
taskScheduler | a scheduler allowing the caller to receive some luciad::IInputEvent s on another thread and resolve them on the UI thread. Can be nullptr . If nullptr , some events won't be emitted. |
luciad::NullArgumentException | If callback is nullptr . |
luciad::TouchGestureRecognizer::~TouchGestureRecognizer | ( | ) |
double luciad::TouchGestureRecognizer::getDisplayScale | ( | ) | const |
double luciad::TouchGestureRecognizer::getDpi | ( | ) | const |
ScreenDistance luciad::TouchGestureRecognizer::getDragThreshold | ( | ) | const |
size_t luciad::TouchGestureRecognizer::getLongPressThreshold | ( | ) | const |
|
noexcept |
ScreenDistance luciad::TouchGestureRecognizer::getMultiTapThreshold | ( | ) | const |
void luciad::TouchGestureRecognizer::onTouchEvent | ( | const TouchPointEvent & | touchPointEvent | ) |
Entry point for the touch events of the gesture recognizer.
touchPointEvent | the luciad::TouchPointEvent object containing a collection of luciad::TouchPoint s. |
void luciad::TouchGestureRecognizer::setDisplayScale | ( | double | scale | ) |
Set the display scale factor.
If no value is provided, a scale factor of 1.0 is assumed.
scale | the display scale factor (adimensional scale value) |
void luciad::TouchGestureRecognizer::setDpi | ( | double | dpi | ) |
Set the display pixel density in dots per inch.
If no value is provided, the platform standard pixel density is assumed.
dpi | the pixel density in dots per inch |
void luciad::TouchGestureRecognizer::setDragThreshold | ( | ScreenDistance | threshold | ) |
Sets the screen distance that is used as threshold to detect if a drag is performed while using touch inputs.
It means that the input device has to move at least that distance before it can be detected as a drag gesture. The default drag threshold is a screen distance of 5 mm.
threshold | the screen distance threshold |
void luciad::TouchGestureRecognizer::setLongPressThreshold | ( | size_t | longPressThreshold | ) |
Set the threshold, in milliseconds, to reach before a long press event is sent.
The default is 700 ms.
longPressThreshold | the threshold in milliseconds. |
void luciad::TouchGestureRecognizer::setMultiTapInterval | ( | size_t | interval | ) |
Set the interval used to detect multiple taps (default is 400 ms).
interval | the maximum time (in milliseconds) between multiple taps. If the interval is set to 0, no multiple taps will be detected. |
void luciad::TouchGestureRecognizer::setMultiTapThreshold | ( | ScreenDistance | threshold | ) |
Set the screen distance threshold to detect multiple taps.
It means that consecutive taps need to be as close as that distance in order to generate an event for a multiple tap.
threshold | the distance threshold |