Init footprint chooser with current footprint.

Fixes: lp:1813882
* https://bugs.launchpad.net/kicad/+bug/1813882
This commit is contained in:
Jeff Young 2019-01-30 15:44:39 +00:00
parent 6880687f00
commit b3319d29c1
3 changed files with 13 additions and 6 deletions

View File

@ -42,6 +42,7 @@
#include <pcb_screen.h>
#include <pcb_display_options.h>
#include <pcb_general_settings.h>
#include <lib_id.h>
/* Forward declarations of classes. */
class BOARD;
@ -57,7 +58,6 @@ class BOARD_DESIGN_SETTINGS;
class ZONE_SETTINGS;
class PCB_PLOT_PARAMS;
class FP_LIB_TABLE;
class LIB_ID;
class PCB_GENERAL_SETTINGS ;
/**
@ -404,9 +404,12 @@ public:
* Function SelectFootprintFromLibTree
* opens a dialog to select a footprint.
*
* @param aUseFootprintViewer = true to allow selection by the footprint viewer
* @param aPreslect = if valid, the LIB_ID to select (otherwise the global history is
* used)
* @param aAllowBroswer = allow selection via the footprint viewer (false when already
* called from footprint viewer)
*/
MODULE* SelectFootprintFromLibTree( bool aUseFootprintViewer = true );
MODULE* SelectFootprintFromLibTree( LIB_ID aPreselect = LIB_ID(), bool aAllowBroswer = true );
/**
* Adds the given module to the board.

View File

@ -746,7 +746,9 @@ void FOOTPRINT_VIEWER_FRAME::UpdateTitle()
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
{
MODULE* module = SelectFootprintFromLibTree( false );
LIB_ID current( getCurNickname(), getCurFootprintName() );
MODULE* module = SelectFootprintFromLibTree( current, false );
if( module )
{

View File

@ -202,7 +202,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
}
MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( bool aAllowBrowser )
MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect, bool aAllowBrowser )
{
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
wxString moduleName;
@ -228,7 +228,9 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( bool aAllowBrowser )
adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, historyInfos, true );
if( !historyInfos.empty() )
if( aPreselect.IsValid() )
adapter->SetPreselectNode( aPreselect, 0 );
else if( !historyInfos.empty() )
adapter->SetPreselectNode( historyInfos[0]->GetLibId(), 0 );
adapter->AddLibraries();