From 19b7755ab72128a288a41af47a601361ffca5d64 Mon Sep 17 00:00:00 2001 From: Peter Montgomery Date: Thu, 25 Jun 2020 22:43:29 +0000 Subject: [PATCH] Coverted Gerbview files to version in master so hotkey_rollover repo only contains changes for the hotkey fix --- pcbnew/tools/pcb_editor_control.cpp | 33 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index f48bf42cc9..f584acc305 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -491,8 +491,11 @@ int PCB_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent ) { int widthIndex = designSettings.GetTrackWidthIndex() + 1; + // If we go past the last track width entry in the list, start over at the beginning if( widthIndex >= (int) designSettings.m_TrackWidthList.size() ) - widthIndex = designSettings.m_TrackWidthList.size() - 1; + { + widthIndex = 0; + } designSettings.SetTrackWidthIndex( widthIndex ); designSettings.UseCustomTrackViaSize( false ); @@ -538,10 +541,16 @@ int PCB_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent ) } else { - int widthIndex = designSettings.GetTrackWidthIndex() - 1; + int widthIndex = 0; // Assume we only have a single track width entry - if( widthIndex < 0 ) - widthIndex = 0; + // If there are more, cycle through them backwards + if( designSettings.m_TrackWidthList.size() > 0 ) + { + widthIndex = designSettings.GetTrackWidthIndex() - 1; + // If we get to the lowest entry start over at the highest + if( widthIndex < 0 ) + widthIndex = designSettings.m_TrackWidthList.size() - 1; + } designSettings.SetTrackWidthIndex( widthIndex ); designSettings.UseCustomTrackViaSize( false ); @@ -588,8 +597,9 @@ int PCB_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent ) { int sizeIndex = designSettings.GetViaSizeIndex() + 1; + // If we go past the last via entry in the list, start over at the beginning if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() ) - sizeIndex = designSettings.m_ViasDimensionsList.size() - 1; + sizeIndex = 0; designSettings.SetViaSizeIndex( sizeIndex ); designSettings.UseCustomTrackViaSize( false ); @@ -636,10 +646,17 @@ int PCB_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent ) } else { - int sizeIndex = designSettings.GetViaSizeIndex() - 1; + int sizeIndex = 0; // Assume we only have a single via size entry - if( sizeIndex < 0 ) - sizeIndex = 0; + // If there are more, cycle through them backwards + if( designSettings.m_ViasDimensionsList.size() > 0 ) + { + sizeIndex = designSettings.GetViaSizeIndex() - 1; + + // If we get to the lowest entry start over at the highest + if( sizeIndex < 0 ) + sizeIndex = designSettings.m_ViasDimensionsList.size() - 1; + } designSettings.SetViaSizeIndex( sizeIndex ); designSettings.UseCustomTrackViaSize( false );