diff --git a/common/lib_tree_model.cpp b/common/lib_tree_model.cpp index 4770e12b44..2e9617b2e7 100644 --- a/common/lib_tree_model.cpp +++ b/common/lib_tree_model.cpp @@ -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(); diff --git a/eeschema/dialogs/dialog_choose_symbol.cpp b/eeschema/dialogs/dialog_choose_symbol.cpp index db93ff09da..1b677e4cfb 100644 --- a/eeschema/dialogs/dialog_choose_symbol.cpp +++ b/eeschema/dialogs/dialog_choose_symbol.cpp @@ -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 ); + + if( !node->m_Footprint.IsEmpty() ) + ShowFootprint( node->m_Footprint ); + else + ShowFootprintFor( node->m_LibId ); - ShowFootprintFor( id ); - PopulateFootprintSelector( id ); + 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() ); } } diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 5d01ce3782..45d048c8bf 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -169,6 +169,11 @@ public: wxString GetSearchText() override; + wxString GetFootprint() override + { + return GetFootprintField().GetText(); + } + /** * For symbols derived from other symbols, IsRoot() indicates no derivation. */ diff --git a/eeschema/picksymbol.cpp b/eeschema/picksymbol.cpp index a15c2086f1..c65faf41f5 100644 --- a/eeschema/picksymbol.cpp +++ b/eeschema/picksymbol.cpp @@ -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 history_list_storage; + std::vector 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& 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, diff --git a/include/lib_tree_item.h b/include/lib_tree_item.h index a563c7da42..e476a1e85c 100644 --- a/include/lib_tree_item.h +++ b/include/lib_tree_item.h @@ -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. */ diff --git a/include/lib_tree_model.h b/include/lib_tree_model.h index 9e797f2943..bcb31d328b 100644 --- a/include/lib_tree_model.h +++ b/include/lib_tree_model.h @@ -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. diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index e32c916cff..857d8b57f6 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -86,7 +86,7 @@ const COLOR4D& FOOTPRINT_PREVIEW_PANEL::GetForegroundColor() KIGFX::PAINTER* painter = GetView()->GetPainter(); auto settings = static_cast( painter->GetSettings() ); - return settings->GetCursorColor(); + return settings->GetLayerColor( F_Fab ); }