1.10 |
Basic class for interpreting mouse events. More...
#include <mousegesture.h>
Public Types | |
using | MouseCallback = std::function< void(Event &event)> |
Type for mouse event callback. | |
Public Member Functions | |
MouseGesture () noexcept | |
EGT_NODISCARD bool | active () const |
Is active? | |
EGT_NODISCARD bool | dragging () const |
Is dragging? | |
Event | handle (const Event &event) |
Pass the raw EventId to this function to get the emulated mouse event. | |
EGT_NODISCARD const DisplayPoint & | mouse_start () const |
Get pointer start position. | |
void | on_async_event (MouseCallback callback) |
Register a callback function to handle the async mouse events. | |
void | start (const DisplayPoint &point) |
Start. | |
void | stop () |
Stop any active dragging state. | |
Static Public Member Functions | |
static EGT_NODISCARD DefaultDim | drag_enable_distance () |
Get the distance to travel to enable the drag mode. | |
static void | drag_enable_distance (DefaultDim distance) |
Set the distance to travel to enable the drag mode. | |
Protected Types | |
using | CallbackArray = std::vector< MouseCallback > |
Type for array of registered callbacks. | |
Protected Member Functions | |
void | invoke_handlers (Event &event) |
Invoke an event on each of the handlers. | |
Protected Attributes | |
bool | m_active {false} |
Currently processing subsequent events. | |
CallbackArray | m_callbacks |
Registered callback functions. | |
bool | m_dragging {false} |
Currently in the dragging state. | |
bool | m_holding {false} |
Currently in the holding state. | |
PeriodicTimer | m_long_click_timer |
Async timer for detecting long clicks. | |
DisplayPoint | m_mouse_start_pos |
The starting position of the mouse. | |
Static Protected Attributes | |
static DefaultDim | m_drag_enable_distance |
Cursor distance to enable the drag mode. | |
Basic class for interpreting mouse events.
For now, this only supports single mouse click, long click, and drag events. The premise behind this class is to interpret raw mouse events and turn them into higher level meaning. Because some of those events can be asynchronous, all events are generated through callbacks registered with on_async_event().
|
protected |
Type for array of registered callbacks.
using MouseCallback = std::function<void(Event& event)> |
Type for mouse event callback.
|
noexcept |
|
inline |
Is active?
|
inlinestatic |
Get the distance to travel to enable the drag mode.
|
inlinestatic |
Set the distance to travel to enable the drag mode.
|
inline |
Is dragging?
Pass the raw EventId to this function to get the emulated mouse event.
|
protected |
Invoke an event on each of the handlers.
|
inline |
Get pointer start position.
void on_async_event | ( | MouseCallback | callback | ) |
Register a callback function to handle the async mouse events.
void start | ( | const DisplayPoint & | point | ) |
Start.
void stop | ( | ) |
Stop any active dragging state.
|
protected |
Currently processing subsequent events.
|
protected |
Registered callback functions.
|
staticprotected |
Cursor distance to enable the drag mode.
|
protected |
Currently in the dragging state.
|
protected |
Currently in the holding state.
|
protected |
Async timer for detecting long clicks.
|
protected |
The starting position of the mouse.