Audacity 3.2.0
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
EffectsLocationPanel Class Referencefinal
Inheritance diagram for EffectsLocationPanel:
[legend]
Collaboration diagram for EffectsLocationPanel:
[legend]

Public Member Functions

template<typename... Args>
 EffectsLocationPanel (Args &&... args)
 
void InitUI ()
 
void AddLocation (const PluginPath &path, bool setFocus=false)
 
void AddLocations (const PluginPaths &paths)
 
PluginPaths GetLocations () const
 
void OnAddNewLocationClicked (wxCommandEvent &)
 
void OnRemoveClicked (wxCommandEvent &evt)
 
void OnBrowseClicked (wxCommandEvent &evt)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Private Member Functions

static int BaseRowIdForIndex (int index)
 
static int IndexForId (int id)
 

Private Attributes

std::vector< wxString > mPaths
 
std::vector< wxTextCtrl * > mPathCtrls
 
wxSizer * mRows {}
 
wxButton * mAddNewLocation {}
 

Detailed Description

Definition at line 43 of file EffectsPrefs.cpp.

Constructor & Destructor Documentation

◆ EffectsLocationPanel()

template<typename... Args>
EffectsLocationPanel::EffectsLocationPanel ( Args &&...  args)
inline

Definition at line 74 of file EffectsPrefs.cpp.

75 : wxPanelWrapper(std::forward<Args>(args)...)
76 {
77 InitUI();
78 }

References InitUI().

Here is the call graph for this function:

Member Function Documentation

◆ AddLocation()

void EffectsLocationPanel::AddLocation ( const PluginPath path,
bool  setFocus = false 
)
inline

Definition at line 93 of file EffectsPrefs.cpp.

94 {
95 const auto baseId = BaseRowIdForIndex(mPathCtrls.size());
96
97 auto rowSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
98 wxTextCtrl* text;
99 wxButton* remove;
100 wxButton* browse;
101 rowSizer->Add(
102 text = safenew wxTextCtrl(this, baseId, path),
103 1, wxEXPAND | wxALL, 3
104 );
105 rowSizer->Add(
106 browse = safenew wxButton(this, baseId + 1, _("Browse...")),
107 0, wxALL, 3
108 );
109 rowSizer->Add(
110 remove = safenew wxButton(this, baseId + 2, _("Remove")),
111 0, wxALL, 3
112 );
113 text->Bind(wxEVT_TEXT, [this](wxCommandEvent& evt)
114 {
115 const auto index = IndexForId(evt.GetId());
116 mPaths[index] = evt.GetString();
117 evt.Skip();
118 });
119
120 browse->Bind(wxEVT_BUTTON, &EffectsLocationPanel::OnBrowseClicked, this);
121 remove->Bind(wxEVT_BUTTON, &EffectsLocationPanel::OnRemoveClicked, this);
122 mPathCtrls.push_back(text);
123 mPaths.push_back(path);
124
125 mRows->Add(rowSizer.release(), 0, wxEXPAND);
126
127 mAddNewLocation->MoveAfterInTabOrder(remove);
128
129 if(setFocus)
130 text->SetFocus();
131
132 wxPostEvent(this, wxCommandEvent(EVT_PLUGIN_LOCATIONS_CHANGED));
133 }
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:10
std::vector< wxString > mPaths
void OnRemoveClicked(wxCommandEvent &evt)
std::vector< wxTextCtrl * > mPathCtrls
static int IndexForId(int id)
wxButton * mAddNewLocation
static int BaseRowIdForIndex(int index)
void OnBrowseClicked(wxCommandEvent &evt)

References _, BaseRowIdForIndex(), IndexForId(), mAddNewLocation, mPathCtrls, mPaths, mRows, OnBrowseClicked(), OnRemoveClicked(), and safenew.

Referenced by AddLocations(), and OnAddNewLocationClicked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddLocations()

void EffectsLocationPanel::AddLocations ( const PluginPaths paths)
inline

Definition at line 135 of file EffectsPrefs.cpp.

136 {
137 for(const auto& location : paths)
138 AddLocation(location);
139 }
void AddLocation(const PluginPath &path, bool setFocus=false)

References AddLocation().

Here is the call graph for this function:

◆ BaseRowIdForIndex()

static int EffectsLocationPanel::BaseRowIdForIndex ( int  index)
inlinestaticprivate

Definition at line 61 of file EffectsPrefs.cpp.

62 {
63 return wxID_HIGHEST + index * 3;
64 }

Referenced by AddLocation(), and OnRemoveClicked().

Here is the caller graph for this function:

◆ GetLocations()

PluginPaths EffectsLocationPanel::GetLocations ( ) const
inline

Definition at line 141 of file EffectsPrefs.cpp.

142 {
143 PluginPaths paths;
144 for(const auto& text : mPaths)
145 {
146 if(!text.IsEmpty())
147 paths.push_back(text);
148 }
149 return paths;
150 }
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215

References mPaths.

◆ IndexForId()

static int EffectsLocationPanel::IndexForId ( int  id)
inlinestaticprivate

Definition at line 66 of file EffectsPrefs.cpp.

67 {
68 return (id - wxID_HIGHEST) / 3;
69 }

Referenced by AddLocation(), OnBrowseClicked(), and OnRemoveClicked().

Here is the caller graph for this function:

◆ InitUI()

void EffectsLocationPanel::InitUI ( )
inline

Definition at line 80 of file EffectsPrefs.cpp.

81 {
82 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
83 mainSizer->Add(mRows = safenew wxBoxSizer(wxVERTICAL), 0, wxEXPAND);
84 mainSizer->Add(
85 mAddNewLocation = safenew wxButton(this, wxID_ANY, _("Add new location")),
86 0, wxALL, 3
87 );
88 SetSizer(mainSizer.release());
89
91 }
void OnAddNewLocationClicked(wxCommandEvent &)

References _, mAddNewLocation, mRows, OnAddNewLocationClicked(), and safenew.

Referenced by EffectsLocationPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnAddNewLocationClicked()

void EffectsLocationPanel::OnAddNewLocationClicked ( wxCommandEvent &  )
inline

Definition at line 152 of file EffectsPrefs.cpp.

153 {
154 AddLocation("", true);
155 }

References AddLocation().

Referenced by InitUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnBrowseClicked()

void EffectsLocationPanel::OnBrowseClicked ( wxCommandEvent &  evt)
inline

Definition at line 181 of file EffectsPrefs.cpp.

182 {
183 const auto index = IndexForId(evt.GetId());
184
185 wxDirDialogWrapper dirDialog(
186 wxGetTopLevelParent(this),
188 mPathCtrls[index]->GetValue()
189 );
190 if(dirDialog.ShowModal() == wxID_OK)
191 mPathCtrls[index]->SetValue(dirDialog.GetPath());//also invoke wxEVT_TEXT
192 }
static const TranslatableString DefaultDialogPrompt

References wxDirDialogWrapper::DefaultDialogPrompt, IndexForId(), and mPathCtrls.

Referenced by AddLocation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRemoveClicked()

void EffectsLocationPanel::OnRemoveClicked ( wxCommandEvent &  evt)
inline

Definition at line 157 of file EffectsPrefs.cpp.

158 {
159 const auto index = IndexForId(evt.GetId());
160 const auto baseId = BaseRowIdForIndex(index);
161 //When item is removed from the sizer the tail gets shifted,
162 //but items in mPathCtrls are not. We need to map index from
163 //mPathCtrls to index in mRows
164 mRows->Remove(
165 std::count_if(
166 mPathCtrls.begin(),
167 mPathCtrls.begin() + index,
168 [](const auto ptr) { return ptr != nullptr; }
169 )
170 );
171
172 FindWindowById(baseId, this)->Destroy();
173 FindWindowById(baseId + 1, this)->Destroy();
174 FindWindowById(baseId + 2, this)->Destroy();
175 mPathCtrls[index] = nullptr;
176 mPaths[index] = wxString{};//Don't save path on commit
177
178 wxPostEvent(this, wxCommandEvent(EVT_PLUGIN_LOCATIONS_CHANGED));
179 }

References BaseRowIdForIndex(), IndexForId(), mPathCtrls, mPaths, and mRows.

Referenced by AddLocation().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mAddNewLocation

wxButton* EffectsLocationPanel::mAddNewLocation {}
private

Definition at line 57 of file EffectsPrefs.cpp.

Referenced by AddLocation(), and InitUI().

◆ mPathCtrls

std::vector<wxTextCtrl*> EffectsLocationPanel::mPathCtrls
private

Definition at line 51 of file EffectsPrefs.cpp.

Referenced by AddLocation(), OnBrowseClicked(), and OnRemoveClicked().

◆ mPaths

std::vector<wxString> EffectsLocationPanel::mPaths
private

Definition at line 48 of file EffectsPrefs.cpp.

Referenced by AddLocation(), GetLocations(), and OnRemoveClicked().

◆ mRows

wxSizer* EffectsLocationPanel::mRows {}
private

Definition at line 56 of file EffectsPrefs.cpp.

Referenced by AddLocation(), InitUI(), and OnRemoveClicked().


The documentation for this class was generated from the following file: