1.8
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
MouseGesture Class Reference

Basic class for interpreting mouse events. More...

Public Types

using MouseCallback = std::function< void(Event &event)>
 Type for mouse event callback. More...
 

Public Member Functions

 MouseGesture () noexcept
 
EGT_NODISCARD bool active () const
 Is active? More...
 
EGT_NODISCARD bool dragging () const
 Is dragging? More...
 
Event handle (const Event &event)
 Pass the raw EventId to this function to get the emulated mouse event. More...
 
EGT_NODISCARD const DisplayPointmouse_start () const
 Get pointer start position. More...
 
void on_async_event (MouseCallback callback)
 Register a callback function to handle the async mouse events. More...
 
void start (const DisplayPoint &point)
 Start. More...
 
void stop ()
 Stop any active dragging state. More...
 

Protected Types

using CallbackArray = std::vector< MouseCallback >
 Type for array of registered callbacks. More...
 

Protected Member Functions

void invoke_handlers (Event &event)
 Invoke an event on each of the handlers. More...
 

Protected Attributes

bool m_active {false}
 Currently processing subsequent events. More...
 
CallbackArray m_callbacks
 Registered callback functions. More...
 
bool m_dragging {false}
 Currently in the dragging state. More...
 
PeriodicTimer m_long_click_timer
 Async timer for detecting long clicks. More...
 
DisplayPoint m_mouse_start_pos
 The starting position of the mouse. More...
 

Detailed Description

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().

Member Typedef Documentation

◆ CallbackArray

using CallbackArray = std::vector<MouseCallback>
protected

Type for array of registered callbacks.

◆ MouseCallback

using MouseCallback = std::function<void(Event& event)>

Type for mouse event callback.

Constructor & Destructor Documentation

◆ MouseGesture()

MouseGesture ( )
noexcept

Member Function Documentation

◆ active()

EGT_NODISCARD bool active ( ) const
inline

Is active?

◆ dragging()

EGT_NODISCARD bool dragging ( ) const
inline

Is dragging?

◆ handle()

Event handle ( const Event event)

Pass the raw EventId to this function to get the emulated mouse event.

◆ invoke_handlers()

void invoke_handlers ( Event event)
protected

Invoke an event on each of the handlers.

◆ mouse_start()

EGT_NODISCARD const DisplayPoint& mouse_start ( ) const
inline

Get pointer start position.

◆ on_async_event()

void on_async_event ( MouseCallback  callback)

Register a callback function to handle the async mouse events.

◆ start()

void start ( const DisplayPoint point)

Start.

◆ stop()

void stop ( )

Stop any active dragging state.

Member Data Documentation

◆ m_active

bool m_active {false}
protected

Currently processing subsequent events.

◆ m_callbacks

CallbackArray m_callbacks
protected

Registered callback functions.

◆ m_dragging

bool m_dragging {false}
protected

Currently in the dragging state.

◆ m_long_click_timer

PeriodicTimer m_long_click_timer
protected

Async timer for detecting long clicks.

◆ m_mouse_start_pos

DisplayPoint m_mouse_start_pos
protected

The starting position of the mouse.