28#include <wx/clipbrd.h>
31#include <wx/splitter.h>
51 const wxArrayString& aFootprintHistoryList,
53 std::function<
void()> aAcceptHandler,
54 std::function<
void()> aEscapeHandler ) :
55 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize ),
56 m_hsplitter( nullptr ),
57 m_vsplitter( nullptr ),
59 m_filter(
std::
move( aFilter ) ),
60 m_acceptHandler(
std::
move( aAcceptHandler ) ),
61 m_escapeHandler(
std::
move( aEscapeHandler ) )
68 _(
"Loading Footprint Libraries" ), 3 );
76 delete progressReporter;
84 std::vector<LIB_TREE_ITEM*> historyInfos;
86 for(
const wxString& item : aFootprintHistoryList )
91 if( fp_info !=
nullptr )
92 historyInfos.push_back( fp_info );
95 adapter->
DoAddLibrary( wxT(
"-- " ) +
_(
"Recently Used" ) + wxT(
" --" ), wxEmptyString,
96 historyInfos,
false, true );
98 if( historyInfos.size() )
108 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
110 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
111 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
114 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
121 auto detailsSizer =
new wxBoxSizer( wxVERTICAL );
122 detailsPanel->SetSizer( detailsSizer );
125 detailsSizer->Add(
m_details, 1, wxEXPAND, 5 );
126 detailsPanel->Layout();
127 detailsSizer->Fit( detailsPanel );
170 Bind( wxEVT_CHAR_HOOK,
171 [&]( wxKeyEvent& aEvent )
173 if( aEvent.GetKeyCode() == WXK_ESCAPE )
175 wxObject* eventSource = aEvent.GetEventObject();
177 if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( eventSource ) )
180 if( textCtrl->GetValue() == m_tree->GetSearchString()
181 && !m_tree->GetSearchString().IsEmpty() )
183 m_tree->SetSearchString( wxEmptyString );
195 aEvent.DoAllowNextEvent();
206 m_open_libs_timer->StartOnce( 300 );
231 catch(
const std::runtime_error& e )
233 wxFAIL_MSG( e.what() );
257 auto horizPixelsFromDU =
261 return GetParent()->ConvertDialogToPixels( sz ).x;
266 int w = cfg.
width < 40 ? horizPixelsFromDU( 440 ) : cfg.
width;
267 int h = cfg.
height < 40 ? horizPixelsFromDU( 340 ) : cfg.
height;
269 GetParent()->SetSize( wxSize( w, h ) );
270 GetParent()->Layout();
275 cfg.
sash_h = horizPixelsFromDU( 220 );
280 cfg.
sash_v = horizPixelsFromDU( 230 );
292 m_adapter->SetPreselectNode( aPreselect, 0 );
307 auto state = wxGetMouseState();
309 if( state.LeftIsDown() )
325 m_adapter->OpenLibs( cfg->m_LibTree.open_libs );
349 wxCommandEvent event( FP_SELECTION_EVENT, GetId() );
350 event.SetEventObject(
this );
352 ProcessWindowEvent( event );
376 if(
m_details && e.GetKeyCode() ==
'C' && e.ControlDown() &&
377 !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
379 wxString txt =
m_details->SelectionToText();
382 if( wxTheClipboard->Open() )
384 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
385 wxTheClipboard->Flush();
386 wxTheClipboard->Close();
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
void AddLibraries(EDA_BASE_FRAME *aParent)
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()
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.