Rename Chains to Macros.

Lots of renaming.
Did not rename the containing files (yet) since that will require makefile updates.
This commit is contained in:
James Crook 2018-03-03 19:08:23 +00:00
parent 8ab69ae5c3
commit c0dcba66dd
16 changed files with 367 additions and 367 deletions

View File

@ -9,8 +9,8 @@
*******************************************************************//*!
\class BatchCommandDialog
\brief Provides a list of configurable commands for use with BatchCommands
\class MacroCommandDialog
\brief 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
@ -48,17 +48,17 @@ selected command.
#define EditParamsButtonID 7002
#define UsePresetButtonID 7003
BEGIN_EVENT_TABLE(BatchCommandDialog, wxDialogWrapper)
EVT_BUTTON(wxID_OK, BatchCommandDialog::OnOk)
EVT_BUTTON(wxID_CANCEL, BatchCommandDialog::OnCancel)
EVT_BUTTON(wxID_HELP, BatchCommandDialog::OnHelp)
EVT_BUTTON(EditParamsButtonID, BatchCommandDialog::OnEditParams)
EVT_BUTTON(UsePresetButtonID, BatchCommandDialog::OnUsePreset)
EVT_LIST_ITEM_ACTIVATED(CommandsListID, BatchCommandDialog::OnItemSelected)
EVT_LIST_ITEM_SELECTED(CommandsListID, BatchCommandDialog::OnItemSelected)
BEGIN_EVENT_TABLE(MacroCommandDialog, wxDialogWrapper)
EVT_BUTTON(wxID_OK, MacroCommandDialog::OnOk)
EVT_BUTTON(wxID_CANCEL, MacroCommandDialog::OnCancel)
EVT_BUTTON(wxID_HELP, MacroCommandDialog::OnHelp)
EVT_BUTTON(EditParamsButtonID, MacroCommandDialog::OnEditParams)
EVT_BUTTON(UsePresetButtonID, MacroCommandDialog::OnUsePreset)
EVT_LIST_ITEM_ACTIVATED(CommandsListID, MacroCommandDialog::OnItemSelected)
EVT_LIST_ITEM_SELECTED(CommandsListID, MacroCommandDialog::OnItemSelected)
END_EVENT_TABLE();
BatchCommandDialog::BatchCommandDialog(wxWindow * parent, wxWindowID id):
MacroCommandDialog::MacroCommandDialog(wxWindow * parent, wxWindowID id):
wxDialogWrapper(parent, id, _("Select Command"),
wxDefaultPosition, wxDefaultSize,
wxCAPTION | wxRESIZE_BORDER)
@ -68,7 +68,7 @@ BatchCommandDialog::BatchCommandDialog(wxWindow * parent, wxWindowID id):
Populate();
}
void BatchCommandDialog::Populate()
void MacroCommandDialog::Populate()
{
//------------------------- Main section --------------------
ShuttleGui S(this, eIsCreating);
@ -76,7 +76,7 @@ void BatchCommandDialog::Populate()
// ----------------------- End of main section --------------
}
void BatchCommandDialog::PopulateOrExchange(ShuttleGui &S)
void MacroCommandDialog::PopulateOrExchange(ShuttleGui &S)
{
S.StartVerticalLay(true);
{
@ -121,9 +121,9 @@ void BatchCommandDialog::PopulateOrExchange(ShuttleGui &S)
Center();
}
void BatchCommandDialog::PopulateCommandList()
void MacroCommandDialog::PopulateCommandList()
{
mCommandNames = BatchCommands::GetAllCommands();
mCommandNames = MacroCommands::GetAllCommands();
mChoices->DeleteAllItems();
for (size_t ii = 0, size = mCommandNames.size(); ii < size; ++ii)
@ -131,33 +131,33 @@ void BatchCommandDialog::PopulateCommandList()
mChoices->InsertItem( ii, std::get<0>( mCommandNames[ii] ) );
}
void BatchCommandDialog::ValidateChoices()
void MacroCommandDialog::ValidateChoices()
{
}
void BatchCommandDialog::OnChoice(wxCommandEvent & WXUNUSED(event))
void MacroCommandDialog::OnChoice(wxCommandEvent & WXUNUSED(event))
{
}
void BatchCommandDialog::OnOk(wxCommandEvent & WXUNUSED(event))
void MacroCommandDialog::OnOk(wxCommandEvent & WXUNUSED(event))
{
mSelectedCommand = mInternalCommandName.Strip(wxString::both);
mSelectedParameters = mParameters->GetValue().Strip(wxString::trailing);
EndModal(true);
}
void BatchCommandDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
void MacroCommandDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
{
EndModal(false);
}
void BatchCommandDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
void MacroCommandDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
{
wxString page = GetHelpPageName();
HelpSystem::ShowHelp(this, page, true);
}
void BatchCommandDialog::OnItemSelected(wxListEvent &event)
void MacroCommandDialog::OnItemSelected(wxListEvent &event)
{
const auto &command = mCommandNames[ event.GetIndex() ];
@ -175,7 +175,7 @@ void BatchCommandDialog::OnItemSelected(wxListEvent &event)
mCommand->SetValue(std::get<0> (command));
mInternalCommandName = std::get<1>( command );
wxString params = BatchCommands::GetCurrentParamsFor(mInternalCommandName);
wxString params = MacroCommands::GetCurrentParamsFor(mInternalCommandName);
if (params.IsEmpty())
{
params = em.GetDefaultPreset(ID);
@ -187,29 +187,29 @@ void BatchCommandDialog::OnItemSelected(wxListEvent &event)
mParameters->SetValue(params);
}
void BatchCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
void MacroCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
{
wxString command = mInternalCommandName;
wxString params = mParameters->GetValue();
params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
params = MacroCommands::PromptForParamsFor(command, params, this).Trim();
mParameters->SetValue(params);
mParameters->Refresh();
}
void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
void MacroCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
{
wxString command = mInternalCommandName;
wxString params = mParameters->GetValue();
wxString preset = BatchCommands::PromptForPresetFor(command, params, this).Trim();
wxString preset = MacroCommands::PromptForPresetFor(command, params, this).Trim();
mParameters->SetValue(preset);
mParameters->Refresh();
}
void BatchCommandDialog::SetCommandAndParams(const wxString &Command, const wxString &Params)
void MacroCommandDialog::SetCommandAndParams(const wxString &Command, const wxString &Params)
{
auto item = make_iterator_range(mCommandNames).index_if(
[&](const CommandName &name){ return Command == std::get<1>( name); }

View File

@ -9,8 +9,8 @@
**********************************************************************/
#ifndef __AUDACITY_BATCH_COMMAND_DIALOG__
#define __AUDACITY_BATCH_COMMAND_DIALOG__
#ifndef __AUDACITY_MACRO_COMMAND_DIALOG__
#define __AUDACITY_MACRO_COMMAND_DIALOG__
#include "MemoryX.h"
#include <wx/defs.h>
@ -37,10 +37,10 @@ class wxListEvent;
class wxButton;
class ShuttleGui;
class BatchCommandDialog final : public wxDialogWrapper {
class MacroCommandDialog final : public wxDialogWrapper {
public:
// constructors and destructors
BatchCommandDialog(wxWindow *parent, wxWindowID id);
MacroCommandDialog(wxWindow *parent, wxWindowID id);
void SetCommandAndParams(const wxString &Command, const wxString &Params);
public:
wxString mSelectedCommand;

View File

@ -2,16 +2,16 @@
Audacity: A Digital Audio Editor
BatchCommands.cpp
MacroCommands.cpp
Dominic Mazzoni
James Crook
********************************************************************//*!
\class BatchCommands
\class MacroCommands
\brief Maintains the chain of commands used in batch processing.
See also BatchCommandDialog and BatchProcessDialog.
See also MacroCommandDialog and ApplyMacroDialog.
*//*******************************************************************/
@ -89,50 +89,50 @@ static const std::pair<const wxChar*, const wxChar*> SpecialCommands[] = {
static const wxString MP3Conversion = wxT("MP3 Conversion");
BatchCommands::BatchCommands()
MacroCommands::MacroCommands()
{
mMessage = "";
ResetChain();
ResetMacro();
wxArrayString names = GetNames();
if (names.Index(MP3Conversion) == wxNOT_FOUND) {
AddChain(MP3Conversion);
RestoreChain(MP3Conversion);
WriteChain(MP3Conversion);
AddMacro(MP3Conversion);
RestoreMacro(MP3Conversion);
WriteMacro(MP3Conversion);
}
}
wxString BatchCommands::GetCommand(int index)
wxString MacroCommands::GetCommand(int index)
{
if (index < 0 || index >= (int)mCommandChain.GetCount()) {
if (index < 0 || index >= (int)mCommandMacro.GetCount()) {
return wxT("");
}
return mCommandChain[index];
return mCommandMacro[index];
}
wxString BatchCommands::GetParams(int index)
wxString MacroCommands::GetParams(int index)
{
if (index < 0 || index >= (int)mParamsChain.GetCount()) {
if (index < 0 || index >= (int)mParamsMacro.GetCount()) {
return wxT("");
}
return mParamsChain[index];
return mParamsMacro[index];
}
int BatchCommands::GetCount()
int MacroCommands::GetCount()
{
return (int)mCommandChain.GetCount();
return (int)mCommandMacro.GetCount();
}
bool BatchCommands::ReadChain(const wxString & chain)
bool MacroCommands::ReadMacro(const wxString & chain)
{
// Clear any previous chain
ResetChain();
ResetMacro();
// Build the filename
wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
wxFileName name(FileNames::MacroDir(), chain, wxT("txt"));
// Set the file name
wxTextFile tf(name.GetFullPath());
@ -160,8 +160,8 @@ bool BatchCommands::ReadChain(const wxString & chain)
wxString parm = tf[i].Mid(splitAt + 1).Strip(wxString::trailing);
// Add to lists
mCommandChain.Add(cmd);
mParamsChain.Add(parm);
mCommandMacro.Add(cmd);
mParamsMacro.Add(parm);
}
}
@ -172,10 +172,10 @@ bool BatchCommands::ReadChain(const wxString & chain)
}
bool BatchCommands::WriteChain(const wxString & chain)
bool MacroCommands::WriteMacro(const wxString & chain)
{
// Build the filename
wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
wxFileName name(FileNames::MacroDir(), chain, wxT("txt"));
// Set the file name
wxTextFile tf(name.GetFullPath());
@ -197,9 +197,9 @@ bool BatchCommands::WriteChain(const wxString & chain)
tf.Clear();
// Copy over the commands
int lines = mCommandChain.GetCount();
int lines = mCommandMacro.GetCount();
for (int i = 0; i < lines; i++) {
tf.AddLine(mCommandChain[i] + wxT(":") + mParamsChain[ i ]);
tf.AddLine(mCommandMacro[i] + wxT(":") + mParamsMacro[ i ]);
}
// Write the chain
@ -211,10 +211,10 @@ bool BatchCommands::WriteChain(const wxString & chain)
return true;
}
bool BatchCommands::AddChain(const wxString & chain)
bool MacroCommands::AddMacro(const wxString & chain)
{
// Build the filename
wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
wxFileName name(FileNames::MacroDir(), chain, wxT("txt"));
// Set the file name
wxTextFile tf(name.GetFullPath());
@ -223,35 +223,35 @@ bool BatchCommands::AddChain(const wxString & chain)
return tf.Create();
}
bool BatchCommands::DeleteChain(const wxString & chain)
bool MacroCommands::DeleteMacro(const wxString & chain)
{
// Build the filename
wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
wxFileName name(FileNames::MacroDir(), chain, wxT("txt"));
// Delete it...wxRemoveFile will display errors
return wxRemoveFile(name.GetFullPath());
}
bool BatchCommands::RenameChain(const wxString & oldchain, const wxString & newchain)
bool MacroCommands::RenameMacro(const wxString & oldchain, const wxString & newchain)
{
// Build the filenames
wxFileName oname(FileNames::ChainDir(), oldchain, wxT("txt"));
wxFileName nname(FileNames::ChainDir(), newchain, wxT("txt"));
wxFileName oname(FileNames::MacroDir(), oldchain, wxT("txt"));
wxFileName nname(FileNames::MacroDir(), newchain, wxT("txt"));
// Rename it...wxRenameFile will display errors
return wxRenameFile(oname.GetFullPath(), nname.GetFullPath());
}
void BatchCommands::SetWavToMp3Chain() // a function per default chain? This is flawed design! MJS
void MacroCommands::SetWavToMp3Macro() // a function per default chain? This is flawed design! MJS
{
ResetChain();
ResetMacro();
AddToChain( wxT("Normalize") );
AddToChain( wxT("ExportMP3") );
AddToMacro( wxT("Normalize") );
AddToMacro( wxT("ExportMP3") );
}
// Gets all commands that are valid for this mode.
auto BatchCommands::GetAllCommands() -> CommandNameVector
auto MacroCommands::GetAllCommands() -> CommandNameVector
{
CommandNameVector commands;
@ -341,7 +341,7 @@ auto BatchCommands::GetAllCommands() -> CommandNameVector
return uniqueCommands;
}
wxString BatchCommands::GetCurrentParamsFor(const wxString & command)
wxString MacroCommands::GetCurrentParamsFor(const wxString & command)
{
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
if (ID.empty())
@ -352,7 +352,7 @@ wxString BatchCommands::GetCurrentParamsFor(const wxString & command)
return EffectManager::Get().GetEffectParameters(ID);
}
wxString BatchCommands::PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent)
wxString MacroCommands::PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent)
{
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
if (ID.empty())
@ -375,7 +375,7 @@ wxString BatchCommands::PromptForParamsFor(const wxString & command, const wxStr
return res;
}
wxString BatchCommands::PromptForPresetFor(const wxString & command, const wxString & params, wxWindow *parent)
wxString MacroCommands::PromptForPresetFor(const wxString & command, const wxString & params, wxWindow *parent)
{
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
if (ID.empty())
@ -395,7 +395,7 @@ wxString BatchCommands::PromptForPresetFor(const wxString & command, const wxStr
return preset;
}
double BatchCommands::GetEndTime()
double MacroCommands::GetEndTime()
{
AudacityProject *project = GetActiveProject();
if( project == NULL )
@ -414,7 +414,7 @@ double BatchCommands::GetEndTime()
return endTime;
}
bool BatchCommands::IsMono()
bool MacroCommands::IsMono()
{
AudacityProject *project = GetActiveProject();
if( project == NULL )
@ -444,7 +444,7 @@ bool BatchCommands::IsMono()
return mono;
}
wxString BatchCommands::BuildCleanFileName(const wxString &fileName, const wxString &extension)
wxString MacroCommands::BuildCleanFileName(const wxString &fileName, const wxString &extension)
{
const wxFileName newFileName{ fileName };
wxString justName = newFileName.GetName();
@ -493,7 +493,7 @@ wxString BatchCommands::BuildCleanFileName(const wxString &fileName, const wxStr
}
// TODO Move this out of Batch Commands
bool BatchCommands::WriteMp3File( const wxString & Name, int bitrate )
bool MacroCommands::WriteMp3File( const wxString & Name, int bitrate )
{ //check if current project is mono or stereo
unsigned numChannels = 2;
if (IsMono()) {
@ -541,7 +541,7 @@ bool BatchCommands::WriteMp3File( const wxString & Name, int bitrate )
// and think again.
// ======= IMPORTANT ========
// CLEANSPEECH remnant
bool BatchCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString & command,const wxString & params)
bool MacroCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString & command,const wxString & params)
{
if (ReportAndSkip(command, params))
return true;
@ -625,7 +625,7 @@ bool BatchCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString &
}
// end CLEANSPEECH remnant
bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & command, const wxString & params, const CommandContext & Context)
bool MacroCommands::ApplyEffectCommand(const PluginID & ID, const wxString & command, const wxString & params, const CommandContext & Context)
{
//Possibly end processing here, if in batch-debug
if( ReportAndSkip(command, params))
@ -669,7 +669,7 @@ bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com
return res;
}
bool BatchCommands::ApplyCommand(const wxString & command, const wxString & params, CommandContext const * pContext)
bool MacroCommands::ApplyCommand(const wxString & command, const wxString & params, CommandContext const * pContext)
{
unsigned int i;
@ -714,7 +714,7 @@ bool BatchCommands::ApplyCommand(const wxString & command, const wxString & para
return false;
}
bool BatchCommands::ApplyCommandInBatchMode(const wxString & command, const wxString &params)
bool MacroCommands::ApplyCommandInBatchMode(const wxString & command, const wxString &params)
{
AudacityProject *project = GetActiveProject();
@ -728,10 +728,10 @@ bool BatchCommands::ApplyCommandInBatchMode(const wxString & command, const wxSt
return ApplyCommand( command, params );
}
// ApplyChain returns true on success, false otherwise.
// ApplyMacro returns true on success, false otherwise.
// Any error reporting to the user in setting up the chain
// has already been done.
bool BatchCommands::ApplyChain(const wxString & filename)
bool MacroCommands::ApplyMacro(const wxString & filename)
{
mFileName = filename;
@ -740,7 +740,7 @@ bool BatchCommands::ApplyChain(const wxString & filename)
auto cleanup = finally( [&] {
if (!res) {
if(proj) {
// Chain failed or was cancelled; revert to the previous state
// Macro failed or was cancelled; revert to the previous state
proj->RollbackState();
}
}
@ -749,20 +749,20 @@ bool BatchCommands::ApplyChain(const wxString & filename)
mAbort = false;
size_t i = 0;
for (; i < mCommandChain.GetCount(); i++) {
if (!ApplyCommandInBatchMode(mCommandChain[i], mParamsChain[i]) || mAbort)
for (; i < mCommandMacro.GetCount(); i++) {
if (!ApplyCommandInBatchMode(mCommandMacro[i], mParamsMacro[i]) || mAbort)
break;
}
res = (i == mCommandChain.GetCount());
res = (i == mCommandMacro.GetCount());
if (!res)
return false;
mFileName.Empty();
// Chain was successfully applied; save the NEW project state
// Macro was successfully applied; save the NEW project state
wxString longDesc, shortDesc;
wxString name = gPrefs->Read(wxT("/Batch/ActiveChain"), wxEmptyString);
wxString name = gPrefs->Read(wxT("/Batch/ActiveMacro"), wxEmptyString);
if (name.IsEmpty())
{
/* i18n-hint: active verb in past tense */
@ -783,45 +783,45 @@ bool BatchCommands::ApplyChain(const wxString & filename)
}
// AbortBatch() allows a premature terminatation of a batch.
void BatchCommands::AbortBatch()
void MacroCommands::AbortBatch()
{
mAbort = true;
}
void BatchCommands::AddToChain(const wxString &command, int before)
void MacroCommands::AddToMacro(const wxString &command, int before)
{
AddToChain(command, GetCurrentParamsFor(command), before);
AddToMacro(command, GetCurrentParamsFor(command), before);
}
void BatchCommands::AddToChain(const wxString &command, const wxString &params, int before)
void MacroCommands::AddToMacro(const wxString &command, const wxString &params, int before)
{
if (before == -1) {
before = (int)mCommandChain.GetCount();
before = (int)mCommandMacro.GetCount();
}
mCommandChain.Insert(command, before);
mParamsChain.Insert(params, before);
mCommandMacro.Insert(command, before);
mParamsMacro.Insert(params, before);
}
void BatchCommands::DeleteFromChain(int index)
void MacroCommands::DeleteFromMacro(int index)
{
if (index < 0 || index >= (int)mCommandChain.GetCount()) {
if (index < 0 || index >= (int)mCommandMacro.GetCount()) {
return;
}
mCommandChain.RemoveAt(index);
mParamsChain.RemoveAt(index);
mCommandMacro.RemoveAt(index);
mParamsMacro.RemoveAt(index);
}
void BatchCommands::ResetChain()
void MacroCommands::ResetMacro()
{
mCommandChain.Clear();
mParamsChain.Clear();
mCommandMacro.Clear();
mParamsMacro.Clear();
}
// ReportAndSkip() is a diagnostic function that avoids actually
// applying the requested effect if in batch-debug mode.
bool BatchCommands::ReportAndSkip(const wxString & command, const wxString & params)
bool MacroCommands::ReportAndSkip(const wxString & command, const wxString & params)
{
int bDebug;
gPrefs->Read(wxT("/Batch/Debug"), &bDebug, false);
@ -842,11 +842,11 @@ bool BatchCommands::ReportAndSkip(const wxString & command, const wxString & par
return true;
}
wxArrayString BatchCommands::GetNames()
wxArrayString MacroCommands::GetNames()
{
wxArrayString names;
wxArrayString files;
wxDir::GetAllFiles(FileNames::ChainDir(), &files, wxT("*.txt"), wxDIR_FILES);
wxDir::GetAllFiles(FileNames::MacroDir(), &files, wxT("*.txt"), wxDIR_FILES);
size_t i;
wxFileName ff;
@ -858,23 +858,23 @@ wxArrayString BatchCommands::GetNames()
return names;
}
bool BatchCommands::IsFixed(const wxString & name)
bool MacroCommands::IsFixed(const wxString & name)
{
if (name == MP3Conversion)
return true;
return false;
}
void BatchCommands::RestoreChain(const wxString & name)
void MacroCommands::RestoreMacro(const wxString & name)
{
// TIDY-ME: Effects change their name with localisation.
// Commands (at least currently) don't. Messy.
if (name == MP3Conversion)
SetWavToMp3Chain();
SetWavToMp3Macro();
}
void BatchCommands::Split(const wxString & str, wxString & command, wxString & param)
void MacroCommands::Split(const wxString & str, wxString & command, wxString & param)
{
int splitAt;
@ -896,7 +896,7 @@ void BatchCommands::Split(const wxString & str, wxString & command, wxString & p
return;
}
wxString BatchCommands::Join(const wxString & command, const wxString & param)
wxString MacroCommands::Join(const wxString & command, const wxString & param)
{
return command + wxT(": ") + param;
}

View File

@ -2,7 +2,7 @@
Audacity: A Digital Audio Editor
BatchCommands.h
MacroCommands.h
Dominic Mazzoni
James Crook
@ -21,12 +21,12 @@
class Effect;
class CommandContext;
class BatchCommands final {
class MacroCommands final {
public:
// constructors and destructors
BatchCommands();
MacroCommands();
public:
bool ApplyChain(const wxString & filename = wxT(""));
bool ApplyMacro(const wxString & filename = wxT(""));
bool ApplyCommand( const wxString & command, const wxString & params, CommandContext const * pContext=NULL );
bool ApplyCommandInBatchMode(const wxString & command, const wxString &params);
bool ApplySpecialCommand(int iCommand, const wxString & command,const wxString & params);
@ -54,34 +54,34 @@ class BatchCommands final {
static wxString PromptForPresetFor(const wxString & command, const wxString & params, wxWindow *parent);
// These commands do depend on the command list.
void ResetChain();
void ResetMacro();
bool ReadChain(const wxString & chain);
bool WriteChain(const wxString & chain);
bool AddChain(const wxString & chain);
bool DeleteChain(const wxString & name);
bool RenameChain(const wxString & oldchain, const wxString & newchain);
bool ReadMacro(const wxString & macro);
bool WriteMacro(const wxString & macro);
bool AddMacro(const wxString & macro);
bool DeleteMacro(const wxString & name);
bool RenameMacro(const wxString & oldmacro, const wxString & newmacro);
void AddToChain(const wxString & command, int before = -1);
void AddToChain(const wxString & command, const wxString & params, int before = -1);
void DeleteFromChain(int index);
void AddToMacro(const wxString & command, int before = -1);
void AddToMacro(const wxString & command, const wxString & params, int before = -1);
void DeleteFromMacro(int index);
wxString GetCommand(int index);
wxString GetParams(int index);
int GetCount();
wxString GetMessage(){ return mMessage;};
void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;};
void SetWavToMp3Chain();
void SetWavToMp3Macro();
bool IsFixed(const wxString & name);
void RestoreChain(const wxString & name);
void RestoreMacro(const wxString & name);
void Split(const wxString & str, wxString & command, wxString & param);
wxString Join(const wxString & command, const wxString & param);
wxArrayString mCommandChain;
wxArrayString mParamsChain;
wxArrayString mCommandMacro;
wxArrayString mParamsMacro;
bool mAbort;
wxString mMessage;

View File

@ -2,15 +2,15 @@
Audacity: A Digital Audio Editor
BatchProcessDialog.cpp
ApplyMacroDialog.cpp
Dominic Mazzoni
James Crook
*******************************************************************//*!
\class BatchProcessDialog
\brief Shows progress in executing commands in BatchCommands.
\class ApplyMacroDialog
\brief Shows progress in executing commands in MacroCommands.
*//*******************************************************************/
@ -55,20 +55,20 @@
#include "widgets/ErrorDialog.h"
#include "widgets/HelpSystem.h"
#define ChainsListID 7001
#define MacrosListID 7001
#define CommandsListID 7002
#define ApplyToProjectID 7003
#define ApplyToFilesID 7004
BEGIN_EVENT_TABLE(BatchProcessDialog, wxDialogWrapper)
EVT_BUTTON(ApplyToProjectID, BatchProcessDialog::OnApplyToProject)
EVT_BUTTON(ApplyToFilesID, BatchProcessDialog::OnApplyToFiles)
EVT_BUTTON(wxID_CANCEL, BatchProcessDialog::OnCancel)
EVT_BUTTON(wxID_HELP, BatchProcessDialog::OnHelp)
BEGIN_EVENT_TABLE(ApplyMacroDialog, wxDialogWrapper)
EVT_BUTTON(ApplyToProjectID, ApplyMacroDialog::OnApplyToProject)
EVT_BUTTON(ApplyToFilesID, ApplyMacroDialog::OnApplyToFiles)
EVT_BUTTON(wxID_CANCEL, ApplyMacroDialog::OnCancel)
EVT_BUTTON(wxID_HELP, ApplyMacroDialog::OnHelp)
END_EVENT_TABLE()
BatchProcessDialog::BatchProcessDialog(wxWindow * parent, bool bInherited):
wxDialogWrapper(parent, wxID_ANY, _("Apply Chain"),
ApplyMacroDialog::ApplyMacroDialog(wxWindow * parent, bool bInherited):
wxDialogWrapper(parent, wxID_ANY, _("Apply Macro"),
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
@ -76,57 +76,57 @@ BatchProcessDialog::BatchProcessDialog(wxWindow * parent, bool bInherited):
mAbort = false;
if( bInherited )
return;
SetLabel(_("Apply Chain")); // Provide visual label
SetName(_("Apply Chain")); // Provide audible label
SetLabel(_("Apply Macro")); // Provide visual label
SetName(_("Apply Macro")); // Provide audible label
Populate();
}
BatchProcessDialog::~BatchProcessDialog()
ApplyMacroDialog::~ApplyMacroDialog()
{
}
void BatchProcessDialog::Populate()
void ApplyMacroDialog::Populate()
{
//------------------------- Main section --------------------
ShuttleGui S(this, eIsCreating);
PopulateOrExchange(S);
// ----------------------- End of main section --------------
// Get and validate the currently active chain
mActiveChain = gPrefs->Read(wxT("/Batch/ActiveChain"), wxT(""));
// Go populate the chains list.
PopulateChains();
// Get and validate the currently active macro
mActiveMacro = gPrefs->Read(wxT("/Batch/ActiveMacro"), wxT(""));
// Go populate the macros list.
PopulateMacros();
Layout();
Fit();
SetSizeHints(GetSize());
Center();
// Set the column size for the chains list.
wxSize sz = mChains->GetClientSize();
mChains->SetColumnWidth(0, sz.x);
// Set the column size for the macros list.
wxSize sz = mMacros->GetClientSize();
mMacros->SetColumnWidth(0, sz.x);
}
/// Defines the dialog and does data exchange with it.
void BatchProcessDialog::PopulateOrExchange(ShuttleGui &S)
void ApplyMacroDialog::PopulateOrExchange(ShuttleGui &S)
{
S.StartVerticalLay(true);
{
/*i18n-hint: A chain is a sequence of commands that can be applied
/*i18n-hint: A macro is a sequence of commands that can be applied
* to one or more audio files.*/
S.StartStatic(_("&Select Chain"), true);
S.StartStatic(_("&Select Macro"), true);
{
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
wxLC_SINGLE_SEL);
mChains = S.Id(ChainsListID).AddListControlReportMode();
mChains->InsertColumn(0, _("Chain"), wxLIST_FORMAT_LEFT);
mMacros = S.Id(MacrosListID).AddListControlReportMode();
mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT);
}
S.EndStatic();
S.StartHorizontalLay(wxALIGN_RIGHT, false);
{
S.SetBorder(10);
S.AddPrompt( _("Apply Chain to:") );
S.AddPrompt( _("Apply Macro to:") );
S.Id(ApplyToProjectID).AddButton(_("&Project"));
S.Id(ApplyToFilesID).AddButton(_("&Files..."));
S.AddSpace( 40 );
@ -137,52 +137,52 @@ void BatchProcessDialog::PopulateOrExchange(ShuttleGui &S)
S.EndVerticalLay();
}
/// This clears and updates the contents of mChains, the list of chains.
void BatchProcessDialog::PopulateChains()
/// This clears and updates the contents of mMacros, the list of macros.
void ApplyMacroDialog::PopulateMacros()
{
wxArrayString names = mBatchCommands.GetNames();
wxArrayString names = mMacroCommands.GetNames();
int i;
mChains->DeleteAllItems();
mMacros->DeleteAllItems();
for (i = 0; i < (int)names.GetCount(); i++) {
mChains->InsertItem(i, names[i]);
mMacros->InsertItem(i, names[i]);
}
int item = mChains->FindItem(-1, mActiveChain);
int item = mMacros->FindItem(-1, mActiveMacro);
if (item == -1) {
item = 0;
mActiveChain = mChains->GetItemText(0);
mActiveMacro = mMacros->GetItemText(0);
}
// Select the name in the list...this will fire an event.
mChains->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
mMacros->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
void BatchProcessDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
void ApplyMacroDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
{
wxString page = GetHelpPageName();
HelpSystem::ShowHelp(this, page, true);
}
void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
void ApplyMacroDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
{
long item = mChains->GetNextItem(-1,
long item = mMacros->GetNextItem(-1,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if (item == -1) {
AudacityMessageBox(_("No chain selected"));
AudacityMessageBox(_("No macro selected"));
return;
}
ApplyChainToProject( item );
ApplyMacroToProject( item );
}
void BatchProcessDialog::ApplyChainToProject( int iChain, bool bHasGui )
void ApplyMacroDialog::ApplyMacroToProject( int iMacro, bool bHasGui )
{
wxString name = mChains->GetItemText(iChain);
wxString name = mMacros->GetItemText(iMacro);
if( name.IsEmpty() )
return;
@ -222,10 +222,10 @@ void BatchProcessDialog::ApplyChainToProject( int iChain, bool bHasGui )
if( bHasGui )
Hide();
gPrefs->Write(wxT("/Batch/ActiveChain"), name);
gPrefs->Write(wxT("/Batch/ActiveMacro"), name);
gPrefs->Flush();
mBatchCommands.ReadChain(name);
mMacroCommands.ReadMacro(name);
// The disabler must get deleted before the EndModal() call. Otherwise,
// the menus on OSX will remain disabled.
@ -233,7 +233,7 @@ void BatchProcessDialog::ApplyChainToProject( int iChain, bool bHasGui )
{
wxWindowDisabler wd(&activityWin);
success = GuardedCall< bool >(
[this]{ return mBatchCommands.ApplyChain(); } );
[this]{ return mMacroCommands.ApplyMacro(); } );
}
if( !bHasGui )
@ -247,18 +247,18 @@ void BatchProcessDialog::ApplyChainToProject( int iChain, bool bHasGui )
Hide();
}
void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
{
long item = mChains->GetNextItem(-1,
long item = mMacros->GetNextItem(-1,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if (item == -1) {
AudacityMessageBox(_("No chain selected"));
AudacityMessageBox(_("No macro selected"));
return;
}
wxString name = mChains->GetItemText(item);
gPrefs->Write(wxT("/Batch/ActiveChain"), name);
wxString name = mMacros->GetItemText(item);
gPrefs->Write(wxT("/Batch/ActiveMacro"), name);
gPrefs->Flush();
AudacityProject *project = GetActiveProject();
@ -383,7 +383,7 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
wxYield();
Hide();
mBatchCommands.ReadChain(name);
mMacroCommands.ReadMacro(name);
for (i = 0; i < (int)files.GetCount(); i++) {
wxWindowDisabler wd(&activityWin);
if (i > 0) {
@ -397,7 +397,7 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
project->Import(files[i]);
project->ZoomAfterImport(nullptr);
project->OnSelectAll(*project);
if (!mBatchCommands.ApplyChain())
if (!mMacroCommands.ApplyMacro())
return false;
if (!activityWin.IsShown() || mAbort)
@ -418,7 +418,7 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
Hide();
}
void BatchProcessDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
void ApplyMacroDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
{
Hide();
}
@ -439,35 +439,35 @@ enum {
UpButtonID,
DownButtonID,
RenameButtonID,
// ChainsListID 7005
// MacrosListID 7005
// CommandsListID, 7002
// Re-Use IDs from BatchProcessDialog.
// Re-Use IDs from ApplyMacroDialog.
ApplyToProjectButtonID = ApplyToProjectID,
ApplyToFilesButtonID = ApplyToFilesID,
};
BEGIN_EVENT_TABLE(EditChainsDialog, BatchProcessDialog)
EVT_LIST_ITEM_SELECTED(ChainsListID, EditChainsDialog::OnChainSelected)
EVT_LIST_ITEM_SELECTED(CommandsListID, EditChainsDialog::OnListSelected)
EVT_LIST_BEGIN_LABEL_EDIT(ChainsListID, EditChainsDialog::OnChainsBeginEdit)
EVT_LIST_END_LABEL_EDIT(ChainsListID, EditChainsDialog::OnChainsEndEdit)
EVT_BUTTON(AddButtonID, EditChainsDialog::OnAdd)
EVT_BUTTON(RemoveButtonID, EditChainsDialog::OnRemove)
EVT_BUTTON(RenameButtonID, EditChainsDialog::OnRename)
EVT_SIZE(EditChainsDialog::OnSize)
BEGIN_EVENT_TABLE(MacrosWindow, ApplyMacroDialog)
EVT_LIST_ITEM_SELECTED(MacrosListID, MacrosWindow::OnMacroSelected)
EVT_LIST_ITEM_SELECTED(CommandsListID, MacrosWindow::OnListSelected)
EVT_LIST_BEGIN_LABEL_EDIT(MacrosListID, MacrosWindow::OnMacrosBeginEdit)
EVT_LIST_END_LABEL_EDIT(MacrosListID, MacrosWindow::OnMacrosEndEdit)
EVT_BUTTON(AddButtonID, MacrosWindow::OnAdd)
EVT_BUTTON(RemoveButtonID, MacrosWindow::OnRemove)
EVT_BUTTON(RenameButtonID, MacrosWindow::OnRename)
EVT_SIZE(MacrosWindow::OnSize)
EVT_LIST_ITEM_ACTIVATED(CommandsListID, EditChainsDialog::OnCommandActivated)
EVT_BUTTON(InsertButtonID, EditChainsDialog::OnInsert)
EVT_BUTTON(EditButtonID, EditChainsDialog::OnEditCommandParams)
EVT_BUTTON(DeleteButtonID, EditChainsDialog::OnDelete)
EVT_BUTTON(UpButtonID, EditChainsDialog::OnUp)
EVT_BUTTON(DownButtonID, EditChainsDialog::OnDown)
EVT_BUTTON(DefaultsButtonID, EditChainsDialog::OnDefaults)
EVT_LIST_ITEM_ACTIVATED(CommandsListID, MacrosWindow::OnCommandActivated)
EVT_BUTTON(InsertButtonID, MacrosWindow::OnInsert)
EVT_BUTTON(EditButtonID, MacrosWindow::OnEditCommandParams)
EVT_BUTTON(DeleteButtonID, MacrosWindow::OnDelete)
EVT_BUTTON(UpButtonID, MacrosWindow::OnUp)
EVT_BUTTON(DownButtonID, MacrosWindow::OnDown)
EVT_BUTTON(DefaultsButtonID, MacrosWindow::OnDefaults)
EVT_BUTTON(wxID_OK, EditChainsDialog::OnOK)
EVT_BUTTON(wxID_CANCEL, EditChainsDialog::OnCancel)
EVT_BUTTON(wxID_OK, MacrosWindow::OnOK)
EVT_BUTTON(wxID_CANCEL, MacrosWindow::OnCancel)
EVT_KEY_DOWN(EditChainsDialog::OnKeyDown)
EVT_KEY_DOWN(MacrosWindow::OnKeyDown)
END_EVENT_TABLE()
enum {
@ -478,13 +478,13 @@ enum {
};
/// Constructor
EditChainsDialog::EditChainsDialog(wxWindow * parent, bool bExpanded):
BatchProcessDialog(parent, true)
MacrosWindow::MacrosWindow(wxWindow * parent, bool bExpanded):
ApplyMacroDialog(parent, true)
{
mbExpanded = bExpanded;
SetLabel(_("Edit Chains")); // Provide visual label
SetName(_("Edit Chains")); // Provide audible label
SetTitle(_("Edit Chains"));
SetLabel(_("Macros")); // Provide visual label
SetName(_("Macros")); // Provide audible label
SetTitle(_("Macros"));
mChanged = false;
mSelectedCommand = 0;
@ -492,27 +492,27 @@ EditChainsDialog::EditChainsDialog(wxWindow * parent, bool bExpanded):
if( mbExpanded )
Populate();
else
BatchProcessDialog::Populate();
ApplyMacroDialog::Populate();
}
EditChainsDialog::~EditChainsDialog()
MacrosWindow::~MacrosWindow()
{
}
/// Creates the dialog and its contents.
void EditChainsDialog::Populate()
void MacrosWindow::Populate()
{
mCommandNames = BatchCommands::GetAllCommands();
mCommandNames = MacroCommands::GetAllCommands();
//------------------------- Main section --------------------
ShuttleGui S(this, eIsCreating);
PopulateOrExchange(S);
// ----------------------- End of main section --------------
// Get and validate the currently active chain
mActiveChain = gPrefs->Read(wxT("/Batch/ActiveChain"), wxT(""));
// Go populate the chains list.
PopulateChains();
// Get and validate the currently active macro
mActiveMacro = gPrefs->Read(wxT("/Batch/ActiveMacro"), wxT(""));
// Go populate the macros list.
PopulateMacros();
// We have a bare list. We need to add columns and content.
PopulateList();
@ -527,20 +527,20 @@ void EditChainsDialog::Populate()
wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5);
Center();
// Set the column size for the chains list.
wxSize sz = mChains->GetClientSize();
mChains->SetColumnWidth(0, sz.x);
// Set the column size for the macros list.
wxSize sz = mMacros->GetClientSize();
mMacros->SetColumnWidth(0, sz.x);
// Size columns properly
FitColumns();
}
/// Defines the dialog and does data exchange with it.
void EditChainsDialog::PopulateOrExchange(ShuttleGui & S)
void MacrosWindow::PopulateOrExchange(ShuttleGui & S)
{
S.StartHorizontalLay(wxEXPAND, 1);
{
S.StartStatic(_("&Chains"));
S.StartStatic(_("&Macros"));
{
// JKC: Experimenting with an alternative way to get multiline
// translated strings to work correctly without very long lines.
@ -555,9 +555,9 @@ void EditChainsDialog::PopulateOrExchange(ShuttleGui & S)
// If it doesn't work out, revert to all-on-one-line.
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_SINGLE_SEL |
wxLC_EDIT_LABELS);
mChains = S.Id(ChainsListID).AddListControlReportMode();
// i18n-hint: This is the heading for a column in the edit chains dialog
mChains->InsertColumn(0, _("Chain"), wxLIST_FORMAT_LEFT);
mMacros = S.Id(MacrosListID).AddListControlReportMode();
// i18n-hint: This is the heading for a column in the edit macros dialog
mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT);
S.StartHorizontalLay(wxCENTER, false);
{
S.Id(AddButtonID).AddButton(_("&Add"));
@ -570,7 +570,7 @@ void EditChainsDialog::PopulateOrExchange(ShuttleGui & S)
S.StartVerticalLay( 1 );
{
S.StartStatic(_("C&hain (Double-Click or press SPACE to edit)"), true);
S.StartStatic(_("Ma&cro (Double-Click or press SPACE to edit)"), true);
{
S.StartHorizontalLay(wxEXPAND,1);
{
@ -603,7 +603,7 @@ void EditChainsDialog::PopulateOrExchange(ShuttleGui & S)
S.EndStatic();
S.StartHorizontalLay(wxALIGN_RIGHT, false);
{
S.AddPrompt( _("Apply Chain to:") );
S.AddPrompt( _("Apply Macro to:") );
S.Id(ApplyToProjectButtonID).AddButton(_("&Project"), wxALIGN_LEFT);
S.Id(ApplyToFilesButtonID).AddButton(_("&Files..."), wxALIGN_LEFT);
S.AddSpace( 40 );
@ -618,14 +618,14 @@ void EditChainsDialog::PopulateOrExchange(ShuttleGui & S)
return;
}
/// This clears and updates the contents of mList, the commands for the current chain.
void EditChainsDialog::PopulateList()
/// This clears and updates the contents of mList, the commands for the current macro.
void MacrosWindow::PopulateList()
{
mList->DeleteAllItems();
for (int i = 0; i < mBatchCommands.GetCount(); i++) {
AddItem(mBatchCommands.GetCommand(i),
mBatchCommands.GetParams(i));
for (int i = 0; i < mMacroCommands.GetCount(); i++) {
AddItem(mMacroCommands.GetCommand(i),
mMacroCommands.GetParams(i));
}
/*i18n-hint: This is the last item in a list.*/
AddItem(_("- END -"), wxT(""));
@ -638,7 +638,7 @@ void EditChainsDialog::PopulateList()
}
/// Add one item into mList
void EditChainsDialog::AddItem(const wxString &Action, const wxString &Params)
void MacrosWindow::AddItem(const wxString &Action, const wxString &Params)
{
// Translate internal command name to a friendly form
auto item = make_iterator_range(mCommandNames).index_if(
@ -657,26 +657,26 @@ void EditChainsDialog::AddItem(const wxString &Action, const wxString &Params)
mList->SetItem(i, ParamsColumn, Params );
}
void EditChainsDialog::UpdateMenus()
void MacrosWindow::UpdateMenus()
{
// OK even on mac, as dialog is modal.
GetActiveProject()->RebuildMenuBar();
}
void EditChainsDialog::UpdateDisplay( bool WXUNUSED(bExpanded) )
void MacrosWindow::UpdateDisplay( bool WXUNUSED(bExpanded) )
{
//if(IsShown())
// DoUpdate();
}
bool EditChainsDialog::ChangeOK()
bool MacrosWindow::ChangeOK()
{
if (mChanged) {
wxString title;
wxString msg;
int id;
title.Printf(_("%s changed"), mActiveChain);
title.Printf(_("%s changed"), mActiveMacro);
msg = _("Do you want to save the changes?");
id = AudacityMessageBox(msg, title, wxYES_NO | wxCANCEL);
@ -685,7 +685,7 @@ bool EditChainsDialog::ChangeOK()
}
if (id == wxYES) {
if (!mBatchCommands.WriteChain(mActiveChain)) {
if (!mMacroCommands.WriteMacro(mActiveMacro)) {
return false;
}
}
@ -695,8 +695,8 @@ bool EditChainsDialog::ChangeOK()
return true;
}
/// An item in the chains list has been selected.
void EditChainsDialog::OnChainSelected(wxListEvent & event)
/// An item in the macros list has been selected.
void MacrosWindow::OnMacroSelected(wxListEvent & event)
{
if (!ChangeOK()) {
event.Veto();
@ -705,12 +705,12 @@ void EditChainsDialog::OnChainSelected(wxListEvent & event)
int item = event.GetIndex();
mActiveChain = mChains->GetItemText(item);
mBatchCommands.ReadChain(mActiveChain);
mActiveMacro = mMacros->GetItemText(item);
mMacroCommands.ReadMacro(mActiveMacro);
if( !mbExpanded )
return;
if (mBatchCommands.IsFixed(mActiveChain)) {
if (mMacroCommands.IsFixed(mActiveMacro)) {
mRemove->Disable();
mRename->Disable();
mDefaults->Enable();
@ -724,14 +724,14 @@ void EditChainsDialog::OnChainSelected(wxListEvent & event)
PopulateList();
}
/// An item in the chains list has been selected.
void EditChainsDialog::OnListSelected(wxListEvent & WXUNUSED(event))
/// An item in the macros list has been selected.
void MacrosWindow::OnListSelected(wxListEvent & WXUNUSED(event))
{
FitColumns();
}
/// The window has been resized.
void EditChainsDialog::OnSize(wxSizeEvent & WXUNUSED(event))
void MacrosWindow::OnSize(wxSizeEvent & WXUNUSED(event))
{
// Refrsh the layout and re-fit the columns.
Layout();
@ -740,7 +740,7 @@ void EditChainsDialog::OnSize(wxSizeEvent & WXUNUSED(event))
FitColumns();
}
void EditChainsDialog::FitColumns()
void MacrosWindow::FitColumns()
{
mList->SetColumnWidth(0, 0); // First column width is zero, to hide it.
@ -785,20 +785,20 @@ void EditChainsDialog::FitColumns()
}
///
void EditChainsDialog::OnChainsBeginEdit(wxListEvent &event)
void MacrosWindow::OnMacrosBeginEdit(wxListEvent &event)
{
int itemNo = event.GetIndex();
wxString chain = mChains->GetItemText(itemNo);
wxString macro = mMacros->GetItemText(itemNo);
if (mBatchCommands.IsFixed(mActiveChain)) {
if (mMacroCommands.IsFixed(mActiveMacro)) {
wxBell();
event.Veto();
}
}
///
void EditChainsDialog::OnChainsEndEdit(wxListEvent &event)
void MacrosWindow::OnMacrosEndEdit(wxListEvent &event)
{
if (event.IsEditCancelled()) {
return;
@ -806,20 +806,20 @@ void EditChainsDialog::OnChainsEndEdit(wxListEvent &event)
wxString newname = event.GetLabel();
mBatchCommands.RenameChain(mActiveChain, newname);
mMacroCommands.RenameMacro(mActiveMacro, newname);
mActiveChain = newname;
mActiveMacro = newname;
PopulateChains();
PopulateMacros();
}
///
void EditChainsDialog::OnAdd(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnAdd(wxCommandEvent & WXUNUSED(event))
{
while (true) {
AudacityTextEntryDialog d(this,
_("Enter name of new chain"),
_("Name of new chain"));
_("Enter name of new macro"),
_("Name of new macro"));
d.SetName(d.GetTitle());
wxString name;
@ -848,11 +848,11 @@ void EditChainsDialog::OnAdd(wxCommandEvent & WXUNUSED(event))
continue;
}
mBatchCommands.AddChain(name);
mMacroCommands.AddMacro(name);
mActiveChain = name;
mActiveMacro = name;
PopulateChains();
PopulateMacros();
UpdateMenus();
break;
@ -860,16 +860,16 @@ void EditChainsDialog::OnAdd(wxCommandEvent & WXUNUSED(event))
}
///
void EditChainsDialog::OnRemove(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnRemove(wxCommandEvent & WXUNUSED(event))
{
long item = mChains->GetNextItem(-1,
long item = mMacros->GetNextItem(-1,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if (item == -1) {
return;
}
wxString name = mChains->GetItemText(item);
wxString name = mMacros->GetItemText(item);
AudacityMessageDialog m(this,
/*i18n-hint: %s will be replaced by the name of a file.*/
wxString::Format(_("Are you sure you want to delete %s?"), name),
@ -879,42 +879,42 @@ void EditChainsDialog::OnRemove(wxCommandEvent & WXUNUSED(event))
return;
}
mBatchCommands.DeleteChain(name);
mMacroCommands.DeleteMacro(name);
if (item >= (mChains->GetItemCount() - 1) && item >= 0) {
if (item >= (mMacros->GetItemCount() - 1) && item >= 0) {
item--;
}
mActiveChain = mChains->GetItemText(item);
mActiveMacro = mMacros->GetItemText(item);
PopulateChains();
PopulateMacros();
UpdateMenus();
}
///
void EditChainsDialog::OnRename(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnRename(wxCommandEvent & WXUNUSED(event))
{
long item = mChains->GetNextItem(-1,
long item = mMacros->GetNextItem(-1,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if (item == -1) {
return;
}
mChains->EditLabel(item);
mMacros->EditLabel(item);
UpdateMenus();
}
/// An item in the list has been selected.
/// Bring up a dialog to allow its parameters to be edited.
void EditChainsDialog::OnCommandActivated(wxListEvent & WXUNUSED(event))
void MacrosWindow::OnCommandActivated(wxListEvent & WXUNUSED(event))
{
wxCommandEvent dummy;
OnEditCommandParams( dummy );
}
///
void EditChainsDialog::OnInsert(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnInsert(wxCommandEvent & WXUNUSED(event))
{
long item = mList->GetNextItem(-1,
wxLIST_NEXT_ALL,
@ -925,13 +925,13 @@ void EditChainsDialog::OnInsert(wxCommandEvent & WXUNUSED(event))
InsertCommandAt( item );
}
void EditChainsDialog::InsertCommandAt(int item)
void MacrosWindow::InsertCommandAt(int item)
{
if (item == -1) {
return;
}
BatchCommandDialog d(this, wxID_ANY);
MacroCommandDialog d(this, wxID_ANY);
if (!d.ShowModal()) {
return;
@ -939,7 +939,7 @@ void EditChainsDialog::InsertCommandAt(int item)
if(d.mSelectedCommand != wxT(""))
{
mBatchCommands.AddToChain(d.mSelectedCommand,
mMacroCommands.AddToMacro(d.mSelectedCommand,
d.mSelectedParameters,
item);
mChanged = true;
@ -948,7 +948,7 @@ void EditChainsDialog::InsertCommandAt(int item)
}
}
void EditChainsDialog::OnEditCommandParams(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnEditCommandParams(wxCommandEvent & WXUNUSED(event))
{
int item = mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
@ -965,13 +965,13 @@ void EditChainsDialog::OnEditCommandParams(wxCommandEvent & WXUNUSED(event))
}
// Just edit the parameters, and not the command.
wxString command = mBatchCommands.GetCommand(item);
wxString params = mBatchCommands.GetParams(item);
wxString command = mMacroCommands.GetCommand(item);
wxString params = mMacroCommands.GetParams(item);
params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
params = MacroCommands::PromptForParamsFor(command, params, this).Trim();
mBatchCommands.DeleteFromChain(item);
mBatchCommands.AddToChain(command,
mMacroCommands.DeleteFromMacro(item);
mMacroCommands.AddToMacro(command,
params,
item);
mChanged = true;
@ -980,7 +980,7 @@ void EditChainsDialog::OnEditCommandParams(wxCommandEvent & WXUNUSED(event))
}
///
void EditChainsDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnDelete(wxCommandEvent & WXUNUSED(event))
{
long item = mList->GetNextItem(-1,
wxLIST_NEXT_ALL,
@ -989,7 +989,7 @@ void EditChainsDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
return;
}
mBatchCommands.DeleteFromChain(item);
mMacroCommands.DeleteFromMacro(item);
mChanged = true;
if (item >= (mList->GetItemCount() - 2) && item >= 0) {
@ -1000,7 +1000,7 @@ void EditChainsDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
}
///
void EditChainsDialog::OnUp(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnUp(wxCommandEvent & WXUNUSED(event))
{
long item = mList->GetNextItem(-1,
wxLIST_NEXT_ALL,
@ -1009,17 +1009,17 @@ void EditChainsDialog::OnUp(wxCommandEvent & WXUNUSED(event))
return;
}
mBatchCommands.AddToChain(mBatchCommands.GetCommand(item),
mBatchCommands.GetParams(item),
mMacroCommands.AddToMacro(mMacroCommands.GetCommand(item),
mMacroCommands.GetParams(item),
item - 1);
mBatchCommands.DeleteFromChain(item + 1);
mMacroCommands.DeleteFromMacro(item + 1);
mChanged = true;
mSelectedCommand = item - 1;
PopulateList();
}
///
void EditChainsDialog::OnDown(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnDown(wxCommandEvent & WXUNUSED(event))
{
long item = mList->GetNextItem(-1,
wxLIST_NEXT_ALL,
@ -1028,45 +1028,45 @@ void EditChainsDialog::OnDown(wxCommandEvent & WXUNUSED(event))
return;
}
mBatchCommands.AddToChain(mBatchCommands.GetCommand(item),
mBatchCommands.GetParams(item),
mMacroCommands.AddToMacro(mMacroCommands.GetCommand(item),
mMacroCommands.GetParams(item),
item + 2);
mBatchCommands.DeleteFromChain(item);
mMacroCommands.DeleteFromMacro(item);
mChanged = true;
mSelectedCommand = item + 1;
PopulateList();
}
void EditChainsDialog::OnApplyToProject(wxCommandEvent & event)
void MacrosWindow::OnApplyToProject(wxCommandEvent & event)
{
if( !SaveChanges() )
return;
BatchProcessDialog::OnApplyToProject( event );
ApplyMacroDialog::OnApplyToProject( event );
}
void EditChainsDialog::OnApplyToFiles(wxCommandEvent & event)
void MacrosWindow::OnApplyToFiles(wxCommandEvent & event)
{
if( !SaveChanges() )
return;
BatchProcessDialog::OnApplyToFiles( event );
ApplyMacroDialog::OnApplyToFiles( event );
}
/// Select the empty Command chain.
void EditChainsDialog::OnDefaults(wxCommandEvent & WXUNUSED(event))
/// Select the empty Command macro.
void MacrosWindow::OnDefaults(wxCommandEvent & WXUNUSED(event))
{
mBatchCommands.RestoreChain(mActiveChain);
mMacroCommands.RestoreMacro(mActiveMacro);
mChanged = true;
PopulateList();
}
bool EditChainsDialog::SaveChanges(){
gPrefs->Write(wxT("/Batch/ActiveChain"), mActiveChain);
bool MacrosWindow::SaveChanges(){
gPrefs->Write(wxT("/Batch/ActiveMacro"), mActiveMacro);
gPrefs->Flush();
if (mChanged) {
if (!mBatchCommands.WriteChain(mActiveChain)) {
if (!mMacroCommands.WriteMacro(mActiveMacro)) {
return false;
}
}
@ -1075,7 +1075,7 @@ bool EditChainsDialog::SaveChanges(){
}
/// Send changed values back to Prefs, and update Audacity.
void EditChainsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
void MacrosWindow::OnOK(wxCommandEvent & WXUNUSED(event))
{
if( !SaveChanges() )
return;
@ -1084,7 +1084,7 @@ void EditChainsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
}
///
void EditChainsDialog::OnCancel(wxCommandEvent & event)
void MacrosWindow::OnCancel(wxCommandEvent & event)
{
if (!ChangeOK()) {
return;
@ -1093,7 +1093,7 @@ void EditChainsDialog::OnCancel(wxCommandEvent & event)
}
///
void EditChainsDialog::OnKeyDown(wxKeyEvent &event)
void MacrosWindow::OnKeyDown(wxKeyEvent &event)
{
if (event.GetKeyCode() == WXK_DELETE) {
wxLogDebug(wxT("wxKeyEvent"));

View File

@ -9,8 +9,8 @@
**********************************************************************/
#ifndef __AUDACITY_BATCH_PROCESS_DIALOG__
#define __AUDACITY_BATCH_PROCESS_DIALOG__
#ifndef __AUDACITY_MACROS_WINDOW__
#define __AUDACITY_MACROS_WINDOW__
#include <wx/defs.h>
#include <wx/string.h>
@ -39,11 +39,11 @@ class wxButton;
class wxTextCtrl;
class ShuttleGui;
class BatchProcessDialog : public wxDialogWrapper {
class ApplyMacroDialog : public wxDialogWrapper {
public:
// constructors and destructors
BatchProcessDialog(wxWindow * parent, bool bInherited=false);
virtual ~BatchProcessDialog();
ApplyMacroDialog(wxWindow * parent, bool bInherited=false);
virtual ~ApplyMacroDialog();
public:
// Populate methods NOT virtual.
void Populate();
@ -55,29 +55,29 @@ class BatchProcessDialog : public wxDialogWrapper {
virtual wxString GetHelpPageName() {return "Tools_Menu#chains_compact_dialog";};
void PopulateChains();
void ApplyChainToProject( int iChain, bool bHasGui=true );
void PopulateMacros();
void ApplyMacroToProject( int iMacro, bool bHasGui=true );
// These will be reused in the derived class...
wxListCtrl *mList;
wxListCtrl *mChains;
BatchCommands mBatchCommands; /// Provides list of available commands.
wxListCtrl *mMacros;
MacroCommands mMacroCommands; /// Provides list of available commands.
wxButton *mOK;
wxButton *mCancel;
wxTextCtrl *mResults;
bool mAbort;
wxString mActiveChain;
wxString mActiveMacro;
DECLARE_EVENT_TABLE()
};
class EditChainsDialog final : public BatchProcessDialog
class MacrosWindow final : public ApplyMacroDialog
{
public:
EditChainsDialog(wxWindow * parent, bool bExpanded=true);
~EditChainsDialog();
MacrosWindow(wxWindow * parent, bool bExpanded=true);
~MacrosWindow();
void UpdateDisplay( bool bExpanded );
private:
@ -94,10 +94,10 @@ private:
bool ChangeOK();
void UpdateMenus();
void OnChainSelected(wxListEvent &event);
void OnMacroSelected(wxListEvent &event);
void OnListSelected(wxListEvent &event);
void OnChainsBeginEdit(wxListEvent &event);
void OnChainsEndEdit(wxListEvent &event);
void OnMacrosBeginEdit(wxListEvent &event);
void OnMacrosEndEdit(wxListEvent &event);
void OnAdd(wxCommandEvent &event);
void OnRemove(wxCommandEvent &event);
void OnRename(wxCommandEvent &event);
@ -122,10 +122,10 @@ private:
void InsertCommandAt(int item);
bool SaveChanges();
// These are already provided by BatchProcessDialog
// These are already provided by ApplyMacroDialog
//wxListCtrl *mList; /// List of commands in current command chain.
//BatchCommands mBatchCommands; /// Provides list of available commands.
//wxListCtrl *mChains; /// List of chains.
//MacroCommands mMacroCommands; /// Provides list of available commands.
//wxListCtrl *mMacros; /// List of chains.
wxButton *mRemove;
wxButton *mRename;

View File

@ -190,9 +190,9 @@ wxString FileNames::HtmlHelpDir()
#endif
}
wxString FileNames::ChainDir()
wxString FileNames::MacroDir()
{
return FileNames::MkDir( wxFileName( DataDir(), wxT("Chains") ).GetFullPath() );
return FileNames::MkDir( wxFileName( DataDir(), wxT("Macros") ).GetFullPath() );
}
wxString FileNames::NRPDir()

View File

@ -44,7 +44,7 @@ public:
static wxString AutoSaveDir();
static wxString HtmlHelpDir();
static wxString HtmlHelpIndexFile(bool quick);
static wxString ChainDir();
static wxString MacroDir();
static wxString NRPDir();
static wxString NRPFile();
static wxString PluginRegistry();

View File

@ -1192,13 +1192,13 @@ void AudacityProject::CreateMenusAndCommands()
c->AddSeparator();
#endif
c->AddItem(wxT("ApplyChain"), _("Appl&y Chain..."), FN(OnApplyChain),
c->AddItem(wxT("ApplyMacro"), _("Appl&y Macro..."), FN(OnApplyMacro),
AudioIONotBusyFlag,
AudioIONotBusyFlag);
c->AddItem(wxT("EditChains"), _("Edit C&hains..."), FN(OnEditChains));
c->AddItem(wxT("ManageMacros"), _("&Macros..."), FN(OnManageMacros));
c->AddSeparator();
PopulateChainsMenu( c, AudioIONotBusyFlag );
PopulateMacrosMenu( c, AudioIONotBusyFlag );
c->AddSeparator();
PopulateEffectsMenu(c,
@ -1706,13 +1706,13 @@ void AudacityProject::CreateMenusAndCommands()
void AudacityProject::PopulateChainsMenu( CommandManager* c, CommandFlag flags )
void AudacityProject::PopulateMacrosMenu( CommandManager* c, CommandFlag flags )
{
wxArrayString names = BatchCommands::GetNames();
wxArrayString names = MacroCommands::GetNames();
int i;
for (i = 0; i < (int)names.GetCount(); i++) {
c->AddItem(wxString::Format("Chain%03i", i ), names[i], FN(OnApplyChainDirectly),
c->AddItem(wxString::Format("Macro%03i", i ), names[i], FN(OnApplyMacroDirectly),
AudioIONotBusyFlag,
AudioIONotBusyFlag);
}
@ -6854,36 +6854,36 @@ void AudacityProject::OnShowExtraMenus(const CommandContext &WXUNUSED(context) )
RebuildAllMenuBars();
}
void AudacityProject::OnApplyChainDirectly(const CommandContext &context )
void AudacityProject::OnApplyMacroDirectly(const CommandContext &context )
{
//wxLogDebug( "Chain was: %s", context.parameter);
BatchProcessDialog dlg(this);
//wxLogDebug( "Macro was: %s", context.parameter);
ApplyMacroDialog dlg(this);
wxString Name = context.parameter;
long item=0;
// Take last three letters (of e.g. Chain007) and convert to a number.
// Take last three letters (of e.g. Macro007) and convert to a number.
Name.Mid( Name.Length() - 3 ).ToLong( &item, 10 );
dlg.ApplyChainToProject( item, false );
dlg.ApplyMacroToProject( item, false );
ModifyUndoMenuItems();
}
void AudacityProject::OnApplyChain(const CommandContext &WXUNUSED(context) )
void AudacityProject::OnApplyMacro(const CommandContext &WXUNUSED(context) )
{
const bool bExpanded = false;
if (!mChainsWindow)
mChainsWindow = safenew EditChainsDialog(this, bExpanded);
mChainsWindow->Show();
mChainsWindow->Raise();
mChainsWindow->UpdateDisplay( bExpanded);
if (!mMacrosWindow)
mMacrosWindow = safenew MacrosWindow(this, bExpanded);
mMacrosWindow->Show();
mMacrosWindow->Raise();
mMacrosWindow->UpdateDisplay( bExpanded);
}
void AudacityProject::OnEditChains(const CommandContext &WXUNUSED(context) )
void AudacityProject::OnManageMacros(const CommandContext &WXUNUSED(context) )
{
const bool bExpanded = true;
if (!mChainsWindow)
mChainsWindow = safenew EditChainsDialog(this, bExpanded);
mChainsWindow->Show();
mChainsWindow->Raise();
mChainsWindow->UpdateDisplay( bExpanded);
if (!mMacrosWindow)
mMacrosWindow = safenew MacrosWindow(this, bExpanded);
mMacrosWindow->Show();
mMacrosWindow->Raise();
mMacrosWindow->UpdateDisplay( bExpanded);
}
void AudacityProject::OnHistory(const CommandContext &WXUNUSED(context) )

View File

@ -24,7 +24,7 @@
private:
void CreateMenusAndCommands();
void PopulateChainsMenu( CommandManager* c, CommandFlag flags );
void PopulateMacrosMenu( CommandManager* c, CommandFlag flags );
void PopulateEffectsMenu(CommandManager *c, EffectType type,
CommandFlag batchflags, CommandFlag realflags);
void AddEffectMenuItems(CommandManager *c,
@ -493,9 +493,9 @@ bool DoEffect(const PluginID & ID, const CommandContext & context, int flags);
void OnEffect(const CommandContext &context );
void OnRepeatLastEffect(const CommandContext &context );
bool DoAudacityCommand(const PluginID & ID, const CommandContext &, int flags);
void OnApplyChain(const CommandContext &context );
void OnApplyChainDirectly(const CommandContext &context );
void OnEditChains(const CommandContext &context );
void OnApplyMacro(const CommandContext &context );
void OnApplyMacroDirectly(const CommandContext &context );
void OnManageMacros(const CommandContext &context );
void OnStereoToMono(const CommandContext &context );
void OnAudacityCommand(const CommandContext &context );
void OnManagePluginsMenu(EffectType Type);

View File

@ -86,7 +86,7 @@ class TranscriptionToolBar;
// windows and frames
class AdornedRulerPanel;
class HistoryWindow;
class EditChainsDialog;
class MacrosWindow;
class LyricsWindow;
class MixerBoard;
class MixerBoardFrame;
@ -680,7 +680,7 @@ private:
bool mActive{ true };
bool mIconized;
EditChainsDialog *mChainsWindow{};
MacrosWindow *mMacrosWindow{};
HistoryWindow *mHistoryWindow{};
LyricsWindow* mLyricsWindow{};
MixerBoardFrame* mMixerBoardFrame{};

View File

@ -225,7 +225,7 @@ bool AudacityCommand::DoAudacityCommand(wxWindow *parent,
return returnVal;
}
// This is used from Chains.
// This is used from Macros.
bool AudacityCommand::PromptUser(wxWindow *parent)
{
return ShowInterface(parent, IsBatchProcessing());

View File

@ -28,8 +28,8 @@ void BatchEvalCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("CommandName"), wxT(""), std::move(commandNameValidator));
auto paramValidator = make_movable<DefaultValidator>();
signature.AddParameter(wxT("ParamString"), wxT(""), std::move(paramValidator));
auto chainValidator = make_movable<DefaultValidator>();
signature.AddParameter(wxT("ChainName"), wxT(""), std::move(chainValidator));
auto macroValidator = make_movable<DefaultValidator>();
signature.AddParameter(wxT("MacroName"), wxT(""), std::move(macroValidator));
}
OldStyleCommandPointer BatchEvalCommandType::Create(std::unique_ptr<CommandOutputTargets> && WXUNUSED(target))
@ -40,19 +40,19 @@ OldStyleCommandPointer BatchEvalCommandType::Create(std::unique_ptr<CommandOutpu
bool BatchEvalCommand::Apply(const CommandContext & context)
{
wxString chainName = GetString(wxT("ChainName"));
if (chainName != wxT(""))
wxString macroName = GetString(wxT("MacroName"));
if (macroName != wxT(""))
{
BatchCommands batch;
batch.ReadChain(chainName);
return batch.ApplyChain();
MacroCommands batch;
batch.ReadMacro(macroName);
return batch.ApplyMacro();
}
wxString cmdName = GetString(wxT("CommandName"));
wxString cmdParams = GetString(wxT("ParamString"));
// Create a Batch that will have just one command in it...
BatchCommands Batch;
MacroCommands Batch;
bool bResult = Batch.ApplyCommand(cmdName, cmdParams, &context);
// Relay messages, if any.
wxString Message = Batch.GetMessage();

View File

@ -10,10 +10,10 @@
******************************************************************//**
\class BatchEvalCommand
\brief Given a string representing a command, pass it to the BatchCommands
\brief Given a string representing a command, pass it to the MacroCommands
system.
The eventual aim is to move the code from BatchCommands out into separate
The eventual aim is to move the code from MacroCommands out into separate
command classes, but until this happens, BatchEvalCommand can act as a 'bridge'
to that system.

View File

@ -13,7 +13,7 @@
ApplyAndSendResponse, and CommandImplementation classes. These are
remnants of Dan Horgans external scripting commands. We now use
AudacityCommand and a shuttle system. This allows commands to be used
from within chains too, to have settings dialogs, using ShuttleGui and
from within macros too, to have settings dialogs, using ShuttleGui and
without need for validators.
Here's the doxygen for the still-remaining going-away classes.
@ -36,8 +36,8 @@ We in effect merge the <something>CommandType classes into the
<something>Command classes.
\class BatchEvalCommand
\brief Command to make processing of chains available to scripting. It can either
make a one command chain, or invoke an existing chain. It will become redundant
\brief Command to make processing of macros available to scripting. It can either
make a one command macro, or invoke an existing macro. It will become redundant
when menu commands are integrated into scripting.
\class HelpCommand

View File

@ -10,7 +10,7 @@
*******************************************************************//**
\class BatchPrefs
\brief A PrefsPanel that builds up a chain of effects in BatchCommands
\brief A PrefsPanel that builds up a chain of effects in MacroCommands
*//*******************************************************************/