mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Break dependency cycle of Effect and EffectManager
This commit is contained in:
parent
0572c0a0d4
commit
37d730edfe
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "../Audacity.h"
|
#include "../Audacity.h"
|
||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
#include "EffectManager.h"
|
|
||||||
|
|
||||||
#include "../Experimental.h"
|
#include "../Experimental.h"
|
||||||
|
|
||||||
@ -25,6 +24,7 @@
|
|||||||
|
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/tokenzr.h>
|
||||||
|
|
||||||
#include "../AudioIO.h"
|
#include "../AudioIO.h"
|
||||||
#include "../LabelTrack.h"
|
#include "../LabelTrack.h"
|
||||||
@ -667,8 +667,7 @@ void Effect::ExportPresets()
|
|||||||
{
|
{
|
||||||
wxString params;
|
wxString params;
|
||||||
GetAutomationParameters(params);
|
GetAutomationParameters(params);
|
||||||
EffectManager & em = EffectManager::Get();
|
wxString commandId = GetSquashedName(GetSymbol().Internal()).GET();
|
||||||
wxString commandId = em.GetSquashedName(GetSymbol().Internal()).GET();
|
|
||||||
params = commandId + ":" + params;
|
params = commandId + ":" + params;
|
||||||
|
|
||||||
auto path = FileNames::DefaultToDocumentsFolder(wxT("Presets/Path"));
|
auto path = FileNames::DefaultToDocumentsFolder(wxT("Presets/Path"));
|
||||||
@ -745,8 +744,7 @@ void Effect::ImportPresets()
|
|||||||
wxString ident = params.BeforeFirst(':');
|
wxString ident = params.BeforeFirst(':');
|
||||||
params = params.AfterFirst(':');
|
params = params.AfterFirst(':');
|
||||||
|
|
||||||
EffectManager & em = EffectManager::Get();
|
wxString commandId = GetSquashedName(GetSymbol().Internal()).GET();
|
||||||
wxString commandId = em.GetSquashedName(GetSymbol().Internal()).GET();
|
|
||||||
|
|
||||||
if (ident != commandId) {
|
if (ident != commandId) {
|
||||||
// effect identifiers are a sensible length!
|
// effect identifiers are a sensible length!
|
||||||
@ -775,6 +773,30 @@ void Effect::ImportPresets()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandID Effect::GetSquashedName(wxString name)
|
||||||
|
{
|
||||||
|
// Get rid of leading and trailing white space
|
||||||
|
name.Trim(true).Trim(false);
|
||||||
|
|
||||||
|
if (name.empty())
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxStringTokenizer st(name, wxT(" "));
|
||||||
|
wxString id;
|
||||||
|
|
||||||
|
// CamelCase the name
|
||||||
|
while (st.HasMoreTokens())
|
||||||
|
{
|
||||||
|
wxString tok = st.GetNextToken();
|
||||||
|
|
||||||
|
id += tok.Left(1).MakeUpper() + tok.Mid(1).MakeLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
bool Effect::HasOptions()
|
bool Effect::HasOptions()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -168,6 +168,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
|
|||||||
void ExportPresets() override;
|
void ExportPresets() override;
|
||||||
void ImportPresets() override;
|
void ImportPresets() override;
|
||||||
|
|
||||||
|
static CommandID GetSquashedName(wxString name);
|
||||||
|
|
||||||
bool HasOptions() override;
|
bool HasOptions() override;
|
||||||
void ShowOptions() override;
|
void ShowOptions() override;
|
||||||
|
|
||||||
|
@ -122,31 +122,7 @@ TranslatableString EffectManager::GetVendorName(const PluginID & ID)
|
|||||||
CommandID EffectManager::GetCommandIdentifier(const PluginID & ID)
|
CommandID EffectManager::GetCommandIdentifier(const PluginID & ID)
|
||||||
{
|
{
|
||||||
wxString name = PluginManager::Get().GetSymbol(ID).Internal();
|
wxString name = PluginManager::Get().GetSymbol(ID).Internal();
|
||||||
return GetSquashedName(name);
|
return Effect::GetSquashedName(name);
|
||||||
}
|
|
||||||
|
|
||||||
CommandID EffectManager::GetSquashedName(wxString name)
|
|
||||||
{
|
|
||||||
// Get rid of leading and trailing white space
|
|
||||||
name.Trim(true).Trim(false);
|
|
||||||
|
|
||||||
if (name.empty())
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxStringTokenizer st(name, wxT(" "));
|
|
||||||
wxString id;
|
|
||||||
|
|
||||||
// CamelCase the name
|
|
||||||
while (st.HasMoreTokens())
|
|
||||||
{
|
|
||||||
wxString tok = st.GetNextToken();
|
|
||||||
|
|
||||||
id += tok.Left(1).MakeUpper() + tok.Mid(1).MakeLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslatableString EffectManager::GetCommandDescription(const PluginID & ID)
|
TranslatableString EffectManager::GetCommandDescription(const PluginID & ID)
|
||||||
|
@ -94,7 +94,6 @@ public:
|
|||||||
ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID);
|
ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID);
|
||||||
TranslatableString GetCommandName(const PluginID & ID);
|
TranslatableString GetCommandName(const PluginID & ID);
|
||||||
CommandID GetCommandIdentifier(const PluginID & ID);
|
CommandID GetCommandIdentifier(const PluginID & ID);
|
||||||
CommandID GetSquashedName(wxString name);
|
|
||||||
TranslatableString GetCommandDescription(const PluginID & ID);
|
TranslatableString GetCommandDescription(const PluginID & ID);
|
||||||
wxString GetCommandUrl(const PluginID & ID);
|
wxString GetCommandUrl(const PluginID & ID);
|
||||||
wxString GetCommandTip(const PluginID & ID);
|
wxString GetCommandTip(const PluginID & ID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user