KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_footprint_filters.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <functional>
23#include <memory>
24#include <vector>
25
26#include <wx/arrstr.h>
27#include <wx/timer.h>
28
31
32class KIWAY;
34class LISTBOX_TRICKS;
35
36
41{
42public:
43 PANEL_FOOTPRINT_FILTERS( wxWindow* aParent, KIWAY& aKiway );
44
45 ~PANEL_FOOTPRINT_FILTERS() override;
46
48 void SetFilters( const wxArrayString& aFilters );
49
51 wxArrayString GetFilters() const;
52
53
54 using FOOTPRINT_ASSIGN_QUERY = std::function<bool()>;
55 using FOOTPRINT_ASSIGNER = std::function<void( const wxString& )>;
56
65
66protected:
67 void OnFpFilterDClick( wxMouseEvent& aEvent ) override;
68 void OnEditFootprintFilter( wxCommandEvent& aEvent ) override;
69 void OnAddFootprintFilter( wxCommandEvent& aEvent ) override;
70
71private:
73 void onModify();
74
78
79 void showFootprintMatches( const std::vector<wxString>& aPatterns );
80
85 wxString matchingFootprintName( long aItem ) const;
86
87 void openFootprintInEditor( const wxString& aFootprintName );
88 void copyFootprintName( const wxString& aFootprintName );
89
93
100 void showFpFilterMatchLoadIndication( bool aShow, float aProgress = 0.0f );
101 void onFpFilterMatchLoadTimer( wxTimerEvent& aEvent );
102
104 void onFilterPreviewText( wxCommandEvent& aEvent );
105
106 void onMatchingFootprintDoubleClick( wxListEvent& aEvent );
107 void onMatchingFootprintContextMenu( wxListEvent& aEvent );
108 void onMatchingFootprintKeyDown( wxKeyEvent& aEvent );
109
112 void onNotebookPageChanged( wxBookCtrlEvent& aEvent );
113
115
116 std::unique_ptr<LISTBOX_TRICKS> m_fpFilterTricks;
117
119 std::unique_ptr<FP_FILTER_MATCHER> m_fpMatcher;
120
124
128
131
134};
Supplies the footprints matching a symbol's footprint filter patterns.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
PANEL_FOOTPRINT_FILTERS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
std::unique_ptr< LISTBOX_TRICKS > m_fpFilterTricks
wxString matchingFootprintName(long aItem) const
Return the "library:footprint" name of the given item in the matches list, or an empty string when th...
std::function< void(const wxString &)> FOOTPRINT_ASSIGNER
FOOTPRINT_ASSIGN_QUERY m_canAssignFootprint
Access to panel-external interfaces.
void OnAddFootprintFilter(wxCommandEvent &aEvent) override
void onMatchingFootprintKeyDown(wxKeyEvent &aEvent)
PANEL_FOOTPRINT_FILTERS(wxWindow *aParent, KIWAY &aKiway)
void openFootprintInEditor(const wxString &aFootprintName)
void onModify()
Mark the host dialog (the top level window) as modified.
wxString m_fpFilterPreview
The sanitised filter text being typed in the Add/Edit filter dialog.
void copyFootprintName(const wxString &aFootprintName)
void onFpFilterMatchLoadTimer(wxTimerEvent &aEvent)
void showFpFilterMatchLoadIndication(bool aShow, float aProgress=0.0f)
Show or hide the footprint filter match list's library load indicator.
WX_DEBOUNCED_ACTION m_filterPreviewDebounce
Debounces the preview of the filter being type to avoid spamming queries.
void onNotebookPageChanged(wxBookCtrlEvent &aEvent)
Query the matches when the page is selected; the libraries are not loaded before that,...
void updateMatchingFootprints()
Refresh the matches list for the current filters, or for the filter being typed in the Add/Edit dialo...
void SetFilters(const wxArrayString &aFilters)
Replace the filters in the list with aFilters.
void SetFootprintFieldAccessors(FOOTPRINT_ASSIGN_QUERY aCanAssign, FOOTPRINT_ASSIGNER aAssign)
Injection for interfaces that reach outside the panel to interact with host dialog.
void OnEditFootprintFilter(wxCommandEvent &aEvent) override
std::function< bool()> FOOTPRINT_ASSIGN_QUERY
void onMatchingFootprintContextMenu(wxListEvent &aEvent)
void showFootprintMatches(const std::vector< wxString > &aPatterns)
void onMatchingFootprintDoubleClick(wxListEvent &aEvent)
void onFilterPreviewText(wxCommandEvent &aEvent)
Preview the filter text typed in the Add/Edit dialog, once typing pauses.
bool matchLibrariesReady()
Return true once the footprint libraries can be queried.
void OnFpFilterDClick(wxMouseEvent &aEvent) override
std::unique_ptr< FP_FILTER_MATCHER > m_fpMatcher
Supplies the matches for the footprint filter patterns.
Debounces an action: runs it only after a quiet period following the last trigger.