28#include <wx/clipbrd.h>
32#include <wx/splitter.h>
52 const wxArrayString& aFootprintHistoryList,
54 std::function<
void()> aAcceptHandler,
55 std::function<
void()> aEscapeHandler ) :
56 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize ),
57 m_hsplitter( nullptr ),
58 m_vsplitter( nullptr ),
60 m_filter(
std::
move( aFilter ) ),
61 m_acceptHandler(
std::
move( aAcceptHandler ) ),
62 m_escapeHandler(
std::
move( aEscapeHandler ) )
69 _(
"Loading Footprint Libraries" ), 1 );
77 delete progressReporter;
85 std::vector<LIB_TREE_ITEM*> historyInfos;
87 for(
const wxString& item : aFootprintHistoryList )
92 if( fp_info !=
nullptr )
93 historyInfos.push_back( fp_info );
96 adapter->
DoAddLibrary( wxT(
"-- " ) +
_(
"Recently Used" ) + wxT(
" --" ), wxEmptyString,
97 historyInfos,
false, true )
98 .m_IsRecentlyUsedGroup =
true;
100 if( historyInfos.size() )
110 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
112 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
113 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
116 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
123 auto detailsSizer =
new wxBoxSizer( wxVERTICAL );
124 detailsPanel->SetSizer( detailsSizer );
127 detailsSizer->Add(
m_details, 1, wxEXPAND, 5 );
128 detailsPanel->Layout();
129 detailsSizer->Fit( detailsPanel );
175 Bind( wxEVT_CHAR_HOOK,
176 [&]( wxKeyEvent& aEvent )
178 if( aEvent.GetKeyCode() == WXK_ESCAPE )
180 wxObject* eventSource = aEvent.GetEventObject();
182 if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( eventSource ) )
185 if( textCtrl->GetValue() == m_tree->GetSearchString()
186 && !m_tree->GetSearchString().IsEmpty() )
188 m_tree->SetSearchString( wxEmptyString );
200 aEvent.DoAllowNextEvent();
211 m_open_libs_timer->StartOnce( 300 );
238 catch(
const std::runtime_error& e )
240 wxFAIL_MSG( e.what() );
278 auto horizPixelsFromDU =
282 return GetParent()->ConvertDialogToPixels( sz ).x;
287 int w = cfg.
width < 40 ? horizPixelsFromDU( 440 ) : cfg.
width;
288 int h = cfg.
height < 40 ? horizPixelsFromDU( 340 ) : cfg.
height;
290 GetParent()->SetSize( wxSize( w, h ) );
291 GetParent()->Layout();
296 cfg.
sash_h = horizPixelsFromDU( 220 );
301 cfg.
sash_v = horizPixelsFromDU( 230 );
313 m_adapter->SetPreselectNode( aPreselect, 0 );
328 auto state = wxGetMouseState();
330 if( state.LeftIsDown() )
346 m_adapter->OpenLibs( cfg->m_LibTree.open_libs );
370 wxCommandEvent event( FP_SELECTION_EVENT, GetId() );
371 event.SetEventObject(
this );
373 ProcessWindowEvent( event );
397 if(
m_details && e.GetKeyCode() ==
'C' && e.ControlDown() &&
398 !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
400 wxString txt =
m_details->SelectionToText();
403 if( wxTheClipboard->Open() )
405 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
406 wxTheClipboard->Flush();
407 wxTheClipboard->Close();
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void AddLibraries(EDA_BASE_FRAME *aParent)
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(PCB_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
Add dark theme support to wxHtmlWindow.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
void SetPreselectNode(const LIB_ID &aLibId, int aUnit)
Set the symbol name to be selected if there are no search results.
LIB_TREE_NODE_LIBRARY & DoAddLibrary(const wxString &aNodeName, const wxString &aDesc, const std::vector< LIB_TREE_ITEM * > &aItemList, bool pinned, bool presorted)
Add the given list of symbols by alias.
void SetFilter(std::function< bool(LIB_TREE_NODE &aNode)> *aFilter)
Set the filter.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
Widget displaying a tree of symbols with optional search text control and description panel.
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
void BlockPreview(bool aBlock)
FOOTPRINT_CHOOSER m_FootprintChooser
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual SETTINGS_MANAGER & GetSettingsManager() const
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
EDA_UNITS GetUserUnits() const
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global program "get" accessor.