LuciadCPillar 2023.1.04
luciad::MouseGestureRecognizer Class Referencefinal

This class generates high-level mouse gesture events from low-level input events. More...

#include <luciad/input/mouse/MouseGestureRecognizer.h>

Public Member Functions

 MouseGestureRecognizer (std::shared_ptr< IInputEventCallback > callback)
 Creates a MouseGestureRecognizer that passes the generated high level luciad::IInputEvents to the given callback. More...
 
 ~MouseGestureRecognizer ()
 
double getDisplayScale () const
 
double getDpi () const
 
ScreenDistance getDragThreshold () const
 
size_t getMultiClickInterval () const noexcept
 Returns the interval used to detect multiple clicks (default is 400 ms). More...
 
void onKeyEvent (const KeyEvent &keyEvent)
 Entry point for the key events of the gesture recognizer. More...
 
void onMouseMoveEvent (const MouseMoveEvent &mouseMoveEvent)
 Entry point for the mouse move events of the gesture recognizer. More...
 
void onMousePressedEvent (const MousePressedEvent &mousePressedEvent)
 Entry point for the mouse pressed events of the gesture recognizer. More...
 
void onMouseReleasedEvent (const MouseReleasedEvent &mouseReleasedEvent)
 Entry point for the mouse released events of the gesture recognizer. More...
 
void onScrollEvent (const ScrollEvent &scrollEvent)
 Entry point for the scroll 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. More...
 
void setMultiClickInterval (size_t interval)
 Set the interval used to detect multiple clicks (default is 400 ms). More...
 

Detailed Description

This class generates high-level mouse gesture events from low-level input events.

High level events are subclasses of luciad::IInputEvent such as luciad::MouseClickEvent. Low levels are used to create those high level events and are dropped afterwards.

For example, a mouse pressed + (possibly multiple) mouse moved + a mouse released sequence is recognized as a drag gesture. A mouse pressed + a mouse released sequence is recognized as a click 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 MouseGestureRecognizer is optional. Events containing MouseButton::unknown() as the mouse button are not processed. 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.

Since
2022.0

Constructor & Destructor Documentation

◆ MouseGestureRecognizer()

luciad::MouseGestureRecognizer::MouseGestureRecognizer ( std::shared_ptr< IInputEventCallback callback)
explicit

Creates a MouseGestureRecognizer that passes the generated high level luciad::IInputEvents to the given callback.

Parameters
callbackthe callback that receive generated luciad::IInputEvents. Can not be nullptr.
Exceptions
luciad::NullArgumentExceptionIf callback is nullptr.

◆ ~MouseGestureRecognizer()

luciad::MouseGestureRecognizer::~MouseGestureRecognizer ( )

Member Function Documentation

◆ getDisplayScale()

double luciad::MouseGestureRecognizer::getDisplayScale ( ) const
Returns
the display scale factor.

◆ getDpi()

double luciad::MouseGestureRecognizer::getDpi ( ) const
Returns
the display pixel density, expressed in dots per inch.

◆ getDragThreshold()

ScreenDistance luciad::MouseGestureRecognizer::getDragThreshold ( ) const
Returns
the screen distance that is used as a threshold to detect if a drag is performed. It means that the mouse cursor has to move at least that distance before it can be detected as a drag gesture.

◆ getMultiClickInterval()

size_t luciad::MouseGestureRecognizer::getMultiClickInterval ( ) const
noexcept

Returns the interval used to detect multiple clicks (default is 400 ms).

◆ onKeyEvent()

void luciad::MouseGestureRecognizer::onKeyEvent ( const KeyEvent keyEvent)

Entry point for the key events of the gesture recognizer.

Parameters
keyEventthe low level key event.

◆ onMouseMoveEvent()

void luciad::MouseGestureRecognizer::onMouseMoveEvent ( const MouseMoveEvent mouseMoveEvent)

Entry point for the mouse move events of the gesture recognizer.

Parameters
mouseMoveEventthe low level mouse move event.

◆ onMousePressedEvent()

void luciad::MouseGestureRecognizer::onMousePressedEvent ( const MousePressedEvent mousePressedEvent)

Entry point for the mouse pressed events of the gesture recognizer.

Parameters
mousePressedEventthe low level mouse press event.

◆ onMouseReleasedEvent()

void luciad::MouseGestureRecognizer::onMouseReleasedEvent ( const MouseReleasedEvent mouseReleasedEvent)

Entry point for the mouse released events of the gesture recognizer.

Parameters
mouseReleasedEventthe low level mouse released event.

◆ onScrollEvent()

void luciad::MouseGestureRecognizer::onScrollEvent ( const ScrollEvent scrollEvent)

Entry point for the scroll events of the gesture recognizer.

Parameters
scrollEventthe low level mouse scroll event.

◆ setDisplayScale()

void luciad::MouseGestureRecognizer::setDisplayScale ( double  scale)

Set the display scale factor.

If no value is provided, a scale factor of 1.0 is assumed.

Parameters
scalethe display scale factor (adimensional scale value)

◆ setDpi()

void luciad::MouseGestureRecognizer::setDpi ( double  dpi)

Set the display pixel density in dots per inch.

If no value is provided, the platform standard pixel density is assumed.

Parameters
dpithe pixel density in dots per inch

◆ setDragThreshold()

void luciad::MouseGestureRecognizer::setDragThreshold ( ScreenDistance  threshold)

Sets the screen distance that is used as threshold to detect if a drag is performed.

It means that the mouse cursor has to move at least that amount of pixels before it can be detected as a drag gesture.

The default value in device independent pixels is 2 pixels.

Parameters
thresholdthe threshold

◆ setMultiClickInterval()

void luciad::MouseGestureRecognizer::setMultiClickInterval ( size_t  interval)

Set the interval used to detect multiple clicks (default is 400 ms).

Parameters
intervalthe maximum time (in milliseconds) between multiple clicks. If the interval is set to 0, no multiple clicks will be detected.