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
 
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.

60 :
61 wxDialogWrapper(parent, id, XO("Select Command"),
62 wxDefaultPosition, wxDefaultSize,
63 wxCAPTION | wxRESIZE_BORDER)
64 , mCatalog{ &project }
65{
66 SetLabel(XO("Select Command")); // Provide visual label
67 SetName(XO("Select Command")); // Provide audible label
68 Populate();
69}
XO("Cut/Copy/Paste")
const auto project
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 164 of file BatchCommandDialog.cpp.

165{
166 EndModal(false);
167}

◆ OnChoice()

void MacroCommandDialog::OnChoice ( wxCommandEvent &  event)
private

Definition at line 149 of file BatchCommandDialog.cpp.

150{
151}

◆ OnEditParams()

void MacroCommandDialog::OnEditParams ( wxCommandEvent &  event)
private

Definition at line 211 of file BatchCommandDialog.cpp.

212{
213 auto command = mInternalCommandName;
214 wxString params = mParameters->GetValue();
215
216 params = MacroCommands::PromptForParamsFor(command, params, *this).Trim();
217
218 mParameters->SetValue(params);
219 mParameters->Refresh();
220}
EffectDistortionSettings params
Definition: Distortion.cpp:77
CommandID mInternalCommandName
wxTextCtrl * mParameters
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, wxWindow &parent)

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

Here is the call graph for this function:

◆ OnHelp()

void MacroCommandDialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 169 of file BatchCommandDialog.cpp.

170{
171 const auto &page = GetHelpPageName();
172 HelpSystem::ShowHelp(this, page, true);
173}
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 175 of file BatchCommandDialog.cpp.

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

References EffectManager::Get(), Identifier::GET(), MacroCommands::GetCurrentParamsFor(), EffectManager::GetDefaultPreset(), EffectManager::GetEffectByIdentifier(), 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 153 of file BatchCommandDialog.cpp.

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

References mInternalCommandName, mParameters, mSelectedCommand, and mSelectedParameters.

◆ OnUsePreset()

void MacroCommandDialog::OnUsePreset ( wxCommandEvent &  event)
private

Definition at line 222 of file BatchCommandDialog.cpp.

223{
224 auto command = mInternalCommandName;
225 wxString params = mParameters->GetValue();
226
227 wxString preset = MacroCommands::PromptForPresetFor(command, params, this).Trim();
228
229 mParameters->SetValue(preset);
230 mParameters->Refresh();
231}
EffectReverbSettings preset
Definition: Reverb.cpp:44
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 71 of file BatchCommandDialog.cpp.

72{
73 //------------------------- Main section --------------------
76 // ----------------------- End of main section --------------
77}
@ 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 136 of file BatchCommandDialog.cpp.

137{
138 mChoices->DeleteAllItems();
139 long ii = 0;
140 for ( const auto &entry : mCatalog )
141 // insert the user-facing string
142 mChoices->InsertItem( ii++, entry.name.StrippedTranslation() );
143}
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 79 of file BatchCommandDialog.cpp.

80{
81 S.StartVerticalLay(true);
82 {
83 S.StartMultiColumn(4, wxEXPAND);
84 {
85 S.SetStretchyCol(1);
86 mCommand = S.AddTextBox(XXO("&Command"), wxT(""), 20);
87 mCommand->SetEditable(false);
89 .Disable() // disable button as box is empty
90 .AddButton(XXO("&Edit Parameters"));
92 .Disable() // disable button as box is empty
93 .AddButton(XXO("&Use Preset"));
94 }
95 S.EndMultiColumn();
96
97 S.StartMultiColumn(2, wxEXPAND);
98 {
99 S.SetStretchyCol(1);
100 mParameters = S.AddTextBox(XXO("&Parameters"), wxT(""), 0);
101 mParameters->SetEditable(false);
102 auto prompt = XXO("&Details");
103 S.Prop(0).AddPrompt(prompt);
104 mDetails = S
105 .Name( prompt )
106 .AddTextWindow( wxT(""));
107 mDetails->SetEditable(false);
108 }
109 S.EndMultiColumn();
110
111 S.Prop(10).StartStatic(XO("Choose command"), true);
112 {
114 .Style(wxSUNKEN_BORDER | wxLC_LIST | wxLC_SINGLE_SEL)
115 .AddListControl();
116 }
117 S.EndStatic();
118 }
119 S.EndVerticalLay();
120
121 S.AddStandardButtons( eOkButton | eCancelButton | eHelpButton);
122
124 if (mChoices->GetItemCount() > 0) {
125 // set first item to be selected (and the focus when the
126 // list first becomes the focus)
127 mChoices->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
128 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
129 }
130
131 SetMinSize(wxSize(780, 560));
132 Fit();
133 Center();
134}
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 233 of file BatchCommandDialog.cpp.

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

References MacroCommandsCatalog::begin(), MacroCommandsCatalog::ByCommandId(), MenuRegistry::Command, MacroCommandsCatalog::end(), EffectManager::Get(), EffectManager::GetEffectByIdentifier(), EffectManager::HasPresets(), 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 145 of file BatchCommandDialog.cpp.

146{
147}

Member Data Documentation

◆ mCatalog

const MacroCommandsCatalog MacroCommandDialog::mCatalog
private

Definition at line 61 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

◆ 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: