KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TOOL_DISPATCHER Class Reference

#include <tool_dispatcher.h>

Inheritance diagram for TOOL_DISPATCHER:

Classes

struct  BUTTON_STATE
 < Stores information about a mouse button state More...
 

Public Member Functions

 TOOL_DISPATCHER (TOOL_MANAGER *aToolMgr)
 
virtual ~TOOL_DISPATCHER ()
 
virtual void ResetState ()
 Bring the dispatcher to its initial state.
 
virtual void DispatchWxEvent (wxEvent &aEvent)
 Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
 
std::optional< TOOL_EVENTGetToolEvent (wxKeyEvent *aKeyEvent, bool *aSpecialKeyFlag)
 Map a wxWidgets key event to a TOOL_EVENT.
 
ACTION_MENUGetCurrentMenu () const
 

Private Member Functions

bool handleMouseButton (wxEvent &aEvent, int aIndex, bool aMotion)
 < Handles mouse related events (click, motion, dragging).
 
KIGFX::VIEWgetView ()
 Saves the state of key modifiers (Alt, Ctrl and so on).
 

Static Private Member Functions

static int decodeModifiers (const wxKeyboardState *aState)
 

Private Attributes

int m_sysDragMinX
 Mininum distance before drag is activated in the X axis.
 
int m_sysDragMinY
 Maximum distance before drag is activated in the Y axis.
 
VECTOR2D m_lastMousePos
 The last mouse cursor position (in world coordinates).
 
VECTOR2D m_lastMousePosScreen
 The last mouse cursor position (in screen coordinates).
 
std::vector< BUTTON_STATE * > m_buttons
 Instance of tool manager that cooperates with the dispatcher.
 
TOOL_MANAGERm_toolMgr
 The menu from the main menubar currently shown (if any; nullptr otherwise)
 
ACTION_MENUm_currentMenu
 

Static Private Attributes

static const int DragTimeThreshold = 300
 < The time threshold for a mouse button press that distinguishes between a single mouse click and a beginning of drag event (expressed in milliseconds).
 
static const int DragDistanceThreshold = 8
 

Detailed Description

  • takes wx events,
  • fixes all wx quirks (mouse warping, panning, ordering problems, etc)
  • translates coordinates to world space
  • low-level input conditioning (drag/click threshold), updating mouse position during view auto-scroll/pan.
  • issues TOOL_EVENTS to the tool manager

Definition at line 52 of file tool_dispatcher.h.

Constructor & Destructor Documentation

◆ TOOL_DISPATCHER()

TOOL_DISPATCHER::TOOL_DISPATCHER ( TOOL_MANAGER aToolMgr)
Parameters
aToolMgrtool manager instance the events will be sent to.

Definition at line 131 of file tool_dispatcher.cpp.

References BUT_AUX1, BUT_AUX2, BUT_LEFT, BUT_MIDDLE, BUT_RIGHT, DragDistanceThreshold, m_buttons, m_sysDragMinX, m_sysDragMinY, and ResetState().

◆ ~TOOL_DISPATCHER()

TOOL_DISPATCHER::~TOOL_DISPATCHER ( )
virtual

Definition at line 156 of file tool_dispatcher.cpp.

References m_buttons.

Member Function Documentation

◆ decodeModifiers()

static int TOOL_DISPATCHER::decodeModifiers ( const wxKeyboardState *  aState)
inlinestaticprivate

Definition at line 90 of file tool_dispatcher.h.

References MD_ALT, MD_CTRL, and MD_SHIFT.

Referenced by DispatchWxEvent(), GetToolEvent(), and handleMouseButton().

◆ DispatchWxEvent()

◆ GetCurrentMenu()

ACTION_MENU * TOOL_DISPATCHER::GetCurrentMenu ( ) const
inline

Definition at line 80 of file tool_dispatcher.h.

References m_currentMenu.

Referenced by LIB_TREE::onHoverTimer().

◆ GetToolEvent()

std::optional< TOOL_EVENT > TOOL_DISPATCHER::GetToolEvent ( wxKeyEvent *  aKeyEvent,
bool *  aSpecialKeyFlag 
)

◆ getView()

KIGFX::VIEW * TOOL_DISPATCHER::getView ( )
private

Saves the state of key modifiers (Alt, Ctrl and so on).

Definition at line 170 of file tool_dispatcher.cpp.

References TOOL_MANAGER::GetView(), and m_toolMgr.

◆ handleMouseButton()

◆ ResetState()

void TOOL_DISPATCHER::ResetState ( )
virtual

Bring the dispatcher to its initial state.

Definition at line 163 of file tool_dispatcher.cpp.

References m_buttons.

Referenced by TOOL_DISPATCHER().

Member Data Documentation

◆ DragDistanceThreshold

const int TOOL_DISPATCHER::DragDistanceThreshold = 8
staticprivate

Definition at line 114 of file tool_dispatcher.h.

Referenced by TOOL_DISPATCHER().

◆ DragTimeThreshold

const int TOOL_DISPATCHER::DragTimeThreshold = 300
staticprivate

< The time threshold for a mouse button press that distinguishes between a single mouse click and a beginning of drag event (expressed in milliseconds).

The distance threshold for mouse cursor that distinguishes between a single mouse click and a beginning of drag event (expressed in screen pixels). System drag preferences take precedence if available

Definition at line 109 of file tool_dispatcher.h.

Referenced by handleMouseButton().

◆ m_buttons

std::vector<BUTTON_STATE*> TOOL_DISPATCHER::m_buttons
private

Instance of tool manager that cooperates with the dispatcher.

Definition at line 124 of file tool_dispatcher.h.

Referenced by DispatchWxEvent(), handleMouseButton(), ResetState(), TOOL_DISPATCHER(), and ~TOOL_DISPATCHER().

◆ m_currentMenu

ACTION_MENU* TOOL_DISPATCHER::m_currentMenu
private

Definition at line 130 of file tool_dispatcher.h.

Referenced by DispatchWxEvent(), and GetCurrentMenu().

◆ m_lastMousePos

VECTOR2D TOOL_DISPATCHER::m_lastMousePos
private

The last mouse cursor position (in world coordinates).

Definition at line 119 of file tool_dispatcher.h.

Referenced by DispatchWxEvent(), and handleMouseButton().

◆ m_lastMousePosScreen

VECTOR2D TOOL_DISPATCHER::m_lastMousePosScreen
private

The last mouse cursor position (in screen coordinates).

State of mouse buttons.

Definition at line 120 of file tool_dispatcher.h.

Referenced by DispatchWxEvent(), and handleMouseButton().

◆ m_sysDragMinX

int TOOL_DISPATCHER::m_sysDragMinX
private

Mininum distance before drag is activated in the X axis.

Definition at line 116 of file tool_dispatcher.h.

Referenced by handleMouseButton(), and TOOL_DISPATCHER().

◆ m_sysDragMinY

int TOOL_DISPATCHER::m_sysDragMinY
private

Maximum distance before drag is activated in the Y axis.

Definition at line 117 of file tool_dispatcher.h.

Referenced by handleMouseButton(), and TOOL_DISPATCHER().

◆ m_toolMgr

TOOL_MANAGER* TOOL_DISPATCHER::m_toolMgr
private

The menu from the main menubar currently shown (if any; nullptr otherwise)

Definition at line 127 of file tool_dispatcher.h.

Referenced by DispatchWxEvent(), getView(), and handleMouseButton().


The documentation for this class was generated from the following files: