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" ), 3 );
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 );
99 if( historyInfos.size() )
109 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
111 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
112 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
115 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
122 auto detailsSizer =
new wxBoxSizer( wxVERTICAL );
123 detailsPanel->SetSizer( detailsSizer );
126 detailsSizer->Add(
m_details, 1, wxEXPAND, 5 );
127 detailsPanel->Layout();
128 detailsSizer->Fit( detailsPanel );
172 Bind( wxEVT_CHAR_HOOK,
173 [&]( wxKeyEvent& aEvent )
175 if( aEvent.GetKeyCode() == WXK_ESCAPE )
177 wxObject* eventSource = aEvent.GetEventObject();
179 if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( eventSource ) )
182 if( textCtrl->GetValue() == m_tree->GetSearchString()
183 && !m_tree->GetSearchString().IsEmpty() )
185 m_tree->SetSearchString( wxEmptyString );
197 aEvent.DoAllowNextEvent();
208 m_open_libs_timer->StartOnce( 300 );
233 catch(
const std::runtime_error& e )
235 wxFAIL_MSG( e.what() );
259 auto horizPixelsFromDU =
263 return GetParent()->ConvertDialogToPixels( sz ).x;
268 int w = cfg.
width < 40 ? horizPixelsFromDU( 440 ) : cfg.
width;
269 int h = cfg.
height < 40 ? horizPixelsFromDU( 340 ) : cfg.
height;
271 GetParent()->SetSize( wxSize( w, h ) );
272 GetParent()->Layout();
277 cfg.
sash_h = horizPixelsFromDU( 220 );
282 cfg.
sash_v = horizPixelsFromDU( 230 );
294 m_adapter->SetPreselectNode( aPreselect, 0 );
309 auto state = wxGetMouseState();
311 if( state.LeftIsDown() )
327 m_adapter->OpenLibs( cfg->m_LibTree.open_libs );
351 wxCommandEvent event( FP_SELECTION_EVENT, GetId() );
352 event.SetEventObject(
this );
354 ProcessWindowEvent( event );
378 if(
m_details && e.GetKeyCode() ==
'C' && e.ControlDown() &&
379 !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
381 wxString txt =
m_details->SelectionToText();
384 if( wxTheClipboard->Open() )
386 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
387 wxTheClipboard->Flush();
388 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.
void 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 symbol filter type.
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,...
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)
Returns a handle to the a given settings by type If the settings have already been loaded,...
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.