Fix all-layer snapping for footprint editor

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15538
This commit is contained in:
Jon Evans 2023-09-16 22:55:29 -04:00
parent d0f37ee55e
commit 467c672bcd
2 changed files with 17 additions and 8 deletions

View File

@ -50,9 +50,10 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
m_LastExportPath(),
m_FootprintTextShownColumns()
{
m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
m_MagneticItems.tracks = MAGNETIC_OPTIONS::NO_EFFECT;
m_MagneticItems.graphics = true;
m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
m_MagneticItems.tracks = MAGNETIC_OPTIONS::NO_EFFECT;
m_MagneticItems.graphics = true;
m_MagneticItems.allLayers = false;
m_AuiPanels.appearance_panel_tab = 0;
m_AuiPanels.right_panel_width = -1;
@ -95,6 +96,9 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics",
&m_MagneticItems.graphics, true ) );
m_params.emplace_back( new PARAM<bool>( "editing.magnetic_all_layers",
&m_MagneticItems.allLayers, false ) );
m_params.emplace_back( new PARAM<bool>( "editing.polar_coords",
&m_PolarCoords, false ) );

View File

@ -58,6 +58,7 @@
#include <string>
#include <tool/tool_manager.h>
#include <footprint_edit_frame.h>
#include <footprint_editor_settings.h>
#include <widgets/wx_progress_reporters.h>
#include <widgets/wx_infobar.h>
#include <wx/hyperlink.h>
@ -1345,7 +1346,10 @@ int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
int PCB_CONTROL::SnapMode( const TOOL_EVENT& aEvent )
{
bool& snapMode = m_frame->GetPcbNewSettings()->m_MagneticItems.allLayers;
MAGNETIC_SETTINGS& settings = m_isFootprintEditor
? m_frame->GetFootprintEditorSettings()->m_MagneticItems
: m_frame->GetPcbNewSettings()->m_MagneticItems;
bool& snapMode = settings.allLayers;
if( aEvent.IsAction( &PCB_ACTIONS::magneticSnapActiveLayer ) )
snapMode = false;
@ -1374,11 +1378,12 @@ int PCB_CONTROL::SnapModeFeedback( const TOOL_EVENT& aEvent )
HOTKEY_CYCLE_POPUP* popup = m_frame->GetHotkeyPopup();
MAGNETIC_SETTINGS& settings = m_isFootprintEditor
? m_frame->GetFootprintEditorSettings()->m_MagneticItems
: m_frame->GetPcbNewSettings()->m_MagneticItems;
if( popup )
{
popup->Popup( _( "Object Snapping" ), labels,
static_cast<int>( m_frame->GetPcbNewSettings()->m_MagneticItems.allLayers ) );
}
popup->Popup( _( "Object Snapping" ), labels, static_cast<int>( settings.allLayers ) );
return 0;
}