mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-03 17:39:25 +02:00
Preload the "Select Preset" with current setting
Also, loads the command parameters box with the default preset if the selected effect doesn't expose any automation parameters.
This commit is contained in:
parent
cb147e5605
commit
e41db0e4b4
@ -165,17 +165,27 @@ void BatchCommandDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
void BatchCommandDialog::OnItemSelected(wxListEvent &event)
|
void BatchCommandDialog::OnItemSelected(wxListEvent &event)
|
||||||
{
|
{
|
||||||
int itemNo = event.GetIndex();
|
wxString command = mChoices->GetItemText(event.GetIndex());
|
||||||
wxString command = mChoices->GetItemText( itemNo );
|
|
||||||
mCommand->SetValue( command );
|
|
||||||
wxString params = BatchCommands::GetCurrentParamsFor( command );
|
|
||||||
mParameters->SetValue( params );
|
|
||||||
|
|
||||||
EffectManager & em = EffectManager::Get();
|
EffectManager & em = EffectManager::Get();
|
||||||
PluginID ID = em.GetEffectByIdentifier( command );
|
PluginID ID = em.GetEffectByIdentifier(command);
|
||||||
wxASSERT(!ID.IsEmpty());
|
wxASSERT(!ID.IsEmpty());
|
||||||
mEditParams->Enable(true);
|
mEditParams->Enable(true);
|
||||||
mUsePreset->Enable(em.HasPresets(ID));
|
mUsePreset->Enable(em.HasPresets(ID));
|
||||||
|
|
||||||
|
if (command == mCommand->GetValue())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCommand->SetValue(command);
|
||||||
|
wxString params = BatchCommands::GetCurrentParamsFor(command);
|
||||||
|
if (params.IsEmpty())
|
||||||
|
{
|
||||||
|
params = em.GetDefaultPreset(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
mParameters->SetValue(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
|
void BatchCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
|
||||||
@ -201,7 +211,7 @@ void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
|
|||||||
wxString command = mCommand->GetValue();
|
wxString command = mCommand->GetValue();
|
||||||
wxString params = mParameters->GetValue();
|
wxString params = mParameters->GetValue();
|
||||||
|
|
||||||
wxString preset = BatchCommands::PromptForPresetFor(command, this);
|
wxString preset = BatchCommands::PromptForPresetFor(command, params, this);
|
||||||
if (!preset.IsEmpty())
|
if (!preset.IsEmpty())
|
||||||
{
|
{
|
||||||
mParameters->SetValue(preset);
|
mParameters->SetValue(preset);
|
||||||
|
@ -305,7 +305,7 @@ wxArrayString BatchCommands::GetAllCommands()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString BatchCommands::GetCurrentParamsFor(wxString command)
|
wxString BatchCommands::GetCurrentParamsFor(const wxString & command)
|
||||||
{
|
{
|
||||||
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
||||||
if( ID.empty() )
|
if( ID.empty() )
|
||||||
@ -316,7 +316,7 @@ wxString BatchCommands::GetCurrentParamsFor(wxString command)
|
|||||||
return EffectManager::Get().GetEffectParameters(ID);
|
return EffectManager::Get().GetEffectParameters(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BatchCommands::PromptForParamsFor(wxString command, wxWindow *parent)
|
bool BatchCommands::PromptForParamsFor(const wxString & command, wxWindow *parent)
|
||||||
{
|
{
|
||||||
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ bool BatchCommands::PromptForParamsFor(wxString command, wxWindow *parent)
|
|||||||
return EffectManager::Get().PromptUser(ID, parent);
|
return EffectManager::Get().PromptUser(ID, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString BatchCommands::PromptForPresetFor(wxString command, wxWindow *parent)
|
wxString BatchCommands::PromptForPresetFor(const wxString & command, const wxString & params, wxWindow *parent)
|
||||||
{
|
{
|
||||||
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ wxString BatchCommands::PromptForPresetFor(wxString command, wxWindow *parent)
|
|||||||
return wxEmptyString; // effect not found.
|
return wxEmptyString; // effect not found.
|
||||||
}
|
}
|
||||||
|
|
||||||
return EffectManager::Get().GetPreset(ID, parent);
|
return EffectManager::Get().GetPreset(ID, params, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
double BatchCommands::GetEndTime()
|
double BatchCommands::GetEndTime()
|
||||||
|
@ -40,10 +40,10 @@ class BatchCommands {
|
|||||||
|
|
||||||
// These commands do not depend on the command list.
|
// These commands do not depend on the command list.
|
||||||
wxArrayString GetNames();
|
wxArrayString GetNames();
|
||||||
static bool PromptForParamsFor( wxString command, wxWindow *parent );
|
static bool PromptForParamsFor(const wxString & command, wxWindow *parent );
|
||||||
static wxString GetCurrentParamsFor( wxString command );
|
static wxString GetCurrentParamsFor(const wxString & command);
|
||||||
static bool SetCurrentParametersFor(const wxString & command, const wxString & params);
|
static bool SetCurrentParametersFor(const wxString & command, const wxString & params);
|
||||||
static wxString PromptForPresetFor( wxString command, wxWindow *parent );
|
static wxString PromptForPresetFor( const wxString & command, const wxString & params, wxWindow *parent );
|
||||||
static bool SetCurrentPresetFor(const wxString & command, const wxString & preset);
|
static bool SetCurrentPresetFor(const wxString & command, const wxString & preset);
|
||||||
static wxArrayString GetAllCommands();
|
static wxArrayString GetAllCommands();
|
||||||
|
|
||||||
|
@ -1104,12 +1104,13 @@ bool Effect::HasFactoryDefaults()
|
|||||||
return HasPrivateConfigGroup(GetFactoryDefaultsGroup());
|
return HasPrivateConfigGroup(GetFactoryDefaultsGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Effect::GetPreset(wxWindow * parent)
|
wxString Effect::GetPreset(wxWindow * parent, const wxString & parms)
|
||||||
{
|
{
|
||||||
EffectPresetsDialog dlg(parent, this);
|
EffectPresetsDialog dlg(parent, this);
|
||||||
dlg.Layout();
|
dlg.Layout();
|
||||||
dlg.Fit();
|
dlg.Fit();
|
||||||
dlg.SetSize(dlg.GetMinSize());
|
dlg.SetSize(dlg.GetMinSize());
|
||||||
|
dlg.SetSelected(parms);
|
||||||
|
|
||||||
if (dlg.ShowModal())
|
if (dlg.ShowModal())
|
||||||
{
|
{
|
||||||
@ -3612,6 +3613,85 @@ EffectPresetsDialog::~EffectPresetsDialog()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString EffectPresetsDialog::GetSelected() const
|
||||||
|
{
|
||||||
|
return mSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectPresetsDialog::SetSelected(const wxString & parms)
|
||||||
|
{
|
||||||
|
wxString preset = parms;
|
||||||
|
if (preset.StartsWith(Effect::kUserPresetIdent))
|
||||||
|
{
|
||||||
|
preset.Replace(Effect::kUserPresetIdent, wxEmptyString, false);
|
||||||
|
SetPrefix(_("User Presets"), preset);
|
||||||
|
}
|
||||||
|
else if (preset.StartsWith(Effect::kFactoryPresetIdent))
|
||||||
|
{
|
||||||
|
preset.Replace(Effect::kFactoryPresetIdent, wxEmptyString, false);
|
||||||
|
SetPrefix(_("Factory Presets"), preset);
|
||||||
|
}
|
||||||
|
else if (preset.StartsWith(Effect::kCurrentSettingsIdent))
|
||||||
|
{
|
||||||
|
SetPrefix(_("Current Settings"), wxEmptyString);
|
||||||
|
}
|
||||||
|
else if (preset.StartsWith(Effect::kFactoryDefaultsIdent))
|
||||||
|
{
|
||||||
|
SetPrefix(_("Factory Defaults"), wxEmptyString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectPresetsDialog::SetPrefix(const wxString & type, const wxString & prefix)
|
||||||
|
{
|
||||||
|
mType->SetStringSelection(type);
|
||||||
|
|
||||||
|
int selected;
|
||||||
|
if (type.IsSameAs(_("User Presets")))
|
||||||
|
{
|
||||||
|
mPresets->Clear();
|
||||||
|
mPresets->Append(mUserPresets);
|
||||||
|
mPresets->Enable(true);
|
||||||
|
mPresets->SetStringSelection(prefix);
|
||||||
|
if (mPresets->GetSelection() == wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
mPresets->SetSelection(0);
|
||||||
|
}
|
||||||
|
mSelection = Effect::kUserPresetIdent + mPresets->GetStringSelection();
|
||||||
|
}
|
||||||
|
else if (type.IsSameAs(_("Factory Presets")))
|
||||||
|
{
|
||||||
|
mPresets->Clear();
|
||||||
|
for (size_t i = 0, cnt = mFactoryPresets.GetCount(); i < cnt; i++)
|
||||||
|
{
|
||||||
|
wxString label = mFactoryPresets[i];
|
||||||
|
if (label.IsEmpty())
|
||||||
|
{
|
||||||
|
label = _("None");
|
||||||
|
}
|
||||||
|
mPresets->Append(label);
|
||||||
|
}
|
||||||
|
mPresets->Enable(true);
|
||||||
|
mPresets->SetStringSelection(prefix);
|
||||||
|
if (mPresets->GetSelection() == wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
mPresets->SetSelection(0);
|
||||||
|
}
|
||||||
|
mSelection = Effect::kFactoryPresetIdent + mPresets->GetStringSelection();
|
||||||
|
}
|
||||||
|
else if (type.IsSameAs(_("Current Settings")))
|
||||||
|
{
|
||||||
|
mPresets->Clear();
|
||||||
|
mPresets->Enable(false);
|
||||||
|
mSelection = Effect::kCurrentSettingsIdent;
|
||||||
|
}
|
||||||
|
else if (type.IsSameAs(_("Factory Defaults")))
|
||||||
|
{
|
||||||
|
mPresets->Clear();
|
||||||
|
mPresets->Enable(false);
|
||||||
|
mSelection = Effect::kFactoryDefaultsIdent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EffectPresetsDialog::UpdateUI()
|
void EffectPresetsDialog::UpdateUI()
|
||||||
{
|
{
|
||||||
int selected = mType->GetSelection();
|
int selected = mType->GetSelection();
|
||||||
@ -3690,9 +3770,3 @@ void EffectPresetsDialog::OnCancel(wxCommandEvent & WXUNUSED(evt))
|
|||||||
|
|
||||||
EndModal(false);
|
EndModal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString EffectPresetsDialog::GetSelected() const
|
|
||||||
{
|
|
||||||
return mSelection;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class AUDACITY_DLL_API Effect : public wxEvtHandler,
|
|||||||
virtual wxArrayString GetUserPresets();
|
virtual wxArrayString GetUserPresets();
|
||||||
virtual bool HasCurrentSettings();
|
virtual bool HasCurrentSettings();
|
||||||
virtual bool HasFactoryDefaults();
|
virtual bool HasFactoryDefaults();
|
||||||
virtual wxString GetPreset(wxWindow * parent);
|
virtual wxString GetPreset(wxWindow * parent, const wxString & parms);
|
||||||
|
|
||||||
virtual bool IsBatchProcessing();
|
virtual bool IsBatchProcessing();
|
||||||
virtual void SetBatchProcessing(bool enable);
|
virtual void SetBatchProcessing(bool enable);
|
||||||
@ -566,8 +566,10 @@ public:
|
|||||||
virtual ~EffectPresetsDialog();
|
virtual ~EffectPresetsDialog();
|
||||||
|
|
||||||
wxString GetSelected() const;
|
wxString GetSelected() const;
|
||||||
|
void SetSelected(const wxString & parms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void SetPrefix(const wxString & type, const wxString & prefix);
|
||||||
void UpdateUI();
|
void UpdateUI();
|
||||||
|
|
||||||
void OnType(wxCommandEvent & evt);
|
void OnType(wxCommandEvent & evt);
|
||||||
|
@ -230,7 +230,7 @@ bool EffectManager::HasPresets(const PluginID & ID)
|
|||||||
effect->HasFactoryDefaults();
|
effect->HasFactoryDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString EffectManager::GetPreset(const PluginID & ID, wxWindow * parent)
|
wxString EffectManager::GetPreset(const PluginID & ID, const wxString & params, wxWindow * parent)
|
||||||
{
|
{
|
||||||
Effect *effect = GetEffect(ID);
|
Effect *effect = GetEffect(ID);
|
||||||
|
|
||||||
@ -239,16 +239,54 @@ wxString EffectManager::GetPreset(const PluginID & ID, wxWindow * parent)
|
|||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString preset = effect->GetPreset(parent);
|
EffectAutomationParameters eap(params);
|
||||||
|
|
||||||
|
wxString preset;
|
||||||
|
if (eap.HasEntry(wxT("Use Preset")))
|
||||||
|
{
|
||||||
|
preset = eap.Read(wxT("Use Preset"));
|
||||||
|
}
|
||||||
|
|
||||||
|
preset = effect->GetPreset(parent, preset);
|
||||||
if (preset.IsEmpty())
|
if (preset.IsEmpty())
|
||||||
{
|
{
|
||||||
return preset;
|
return preset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eap.DeleteAll();
|
||||||
|
|
||||||
|
eap.Write(wxT("Use Preset"), preset);
|
||||||
|
eap.GetParameters(preset);
|
||||||
|
|
||||||
|
return preset;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString EffectManager::GetDefaultPreset(const PluginID & ID)
|
||||||
|
{
|
||||||
|
Effect *effect = GetEffect(ID);
|
||||||
|
|
||||||
|
if (!effect)
|
||||||
|
{
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString preset;
|
||||||
|
if (effect->HasCurrentSettings())
|
||||||
|
{
|
||||||
|
preset = Effect::kCurrentSettingsIdent;
|
||||||
|
}
|
||||||
|
else if (effect->HasFactoryDefaults())
|
||||||
|
{
|
||||||
|
preset = Effect::kFactoryDefaultsIdent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!preset.IsEmpty())
|
||||||
|
{
|
||||||
EffectAutomationParameters eap;
|
EffectAutomationParameters eap;
|
||||||
|
|
||||||
eap.Write(wxT("Use Preset"), preset);
|
eap.Write(wxT("Use Preset"), preset);
|
||||||
eap.GetParameters(preset);
|
eap.GetParameters(preset);
|
||||||
|
}
|
||||||
|
|
||||||
return preset;
|
return preset;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,8 @@ public:
|
|||||||
bool SetEffectParameters(const PluginID & ID, const wxString & params);
|
bool SetEffectParameters(const PluginID & ID, const wxString & params);
|
||||||
bool PromptUser(const PluginID & ID, wxWindow *parent);
|
bool PromptUser(const PluginID & ID, wxWindow *parent);
|
||||||
bool HasPresets(const PluginID & ID);
|
bool HasPresets(const PluginID & ID);
|
||||||
wxString GetPreset(const PluginID & ID, wxWindow * parent);
|
wxString GetPreset(const PluginID & ID, const wxString & params, wxWindow * parent);
|
||||||
|
wxString GetDefaultPreset(const PluginID & ID);
|
||||||
|
|
||||||
// Realtime effect processing
|
// Realtime effect processing
|
||||||
bool RealtimeIsActive();
|
bool RealtimeIsActive();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user