mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-15 17:11:20 +01:00
Add buttons to Edit Chains Dialog
- Added the Apply-to-Project and Apply-To-Files buttons - Derived EditChainsDialog from BatchProcessDialog so as to share code. - Added Edit button, for people who don't realise they can click on the list. - Clicking on list now directly invokes the parameter editing. - Insert and Edit now insert before --END-- if nothing was selected.
This commit is contained in:
@@ -65,18 +65,19 @@ BEGIN_EVENT_TABLE(BatchProcessDialog, wxDialogWrapper)
|
||||
EVT_BUTTON(wxID_CANCEL, BatchProcessDialog::OnCancel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BatchProcessDialog::BatchProcessDialog(wxWindow * parent):
|
||||
BatchProcessDialog::BatchProcessDialog(wxWindow * parent, bool bInherited):
|
||||
wxDialogWrapper(parent, wxID_ANY, _("Apply Chain"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
//AudacityProject * p = GetActiveProject();
|
||||
|
||||
mAbort = false;
|
||||
if( bInherited )
|
||||
return;
|
||||
SetLabel(_("Apply Chain")); // Provide visual label
|
||||
SetName(_("Apply Chain")); // Provide audible label
|
||||
Populate();
|
||||
|
||||
mAbort = false;
|
||||
}
|
||||
|
||||
BatchProcessDialog::~BatchProcessDialog()
|
||||
@@ -422,21 +423,25 @@ void BatchProcessDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
|
||||
#include "BatchCommandDialog.h"
|
||||
|
||||
enum {
|
||||
// ChainsListID 7005
|
||||
AddButtonID = 10000,
|
||||
RemoveButtonID,
|
||||
// CommandsListID, 7002
|
||||
ImportButtonID,
|
||||
ExportButtonID,
|
||||
DefaultsButtonID,
|
||||
InsertButtonID,
|
||||
EditButtonID,
|
||||
DeleteButtonID,
|
||||
UpButtonID,
|
||||
DownButtonID,
|
||||
RenameButtonID
|
||||
RenameButtonID,
|
||||
// ChainsListID 7005
|
||||
// CommandsListID, 7002
|
||||
// Re-Use IDs from BatchProcessDialog.
|
||||
ApplyToProjectButtonID = ApplyToProjectID,
|
||||
ApplyToFilesButtonID = ApplyToFilesID,
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(EditChainsDialog, wxDialogWrapper)
|
||||
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)
|
||||
@@ -448,6 +453,7 @@ BEGIN_EVENT_TABLE(EditChainsDialog, wxDialogWrapper)
|
||||
|
||||
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)
|
||||
@@ -468,12 +474,14 @@ enum {
|
||||
|
||||
/// Constructor
|
||||
EditChainsDialog::EditChainsDialog(wxWindow * parent):
|
||||
wxDialogWrapper(parent, wxID_ANY, _("Edit Chains"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
BatchProcessDialog(parent, true)
|
||||
// , wxID_ANY, _("Edit Chains"),
|
||||
// wxDefaultPosition, wxDefaultSize,
|
||||
// wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
SetLabel(_("Edit Chains")); // Provide visual label
|
||||
SetName(_("Edit Chains")); // Provide audible label
|
||||
SetTitle(_("Edit Chains"));
|
||||
|
||||
mChanged = false;
|
||||
mSelectedCommand = 0;
|
||||
@@ -571,11 +579,25 @@ void EditChainsDialog::PopulateOrExchange(ShuttleGui & S)
|
||||
|
||||
S.StartHorizontalLay(wxCENTER, false);
|
||||
{
|
||||
S.Id(InsertButtonID).AddButton(_("&Insert"), wxALIGN_LEFT);
|
||||
S.Id(DeleteButtonID).AddButton(_("De&lete"), wxALIGN_LEFT);
|
||||
S.Id(UpButtonID).AddButton(_("Move &Up"), wxALIGN_LEFT);
|
||||
S.Id(DownButtonID).AddButton(_("Move &Down"), wxALIGN_LEFT);
|
||||
mDefaults = S.Id(DefaultsButtonID).AddButton(_("De&faults"));
|
||||
S.AddPrompt( _("Command:") );
|
||||
S.StartHorizontalLay(wxCENTER, false);
|
||||
{
|
||||
S.Id(InsertButtonID).AddButton(_("&Insert"), wxALIGN_LEFT);
|
||||
S.Id(EditButtonID).AddButton(_("&Edit"), wxALIGN_LEFT);
|
||||
S.Id(DeleteButtonID).AddButton(_("De&lete"), wxALIGN_LEFT);
|
||||
S.Id(UpButtonID).AddButton(_("Move &Up"), wxALIGN_LEFT);
|
||||
S.Id(DownButtonID).AddButton(_("Move &Down"), wxALIGN_LEFT);
|
||||
mDefaults = S.Id(DefaultsButtonID).AddButton(_("De&faults"));
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
S.AddSpace( 40 );
|
||||
S.AddPrompt( _("Apply Chain to:") );
|
||||
S.StartHorizontalLay(wxCENTER, false);
|
||||
{
|
||||
S.Id(ApplyToProjectButtonID).AddButton(_("&Project"), wxALIGN_LEFT);
|
||||
S.Id(ApplyToFilesButtonID).AddButton(_("&Files"), wxALIGN_LEFT);
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
}
|
||||
@@ -881,6 +903,10 @@ void EditChainsDialog::OnRename(wxCommandEvent & WXUNUSED(event))
|
||||
/// Bring up a dialog to allow its parameters to be edited.
|
||||
void EditChainsDialog::OnCommandActivated(wxListEvent &event)
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
OnEditCommandParams( dummy );
|
||||
|
||||
#if 0
|
||||
int item = event.GetIndex();
|
||||
|
||||
BatchCommandDialog d(this, wxID_ANY);
|
||||
@@ -901,6 +927,7 @@ void EditChainsDialog::OnCommandActivated(wxListEvent &event)
|
||||
mSelectedCommand = item;
|
||||
|
||||
PopulateList();
|
||||
#endif
|
||||
}
|
||||
|
||||
///
|
||||
@@ -909,6 +936,14 @@ void EditChainsDialog::OnInsert(wxCommandEvent & WXUNUSED(event))
|
||||
long item = mList->GetNextItem(-1,
|
||||
wxLIST_NEXT_ALL,
|
||||
wxLIST_STATE_SELECTED);
|
||||
if (item == -1) {
|
||||
item = mList->GetItemCount()-1;
|
||||
}
|
||||
InsertCommandAt( item );
|
||||
}
|
||||
|
||||
void EditChainsDialog::InsertCommandAt(int item)
|
||||
{
|
||||
if (item == -1) {
|
||||
return;
|
||||
}
|
||||
@@ -925,13 +960,42 @@ void EditChainsDialog::OnInsert(wxCommandEvent & WXUNUSED(event))
|
||||
d.mSelectedParameters,
|
||||
item);
|
||||
mChanged = true;
|
||||
|
||||
mSelectedCommand = item + 1;
|
||||
|
||||
PopulateList();
|
||||
}
|
||||
}
|
||||
|
||||
void EditChainsDialog::OnEditCommandParams(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
int item = mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
||||
|
||||
// LAST command in list is END.
|
||||
// If nothing selected, add at END.
|
||||
// If END selected, add at END.
|
||||
// When adding at end we use InsertCommandAt, so that a new command
|
||||
// can be chosen.
|
||||
int lastItem = mList->GetItemCount()-1;
|
||||
if( (item<0) || (item+1) == mList->GetItemCount() )
|
||||
{
|
||||
InsertCommandAt( lastItem );
|
||||
return;
|
||||
}
|
||||
|
||||
// Just edit the parameters, and not the command.
|
||||
wxString command = mBatchCommands.GetCommand(item);
|
||||
wxString params = mBatchCommands.GetParams(item);
|
||||
|
||||
params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
|
||||
|
||||
mBatchCommands.DeleteFromChain(item);
|
||||
mBatchCommands.AddToChain(command,
|
||||
params,
|
||||
item);
|
||||
mChanged = true;
|
||||
mSelectedCommand = item;
|
||||
PopulateList();
|
||||
}
|
||||
|
||||
///
|
||||
void EditChainsDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
@@ -943,15 +1007,12 @@ void EditChainsDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
mBatchCommands.DeleteFromChain(item);
|
||||
|
||||
mChanged = true;
|
||||
|
||||
if (item >= (mList->GetItemCount() - 2) && item >= 0) {
|
||||
item--;
|
||||
}
|
||||
|
||||
mSelectedCommand = item;
|
||||
|
||||
PopulateList();
|
||||
}
|
||||
|
||||
@@ -969,11 +1030,8 @@ void EditChainsDialog::OnUp(wxCommandEvent & WXUNUSED(event))
|
||||
mBatchCommands.GetParams(item),
|
||||
item - 1);
|
||||
mBatchCommands.DeleteFromChain(item + 1);
|
||||
|
||||
mChanged = true;
|
||||
|
||||
mSelectedCommand = item - 1;
|
||||
|
||||
PopulateList();
|
||||
}
|
||||
|
||||
@@ -991,14 +1049,25 @@ void EditChainsDialog::OnDown(wxCommandEvent & WXUNUSED(event))
|
||||
mBatchCommands.GetParams(item),
|
||||
item + 2);
|
||||
mBatchCommands.DeleteFromChain(item);
|
||||
|
||||
mChanged = true;
|
||||
|
||||
mSelectedCommand = item + 1;
|
||||
|
||||
PopulateList();
|
||||
}
|
||||
|
||||
void EditChainsDialog::OnApplyToProject(wxCommandEvent & event)
|
||||
{
|
||||
if( !SaveChanges() )
|
||||
return;
|
||||
BatchProcessDialog::OnApplyToProject( event );
|
||||
}
|
||||
|
||||
void EditChainsDialog::OnApplyToFiles(wxCommandEvent & event)
|
||||
{
|
||||
if( !SaveChanges() )
|
||||
return;
|
||||
BatchProcessDialog::OnApplyToFiles( event );
|
||||
}
|
||||
|
||||
/// Select the empty Command chain.
|
||||
void EditChainsDialog::OnDefaults(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
@@ -1009,29 +1078,35 @@ void EditChainsDialog::OnDefaults(wxCommandEvent & WXUNUSED(event))
|
||||
PopulateList();
|
||||
}
|
||||
|
||||
/// Send changed values back to Prefs, and update Audacity.
|
||||
void EditChainsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
bool EditChainsDialog::SaveChanges(){
|
||||
gPrefs->Write(wxT("/Batch/ActiveChain"), mActiveChain);
|
||||
gPrefs->Flush();
|
||||
|
||||
if (mChanged) {
|
||||
if (!mBatchCommands.WriteChain(mActiveChain)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mChanged = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Send changed values back to Prefs, and update Audacity.
|
||||
void EditChainsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
if( !SaveChanges() )
|
||||
return;
|
||||
EndModal(true);
|
||||
}
|
||||
|
||||
///
|
||||
void EditChainsDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
|
||||
void EditChainsDialog::OnCancel(wxCommandEvent & event)
|
||||
{
|
||||
if (!ChangeOK()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EndModal(false);
|
||||
BatchProcessDialog::OnCancel( event );
|
||||
//EndModal(false);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user