Common: add fast grid cycling

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/12339
This commit is contained in:
Mike Williams 2023-08-03 11:55:49 -04:00
parent 9e019a1ad1
commit a75fb44349
4 changed files with 20 additions and 0 deletions

View File

@ -523,6 +523,11 @@ TOOL_ACTION ACTIONS::gridFast2( "common.Control.gridFast2",
MD_ALT + '2', LEGACY_HK_NAME( "Switch Grid To Fast Grid2" ),
_( "Switch to Fast Grid 2" ), "" );
TOOL_ACTION ACTIONS::gridFastCycle( "common.Control.gridFastCycle",
AS_GLOBAL,
MD_ALT + '4', LEGACY_HK_NAME( "Switch Grid To Next Fast Grid" ),
_( "Cycle Fast Grid" ), "" );
TOOL_ACTION ACTIONS::gridNext( "common.Control.gridNext",
AS_GLOBAL,
'N', LEGACY_HK_NAME( "Switch Grid To Next" ),

View File

@ -509,6 +509,18 @@ int COMMON_TOOLS::GridFast2( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::GridFastCycle( const TOOL_EVENT& aEvent )
{
if( m_toolMgr->GetSettings()->m_Window.grid.last_size_idx
== m_frame->config()->m_Window.grid.fast_grid_1 )
{
return GridPreset( m_frame->config()->m_Window.grid.fast_grid_2 );
}
return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1 );
}
int COMMON_TOOLS::ToggleGrid( const TOOL_EVENT& aEvent )
{
m_frame->SetGridVisibility( !m_frame->IsGridVisible() );
@ -671,6 +683,7 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() );
Go( &COMMON_TOOLS::GridFast1, ACTIONS::gridFast1.MakeEvent() );
Go( &COMMON_TOOLS::GridFast2, ACTIONS::gridFast2.MakeEvent() );
Go( &COMMON_TOOLS::GridFastCycle, ACTIONS::gridFastCycle.MakeEvent() );
Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() );
Go( &COMMON_TOOLS::ToggleGridOverrides, ACTIONS::toggleGridOverrides.MakeEvent() );
Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() );

View File

@ -136,6 +136,7 @@ public:
// Grid control
static TOOL_ACTION gridFast1;
static TOOL_ACTION gridFast2;
static TOOL_ACTION gridFastCycle;
static TOOL_ACTION gridNext;
static TOOL_ACTION gridPrev;
static TOOL_ACTION gridSetOrigin;

View File

@ -82,6 +82,7 @@ public:
int GridPreset( const TOOL_EVENT& aEvent );
int GridFast1( const TOOL_EVENT& aEvent );
int GridFast2( const TOOL_EVENT& aEvent );
int GridFastCycle( const TOOL_EVENT& aEvent );
int ToggleGrid( const TOOL_EVENT& aEvent );
int ToggleGridOverrides( const TOOL_EVENT& aEvent );
int GridProperties( const TOOL_EVENT& aEvent );