1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-18 17:47:41 +02:00

Add all chains into the Tools menu.

This commit is contained in:
James Crook 2018-03-02 21:56:24 +00:00
parent 8cd5d7f4fe
commit e6a2d0f99a
4 changed files with 53 additions and 3 deletions

View File

@ -161,11 +161,18 @@ void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
long item = mChains->GetNextItem(-1, long item = mChains->GetNextItem(-1,
wxLIST_NEXT_ALL, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED); wxLIST_STATE_SELECTED);
if (item == -1) { if (item == -1) {
AudacityMessageBox(_("No chain selected")); AudacityMessageBox(_("No chain selected"));
return; return;
} }
wxString name = mChains->GetItemText(item); }
void BatchProcessDialog::ApplyChainToProject( int iChain, bool bHasGui )
{
wxString name = mChains->GetItemText(iChain);
if( name.IsEmpty() )
return;
wxDialog * pD = safenew wxDialogWrapper(this, wxID_ANY, GetTitle()); wxDialog * pD = safenew wxDialogWrapper(this, wxID_ANY, GetTitle());
pD->SetName(pD->GetTitle()); pD->SetName(pD->GetTitle());
@ -197,7 +204,8 @@ void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
// the 'Hide' converts us from a Modal into a regular dialog, // the 'Hide' converts us from a Modal into a regular dialog,
// as far as closing is concerned. On Linux we can't close with // as far as closing is concerned. On Linux we can't close with
// EndModal() anymore after this. // EndModal() anymore after this.
Hide(); if( bHasGui )
Hide();
gPrefs->Write(wxT("/Batch/ActiveChain"), name); gPrefs->Write(wxT("/Batch/ActiveChain"), name);
gPrefs->Flush(); gPrefs->Flush();
@ -213,6 +221,10 @@ void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
[this]{ return mBatchCommands.ApplyChain(); } ); [this]{ return mBatchCommands.ApplyChain(); } );
} }
if( !bHasGui )
return;
if (!success) { if (!success) {
Show(); Show();
return; return;

View File

@ -55,6 +55,9 @@ class BatchProcessDialog : public wxDialogWrapper {
virtual wxString GetHelpPageName() {return "Tools_Menu#chains_compact_dialog";}; virtual wxString GetHelpPageName() {return "Tools_Menu#chains_compact_dialog";};
void ApplyChainToProject( int iChain, bool bHasGui=true );
// These will be reused in the derived class... // These will be reused in the derived class...
wxListCtrl *mList; wxListCtrl *mList;
wxListCtrl *mChains; wxListCtrl *mChains;

View File

@ -167,6 +167,10 @@ enum {
#include "commands/CommandContext.h" #include "commands/CommandContext.h"
#include "commands/ScreenshotCommand.h" #include "commands/ScreenshotCommand.h"
#include "BatchCommands.h"
// //
// Effects menu arrays // Effects menu arrays
// //
@ -1193,6 +1197,8 @@ void AudacityProject::CreateMenusAndCommands()
AudioIONotBusyFlag); AudioIONotBusyFlag);
c->AddItem(wxT("EditChains"), _("Edit C&hains..."), FN(OnEditChains)); c->AddItem(wxT("EditChains"), _("Edit C&hains..."), FN(OnEditChains));
c->AddSeparator();
PopulateChainsMenu( c, AudioIONotBusyFlag );
c->AddSeparator(); c->AddSeparator();
PopulateEffectsMenu(c, PopulateEffectsMenu(c,
@ -1698,6 +1704,22 @@ void AudacityProject::CreateMenusAndCommands()
#endif #endif
} }
void AudacityProject::PopulateChainsMenu( CommandManager* c, CommandFlag flags )
{
wxArrayString names = BatchCommands::GetNames();
int i;
for (i = 0; i < (int)names.GetCount(); i++) {
c->AddItem(wxString::Format("Chain%03i", i ), names[i], FN(OnApplyChainDirectly),
AudioIONotBusyFlag,
AudioIONotBusyFlag);
}
}
/// The effects come from a plug in list /// The effects come from a plug in list
/// This code iterates through the list, adding effects into /// This code iterates through the list, adding effects into
/// the menu. /// the menu.
@ -8457,6 +8479,18 @@ void AudacityProject::OnApplyChain(const CommandContext &WXUNUSED(context) )
ModifyUndoMenuItems(); ModifyUndoMenuItems();
} }
void AudacityProject::OnApplyChainDirectly(const CommandContext &context )
{
//wxLogDebug( "Chain was: %s", context.parameter);
BatchProcessDialog dlg(this);
wxString Name = context.parameter;
long item=0;
// Take last three letters (of e.g. Chain007) and convert to a number.
Name.Mid( Name.Length() - 3 ).ToLong( &item, 10 );
dlg.ApplyChainToProject( item, false );
ModifyUndoMenuItems();
}
void AudacityProject::OnEditChains(const CommandContext &WXUNUSED(context) ) void AudacityProject::OnEditChains(const CommandContext &WXUNUSED(context) )
{ {
EditChainsDialog dlg(this); EditChainsDialog dlg(this);

View File

@ -24,7 +24,7 @@
private: private:
void CreateMenusAndCommands(); void CreateMenusAndCommands();
void PopulateChainsMenu( CommandManager* c, CommandFlag flags );
void PopulateEffectsMenu(CommandManager *c, EffectType type, void PopulateEffectsMenu(CommandManager *c, EffectType type,
CommandFlag batchflags, CommandFlag realflags); CommandFlag batchflags, CommandFlag realflags);
void AddEffectMenuItems(CommandManager *c, void AddEffectMenuItems(CommandManager *c,
@ -494,6 +494,7 @@ void OnEffect(const CommandContext &context );
void OnRepeatLastEffect(const CommandContext &context ); void OnRepeatLastEffect(const CommandContext &context );
bool DoAudacityCommand(const PluginID & ID, const CommandContext &, int flags); bool DoAudacityCommand(const PluginID & ID, const CommandContext &, int flags);
void OnApplyChain(const CommandContext &context ); void OnApplyChain(const CommandContext &context );
void OnApplyChainDirectly(const CommandContext &context );
void OnEditChains(const CommandContext &context ); void OnEditChains(const CommandContext &context );
void OnStereoToMono(const CommandContext &context ); void OnStereoToMono(const CommandContext &context );
void OnAudacityCommand(const CommandContext &context ); void OnAudacityCommand(const CommandContext &context );