Make fromHotkey parameter explicit, and don't set it for non-hotkeys.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15527
This commit is contained in:
Jeff Young 2023-08-31 17:00:35 +01:00
parent c2fd2f42eb
commit c9acca1342
2 changed files with 11 additions and 11 deletions

View File

@ -434,7 +434,7 @@ int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
if( currentGrid >= int( m_grids.size() ) ) if( currentGrid >= int( m_grids.size() ) )
currentGrid = 0; currentGrid = 0;
return OnGridChanged(); return OnGridChanged( true );
} }
@ -447,23 +447,23 @@ int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent )
if( currentGrid < 0 ) if( currentGrid < 0 )
currentGrid = (int) m_grids.size() - 1; currentGrid = (int) m_grids.size() - 1;
return OnGridChanged(); return OnGridChanged( true );
} }
int COMMON_TOOLS::GridPreset( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::GridPreset( const TOOL_EVENT& aEvent )
{ {
return GridPreset( aEvent.Parameter<int>() ); return GridPreset( aEvent.Parameter<int>(), false );
} }
int COMMON_TOOLS::GridPreset( int idx ) int COMMON_TOOLS::GridPreset( int idx, bool aFromHotkey )
{ {
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
currentGrid = alg::clamp( 0, idx, (int) m_grids.size() - 1 ); currentGrid = alg::clamp( 0, idx, (int) m_grids.size() - 1 );
return OnGridChanged(); return OnGridChanged( aFromHotkey );
} }
@ -496,13 +496,13 @@ int COMMON_TOOLS::OnGridChanged( bool aFromHotkey )
int COMMON_TOOLS::GridFast1( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::GridFast1( const TOOL_EVENT& aEvent )
{ {
return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1 ); return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1, true );
} }
int COMMON_TOOLS::GridFast2( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::GridFast2( const TOOL_EVENT& aEvent )
{ {
return GridPreset( m_frame->config()->m_Window.grid.fast_grid_2 ); return GridPreset( m_frame->config()->m_Window.grid.fast_grid_2, true );
} }
@ -511,10 +511,10 @@ int COMMON_TOOLS::GridFastCycle( const TOOL_EVENT& aEvent )
if( m_toolMgr->GetSettings()->m_Window.grid.last_size_idx if( m_toolMgr->GetSettings()->m_Window.grid.last_size_idx
== m_frame->config()->m_Window.grid.fast_grid_1 ) == 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_2, true );
} }
return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1 ); return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1, true );
} }

View File

@ -86,9 +86,9 @@ public:
int ToggleGrid( const TOOL_EVENT& aEvent ); int ToggleGrid( const TOOL_EVENT& aEvent );
int ToggleGridOverrides( const TOOL_EVENT& aEvent ); int ToggleGridOverrides( const TOOL_EVENT& aEvent );
int GridProperties( const TOOL_EVENT& aEvent ); int GridProperties( const TOOL_EVENT& aEvent );
int GridPreset( int idx ); int GridPreset( int idx, bool aFromHotkey );
int GridOrigin( const TOOL_EVENT& aEvent ); int GridOrigin( const TOOL_EVENT& aEvent );
int OnGridChanged( bool aFromHotkey = true ); int OnGridChanged( bool aFromHotkey );
const std::vector<VECTOR2I> Grids() const { return m_grids; } const std::vector<VECTOR2I> Grids() const { return m_grids; }