Push resetLocalCoords down into COMMON_TOOLS.

Fixes: lp:1830693
* https://bugs.launchpad.net/kicad/+bug/1830693
This commit is contained in:
Jeff Young 2019-05-28 15:39:14 +01:00
parent a27e4246e0
commit 0260b32125
21 changed files with 67 additions and 94 deletions

View File

@ -312,6 +312,10 @@ TOOL_ACTION ACTIONS::togglePolarCoords( "common.Control.togglePolarCoords",
_( "Polar Coordinates" ), _( "Switch between polar and cartesian coordinate systems" ),
polar_coord_xpm );
TOOL_ACTION ACTIONS::resetLocalCoords( "common.Control.resetLocalCoords",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ),
"", "" );
TOOL_ACTION ACTIONS::toggleCursor( "common.Control.toggleCursor",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_TOGGLE_CURSOR ),
_( "Always Show Cursor" ), _( "Display crosshairs even in selection tool" ),

View File

@ -462,6 +462,21 @@ int COMMON_TOOLS::TogglePolarCoords( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::ResetLocalCoords( const TOOL_EVENT& aEvent )
{
auto vcSettings = m_toolMgr->GetCurrentToolVC();
// Use either the active tool forced cursor position or the general settings
VECTOR2I cursorPos = vcSettings.m_forceCursorPosition ? vcSettings.m_forcedPosition :
getViewControls()->GetCursorPosition();
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar();
return 0;
}
int COMMON_TOOLS::ToggleCursor( const TOOL_EVENT& aEvent )
{
auto& galOpts = m_frame->GetGalDisplayOptions();
@ -540,6 +555,7 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::MetricUnits, ACTIONS::metricUnits.MakeEvent() );
Go( &COMMON_TOOLS::ToggleUnits, ACTIONS::toggleUnits.MakeEvent() );
Go( &COMMON_TOOLS::TogglePolarCoords, ACTIONS::togglePolarCoords.MakeEvent() );
Go( &COMMON_TOOLS::ResetLocalCoords, ACTIONS::resetLocalCoords.MakeEvent() );
Go( &COMMON_TOOLS::ToggleCursor, ACTIONS::toggleCursor.MakeEvent() );
Go( &COMMON_TOOLS::ToggleCursorStyle, ACTIONS::toggleCursorStyle.MakeEvent() );

View File

@ -52,7 +52,6 @@ public:
// Miscellaneous
static TOOL_ACTION zoomTool;
static TOOL_ACTION resetCoords;
static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits;
static TOOL_ACTION showHelp;

View File

@ -44,10 +44,6 @@ using namespace std::placeholders;
// Miscellaneous
TOOL_ACTION CVPCB_ACTIONS::resetCoords( "cvpcb.Control.resetCoords",
AS_GLOBAL, ' ',//TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ),
"", "" );
TOOL_ACTION CVPCB_ACTIONS::switchCursor( "cvpcb.Control.switchCursor",
AS_GLOBAL, 0,
"", "" );
@ -80,21 +76,6 @@ void CVPCB_CONTROL::Reset( RESET_REASON aReason )
// Miscellaneous
int CVPCB_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
{
auto vcSettings = m_toolMgr->GetCurrentToolVC();
// Use either the active tool forced cursor position or the general settings
VECTOR2I cursorPos = vcSettings.m_forceCursorPosition ? vcSettings.m_forcedPosition :
getViewControls()->GetCursorPosition();
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar();
return 0;
}
int CVPCB_CONTROL::SwitchCursor( const TOOL_EVENT& aEvent )
{
auto& galOpts = m_frame->GetGalDisplayOptions();
@ -116,7 +97,6 @@ int CVPCB_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
void CVPCB_CONTROL::setTransitions()
{
// Miscellaneous
Go( &CVPCB_CONTROL::ResetCoords, CVPCB_ACTIONS::resetCoords.MakeEvent() );
Go( &CVPCB_CONTROL::SwitchCursor, CVPCB_ACTIONS::switchCursor.MakeEvent() );
Go( &CVPCB_CONTROL::SwitchUnits, CVPCB_ACTIONS::switchUnits.MakeEvent() );
}

View File

@ -49,7 +49,6 @@ public:
void Reset( RESET_REASON aReason ) override;
// Miscellaneous
int ResetCoords( const TOOL_EVENT& aEvent );
int SwitchCursor( const TOOL_EVENT& aEvent );
int SwitchUnits( const TOOL_EVENT& aEvent );

View File

@ -115,6 +115,9 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
m_menu.CloseContextMenu( evt );
}
else
m_toolMgr->PassEvent();
}
// This tool is supposed to be active forever

View File

@ -453,6 +453,9 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
m_menu.CloseContextMenu( evt );
}
else
m_toolMgr->PassEvent();
}
// This tool is supposed to be active forever

View File

@ -69,8 +69,7 @@ static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ),
HK_PREFERENCES, GR_KB_CTRL + ',', (int) wxID_PREFERENCES );
static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ),
HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkSwitchHighContrastMode( _HKI( "Toggle High Contrast Mode" ),
HK_SWITCH_HIGHCONTRAST_MODE, 'H' + GR_KB_CTRL );

View File

@ -77,7 +77,6 @@ public:
// Miscellaneous
static TOOL_ACTION selectionTool;
static TOOL_ACTION zoomTool;
static TOOL_ACTION resetCoords;
static TOOL_ACTION showHelp;
// Highlighting

View File

@ -92,10 +92,6 @@ TOOL_ACTION GERBVIEW_ACTIONS::dcodeDisplay( "gerbview.Control.dcodeDisplay",
_( "Show DCodes" ), _( "Show dcode number" ),
show_dcodenumber_xpm );
TOOL_ACTION GERBVIEW_ACTIONS::resetCoords( "gerbview.Control.resetCoords",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ),
"", "" );
TOOL_ACTION GERBVIEW_ACTIONS::showHelp( "gerbview.Control.showHelp",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HELP ),
"", "" );
@ -229,17 +225,6 @@ int GERBVIEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
}
int GERBVIEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
{
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar();
return 0;
}
int GERBVIEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
{
m_frame->ChangeUserUnits( m_frame->GetUserUnits() == INCHES ? MILLIMETRES : INCHES );
@ -271,6 +256,5 @@ void GERBVIEW_CONTROL::setTransitions()
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::negativeObjectDisplay.MakeEvent() );
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::dcodeDisplay.MakeEvent() );
Go( &GERBVIEW_CONTROL::ResetCoords, GERBVIEW_ACTIONS::resetCoords.MakeEvent() );
Go( &GERBVIEW_CONTROL::ShowHelp, GERBVIEW_ACTIONS::showHelp.MakeEvent() );
}

View File

@ -57,7 +57,6 @@ public:
int HighlightControl( const TOOL_EVENT& aEvent );
// Miscellaneous
int ResetCoords( const TOOL_EVENT& aEvent );
int SwitchUnits( const TOOL_EVENT& aEvent );
int ShowHelp( const TOOL_EVENT& aEvent );

View File

@ -261,6 +261,9 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
m_menu.CloseContextMenu( evt );
}
else
m_toolMgr->PassEvent();
}
// This tool is supposed to be active forever

View File

@ -129,6 +129,7 @@ public:
static TOOL_ACTION metricUnits;
static TOOL_ACTION toggleUnits;
static TOOL_ACTION togglePolarCoords;
static TOOL_ACTION resetLocalCoords;
// Misc
static TOOL_ACTION acceleratedGraphics;

View File

@ -70,6 +70,7 @@ public:
int MetricUnits( const TOOL_EVENT& aEvent );
int ToggleUnits( const TOOL_EVENT& aEvent );
int TogglePolarCoords( const TOOL_EVENT& aEvent );
int ResetLocalCoords( const TOOL_EVENT& aEvent );
// Grid control
int GridNext( const TOOL_EVENT& aEvent );

View File

@ -636,9 +636,8 @@ namespace TOOL_EVT_UTILS
/**
* Function IsCancelInteractive()
*
* @return true if this event should restart/end an ongoing interactive
* tool's event loop (eg esc key, click cancel, start different
* tool)
* Indicates the event should restart/end an ongoing interactive tool's
* event loop (eg esc key, click cancel, start different tool)
*/
bool IsCancelInteractive( const TOOL_EVENT& aEvt );

View File

@ -220,6 +220,9 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
m_menu.CloseContextMenu( evt );
}
else
m_toolMgr->PassEvent();
}
// This tool is supposed to be active forever

View File

@ -1144,7 +1144,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
m_view->Update( &preview );
frame()->SetMsgPanel( aGraphic );
}
else if( evt->IsAction( &PCB_ACTIONS::resetCoords ) )
else if( evt->IsAction( &ACTIONS::resetLocalCoords ) )
{
IsOCurseurSet = true;
}

View File

@ -302,7 +302,6 @@ public:
// Miscellaneous
static TOOL_ACTION selectionTool;
static TOOL_ACTION pickerTool;
static TOOL_ACTION resetCoords;
static TOOL_ACTION measureTool;
static TOOL_ACTION updateUnits;
static TOOL_ACTION deleteTool;

View File

@ -197,10 +197,6 @@ TOOL_ACTION PCB_ACTIONS::selectionTool( "pcbnew.Control.selectionTool",
_( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::resetCoords( "pcbnew.Control.resetCoords",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ),
"", "" );
TOOL_ACTION PCB_ACTIONS::deleteTool( "pcbnew.Control.deleteTool",
AS_GLOBAL, 0,
_( "Delete Items Tool" ), _( "Click on items to delete them" ),
@ -627,21 +623,6 @@ int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent )
// Miscellaneous
int PCBNEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
{
auto vcSettings = m_toolMgr->GetCurrentToolVC();
// Use either the active tool forced cursor position or the general settings
VECTOR2I cursorPos = vcSettings.m_forceCursorPosition ? vcSettings.m_forcedPosition :
getViewControls()->GetCursorPosition();
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar();
return 0;
}
static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
{
SELECTION_TOOL* selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
@ -1057,7 +1038,6 @@ void PCBNEW_CONTROL::setTransitions()
Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
// Miscellaneous
Go( &PCBNEW_CONTROL::ResetCoords, PCB_ACTIONS::resetCoords.MakeEvent() );
Go( &PCBNEW_CONTROL::DeleteItemCursor, PCB_ACTIONS::deleteTool.MakeEvent() );
Go( &PCBNEW_CONTROL::ShowHelp, PCB_ACTIONS::showHelp.MakeEvent() );
Go( &PCBNEW_CONTROL::ToBeDone, PCB_ACTIONS::toBeDone.MakeEvent() );

View File

@ -91,7 +91,6 @@ public:
int Redo( const TOOL_EVENT& aEvent );
// Miscellaneous
int ResetCoords( const TOOL_EVENT& aEvent );
int DeleteItemCursor( const TOOL_EVENT& aEvent );
int Paste( const TOOL_EVENT& aEvent );
int AppendBoardFromFile( const TOOL_EVENT& aEvent );

View File

@ -370,6 +370,9 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
m_menu.CloseContextMenu( evt );
}
else
m_toolMgr->PassEvent();
}
// This tool is supposed to be active forever