Audacity  3.0.3
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 27 of file BatchCommandDialog.h.

Constructor & Destructor Documentation

◆ MacroCommandDialog()

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

Definition at line 64 of file BatchCommandDialog.cpp.

65  :
66  wxDialogWrapper(parent, id, XO("Select Command"),
67  wxDefaultPosition, wxDefaultSize,
68  wxCAPTION | wxRESIZE_BORDER)
69  , mCatalog{ &project }
70 {
71  SetLabel(XO("Select Command")); // Provide visual label
72  SetName(XO("Select Command")); // Provide audible label
73  Populate();
74 }

Member Function Documentation

◆ GetHelpPageName()

ManualPageID MacroCommandDialog::GetHelpPageName ( )
inlineprivate

Definition at line 45 of file BatchCommandDialog.h.

45 { 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 169 of file BatchCommandDialog.cpp.

170 {
171  EndModal(false);
172 }

◆ OnChoice()

void MacroCommandDialog::OnChoice ( wxCommandEvent &  event)
private

Definition at line 154 of file BatchCommandDialog.cpp.

155 {
156 }

◆ OnEditParams()

void MacroCommandDialog::OnEditParams ( wxCommandEvent &  event)
private

Definition at line 216 of file BatchCommandDialog.cpp.

217 {
218  auto command = mInternalCommandName;
219  wxString params = mParameters->GetValue();
220 
221  params = MacroCommands::PromptForParamsFor(command, params, *this).Trim();
222 
223  mParameters->SetValue(params);
224  mParameters->Refresh();
225 }

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 174 of file BatchCommandDialog.cpp.

175 {
176  const auto &page = GetHelpPageName();
177  HelpSystem::ShowHelp(this, page, true);
178 }

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

Here is the call graph for this function:

◆ OnItemSelected()

void MacroCommandDialog::OnItemSelected ( wxListEvent &  event)
private

Definition at line 180 of file BatchCommandDialog.cpp.

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

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 158 of file BatchCommandDialog.cpp.

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

References mInternalCommandName, mParameters, mSelectedCommand, and mSelectedParameters.

◆ OnUsePreset()

void MacroCommandDialog::OnUsePreset ( wxCommandEvent &  event)
private

Definition at line 227 of file BatchCommandDialog.cpp.

228 {
229  auto command = mInternalCommandName;
230  wxString params = mParameters->GetValue();
231 
232  wxString preset = MacroCommands::PromptForPresetFor(command, params, this).Trim();
233 
234  mParameters->SetValue(preset);
235  mParameters->Refresh();
236 }

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

Here is the call graph for this function:

◆ Populate()

void MacroCommandDialog::Populate ( )
private

Definition at line 76 of file BatchCommandDialog.cpp.

77 {
78  //------------------------- Main section --------------------
79  ShuttleGui S(this, eIsCreating);
81  // ----------------------- End of main section --------------
82 }

References eIsCreating, and PopulateOrExchange().

Here is the call graph for this function:

◆ PopulateCommandList()

void MacroCommandDialog::PopulateCommandList ( )
private

Definition at line 141 of file BatchCommandDialog.cpp.

142 {
143  mChoices->DeleteAllItems();
144  long ii = 0;
145  for ( const auto &entry : mCatalog )
146  // insert the user-facing string
147  mChoices->InsertItem( ii++, entry.name.StrippedTranslation() );
148 }

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 84 of file BatchCommandDialog.cpp.

85 {
86  S.StartVerticalLay(true);
87  {
88  S.StartMultiColumn(4, wxEXPAND);
89  {
90  S.SetStretchyCol(1);
91  mCommand = S.AddTextBox(XXO("&Command"), wxT(""), 20);
92  mCommand->SetEditable(false);
94  .Disable() // disable button as box is empty
95  .AddButton(XXO("&Edit Parameters"));
97  .Disable() // disable button as box is empty
98  .AddButton(XXO("&Use Preset"));
99  }
100  S.EndMultiColumn();
101 
102  S.StartMultiColumn(2, wxEXPAND);
103  {
104  S.SetStretchyCol(1);
105  mParameters = S.AddTextBox(XXO("&Parameters"), wxT(""), 0);
106  mParameters->SetEditable(false);
107  auto prompt = XXO("&Details");
108  S.Prop(0).AddPrompt(prompt);
109  mDetails = S
110  .Name( prompt )
111  .AddTextWindow( wxT(""));
112  mDetails->SetEditable(false);
113  }
114  S.EndMultiColumn();
115 
116  S.Prop(10).StartStatic(XO("Choose command"), true);
117  {
119  .Style(wxSUNKEN_BORDER | wxLC_LIST | wxLC_SINGLE_SEL)
120  .AddListControl();
121  }
122  S.EndStatic();
123  }
124  S.EndVerticalLay();
125 
127 
129  if (mChoices->GetItemCount() > 0) {
130  // set first item to be selected (and the focus when the
131  // list first becomes the focus)
132  mChoices->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
133  wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
134  }
135 
136  SetMinSize(wxSize(780, 560));
137  Fit();
138  Center();
139 }

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddListControl(), ShuttleGuiBase::AddPrompt(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddTextWindow(), CommandsListID, ShuttleGui::Disable(), eCancelButton, EditParamsButtonID, eHelpButton, ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), eOkButton, ShuttleGui::Id(), mChoices, mCommand, mDetails, mEditParams, mParameters, mUsePreset, ShuttleGui::Name(), PopulateCommandList(), ShuttleGui::Prop(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartVerticalLay(), ShuttleGui::Style(), UsePresetButtonID, 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 238 of file BatchCommandDialog.cpp.

239 {
240  auto iter = mCatalog.ByCommandId( Command );
241 
242  mParameters->SetValue( Params );
243 
245  if (iter == mCatalog.end())
246  // uh oh, using GET to expose an internal name to the user!
247  // in default of any better friendly name
248  mCommand->SetValue( Command.GET() );
249  else {
250  mCommand->SetValue( iter->name.StrippedTranslation() );
251  // using GET to expose a CommandID to the user!
252  // Macro command details are one place that we do expose Identifier
253  // to (more sophisticated) users
254  mDetails->SetValue(
255  iter->name.Internal() + "\r\n" + iter->category.Translation() );
256  mChoices->SetItemState(iter - mCatalog.begin(),
257  wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
258 
261 
262  // If ID is empty, then the effect wasn't found, in which case, the user must have
263  // selected one of the "special" commands.
264  mEditParams->Enable(!ID.empty());
265  mUsePreset->Enable(em.HasPresets(ID));
266  }
267 }

References MacroCommandsCatalog::begin(), MacroCommandsCatalog::ByCommandId(), MenuTable::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 150 of file BatchCommandDialog.cpp.

151 {
152 }

Member Data Documentation

◆ mCatalog

const MacroCommandsCatalog MacroCommandDialog::mCatalog
private

Definition at line 60 of file BatchCommandDialog.h.

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

◆ mChoices

wxListCtrl* MacroCommandDialog::mChoices
private

◆ mCommand

wxTextCtrl* MacroCommandDialog::mCommand
private

Definition at line 54 of file BatchCommandDialog.h.

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

◆ mDetails

wxTextCtrl* MacroCommandDialog::mDetails
private

Definition at line 56 of file BatchCommandDialog.h.

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

◆ mEditParams

wxButton* MacroCommandDialog::mEditParams
private

Definition at line 51 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 33 of file BatchCommandDialog.h.

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

◆ mSelectedParameters

wxString MacroCommandDialog::mSelectedParameters

Definition at line 34 of file BatchCommandDialog.h.

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

◆ mUsePreset

wxButton* MacroCommandDialog::mUsePreset
private

Definition at line 52 of file BatchCommandDialog.h.

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


The documentation for this class was generated from the following files:
MacroCommandDialog::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Definition: BatchCommandDialog.cpp:84
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1184
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:604
MacroCommandDialog::mDetails
wxTextCtrl * mDetails
Definition: BatchCommandDialog.h:56
MacroCommands::GetCurrentParamsFor
static wxString GetCurrentParamsFor(const CommandID &command)
Definition: BatchCommands.cpp:435
MacroCommands::PromptForPresetFor
static wxString PromptForPresetFor(const CommandID &command, const wxString &params, wxWindow *parent)
Definition: BatchCommands.cpp:472
MacroCommandsCatalog::end
Entries::const_iterator end() const
Definition: BatchCommands.h:48
MacroCommandDialog::mCatalog
const MacroCommandsCatalog mCatalog
Definition: BatchCommandDialog.h:60
entry
static ProjectFileIORegistry::WriterEntry entry
Definition: ProjectSettings.cpp:197
MacroCommandDialog::Populate
void Populate()
Definition: BatchCommandDialog.cpp:76
XO
#define XO(s)
Definition: Internat.h:31
MacroCommandsCatalog::ByCommandId
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Definition: BatchCommands.cpp:426
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
wxDialogWrapper::SetLabel
void SetLabel(const TranslatableString &title)
Definition: wxPanelWrapper.cpp:71
EffectManager::Get
static EffectManager & Get()
Definition: EffectManager.cpp:42
ShuttleGuiBase::AddListControl
wxListCtrl * AddListControl(std::initializer_list< const ListControlColumn > columns={}, long listControlStyles=0)
Definition: ShuttleGui.cpp:782
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:727
CommandsListID
#define CommandsListID
Definition: BatchCommandDialog.cpp:50
XXO
#define XXO(s)
Definition: Internat.h:44
eCancelButton
@ eCancelButton
Definition: ShuttleGui.h:601
EffectManager
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:46
MacroCommandDialog::mSelectedCommand
CommandID mSelectedCommand
Definition: BatchCommandDialog.h:33
ShuttleGuiBase::AddTextBox
wxTextCtrl * AddTextBox(const TranslatableString &Caption, const wxString &Value, const int nChars)
Definition: ShuttleGui.cpp:638
ShuttleGui::Disable
ShuttleGui & Disable(bool disabled=true)
Definition: ShuttleGui.h:650
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1203
PluginID
wxString PluginID
Definition: EffectManager.h:30
MacroCommandDialog::mSelectedParameters
wxString mSelectedParameters
Definition: BatchCommandDialog.h:34
EditParamsButtonID
#define EditParamsButtonID
Definition: BatchCommandDialog.cpp:51
ShuttleGui::Prop
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:725
MacroCommandDialog::mInternalCommandName
CommandID mInternalCommandName
Definition: BatchCommandDialog.h:58
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:360
Identifier::GET
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
EffectManager::HasPresets
bool HasPresets(const PluginID &ID)
Definition: EffectManager.cpp:333
EffectManager::GetDefaultPreset
wxString GetDefaultPreset(const PluginID &ID)
Definition: EffectManager.cpp:660
MacroCommandDialog::mParameters
wxTextCtrl * mParameters
Definition: BatchCommandDialog.h:55
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:663
UsePresetButtonID
#define UsePresetButtonID
Definition: BatchCommandDialog.cpp:52
eOkButton
@ eOkButton
Definition: ShuttleGui.h:600
MacroCommands::PromptForParamsFor
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, wxWindow &parent)
Definition: BatchCommands.cpp:447
MacroCommandDialog::PopulateCommandList
void PopulateCommandList()
Definition: BatchCommandDialog.cpp:141
MenuTable::Command
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: CommandManager.h:675
MacroCommandsCatalog::begin
Entries::const_iterator begin() const
Definition: BatchCommands.h:47
EffectManager::GetEffectByIdentifier
const PluginID & GetEffectByIdentifier(const CommandID &strTarget)
Definition: EffectManager.cpp:821
MacroCommandDialog::mChoices
wxListCtrl * mChoices
Definition: BatchCommandDialog.h:53
wxDialogWrapper::wxDialogWrapper
wxDialogWrapper()
Definition: wxPanelWrapper.h:84
MacroCommandDialog::GetHelpPageName
ManualPageID GetHelpPageName()
Definition: BatchCommandDialog.h:45
ShuttleGuiBase::AddTextWindow
wxTextCtrl * AddTextWindow(const wxString &Value)
Multiline text box that grows.
Definition: ShuttleGui.cpp:712
ShuttleGui::AddStandardButtons
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2444
MacroCommandDialog::mEditParams
wxButton * mEditParams
Definition: BatchCommandDialog.h:51
params
EffectDistortion::Params params
Definition: Distortion.cpp:99
ShuttleGuiBase::AddPrompt
void AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:238
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:202
MacroCommandDialog::mUsePreset
wxButton * mUsePreset
Definition: BatchCommandDialog.h:52
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
MacroCommandDialog::mCommand
wxTextCtrl * mCommand
Definition: BatchCommandDialog.h:54