Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EffectPresetsDialog Class Referencefinal

#include <EffectPresetDialog.h>

Inheritance diagram for EffectPresetsDialog:
[legend]
Collaboration diagram for EffectPresetsDialog:
[legend]

Public Member Functions

 EffectPresetsDialog (wxWindow *parent, EffectPlugin *effect)
 
virtual ~EffectPresetsDialog ()
 
wxString GetSelected () const
 
void SetSelected (const wxString &parms)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void SetPrefix (const TranslatableString &type, const wxString &prefix)
 
void UpdateUI ()
 
void OnType (wxCommandEvent &evt)
 
void OnOk (wxCommandEvent &evt)
 
void OnCancel (wxCommandEvent &evt)
 

Private Attributes

wxChoice * mType
 
wxListBox * mPresets
 
RegistryPaths mFactoryPresets
 
RegistryPaths mUserPresets
 
wxString mSelection
 

Detailed Description

Definition at line 9 of file EffectPresetDialog.h.

Constructor & Destructor Documentation

◆ EffectPresetsDialog()

EffectPresetsDialog::EffectPresetsDialog ( wxWindow *  parent,
EffectPlugin effect 
)

Definition at line 18 of file EffectPresetDialog.cpp.

19 : wxDialogWrapper(parent, wxID_ANY, XO("Select Preset"))
20{
22 S.StartVerticalLay();
23 {
24 S.StartTwoColumn();
25 S.SetStretchyCol(1);
26 {
27 S.AddPrompt(XXO("Type:"));
28 mType = S.Id(ID_Type).AddChoice({}, {}, 0);
29
30 S.AddPrompt(XXO("&Preset:"));
31 mPresets = S.Style(wxLB_SINGLE | wxLB_NEEDED_SB).AddListBox({});
32 }
33 S.EndTwoColumn();
34
35 S.AddStandardButtons();
36 }
37 S.EndVerticalLay();
38
41
42 if (mUserPresets.size() > 0)
43 {
44 mType->Append(_("User Presets"));
45 }
46
47 if (mFactoryPresets.size() > 0)
48 {
49 mType->Append(_("Factory Presets"));
50 }
51
52 if (HasCurrentSettings(*effect))
53 {
54 mType->Append(_("Current Settings"));
55 }
56
57 if (HasFactoryDefaults(*effect))
58 {
59 mType->Append(_("Factory Defaults"));
60 }
61
62 UpdateUI();
63}
bool HasCurrentSettings(EffectPlugin &host)
bool HasFactoryDefaults(EffectPlugin &host)
RegistryPaths GetUserPresets(EffectPlugin &host)
@ ID_Type
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:73
@ eIsCreating
Definition: ShuttleGui.h:37
#define S(N)
Definition: ToChars.cpp:64
virtual const EffectSettingsManager & GetDefinition() const =0
RegistryPaths mFactoryPresets
RegistryPaths mUserPresets
virtual RegistryPaths GetFactoryPresets() const =0
Report names of factory presets.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640

References _, eIsCreating, GetUserPresets(), HasCurrentSettings(), HasFactoryDefaults(), ID_Type, S, and XXO().

Here is the call graph for this function:

◆ ~EffectPresetsDialog()

EffectPresetsDialog::~EffectPresetsDialog ( )
virtual

Definition at line 65 of file EffectPresetDialog.cpp.

66{
67}

Member Function Documentation

◆ GetSelected()

wxString EffectPresetsDialog::GetSelected ( ) const

Definition at line 69 of file EffectPresetDialog.cpp.

70{
71 return mSelection;
72}

References mSelection.

Referenced by MacroCommands::PromptForPresetFor().

Here is the caller graph for this function:

◆ OnCancel()

void EffectPresetsDialog::OnCancel ( wxCommandEvent &  evt)
private

Definition at line 226 of file EffectPresetDialog.cpp.

227{
228 mSelection = wxEmptyString;
229
230 EndModal(false);
231}

References mSelection.

◆ OnOk()

void EffectPresetsDialog::OnOk ( wxCommandEvent &  evt)
private

Definition at line 219 of file EffectPresetDialog.cpp.

220{
221 UpdateUI();
222
223 EndModal(true);
224}

References UpdateUI().

Here is the call graph for this function:

◆ OnType()

void EffectPresetsDialog::OnType ( wxCommandEvent &  evt)
private

Definition at line 214 of file EffectPresetDialog.cpp.

215{
216 UpdateUI();
217}

References UpdateUI().

Here is the call graph for this function:

◆ SetPrefix()

void EffectPresetsDialog::SetPrefix ( const TranslatableString type,
const wxString &  prefix 
)
private

Definition at line 97 of file EffectPresetDialog.cpp.

99{
100 mType->SetStringSelection(type.Translation());
101
102 if (type == XO("User Presets"))
103 {
104 mPresets->Clear();
105 for (const auto& preset : mUserPresets)
106 mPresets->Append(preset);
107 mPresets->Enable(true);
108 mPresets->SetStringSelection(prefix);
109 if (mPresets->GetSelection() == wxNOT_FOUND)
110 {
111 mPresets->SetSelection(0);
112 }
113 mSelection =
114 EffectPlugin::kUserPresetIdent + mPresets->GetStringSelection();
115 }
116 else if (type == XO("Factory Presets"))
117 {
118 mPresets->Clear();
119 for (size_t i = 0, cnt = mFactoryPresets.size(); i < cnt; i++)
120 {
121 auto label = mFactoryPresets[i];
122 if (label.empty())
123 {
124 label = _("None");
125 }
126 mPresets->Append(label);
127 }
128 mPresets->Enable(true);
129 mPresets->SetStringSelection(prefix);
130 if (mPresets->GetSelection() == wxNOT_FOUND)
131 {
132 mPresets->SetSelection(0);
133 }
134 mSelection =
135 EffectPlugin::kFactoryPresetIdent + mPresets->GetStringSelection();
136 }
137 else if (type == XO("Current Settings"))
138 {
139 mPresets->Clear();
140 mPresets->Enable(false);
142 }
143 else if (type == XO("Factory Defaults"))
144 {
145 mPresets->Clear();
146 mPresets->Enable(false);
148 }
149}
ReverbSettings preset
Definition: ReverbBase.cpp:25
TranslatableString label
Definition: TagsEditor.cpp:165
static const wxString kUserPresetIdent
Definition: EffectPlugin.h:40
static const wxString kFactoryPresetIdent
Definition: EffectPlugin.h:41
static const wxString kCurrentSettingsIdent
Definition: EffectPlugin.h:42
static const wxString kFactoryDefaultsIdent
Definition: EffectPlugin.h:43
wxString Translation() const

References _, TranslatableString::empty(), EffectPlugin::kCurrentSettingsIdent, EffectPlugin::kFactoryDefaultsIdent, EffectPlugin::kFactoryPresetIdent, EffectPlugin::kUserPresetIdent, label, mFactoryPresets, mPresets, mSelection, mType, mUserPresets, preset, TranslatableString::Translation(), and XO().

Referenced by SetSelected().

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

◆ SetSelected()

void EffectPresetsDialog::SetSelected ( const wxString &  parms)

Definition at line 74 of file EffectPresetDialog.cpp.

75{
76 wxString preset = parms;
78 {
79 preset.Replace(EffectPlugin::kUserPresetIdent, wxEmptyString, false);
80 SetPrefix(XO("User Presets"), preset);
81 }
82 else if (preset.StartsWith(EffectPlugin::kFactoryPresetIdent))
83 {
84 preset.Replace(EffectPlugin::kFactoryPresetIdent, wxEmptyString, false);
85 SetPrefix(XO("Factory Presets"), preset);
86 }
88 {
89 SetPrefix(XO("Current Settings"), wxEmptyString);
90 }
92 {
93 SetPrefix(XO("Factory Defaults"), wxEmptyString);
94 }
95}
void SetPrefix(const TranslatableString &type, const wxString &prefix)

References EffectPlugin::kCurrentSettingsIdent, EffectPlugin::kFactoryDefaultsIdent, EffectPlugin::kFactoryPresetIdent, EffectPlugin::kUserPresetIdent, preset, SetPrefix(), and XO().

Referenced by MacroCommands::PromptForPresetFor().

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

◆ UpdateUI()

void EffectPresetsDialog::UpdateUI ( )
private

Definition at line 151 of file EffectPresetDialog.cpp.

152{
153 int selected = mType->GetSelection();
154 if (selected == wxNOT_FOUND)
155 {
156 selected = 0;
157 mType->SetSelection(selected);
158 }
159 wxString type = mType->GetString(selected);
160
161 if (type == _("User Presets"))
162 {
163 selected = mPresets->GetSelection();
164 if (selected == wxNOT_FOUND)
165 {
166 selected = 0;
167 }
168
169 mPresets->Clear();
170 for (const auto& preset : mUserPresets)
171 mPresets->Append(preset);
172 mPresets->Enable(true);
173 mPresets->SetSelection(selected);
174 mSelection =
175 EffectPlugin::kUserPresetIdent + mPresets->GetString(selected);
176 }
177 else if (type == _("Factory Presets"))
178 {
179 selected = mPresets->GetSelection();
180 if (selected == wxNOT_FOUND)
181 {
182 selected = 0;
183 }
184
185 mPresets->Clear();
186 for (size_t i = 0, cnt = mFactoryPresets.size(); i < cnt; i++)
187 {
188 auto label = mFactoryPresets[i];
189 if (label.empty())
190 {
191 label = _("None");
192 }
193 mPresets->Append(label);
194 }
195 mPresets->Enable(true);
196 mPresets->SetSelection(selected);
197 mSelection =
198 EffectPlugin::kFactoryPresetIdent + mPresets->GetString(selected);
199 }
200 else if (type == _("Current Settings"))
201 {
202 mPresets->Clear();
203 mPresets->Enable(false);
205 }
206 else if (type == _("Factory Defaults"))
207 {
208 mPresets->Clear();
209 mPresets->Enable(false);
211 }
212}

References _, TranslatableString::empty(), EffectPlugin::kCurrentSettingsIdent, EffectPlugin::kFactoryDefaultsIdent, EffectPlugin::kFactoryPresetIdent, EffectPlugin::kUserPresetIdent, label, mFactoryPresets, mPresets, mSelection, mType, mUserPresets, and preset.

Referenced by OnOk(), and OnType().

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

Member Data Documentation

◆ mFactoryPresets

RegistryPaths EffectPresetsDialog::mFactoryPresets
private

Definition at line 30 of file EffectPresetDialog.h.

Referenced by SetPrefix(), and UpdateUI().

◆ mPresets

wxListBox* EffectPresetsDialog::mPresets
private

Definition at line 28 of file EffectPresetDialog.h.

Referenced by SetPrefix(), and UpdateUI().

◆ mSelection

wxString EffectPresetsDialog::mSelection
private

Definition at line 32 of file EffectPresetDialog.h.

Referenced by GetSelected(), OnCancel(), SetPrefix(), and UpdateUI().

◆ mType

wxChoice* EffectPresetsDialog::mType
private

Definition at line 27 of file EffectPresetDialog.h.

Referenced by SetPrefix(), and UpdateUI().

◆ mUserPresets

RegistryPaths EffectPresetsDialog::mUserPresets
private

Definition at line 31 of file EffectPresetDialog.h.

Referenced by SetPrefix(), and UpdateUI().


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