KiCad PCB EDA Suite
|
#include <tool_dispatcher.h>
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. More... | |
virtual void | DispatchWxEvent (wxEvent &aEvent) |
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those. More... | |
std::optional< TOOL_EVENT > | GetToolEvent (wxKeyEvent *aKeyEvent, bool *aSpecialKeyFlag) |
Map a wxWidgets key event to a TOOL_EVENT. More... | |
Private Member Functions | |
bool | handleMouseButton (wxEvent &aEvent, int aIndex, bool aMotion) |
Saves the state of key modifiers (Alt, Ctrl and so on). More... | |
KIGFX::VIEW * | getView () |
Instance of tool manager that cooperates with the dispatcher. More... | |
Static Private Member Functions | |
static int | decodeModifiers (const wxKeyboardState *aState) |
Stores all the information regarding a mouse button state. More... | |
Private Attributes | |
int | m_sysDragMinX |
Maximum distance before drag is activated in the Y axis. More... | |
int | m_sysDragMinY |
Handles mouse related events (click, motion, dragging). More... | |
VECTOR2D | m_lastMousePos |
The last mouse cursor position (in world coordinates). More... | |
VECTOR2D | m_lastMousePosScreen |
State of mouse buttons. More... | |
std::vector< BUTTON_STATE * > | m_buttons |
Returns the instance of VIEW, used by the application. More... | |
TOOL_MANAGER * | m_toolMgr |
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). More... | |
static const int | DragDistanceThreshold = 8 |
Mininum distance before drag is activated in the X axis. More... | |
Definition at line 51 of file tool_dispatcher.h.
TOOL_DISPATCHER::TOOL_DISPATCHER | ( | TOOL_MANAGER * | aToolMgr | ) |
aToolMgr | tool manager instance the events will be sent to. |
Definition at line 127 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().
|
virtual |
Definition at line 151 of file tool_dispatcher.cpp.
References m_buttons.
|
inlinestaticprivate |
Stores all the information regarding a mouse button state.
Definition at line 98 of file tool_dispatcher.h.
References MD_ALT, MD_CTRL, and MD_SHIFT.
Referenced by DispatchWxEvent(), GetToolEvent(), and handleMouseButton().
|
virtual |
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
aEvent | is the wxWidgets event to be processed. |
Definition at line 420 of file tool_dispatcher.cpp.
References decodeModifiers(), dump(), KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE, KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary(), KIGFX::VIEW_CONTROLS::GetMousePosition(), TOOLS_HOLDER::GetToolCanvas(), GetToolEvent(), TOOL_MANAGER::GetToolHolder(), TOOL_MANAGER::GetViewControls(), handleMouseButton(), KIUI::IsInputControlEditable(), KIUI::IsInputControlFocused(), isMouseClick(), KIPLATFORM::UI::IsWindowActive(), kicadTraceKeyEvent, kicadTraceToolStack, m_buttons, m_lastMousePos, m_lastMousePosScreen, m_toolMgr, ACTION_MENU::OnMenuEvent(), TOOL_MANAGER::ProcessEvent(), TA_MOUSE_MOTION, and TC_MOUSE.
Referenced by FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME(), EDA_3D_CANVAS::OnEvent(), EDA_DRAW_PANEL_GAL::OnEvent(), PANEL_PREVIEW_3D_MODEL::OnMenuEvent(), EDA_BASE_FRAME::OnMenuEvent(), CVPCB_MAINFRAME::setupEventHandlers(), SIMULATOR_FRAME::setupTools(), KICAD_MANAGER_FRAME::setupTools(), SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME(), and CVPCB_MAINFRAME::~CVPCB_MAINFRAME().
std::optional< TOOL_EVENT > TOOL_DISPATCHER::GetToolEvent | ( | wxKeyEvent * | aKeyEvent, |
bool * | aSpecialKeyFlag | ||
) |
Map a wxWidgets key event to a TOOL_EVENT.
Definition at line 340 of file tool_dispatcher.cpp.
References decodeModifiers(), dump(), ignore_unused(), isKeyModifierOnly(), isKeySpecialCode(), kicadTraceKeyEvent, MD_ALT, MD_CTRL, TA_CANCEL_TOOL, TA_KEY_PRESSED, TC_COMMAND, TC_KEYBOARD, and translateSpecialCode().
Referenced by DispatchWxEvent().
|
private |
Instance of tool manager that cooperates with the dispatcher.
Definition at line 165 of file tool_dispatcher.cpp.
References TOOL_MANAGER::GetView(), and m_toolMgr.
|
private |
Saves the state of key modifiers (Alt, Ctrl and so on).
Definition at line 171 of file tool_dispatcher.cpp.
References TOOL_DISPATCHER::BUTTON_STATE::button, TOOL_DISPATCHER::BUTTON_STATE::dblClickEvent, decodeModifiers(), down, TOOL_DISPATCHER::BUTTON_STATE::downEvent, TOOL_DISPATCHER::BUTTON_STATE::downPosition, TOOL_DISPATCHER::BUTTON_STATE::downTimestamp, TOOL_DISPATCHER::BUTTON_STATE::dragging, TOOL_DISPATCHER::BUTTON_STATE::dragOrigin, TOOL_DISPATCHER::BUTTON_STATE::dragOriginScreen, DragTimeThreshold, TOOL_DISPATCHER::BUTTON_STATE::GetState(), m_buttons, m_lastMousePos, m_lastMousePosScreen, m_sysDragMinX, m_sysDragMinY, m_toolMgr, TOOL_DISPATCHER::BUTTON_STATE::pressed, TOOL_MANAGER::ProcessEvent(), TA_MOUSE_CLICK, TA_MOUSE_DBLCLICK, TA_MOUSE_DOWN, TA_MOUSE_DRAG, TA_MOUSE_UP, TC_MOUSE, up, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by DispatchWxEvent().
|
virtual |
Bring the dispatcher to its initial state.
Definition at line 158 of file tool_dispatcher.cpp.
References m_buttons.
Referenced by TOOL_DISPATCHER().
|
staticprivate |
Mininum distance before drag is activated in the X axis.
Definition at line 87 of file tool_dispatcher.h.
Referenced by TOOL_DISPATCHER().
|
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 82 of file tool_dispatcher.h.
Referenced by handleMouseButton().
|
private |
Returns the instance of VIEW, used by the application.
Definition at line 124 of file tool_dispatcher.h.
Referenced by DispatchWxEvent(), handleMouseButton(), ResetState(), TOOL_DISPATCHER(), and ~TOOL_DISPATCHER().
|
private |
The last mouse cursor position (in world coordinates).
The last mouse cursor position (in screen coordinates).
Definition at line 118 of file tool_dispatcher.h.
Referenced by DispatchWxEvent(), and handleMouseButton().
|
private |
State of mouse buttons.
Definition at line 121 of file tool_dispatcher.h.
Referenced by DispatchWxEvent(), and handleMouseButton().
|
private |
Maximum distance before drag is activated in the Y axis.
Definition at line 90 of file tool_dispatcher.h.
Referenced by handleMouseButton(), and TOOL_DISPATCHER().
|
private |
Handles mouse related events (click, motion, dragging).
Definition at line 92 of file tool_dispatcher.h.
Referenced by handleMouseButton(), and TOOL_DISPATCHER().
|
private |
Definition at line 130 of file tool_dispatcher.h.
Referenced by DispatchWxEvent(), getView(), and handleMouseButton().