diff --git a/src/BatchCommandDialog.cpp b/src/BatchCommandDialog.cpp index 3fd628f09..24c764326 100644 --- a/src/BatchCommandDialog.cpp +++ b/src/BatchCommandDialog.cpp @@ -95,10 +95,13 @@ void BatchCommandDialog::PopulateOrExchange(ShuttleGui &S) S.SetStretchyCol(1); mParameters = S.AddTextBox(_("&Parameters"), wxT(""), 0); mParameters->SetEditable(false); + S.Prop(0).AddPrompt( _("&Details" ) ); + mDetails = S.AddTextWindow( wxT("")); + mDetails->SetEditable(false); } S.EndMultiColumn(); - S.StartStatic(_("C&hoose command"), true); + S.Prop(10).StartStatic(_("C&hoose command"), true); { S.SetStyle(wxSUNKEN_BORDER | wxLC_LIST | wxLC_SINGLE_SEL); mChoices = S.Id(CommandsListID).AddListControl(); @@ -111,7 +114,7 @@ void BatchCommandDialog::PopulateOrExchange(ShuttleGui &S) PopulateCommandList(); - SetMinSize(wxSize(500, 400)); + SetMinSize(wxSize(780, 560)); Fit(); Center(); } @@ -123,26 +126,9 @@ void BatchCommandDialog::PopulateCommandList() mChoices->DeleteAllItems(); for (size_t ii = 0, size = mCommandNames.size(); ii < size; ++ii) // insert the user-facing string - mChoices->InsertItem( ii, mCommandNames[ii].first ); + mChoices->InsertItem( ii, std::get<0>( mCommandNames[ii] ) ); } -#if 0 -int BatchCommandDialog::GetSelectedItem() -{ - int i; - mSelectedCommand = wxT(""); - for(i=0;iGetItemCount();i++) - { - if( mChoices->GetItemState( i, wxLIST_STATE_FOCUSED) != 0) - { - mSelectedCommand = mChoices->GetItemText( i ); - return i; - } - } - return -1; -} -#endif - void BatchCommandDialog::ValidateChoices() { } @@ -168,25 +154,28 @@ void BatchCommandDialog::OnItemSelected(wxListEvent &event) const auto &command = mCommandNames[ event.GetIndex() ]; EffectManager & em = EffectManager::Get(); - PluginID ID = em.GetEffectByIdentifier(command.second); + PluginID ID = em.GetEffectByIdentifier( std::get<1>( command )); // If ID is empty, then the effect wasn't found, in which case, the user must have // selected one of the "special" commands. mEditParams->Enable(!ID.IsEmpty()); mUsePreset->Enable(em.HasPresets(ID)); - if (command.first == mCommand->GetValue()) + if (std::get<0>( command ) == mCommand->GetValue()) return; - mCommand->SetValue(command.first); - mInternalCommandName = command.second; + mCommand->SetValue(std::get<0> (command)); + mInternalCommandName = std::get<1>( command ); - wxString params = BatchCommands::GetCurrentParamsFor(command.second); + wxString params = BatchCommands::GetCurrentParamsFor(mInternalCommandName); if (params.IsEmpty()) { params = em.GetDefaultPreset(ID); } + // Cryptic command and category. + // Later we can put help information there, perhaps. + mDetails->SetValue( mInternalCommandName + "\r\n" + std::get<2>(command) ); mParameters->SetValue(params); } @@ -215,7 +204,7 @@ void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event)) void BatchCommandDialog::SetCommandAndParams(const wxString &Command, const wxString &Params) { auto item = make_iterator_range(mCommandNames).index_if( - [&](const CommandName &name){ return Command == name.second; } + [&](const CommandName &name){ return Command == std::get<1>( name); } ); mParameters->SetValue( Params ); @@ -224,7 +213,8 @@ void BatchCommandDialog::SetCommandAndParams(const wxString &Command, const wxSt if (item < 0) mCommand->SetValue( Command ); else { - mCommand->SetValue( mCommandNames[item].first ); + mCommand->SetValue( std::get<0>( mCommandNames[item]) ); + mDetails->SetValue( std::get<1>(mCommandNames[item]) + "\r\n" + std::get<2>(mCommandNames[item]) ); mChoices->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); EffectManager & em = EffectManager::Get(); diff --git a/src/BatchCommandDialog.h b/src/BatchCommandDialog.h index 89b53ed9a..62d9dab81 100644 --- a/src/BatchCommandDialog.h +++ b/src/BatchCommandDialog.h @@ -12,6 +12,7 @@ #ifndef __AUDACITY_BATCH_COMMAND_DIALOG__ #define __AUDACITY_BATCH_COMMAND_DIALOG__ +#include #include #include @@ -63,10 +64,11 @@ class BatchCommandDialog final : public wxDialogWrapper { wxListCtrl *mChoices; wxTextCtrl * mCommand; wxTextCtrl * mParameters; + wxTextCtrl * mDetails; wxString mInternalCommandName; - using CommandName = std::pair; + using CommandName = std::tuple; using CommandNameVector = std::vector; CommandNameVector mCommandNames; diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 282774717..bb81d8bdb 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -258,11 +258,9 @@ auto BatchCommands::GetAllCommands() -> CommandNameVector // CLEANSPEECH remnant for( const auto &command : SpecialCommands ) - commands.push_back( { - //wxGetTranslation - (command.first), - command.second - } ); + commands.push_back( + CommandName( command.first, command.second, _("Special Command") ) + ); // end CLEANSPEECH remnant @@ -274,10 +272,14 @@ auto BatchCommands::GetAllCommands() -> CommandNameVector { auto command = em.GetCommandIdentifier(plug->GetID()); if (!command.IsEmpty()) - commands.push_back( { - plug->GetUntranslatedName(), // plug->GetTranslatedName(), - command - } ); + commands.push_back( + CommandName( + plug->GetUntranslatedName(), // plug->GetTranslatedName(), + command, + plug->GetPluginType() == PluginTypeEffect ? + _("Effect") : _("Menu Command (With Parameters)") + ) + ); plug = pm.GetNextPlugin(PluginTypeEffect|PluginTypeAudacityCommand); } } @@ -290,13 +292,26 @@ auto BatchCommands::GetAllCommands() -> CommandNameVector mManager->GetAllCommandLabels(mLabels, false); mManager->GetAllCommandNames(mNames, false); for(size_t i=0; i CommandNameVector std::sort( commands.begin(), commands.end(), [](const CommandName &a, const CommandName &b) - { return a.first < b.first; } + { return std::get<0>(a) < std::get<0>(b); } ); diff --git a/src/BatchCommands.h b/src/BatchCommands.h index 5ff0c09f4..88f2513a5 100644 --- a/src/BatchCommands.h +++ b/src/BatchCommands.h @@ -12,6 +12,7 @@ #ifndef __AUDACITY_BATCH_COMMANDS_DIALOG__ #define __AUDACITY_BATCH_COMMANDS_DIALOG__ +#include #include #include @@ -43,7 +44,7 @@ class BatchCommands final { static wxArrayString GetNames(); // A pair of user-visible name, and internal string identifier - using CommandName = std::pair; + using CommandName = std::tuple; using CommandNameVector = std::vector; // Result is sorted by user-visible name static CommandNameVector GetAllCommands(); diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp index 99a2bca8a..b2375e84b 100644 --- a/src/BatchProcessDialog.cpp +++ b/src/BatchProcessDialog.cpp @@ -655,11 +655,11 @@ void EditChainsDialog::AddItem(const wxString &Action, const wxString &Params) { // Translate internal command name to a friendly form auto item = make_iterator_range(mCommandNames).index_if( - [&](const CommandName &name){ return Action == name.second; } + [&](const CommandName &name){ return Action == std::get<1>(name); } ); auto friendlyName = item >= 0 ? // wxGetTranslation - ( mCommandNames[item].first ) + std::get<0>( mCommandNames[item] ) : Action; int i = mList->GetItemCount(); diff --git a/src/BatchProcessDialog.h b/src/BatchProcessDialog.h index 5f9fce2ff..744faf794 100644 --- a/src/BatchProcessDialog.h +++ b/src/BatchProcessDialog.h @@ -126,7 +126,7 @@ private: int mSelectedCommand; bool mChanged; - using CommandName = std::pair; + using CommandName = std::tuple; using CommandNameVector = std::vector; CommandNameVector mCommandNames;