Footprint editor: always export the currently loaded footprint.

Previously, it was not always the edited footprint, but a footprint
selected from the library tree.
It was especially annoying when the footprint was loaded from the board editor:
The footprint was not the loaded footprint, but its copy from library.
From master branch
This commit is contained in:
jean-pierre charras 2023-03-29 18:46:30 +02:00
parent 80b842a704
commit 9466624f9d
2 changed files with 12 additions and 8 deletions

View File

@ -110,6 +110,13 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty(); return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
}; };
auto fpExportCondition =
[ this ]( const SELECTION& aSel )
{
FOOTPRINT* fp = m_frame->GetBoard()->GetFirstFootprint();
return fp != nullptr;
};
ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition ); ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition ); ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
@ -132,7 +139,7 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
ctxMenu.AddSeparator(); ctxMenu.AddSeparator();
ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition ); ctxMenu.AddItem( PCB_ACTIONS::importFootprint, libInferredCondition );
ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpSelectedCondition ); ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpExportCondition );
// If we've got nothing else to show, at least show a hide tree option // If we've got nothing else to show, at least show a hide tree option
ctxMenu.AddItem( PCB_ACTIONS::hideFootprintTree, !libInferredCondition ); ctxMenu.AddItem( PCB_ACTIONS::hideFootprintTree, !libInferredCondition );
@ -526,14 +533,11 @@ int FOOTPRINT_EDITOR_CONTROL::ImportFootprint( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_CONTROL::ExportFootprint( const TOOL_EVENT& aEvent ) int FOOTPRINT_EDITOR_CONTROL::ExportFootprint( const TOOL_EVENT& aEvent )
{ {
LIB_ID fpID = m_frame->GetTreeFPID(); LIB_ID fpID = m_frame->GetTreeFPID();
FOOTPRINT* fp; FOOTPRINT* fp = m_frame->GetBoard()->GetFirstFootprint();
if( !fpID.IsValid() )
fp = m_frame->GetBoard()->GetFirstFootprint();
else
fp = m_frame->LoadFootprint( fpID );
if( fp )
m_frame->ExportFootprint( fp ); m_frame->ExportFootprint( fp );
return 0; return 0;
} }

View File

@ -445,7 +445,7 @@ TOOL_ACTION PCB_ACTIONS::importFootprint( "pcbnew.ModuleEditor.importFootprint",
TOOL_ACTION PCB_ACTIONS::exportFootprint( "pcbnew.ModuleEditor.exportFootprint", TOOL_ACTION PCB_ACTIONS::exportFootprint( "pcbnew.ModuleEditor.exportFootprint",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Export Footprint..." ), _( "Export footprint to file" ), _( "Export Current Footprint..." ), _( "Export edited footprint to file" ),
BITMAPS::export_module ); BITMAPS::export_module );
TOOL_ACTION PCB_ACTIONS::footprintProperties( "pcbnew.ModuleEditor.footprintProperties", TOOL_ACTION PCB_ACTIONS::footprintProperties( "pcbnew.ModuleEditor.footprintProperties",