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

Provides a list of configurable commands for use with MacroCommands. More...

#include <BatchCommandDialog.h>

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

Public Member Functions

 MacroCommandDialog (wxWindow *parent, wxWindowID id, AudacityProject &project)
 
void SetCommandAndParams (const CommandID &Command, const wxString &Params)
 
- 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
 

Public Attributes

CommandID mSelectedCommand
 
wxString mSelectedParameters
 

Private Member Functions

void Populate ()
 
void PopulateOrExchange (ShuttleGui &S)
 
void OnEditParams (wxCommandEvent &event)
 
void OnUsePreset (wxCommandEvent &event)
 
void OnChoice (wxCommandEvent &event)
 
void OnOk (wxCommandEvent &event)
 
void OnCancel (wxCommandEvent &event)
 
void OnHelp (wxCommandEvent &event)
 
void OnItemSelected (wxListEvent &event)
 
ManualPageID GetHelpPageName ()
 
void ValidateChoices ()
 
void PopulateCommandList ()
 

Private Attributes

wxButton * mEditParams
 
wxButton * mUsePreset
 
wxListCtrl * mChoices
 
wxTextCtrl * mCommand
 
wxTextCtrl * mParameters
 
wxTextCtrl * mDetails
 
CommandID mInternalCommandName
 
AudacityProjectmProject
 
const MacroCommandsCatalog mCatalog
 

Detailed Description

Provides a list of configurable commands for use with MacroCommands.

Provides a list of commands, mostly effects, which can be chained together in a simple linear sequence. Can configure parameters on each selected command.

Definition at line 28 of file BatchCommandDialog.h.

Constructor & Destructor Documentation

◆ MacroCommandDialog()

MacroCommandDialog::MacroCommandDialog ( wxWindow *  parent,
wxWindowID  id,
AudacityProject project 
)

Definition at line 59 of file BatchCommandDialog.cpp.

62 parent, id, XO("Select Command"), wxDefaultPosition, wxDefaultSize,
63 wxCAPTION | wxRESIZE_BORDER)
64 , mProject { project }
65 , mCatalog { &project }
66{
67 SetLabel(XO("Select Command")); // Provide visual label
68 SetName(XO("Select Command")); // Provide audible label
69 Populate();
70}
XO("Cut/Copy/Paste")
const auto project
AudacityProject & mProject
const MacroCommandsCatalog mCatalog
void SetLabel(const TranslatableString &title)

References project.

Member Function Documentation

◆ GetHelpPageName()

ManualPageID MacroCommandDialog::GetHelpPageName ( )
inlineprivate

Definition at line 46 of file BatchCommandDialog.h.

46{ return L"Scripting Reference" ; }

Referenced by OnHelp().

Here is the caller graph for this function:

◆ OnCancel()

void MacroCommandDialog::OnCancel ( wxCommandEvent &  event)
private

Definition at line 165 of file BatchCommandDialog.cpp.

166{
167 EndModal(false);
168}

◆ OnChoice()

void MacroCommandDialog::OnChoice ( wxCommandEvent &  event)
private

Definition at line 150 of file BatchCommandDialog.cpp.

151{
152}

◆ OnEditParams()

void MacroCommandDialog::OnEditParams ( wxCommandEvent &  event)
private

Definition at line 213 of file BatchCommandDialog.cpp.

214{
215 auto command = mInternalCommandName;
216 wxString params = mParameters->GetValue();
217
219
220 mParameters->SetValue(params);
221 mParameters->Refresh();
222}
EffectDistortionSettings params
CommandID mInternalCommandName
wxTextCtrl * mParameters
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, AudacityProject &project)

References mInternalCommandName, mParameters, mProject, params, and MacroCommands::PromptForParamsFor().

Here is the call graph for this function:

◆ OnHelp()

void MacroCommandDialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 170 of file BatchCommandDialog.cpp.

171{
172 const auto &page = GetHelpPageName();
173 HelpSystem::ShowHelp(this, page, true);
174}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231
ManualPageID GetHelpPageName()

References GetHelpPageName(), and HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnItemSelected()

void MacroCommandDialog::OnItemSelected ( wxListEvent &  event)
private

Definition at line 176 of file BatchCommandDialog.cpp.

177{
178 const auto &command = mCatalog[ event.GetIndex() ];
179
181 PluginID ID =
182 PluginManager::Get().GetByCommandIdentifier(command.name.Internal());
183
184 // If ID is empty, then the effect wasn't found, in which case, the user must have
185 // selected one of the "special" commands.
186 mEditParams->Enable(!ID.empty());
187 mUsePreset->Enable(em.HasPresets(ID));
188
189 auto value = command.name.StrippedTranslation();
190 if ( value == mCommand->GetValue() )
191 // This uses the assumption of uniqueness of translated names!
192 return;
193
194 mCommand->SetValue(value);
195 mInternalCommandName = command.name.Internal();
196
198 if (params.empty())
199 {
200 params = em.GetDefaultPreset(ID);
201 }
202
203 // using GET to expose a CommandID to the user!
204 // Cryptic command and category.
205 // Later we can put help information there, perhaps.
206 // Macro command details are one place that we do expose Identifier
207 // to (more sophisticated) users
208 mDetails->SetValue(
209 mInternalCommandName.GET() + "\r\n" + command.category.Translation() );
210 mParameters->SetValue(params);
211}
wxString PluginID
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:52
bool HasPresets(const PluginID &ID)
static EffectManager & Get()
wxString GetDefaultPreset(const PluginID &ID)
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
static wxString GetCurrentParamsFor(const CommandID &command)
const PluginID & GetByCommandIdentifier(const CommandID &strTarget)
static PluginManager & Get()

References EffectManager::Get(), PluginManager::Get(), Identifier::GET(), PluginManager::GetByCommandIdentifier(), MacroCommands::GetCurrentParamsFor(), EffectManager::GetDefaultPreset(), EffectManager::HasPresets(), mCatalog, mCommand, mDetails, mEditParams, mInternalCommandName, mParameters, mUsePreset, and params.

Here is the call graph for this function:

◆ OnOk()

void MacroCommandDialog::OnOk ( wxCommandEvent &  event)
private

Definition at line 154 of file BatchCommandDialog.cpp.

155{
157 // .Strip(wxString::both) // PRL: used to do this, here only,
158 // but ultimately mSelectedCommand is looked up in the catalog without
159 // similar adjustment of whitespace in the comparison
160 ;
161 mSelectedParameters = mParameters->GetValue().Strip(wxString::trailing);
162 EndModal(true);
163}

References mInternalCommandName, mParameters, mSelectedCommand, and mSelectedParameters.

◆ OnUsePreset()

void MacroCommandDialog::OnUsePreset ( wxCommandEvent &  event)
private

Definition at line 224 of file BatchCommandDialog.cpp.

225{
226 auto command = mInternalCommandName;
227 wxString params = mParameters->GetValue();
228
229 wxString preset = MacroCommands::PromptForPresetFor(command, params, this).Trim();
230
231 mParameters->SetValue(preset);
232 mParameters->Refresh();
233}
ReverbSettings preset
Definition: ReverbBase.cpp:25
static wxString PromptForPresetFor(const CommandID &command, const wxString &params, wxWindow *parent)

References mInternalCommandName, mParameters, params, preset, and MacroCommands::PromptForPresetFor().

Here is the call graph for this function:

◆ Populate()

void MacroCommandDialog::Populate ( )
private

Definition at line 72 of file BatchCommandDialog.cpp.

73{
74 //------------------------- Main section --------------------
77 // ----------------------- End of main section --------------
78}
@ eIsCreating
Definition: ShuttleGui.h:37
#define S(N)
Definition: ToChars.cpp:64
void PopulateOrExchange(ShuttleGui &S)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640

References eIsCreating, PopulateOrExchange(), and S.

Here is the call graph for this function:

◆ PopulateCommandList()

void MacroCommandDialog::PopulateCommandList ( )
private

Definition at line 137 of file BatchCommandDialog.cpp.

138{
139 mChoices->DeleteAllItems();
140 long ii = 0;
141 for ( const auto &entry : mCatalog )
142 // insert the user-facing string
143 mChoices->InsertItem( ii++, entry.name.StrippedTranslation() );
144}
static ProjectFileIORegistry::AttributeWriterEntry entry

References entry, mCatalog, and mChoices.

Referenced by PopulateOrExchange().

Here is the caller graph for this function:

◆ PopulateOrExchange()

void MacroCommandDialog::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 80 of file BatchCommandDialog.cpp.

81{
82 S.StartVerticalLay(true);
83 {
84 S.StartMultiColumn(4, wxEXPAND);
85 {
86 S.SetStretchyCol(1);
87 mCommand = S.AddTextBox(XXO("&Command"), wxT(""), 20);
88 mCommand->SetEditable(false);
90 .Disable() // disable button as box is empty
91 .AddButton(XXO("&Edit Parameters"));
93 .Disable() // disable button as box is empty
94 .AddButton(XXO("&Use Preset"));
95 }
96 S.EndMultiColumn();
97
98 S.StartMultiColumn(2, wxEXPAND);
99 {
100 S.SetStretchyCol(1);
101 mParameters = S.AddTextBox(XXO("&Parameters"), wxT(""), 0);
102 mParameters->SetEditable(false);
103 auto prompt = XXO("&Details");
104 S.Prop(0).AddPrompt(prompt);
105 mDetails = S
106 .Name( prompt )
107 .AddTextWindow( wxT(""));
108 mDetails->SetEditable(false);
109 }
110 S.EndMultiColumn();
111
112 S.Prop(10).StartStatic(XO("Choose command"), true);
113 {
115 .Style( wxLC_LIST | wxLC_SINGLE_SEL)
116 .AddListControl();
117 }
118 S.EndStatic();
119 }
120 S.EndVerticalLay();
121
122 S.AddStandardButtons( eOkButton | eCancelButton | eHelpButton);
123
125 if (mChoices->GetItemCount() > 0) {
126 // set first item to be selected (and the focus when the
127 // list first becomes the focus)
128 mChoices->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
129 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
130 }
131
132 SetMinSize(wxSize(780, 560));
133 Fit();
134 Center();
135}
wxT("CloseDown"))
#define EditParamsButtonID
#define UsePresetButtonID
#define CommandsListID
XXO("&Cut/Copy/Paste Toolbar")
@ eOkButton
Definition: ShuttleGui.h:609
@ eCancelButton
Definition: ShuttleGui.h:610
@ eHelpButton
Definition: ShuttleGui.h:613

References CommandsListID, eCancelButton, EditParamsButtonID, eHelpButton, eOkButton, mChoices, mCommand, mDetails, mEditParams, mParameters, mUsePreset, PopulateCommandList(), S, UsePresetButtonID, wxT(), XO(), and XXO().

Referenced by Populate().

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

◆ SetCommandAndParams()

void MacroCommandDialog::SetCommandAndParams ( const CommandID Command,
const wxString &  Params 
)

Definition at line 235 of file BatchCommandDialog.cpp.

236{
237 auto iter = mCatalog.ByCommandId( Command );
238
239 mParameters->SetValue( Params );
240
242 if (iter == mCatalog.end())
243 // uh oh, using GET to expose an internal name to the user!
244 // in default of any better friendly name
245 mCommand->SetValue( Command.GET() );
246 else {
247 mCommand->SetValue( iter->name.StrippedTranslation() );
248 // using GET to expose a CommandID to the user!
249 // Macro command details are one place that we do expose Identifier
250 // to (more sophisticated) users
251 mDetails->SetValue(
252 iter->name.Internal() + "\r\n" + iter->category.Translation() );
253 mChoices->SetItemState(iter - mCatalog.begin(),
254 wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
255
257
258 // If ID is empty, then the effect wasn't found, in which case, the user must have
259 // selected one of the "special" commands.
260 mEditParams->Enable(!ID.empty());
261 mUsePreset->Enable(EffectManager::Get().HasPresets(ID));
262 }
263}
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Entries::const_iterator end() const
Definition: BatchCommands.h:52
Entries::const_iterator begin() const
Definition: BatchCommands.h:51
constexpr auto Command
Definition: MenuRegistry.h:456

References MacroCommandsCatalog::begin(), MacroCommandsCatalog::ByCommandId(), MenuRegistry::Command, MacroCommandsCatalog::end(), EffectManager::Get(), PluginManager::Get(), PluginManager::GetByCommandIdentifier(), mCatalog, mChoices, mCommand, mDetails, mEditParams, mInternalCommandName, mParameters, and mUsePreset.

Here is the call graph for this function:

◆ ValidateChoices()

void MacroCommandDialog::ValidateChoices ( )
private

Definition at line 146 of file BatchCommandDialog.cpp.

147{
148}

Member Data Documentation

◆ mCatalog

const MacroCommandsCatalog MacroCommandDialog::mCatalog
private

Definition at line 62 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateCommandList(), and SetCommandAndParams().

◆ mChoices

wxListCtrl* MacroCommandDialog::mChoices
private

◆ mCommand

wxTextCtrl* MacroCommandDialog::mCommand
private

Definition at line 55 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().

◆ mDetails

wxTextCtrl* MacroCommandDialog::mDetails
private

Definition at line 57 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().

◆ mEditParams

wxButton* MacroCommandDialog::mEditParams
private

Definition at line 52 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().

◆ mInternalCommandName

CommandID MacroCommandDialog::mInternalCommandName
private

◆ mParameters

wxTextCtrl* MacroCommandDialog::mParameters
private

◆ mProject

AudacityProject& MacroCommandDialog::mProject
private

Definition at line 61 of file BatchCommandDialog.h.

Referenced by OnEditParams().

◆ mSelectedCommand

CommandID MacroCommandDialog::mSelectedCommand

Definition at line 34 of file BatchCommandDialog.h.

Referenced by MacrosWindow::InsertCommandAt(), and OnOk().

◆ mSelectedParameters

wxString MacroCommandDialog::mSelectedParameters

Definition at line 35 of file BatchCommandDialog.h.

Referenced by MacrosWindow::InsertCommandAt(), and OnOk().

◆ mUsePreset

wxButton* MacroCommandDialog::mUsePreset
private

Definition at line 53 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().


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