Keep footprint selection in Symbol Chooser history list.

Fixes https://gitlab.com/kicad/code/kicad/issues/1841
This commit is contained in:
Jeff Young 2022-06-05 18:58:27 +01:00
parent a22a18b067
commit 244042ce51
7 changed files with 40 additions and 11 deletions

View File

@ -164,6 +164,7 @@ LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID( LIB_TREE_NODE* aParent, LIB_TREE_ITE
m_Name = aItem->GetName();
m_Desc = aItem->GetDescription();
m_Footprint = aItem->GetFootprint();
m_MatchName = aItem->GetName();
m_SearchText = aItem->GetSearchText();

View File

@ -515,16 +515,18 @@ void DIALOG_CHOOSE_SYMBOL::OnFootprintSelected( wxCommandEvent& aEvent )
void DIALOG_CHOOSE_SYMBOL::OnComponentPreselected( wxCommandEvent& aEvent )
{
int unit = 0;
LIB_TREE_NODE* node = m_tree->GetCurrentTreeNode();
LIB_ID id = m_tree->GetSelectedLibId( &unit );
if( id.IsValid() )
if( node && node->m_LibId.IsValid() )
{
m_symbol_preview->DisplaySymbol( id, unit );
m_symbol_preview->DisplaySymbol( node->m_LibId, node->m_Unit );
ShowFootprintFor( id );
PopulateFootprintSelector( id );
if( !node->m_Footprint.IsEmpty() )
ShowFootprint( node->m_Footprint );
else
ShowFootprintFor( node->m_LibId );
PopulateFootprintSelector( node->m_LibId );
}
else
{
@ -533,7 +535,7 @@ void DIALOG_CHOOSE_SYMBOL::OnComponentPreselected( wxCommandEvent& aEvent )
if( m_fp_preview && m_fp_preview->IsInitialized() )
m_fp_preview->SetStatusText( wxEmptyString );
PopulateFootprintSelector( id );
PopulateFootprintSelector( LIB_ID() );
}
}

View File

@ -169,6 +169,11 @@ public:
wxString GetSearchText() override;
wxString GetFootprint() override
{
return GetFootprintField().GetText();
}
/**
* For symbols derived from other symbols, IsRoot() indicates no derivation.
*/

View File

@ -131,7 +131,10 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SYMBOL_LIBRARY_FILTER
modelAdapter->SetFilter( SYMBOL_TREE_MODEL_ADAPTER::SYM_FILTER_POWER );
}
std::vector< LIB_TREE_ITEM* > history_list;
std::vector<LIB_SYMBOL> history_list_storage;
std::vector<LIB_TREE_ITEM*> history_list;
history_list_storage.reserve( aHistoryList.size() );
for( const PICKED_SYMBOL& i : aHistoryList )
{
@ -139,7 +142,19 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SYMBOL_LIBRARY_FILTER
// This can be null, for example when a symbol has been deleted from a library
if( symbol )
history_list.push_back( symbol );
{
history_list_storage.emplace_back( *symbol );
for( const std::pair<int, wxString>& fieldDef : i.Fields )
{
LIB_FIELD* field = history_list_storage.back().GetFieldById( fieldDef.first );
if( field )
field->SetText( fieldDef.second );
}
history_list.push_back( &history_list_storage.back() );
}
}
modelAdapter->DoAddLibrary( wxT( "-- " ) + _( "Recently Used" ) + wxT( " --" ), wxEmptyString,

View File

@ -56,6 +56,11 @@ public:
*/
virtual bool IsRoot() const { return true; }
/**
* For items with footprint fields.
*/
virtual wxString GetFootprint() { return wxEmptyString; }
/**
* For items with units, return the number of units.
*/

View File

@ -130,6 +130,7 @@ public:
wxString m_Name; // Actual name of the part
wxString m_Desc; // Description to be displayed
wxString m_Footprint; // Footprint ID as a string (ie: the footprint field text)
wxString m_MatchName; // Normalized name for matching
wxString m_SearchText; // Descriptive text to search
bool m_Normalized; // Support for lazy normalization.

View File

@ -86,7 +86,7 @@ const COLOR4D& FOOTPRINT_PREVIEW_PANEL::GetForegroundColor()
KIGFX::PAINTER* painter = GetView()->GetPainter();
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
return settings->GetCursorColor();
return settings->GetLayerColor( F_Fab );
}