diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 06cb7b9e02..35ff69b65c 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -47,6 +47,66 @@ TOOL_ACTION ACTIONS::centerContents( "common.Control.centerContents", AS_GLOBAL, 0, "", "" ); +// Cursor control +TOOL_ACTION ACTIONS::cursorUp( "common.Control.cursorUp", + AS_GLOBAL, WXK_UP, + "", "", NULL, AF_NONE, (void*) CURSOR_UP ); + +TOOL_ACTION ACTIONS::cursorDown( "common.Control.cursorDown", + AS_GLOBAL, WXK_DOWN, + "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); + +TOOL_ACTION ACTIONS::cursorLeft( "common.Control.cursorLeft", + AS_GLOBAL, WXK_LEFT, + "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); + +TOOL_ACTION ACTIONS::cursorRight( "common.Control.cursorRight", + AS_GLOBAL, WXK_RIGHT, + "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); + + +TOOL_ACTION ACTIONS::cursorUpFast( "common.Control.cursorUpFast", + AS_GLOBAL, MD_CTRL + WXK_UP, + "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) ); + +TOOL_ACTION ACTIONS::cursorDownFast( "common.Control.cursorDownFast", + AS_GLOBAL, MD_CTRL + WXK_DOWN, + "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) ); + +TOOL_ACTION ACTIONS::cursorLeftFast( "common.Control.cursorLeftFast", + AS_GLOBAL, MD_CTRL + WXK_LEFT, + "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) ); + +TOOL_ACTION ACTIONS::cursorRightFast( "common.Control.cursorRightFast", + AS_GLOBAL, MD_CTRL + WXK_RIGHT, + "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) ); + + +TOOL_ACTION ACTIONS::cursorClick( "common.Control.cursorClick", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_CLICK ), + "", "", NULL, AF_NONE, (void*) CURSOR_CLICK ); + +TOOL_ACTION ACTIONS::cursorDblClick( "common.Control.cursorDblClick", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_DCLICK ), + "", "", NULL, AF_NONE, (void*) CURSOR_DBL_CLICK ); + + +TOOL_ACTION ACTIONS::panUp( "common.Control.panUp", + AS_GLOBAL, MD_SHIFT + WXK_UP, + "", "", NULL, AF_NONE, (void*) CURSOR_UP ); + +TOOL_ACTION ACTIONS::panDown( "common.Control.panDown", + AS_GLOBAL, MD_SHIFT + WXK_DOWN, + "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); + +TOOL_ACTION ACTIONS::panLeft( "common.Control.panLeft", + AS_GLOBAL, MD_SHIFT + WXK_LEFT, + "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); + +TOOL_ACTION ACTIONS::panRight( "common.Control.panRight", + AS_GLOBAL, MD_SHIFT + WXK_RIGHT, + "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); + // Grid control TOOL_ACTION ACTIONS::gridFast1( "common.Control.gridFast1", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_FASTGRID1 ), diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 727fcd3361..9995c12a40 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -57,6 +58,107 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason ) } +// Cursor control +int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent ) +{ + long type = aEvent.Parameter(); + bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE; + type &= ~ACTIONS::CURSOR_FAST_MOVE; + bool mirroredX = getView()->IsMirroredX(); + + VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true ); + VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() ); + + if( fastMove ) + gridSize = gridSize * 10; + + switch( type ) + { + case ACTIONS::CURSOR_UP: + cursor -= VECTOR2D( 0, gridSize.y ); + break; + + case ACTIONS::CURSOR_DOWN: + cursor += VECTOR2D( 0, gridSize.y ); + break; + + case ACTIONS::CURSOR_LEFT: + cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); + break; + + case ACTIONS::CURSOR_RIGHT: + cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); + break; + + case ACTIONS::CURSOR_CLICK: // fall through + case ACTIONS::CURSOR_DBL_CLICK: + { + TOOL_ACTIONS action = TA_NONE; + int modifiers = 0; + + modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0; + modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0; + modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0; + + if( type == ACTIONS::CURSOR_CLICK ) + action = TA_MOUSE_CLICK; + else if( type == ACTIONS::CURSOR_DBL_CLICK ) + action = TA_MOUSE_DBLCLICK; + else + wxFAIL; + + TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers ); + evt.SetMousePosition( getViewControls()->GetCursorPosition() ); + m_toolMgr->ProcessEvent( evt ); + + return 0; + } + break; + } + + getViewControls()->SetCursorPosition( cursor ); + + return 0; +} + + +int COMMON_TOOLS::PanControl( const TOOL_EVENT& aEvent ) +{ + long type = aEvent.Parameter(); + KIGFX::VIEW* view = getView(); + VECTOR2D center = view->GetCenter(); + VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() ) * 10; + bool mirroredX = view->IsMirroredX(); + + switch( type ) + { + case ACTIONS::CURSOR_UP: + center -= VECTOR2D( 0, gridSize.y ); + break; + + case ACTIONS::CURSOR_DOWN: + center += VECTOR2D( 0, gridSize.y ); + break; + + case ACTIONS::CURSOR_LEFT: + center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); + break; + + case ACTIONS::CURSOR_RIGHT: + center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); + break; + + default: + wxFAIL; + break; + } + + view->SetCenter( center ); + + return 0; +} + + int COMMON_TOOLS::ZoomInOut( const TOOL_EVENT& aEvent ) { bool direction = aEvent.IsAction( &ACTIONS::zoomIn ); @@ -268,6 +370,26 @@ int COMMON_TOOLS::ToggleCursor( const TOOL_EVENT& aEvent ) void COMMON_TOOLS::setTransitions() { + // Cursor control + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorUp.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDown.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorLeft.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorRight.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorUpFast.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDownFast.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorLeftFast.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorRightFast.MakeEvent() ); + + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorClick.MakeEvent() ); + Go( &COMMON_TOOLS::CursorControl, ACTIONS::cursorDblClick.MakeEvent() ); + + // Pan control + Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() ); + Go( &COMMON_TOOLS::PanControl, ACTIONS::panDown.MakeEvent() ); + Go( &COMMON_TOOLS::PanControl, ACTIONS::panLeft.MakeEvent() ); + Go( &COMMON_TOOLS::PanControl, ACTIONS::panRight.MakeEvent() ); + + // Zoom control Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() ); Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomOut.MakeEvent() ); Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomInCenter.MakeEvent() ); diff --git a/cvpcb/tools/cvpcb_actions.h b/cvpcb/tools/cvpcb_actions.h index e0f4eda9cb..b94512e000 100644 --- a/cvpcb/tools/cvpcb_actions.h +++ b/cvpcb/tools/cvpcb_actions.h @@ -50,25 +50,6 @@ public: static TOOL_ACTION no_selectionTool; static TOOL_ACTION measureTool; - /// Cursor control with keyboard - static TOOL_ACTION cursorUp; - static TOOL_ACTION cursorDown; - static TOOL_ACTION cursorLeft; - static TOOL_ACTION cursorRight; - - static TOOL_ACTION cursorUpFast; - static TOOL_ACTION cursorDownFast; - static TOOL_ACTION cursorLeftFast; - static TOOL_ACTION cursorRightFast; - - static TOOL_ACTION cursorClick; - - // Panning with keyboard - static TOOL_ACTION panUp; - static TOOL_ACTION panDown; - static TOOL_ACTION panLeft; - static TOOL_ACTION panRight; - // Miscellaneous static TOOL_ACTION zoomTool; static TOOL_ACTION resetCoords; diff --git a/cvpcb/tools/cvpcb_control.cpp b/cvpcb/tools/cvpcb_control.cpp index 77ed2b3ab6..06782c2541 100644 --- a/cvpcb/tools/cvpcb_control.cpp +++ b/cvpcb/tools/cvpcb_control.cpp @@ -42,37 +42,6 @@ #include using namespace std::placeholders; -// Cursor control -TOOL_ACTION CVPCB_ACTIONS::cursorUp( "cvpcb.Control.cursorUp", - AS_GLOBAL, WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP ); -TOOL_ACTION CVPCB_ACTIONS::cursorDown( "cvpcb.Control.cursorDown", - AS_GLOBAL, WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); -TOOL_ACTION CVPCB_ACTIONS::cursorLeft( "cvpcb.Control.cursorLeft", - AS_GLOBAL, WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); -TOOL_ACTION CVPCB_ACTIONS::cursorRight( "cvpcb.Control.cursorRight", - AS_GLOBAL, WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); - -TOOL_ACTION CVPCB_ACTIONS::cursorUpFast( "cvpcb.Control.cursorUpFast", - AS_GLOBAL, MD_CTRL + WXK_UP, "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) ); -TOOL_ACTION CVPCB_ACTIONS::cursorDownFast( "cvpcb.Control.cursorDownFast", - AS_GLOBAL, MD_CTRL + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) ); -TOOL_ACTION CVPCB_ACTIONS::cursorLeftFast( "cvpcb.Control.cursorLeftFast", - AS_GLOBAL, MD_CTRL + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) ); -TOOL_ACTION CVPCB_ACTIONS::cursorRightFast( "cvpcb.Control.cursorRightFast", - AS_GLOBAL, MD_CTRL + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) ); - -TOOL_ACTION CVPCB_ACTIONS::cursorClick( "cvpcb.Control.cursorClick", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_CLICK ), - "", "", NULL, AF_NONE, (void*) CURSOR_CLICK ); - -TOOL_ACTION CVPCB_ACTIONS::panUp( "cvpcb.Control.panUp", - AS_GLOBAL, MD_SHIFT + WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP ); -TOOL_ACTION CVPCB_ACTIONS::panDown( "cvpcb.Control.panDown", - AS_GLOBAL, MD_SHIFT + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); -TOOL_ACTION CVPCB_ACTIONS::panLeft( "cvpcb.Control.panLeft", - AS_GLOBAL, MD_SHIFT + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); -TOOL_ACTION CVPCB_ACTIONS::panRight( "cvpcb.Control.panRight", - AS_GLOBAL, MD_SHIFT + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); // Miscellaneous TOOL_ACTION CVPCB_ACTIONS::resetCoords( "cvpcb.Control.resetCoords", @@ -110,109 +79,6 @@ void CVPCB_CONTROL::Reset( RESET_REASON aReason ) } -// Cursor control -int CVPCB_CONTROL::CursorControl( const TOOL_EVENT& aEvent ) -{ - long type = aEvent.Parameter(); - bool fastMove = type & CVPCB_ACTIONS::CURSOR_FAST_MOVE; - type &= ~CVPCB_ACTIONS::CURSOR_FAST_MOVE; - bool mirroredX = getView()->IsMirroredX(); - - GRID_HELPER gridHelper( m_frame ); - VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true ); - VECTOR2I gridSize = gridHelper.GetGrid(); - - if( fastMove ) - gridSize = gridSize * 10; - - switch( type ) - { - case CVPCB_ACTIONS::CURSOR_UP: - cursor -= VECTOR2D( 0, gridSize.y ); - break; - - case CVPCB_ACTIONS::CURSOR_DOWN: - cursor += VECTOR2D( 0, gridSize.y ); - break; - - case CVPCB_ACTIONS::CURSOR_LEFT: - cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - case CVPCB_ACTIONS::CURSOR_RIGHT: - cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - case CVPCB_ACTIONS::CURSOR_CLICK: // fall through - case CVPCB_ACTIONS::CURSOR_DBL_CLICK: - { - TOOL_ACTIONS action = TA_NONE; - int modifiers = 0; - - modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0; - modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0; - modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0; - - if( type == CVPCB_ACTIONS::CURSOR_CLICK ) - action = TA_MOUSE_CLICK; - else if( type == CVPCB_ACTIONS::CURSOR_DBL_CLICK ) - action = TA_MOUSE_DBLCLICK; - else - wxFAIL; - - TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers ); - evt.SetMousePosition( getViewControls()->GetCursorPosition() ); - m_toolMgr->ProcessEvent( evt ); - - return 0; - } - break; - } - - getViewControls()->SetCursorPosition( cursor ); - - return 0; -} - - -int CVPCB_CONTROL::PanControl( const TOOL_EVENT& aEvent ) -{ - long type = aEvent.Parameter(); - KIGFX::VIEW* view = getView(); - GRID_HELPER gridHelper( m_frame ); - VECTOR2D center = view->GetCenter(); - VECTOR2I gridSize = gridHelper.GetGrid() * 10; - bool mirroredX = view->IsMirroredX(); - - switch( type ) - { - case CVPCB_ACTIONS::CURSOR_UP: - center -= VECTOR2D( 0, gridSize.y ); - break; - - case CVPCB_ACTIONS::CURSOR_DOWN: - center += VECTOR2D( 0, gridSize.y ); - break; - - case CVPCB_ACTIONS::CURSOR_LEFT: - center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - case CVPCB_ACTIONS::CURSOR_RIGHT: - center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - default: - wxFAIL; - break; - } - - view->SetCenter( center ); - - return 0; -} - - // Miscellaneous int CVPCB_CONTROL::ResetCoords( const TOOL_EVENT& aEvent ) { @@ -258,23 +124,6 @@ int CVPCB_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent ) void CVPCB_CONTROL::setTransitions() { - // Cursor control - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorUp.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorDown.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorLeft.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorRight.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorUpFast.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorDownFast.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorLeftFast.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorRightFast.MakeEvent() ); - Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorClick.MakeEvent() ); - - // Pan control - Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panUp.MakeEvent() ); - Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panDown.MakeEvent() ); - Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panLeft.MakeEvent() ); - Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panRight.MakeEvent() ); - // Miscellaneous Go( &CVPCB_CONTROL::ResetCoords, CVPCB_ACTIONS::resetCoords.MakeEvent() ); Go( &CVPCB_CONTROL::SwitchCursor, CVPCB_ACTIONS::switchCursor.MakeEvent() ); diff --git a/cvpcb/tools/cvpcb_control.h b/cvpcb/tools/cvpcb_control.h index 0937ccc90e..2143b1ceaa 100644 --- a/cvpcb/tools/cvpcb_control.h +++ b/cvpcb/tools/cvpcb_control.h @@ -48,9 +48,6 @@ public: /// @copydoc TOOL_INTERACTIVE::Reset() void Reset( RESET_REASON aReason ) override; - int CursorControl( const TOOL_EVENT& aEvent ); - int PanControl( const TOOL_EVENT& aEvent ); - // Miscellaneous int ResetCoords( const TOOL_EVENT& aEvent ); int SwitchCursor( const TOOL_EVENT& aEvent ); diff --git a/gerbview/tools/gerbview_actions.h b/gerbview/tools/gerbview_actions.h index 7ee2e6e06e..ce348c3c63 100644 --- a/gerbview/tools/gerbview_actions.h +++ b/gerbview/tools/gerbview_actions.h @@ -95,26 +95,10 @@ public: static TOOL_ACTION gridResetOrigin; static TOOL_ACTION gridPreset; - /// Cursor control with keyboard - static TOOL_ACTION cursorUp; - static TOOL_ACTION cursorDown; - static TOOL_ACTION cursorLeft; - static TOOL_ACTION cursorRight; - - static TOOL_ACTION cursorUpFast; - static TOOL_ACTION cursorDownFast; - static TOOL_ACTION cursorLeftFast; - static TOOL_ACTION cursorRightFast; - + /// Cursor control static TOOL_ACTION cursorClick; static TOOL_ACTION cursorDblClick; - // Panning with keyboard - static TOOL_ACTION panUp; - static TOOL_ACTION panDown; - static TOOL_ACTION panLeft; - static TOOL_ACTION panRight; - // Miscellaneous static TOOL_ACTION selectionTool; static TOOL_ACTION zoomTool; diff --git a/include/tool/actions.h b/include/tool/actions.h index 9433510e8a..5e7da3eef0 100644 --- a/include/tool/actions.h +++ b/include/tool/actions.h @@ -58,6 +58,26 @@ public: static TOOL_ACTION zoomTool; static TOOL_ACTION centerContents; + /// Cursor control with keyboard + static TOOL_ACTION cursorUp; + static TOOL_ACTION cursorDown; + static TOOL_ACTION cursorLeft; + static TOOL_ACTION cursorRight; + + static TOOL_ACTION cursorUpFast; + static TOOL_ACTION cursorDownFast; + static TOOL_ACTION cursorLeftFast; + static TOOL_ACTION cursorRightFast; + + static TOOL_ACTION cursorClick; + static TOOL_ACTION cursorDblClick; + + // Panning with keyboard + static TOOL_ACTION panUp; + static TOOL_ACTION panDown; + static TOOL_ACTION panLeft; + static TOOL_ACTION panRight; + // Grid control static TOOL_ACTION gridFast1; static TOOL_ACTION gridFast2; diff --git a/include/tool/common_tools.h b/include/tool/common_tools.h index ceac56112c..d18649cec9 100644 --- a/include/tool/common_tools.h +++ b/include/tool/common_tools.h @@ -53,7 +53,10 @@ public: int CenterContents( const TOOL_EVENT& aEvent ); + int PanControl( const TOOL_EVENT& aEvent ); + // Cursor control + int CursorControl( const TOOL_EVENT& aEvent ); int ToggleCursor( const TOOL_EVENT& aEvent ); // Grid control diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index c1efea1e7b..e49c916b17 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -353,26 +353,6 @@ public: static TOOL_ACTION microwaveCreateLine; - /// Cursor control with keyboard - static TOOL_ACTION cursorUp; - static TOOL_ACTION cursorDown; - static TOOL_ACTION cursorLeft; - static TOOL_ACTION cursorRight; - - static TOOL_ACTION cursorUpFast; - static TOOL_ACTION cursorDownFast; - static TOOL_ACTION cursorLeftFast; - static TOOL_ACTION cursorRightFast; - - static TOOL_ACTION cursorClick; - static TOOL_ACTION cursorDblClick; - - // Panning with keyboard - static TOOL_ACTION panUp; - static TOOL_ACTION panDown; - static TOOL_ACTION panLeft; - static TOOL_ACTION panRight; - // Locking static TOOL_ACTION toggleLock; static TOOL_ACTION lock; diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index d54f120fde..829fec683d 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -174,41 +174,6 @@ TOOL_ACTION PCB_ACTIONS::layerChanged( "pcbnew.Control.layerChanged", AS_GLOBAL, 0, "", "", NULL, AF_NOTIFY ); -// Cursor control -TOOL_ACTION PCB_ACTIONS::cursorUp( "pcbnew.Control.cursorUp", - AS_GLOBAL, WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP ); -TOOL_ACTION PCB_ACTIONS::cursorDown( "pcbnew.Control.cursorDown", - AS_GLOBAL, WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); -TOOL_ACTION PCB_ACTIONS::cursorLeft( "pcbnew.Control.cursorLeft", - AS_GLOBAL, WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); -TOOL_ACTION PCB_ACTIONS::cursorRight( "pcbnew.Control.cursorRight", - AS_GLOBAL, WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); - -TOOL_ACTION PCB_ACTIONS::cursorUpFast( "pcbnew.Control.cursorUpFast", - AS_GLOBAL, MD_CTRL + WXK_UP, "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) ); -TOOL_ACTION PCB_ACTIONS::cursorDownFast( "pcbnew.Control.cursorDownFast", - AS_GLOBAL, MD_CTRL + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) ); -TOOL_ACTION PCB_ACTIONS::cursorLeftFast( "pcbnew.Control.cursorLeftFast", - AS_GLOBAL, MD_CTRL + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) ); -TOOL_ACTION PCB_ACTIONS::cursorRightFast( "pcbnew.Control.cursorRightFast", - AS_GLOBAL, MD_CTRL + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) ); - -TOOL_ACTION PCB_ACTIONS::cursorClick( "pcbnew.Control.cursorClick", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_CLICK ), - "", "", NULL, AF_NONE, (void*) CURSOR_CLICK ); -TOOL_ACTION PCB_ACTIONS::cursorDblClick( "pcbnew.Control.cursorDblClick", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_DCLICK ), - "", "", NULL, AF_NONE, (void*) CURSOR_DBL_CLICK ); - -TOOL_ACTION PCB_ACTIONS::panUp( "pcbnew.Control.panUp", - AS_GLOBAL, MD_SHIFT + WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP ); -TOOL_ACTION PCB_ACTIONS::panDown( "pcbnew.Control.panDown", - AS_GLOBAL, MD_SHIFT + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); -TOOL_ACTION PCB_ACTIONS::panLeft( "pcbnew.Control.panLeft", - AS_GLOBAL, MD_SHIFT + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); -TOOL_ACTION PCB_ACTIONS::panRight( "pcbnew.Control.panRight", - AS_GLOBAL, MD_SHIFT + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); - // Miscellaneous TOOL_ACTION PCB_ACTIONS::selectionTool( "pcbnew.Control.selectionTool", AS_GLOBAL, 0, @@ -569,109 +534,6 @@ int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent ) } -// Cursor control -int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent ) -{ - long type = aEvent.Parameter(); - bool fastMove = type & PCB_ACTIONS::CURSOR_FAST_MOVE; - type &= ~PCB_ACTIONS::CURSOR_FAST_MOVE; - bool mirroredX = getView()->IsMirroredX(); - - GRID_HELPER gridHelper( m_frame ); - VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true ); - VECTOR2I gridSize = gridHelper.GetGrid(); - - if( fastMove ) - gridSize = gridSize * 10; - - switch( type ) - { - case PCB_ACTIONS::CURSOR_UP: - cursor -= VECTOR2D( 0, gridSize.y ); - break; - - case PCB_ACTIONS::CURSOR_DOWN: - cursor += VECTOR2D( 0, gridSize.y ); - break; - - case PCB_ACTIONS::CURSOR_LEFT: - cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - case PCB_ACTIONS::CURSOR_RIGHT: - cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - case PCB_ACTIONS::CURSOR_CLICK: // fall through - case PCB_ACTIONS::CURSOR_DBL_CLICK: - { - TOOL_ACTIONS action = TA_NONE; - int modifiers = 0; - - modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0; - modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0; - modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0; - - if( type == PCB_ACTIONS::CURSOR_CLICK ) - action = TA_MOUSE_CLICK; - else if( type == PCB_ACTIONS::CURSOR_DBL_CLICK ) - action = TA_MOUSE_DBLCLICK; - else - wxFAIL; - - TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers ); - evt.SetMousePosition( getViewControls()->GetCursorPosition() ); - m_toolMgr->ProcessEvent( evt ); - - return 0; - } - break; - } - - getViewControls()->SetCursorPosition( cursor ); - - return 0; -} - - -int PCBNEW_CONTROL::PanControl( const TOOL_EVENT& aEvent ) -{ - long type = aEvent.Parameter(); - KIGFX::VIEW* view = getView(); - GRID_HELPER gridHelper( m_frame ); - VECTOR2D center = view->GetCenter(); - VECTOR2I gridSize = gridHelper.GetGrid() * 10; - bool mirroredX = view->IsMirroredX(); - - switch( type ) - { - case PCB_ACTIONS::CURSOR_UP: - center -= VECTOR2D( 0, gridSize.y ); - break; - - case PCB_ACTIONS::CURSOR_DOWN: - center += VECTOR2D( 0, gridSize.y ); - break; - - case PCB_ACTIONS::CURSOR_LEFT: - center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - case PCB_ACTIONS::CURSOR_RIGHT: - center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 ); - break; - - default: - wxFAIL; - break; - } - - view->SetCenter( center ); - - return 0; -} - - // Grid control int PCBNEW_CONTROL::GridFast1( const TOOL_EVENT& aEvent ) { @@ -1161,24 +1023,6 @@ void PCBNEW_CONTROL::setTransitions() Go( &PCBNEW_CONTROL::LayerAlphaInc, PCB_ACTIONS::layerAlphaInc.MakeEvent() ); Go( &PCBNEW_CONTROL::LayerAlphaDec, PCB_ACTIONS::layerAlphaDec.MakeEvent() ); - // Cursor control - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorUp.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorDown.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorLeft.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorRight.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorUpFast.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorDownFast.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorLeftFast.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorRightFast.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorClick.MakeEvent() ); - Go( &PCBNEW_CONTROL::CursorControl, PCB_ACTIONS::cursorDblClick.MakeEvent() ); - - // Pan control - Go( &PCBNEW_CONTROL::PanControl, PCB_ACTIONS::panUp.MakeEvent() ); - Go( &PCBNEW_CONTROL::PanControl, PCB_ACTIONS::panDown.MakeEvent() ); - Go( &PCBNEW_CONTROL::PanControl, PCB_ACTIONS::panLeft.MakeEvent() ); - Go( &PCBNEW_CONTROL::PanControl, PCB_ACTIONS::panRight.MakeEvent() ); - // Grid control Go( &PCBNEW_CONTROL::GridFast1, ACTIONS::gridFast1.MakeEvent() ); Go( &PCBNEW_CONTROL::GridFast2, ACTIONS::gridFast2.MakeEvent() ); diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index 69c7cccdee..90451f4a36 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -70,9 +70,6 @@ public: int LayerAlphaInc( const TOOL_EVENT& aEvent ); int LayerAlphaDec( const TOOL_EVENT& aEvent ); - int CursorControl( const TOOL_EVENT& aEvent ); - int PanControl( const TOOL_EVENT& aEvent ); - // Grid control int GridFast1( const TOOL_EVENT& aEvent ); int GridFast2( const TOOL_EVENT& aEvent );