diff --git a/include/audacity/EffectInterface.h b/include/audacity/EffectInterface.h index 66069aa29..09aa10ac7 100755 --- a/include/audacity/EffectInterface.h +++ b/include/audacity/EffectInterface.h @@ -62,17 +62,30 @@ class ShuttleParams; /*************************************************************************************//** +\class ParamsInterface +\brief ParamsInterface provides a DefineParameters virtual function, +that defines the parameters of the command. + +*******************************************************************************************/ +class AUDACITY_DLL_API ParamsInterface /* not final */ +{ +public: + virtual ~ParamsInterface() {}; + // returns true if implemented. + virtual bool DefineParams( ShuttleParams & WXUNUSED(S) ){ return false;}; +}; + +/*************************************************************************************//** + \class CommandDefinitionInterface \brief CommandDefinitionInterface is an IdentInterface (to name the command) along with a DefineParameters virtual function, that defines the parameters of the command. *******************************************************************************************/ -class AUDACITY_DLL_API CommandDefinitionInterface /* not final */ : public IdentInterface +class AUDACITY_DLL_API CommandDefinitionInterface /* not final */ : public IdentInterface, public ParamsInterface { public: virtual ~CommandDefinitionInterface() {}; - // returns true if implemented. - virtual bool DefineParams( ShuttleParams & WXUNUSED(S) ){ return false;}; }; /*************************************************************************************//** @@ -83,7 +96,7 @@ public: flag-functions for interactivity, play-preview and whether the effect can run without a GUI. *******************************************************************************************/ -class AUDACITY_DLL_API EffectDefinitionInterface /* not final */ : public CommandDefinitionInterface +class AUDACITY_DLL_API EffectDefinitionInterface /* not final */ : public IdentInterface, public ParamsInterface { public: virtual ~EffectDefinitionInterface() {}; diff --git a/include/audacity/ModuleInterface.h b/include/audacity/ModuleInterface.h index 4794d95be..fb2da32d7 100644 --- a/include/audacity/ModuleInterface.h +++ b/include/audacity/ModuleInterface.h @@ -120,7 +120,7 @@ public: // Return value is the number of plugins found. using RegistrationCallback = std::function< - const PluginID &(ModuleInterface *, CommandDefinitionInterface *) >; + const PluginID &(ModuleInterface *, IdentInterface *) >; virtual unsigned DiscoverPluginsAtPath( const wxString & path, wxString &errMsg, const RegistrationCallback &callback ) diff --git a/include/audacity/PluginInterface.h b/include/audacity/PluginInterface.h index 806fe91f0..93ac2bf88 100644 --- a/include/audacity/PluginInterface.h +++ b/include/audacity/PluginInterface.h @@ -57,9 +57,9 @@ class PluginManagerInterface /* not final */ public: static const PluginID &DefaultRegistrationCallback( - ModuleInterface *provider, CommandDefinitionInterface *ident ); - static const PluginID &GenericRegistrationCallback( - ModuleInterface *provider, CommandDefinitionInterface *ident ); + ModuleInterface *provider, IdentInterface *ident ); + static const PluginID &AudacityCommandRegistrationCallback( + ModuleInterface *provider, IdentInterface *ident ); virtual bool IsPluginRegistered(const wxString & path) = 0; diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 2ac32689f..22142c7cf 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -269,7 +269,7 @@ auto BatchCommands::GetAllCommands() -> CommandNameVector PluginManager & pm = PluginManager::Get(); EffectManager & em = EffectManager::Get(); { - const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect|PluginTypeGeneric); + const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect|PluginTypeAudacityCommand); while (plug) { auto command = em.GetCommandIdentifier(plug->GetID()); @@ -278,7 +278,7 @@ auto BatchCommands::GetAllCommands() -> CommandNameVector plug->GetUntranslatedName(), // plug->GetTranslatedName(), command } ); - plug = pm.GetNextPlugin(PluginTypeEffect|PluginTypeGeneric); + plug = pm.GetNextPlugin(PluginTypeEffect|PluginTypeAudacityCommand); } } @@ -615,7 +615,7 @@ bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com // FIXME: for later versions may want to not select-all in batch mode. // IF nothing selected, THEN select everything // (most effects require that you have something selected). - if( plug->GetPluginType() != PluginTypeGeneric ) + if( plug->GetPluginType() != PluginTypeAudacityCommand ) project->SelectAllIfNone(); bool res = false; @@ -625,7 +625,7 @@ bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com // transfer the parameters to the effect... if (EffectManager::Get().SetEffectParameters(ID, params)) { - if( plug->GetPluginType() == PluginTypeGeneric ) + if( plug->GetPluginType() == PluginTypeAudacityCommand ) // and apply the effect... res = project->DoAudacityCommand(ID, Context, diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index d6211777a..d807139c9 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1410,18 +1410,24 @@ void PluginDescriptor::SetImporterExtensions(const wxArrayString & extensions) // ============================================================================ const PluginID &PluginManagerInterface::DefaultRegistrationCallback( - ModuleInterface *provider, CommandDefinitionInterface *pInterface ) + ModuleInterface *provider, IdentInterface *pInterface ) { EffectDefinitionInterface * pEInterface = dynamic_cast(pInterface); if( pEInterface ) return PluginManager::Get().RegisterPlugin(provider, pEInterface, PluginTypeEffect); - return PluginManager::Get().RegisterPlugin(provider, pInterface); + CommandDefinitionInterface * pCInterface = dynamic_cast(pInterface); + if( pCInterface ) + return PluginManager::Get().RegisterPlugin(provider, pCInterface); + return ""; } -const PluginID &PluginManagerInterface::GenericRegistrationCallback( - ModuleInterface *provider, CommandDefinitionInterface *pInterface ) +const PluginID &PluginManagerInterface::AudacityCommandRegistrationCallback( + ModuleInterface *provider, IdentInterface *pInterface ) { - return PluginManager::Get().RegisterPlugin(provider, pInterface); + CommandDefinitionInterface * pCInterface = dynamic_cast(pInterface); + if( pCInterface ) + return PluginManager::Get().RegisterPlugin(provider, pCInterface); + return ""; } @@ -1450,17 +1456,10 @@ const PluginID & PluginManager::RegisterPlugin(ModuleInterface *module) const PluginID & PluginManager::RegisterPlugin(ModuleInterface *provider, CommandDefinitionInterface *command) { - PluginDescriptor & plug = CreatePlugin(GetID(command), command, (PluginType)PluginTypeGeneric); + PluginDescriptor & plug = CreatePlugin(GetID(command), command, (PluginType)PluginTypeAudacityCommand); plug.SetProviderID(PluginManager::GetID(provider)); - //plug.SetEffectType(effect->GetType()); - //plug.SetEffectFamily(effect->GetFamily()); - //plug.SetEffectInteractive(effect->IsInteractive()); - //plug.SetEffectDefault(effect->IsDefault()); - //plug.SetEffectRealtime(effect->SupportsRealtime()); - //plug.SetEffectAutomatable(effect->SupportsAutomation()); - plug.SetEnabled(true); plug.SetValid(true); @@ -1874,7 +1873,7 @@ bool PluginManager::DropFile(const wxString &fileName) std::vector ids; std::vector names; nPlugIns = module->DiscoverPluginsAtPath(dstPath, errMsg, - [&](ModuleInterface *provider, CommandDefinitionInterface *ident){ + [&](ModuleInterface *provider, IdentInterface *ident){ // Register as by default, but also collecting the PluginIDs // and names const PluginID * id = &PluginManagerInterface::DefaultRegistrationCallback( @@ -1945,7 +1944,7 @@ void PluginManager::Load() // Now the rest LoadGroup(®istry, PluginTypeEffect); - LoadGroup(®istry, PluginTypeGeneric ); + LoadGroup(®istry, PluginTypeAudacityCommand ); LoadGroup(®istry, PluginTypeExporter); LoadGroup(®istry, PluginTypeImporter); @@ -2243,7 +2242,7 @@ void PluginManager::Save() // Save the individual groups SaveGroup(®istry, PluginTypeEffect); SaveGroup(®istry, PluginTypeExporter); - SaveGroup(®istry, PluginTypeGeneric); + SaveGroup(®istry, PluginTypeAudacityCommand); SaveGroup(®istry, PluginTypeImporter); SaveGroup(®istry, PluginTypeStub); @@ -2669,7 +2668,7 @@ PluginID PluginManager::GetID(ModuleInterface *module) PluginID PluginManager::GetID(CommandDefinitionInterface *command) { return wxString::Format(wxT("%s_%s_%s_%s_%s"), - GetPluginTypeString(PluginTypeGeneric), + GetPluginTypeString(PluginTypeAudacityCommand), wxEmptyString, command->GetVendor(), command->GetName(), @@ -2712,7 +2711,7 @@ wxString PluginManager::GetPluginTypeString(PluginType type) case PluginTypeEffect: str = wxT("Effect"); break; - case PluginTypeGeneric: + case PluginTypeAudacityCommand: str = wxT("Generic"); break; case PluginTypeExporter: diff --git a/src/PluginManager.h b/src/PluginManager.h index 8e97ac287..a0991e7eb 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -34,7 +34,7 @@ typedef enum PluginTypeNone = 0, // 2.1.0 placeholder entries...not used by 2.1.1 or greater PluginTypeStub =1, // Used for plugins that have not yet been registered PluginTypeEffect =1<<1, - PluginTypeGeneric=1<<2, + PluginTypeAudacityCommand=1<<2, PluginTypeExporter=1<<3, PluginTypeImporter=1<<4, PluginTypeModule=1<<5, diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index abdfb7eb6..7d608adbe 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -16,7 +16,6 @@ This class now lists - Tracks - Clips - Labels -- Keycodes - Boxes *//*******************************************************************/ @@ -39,7 +38,7 @@ This class now lists #include "../ShuttleGui.h" #include "CommandContext.h" -const int nTypes =7; +const int nTypes =6; static const wxString kTypes[nTypes] = { XO("Commands"), @@ -47,7 +46,6 @@ static const wxString kTypes[nTypes] = XO("Tracks"), XO("Clips"), XO("Labels"), - XO("Keycodes"), XO("Boxes") }; @@ -57,7 +55,6 @@ enum { kTracks, kClips, kLabels, - kKeycodes, kBoxes }; @@ -133,7 +130,6 @@ bool GetInfoCommand::ApplyInner(const CommandContext &context) case kTracks : return SendTracks( context ); case kClips : return SendClips( context ); case kLabels : return SendLabels( context ); - case kKeycodes : return SendKeycodes( context ); case kBoxes : return SendBoxes( context ); default: context.Status( "Command options not recognised" ); @@ -177,44 +173,20 @@ bool GetInfoCommand::SendCommands(const CommandContext &context ) PluginManager & pm = PluginManager::Get(); EffectManager & em = EffectManager::Get(); { - const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect | PluginTypeGeneric); + const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect | PluginTypeAudacityCommand); while (plug) { auto command = em.GetCommandIdentifier(plug->GetID()); if (!command.IsEmpty()){ em.GetCommandDefinition( plug->GetID(), context ); } - plug = pm.GetNextPlugin(PluginTypeEffect | PluginTypeGeneric ); + plug = pm.GetNextPlugin(PluginTypeEffect | PluginTypeAudacityCommand ); } } context.EndArray(); return true; } -#if 0 -// Old version which gives enabled/disabled status too. -bool GetInfoCommand::SendMenus(const CommandContext &context) -{ - bool bShowStatus = true; - wxArrayString names; - CommandManager *cmdManager = context.GetProject()->GetCommandManager(); - cmdManager->GetAllCommandNames(names, false); - wxArrayString::iterator iter; - for (iter = names.begin(); iter != names.end(); ++iter) - { - wxString name = *iter; - wxString out = name; - if (bShowStatus) - { - out += wxT("\t"); - out += cmdManager->GetEnabled(name) ? wxT("Enabled") : wxT("Disabled"); - } - context.Status(out); - } - return true; -} -#endif - bool GetInfoCommand::SendBoxes(const CommandContext &context) { //context.Status("Boxes"); @@ -333,12 +305,6 @@ bool GetInfoCommand::SendLabels(const CommandContext &context) return true; } -bool GetInfoCommand::SendKeycodes(const CommandContext &context) -{ - context.Status("Keycodes - Not yet"); - return true; -} - /******************************************************************* The various Explore functions are called from the Send functions, and may be recursive. 'Send' is the top level. diff --git a/src/commands/GetInfoCommand.h b/src/commands/GetInfoCommand.h index 17c02d667..38cef1c7b 100644 --- a/src/commands/GetInfoCommand.h +++ b/src/commands/GetInfoCommand.h @@ -52,7 +52,6 @@ private: bool SendTracks(const CommandContext & context); bool SendLabels(const CommandContext & context); bool SendClips(const CommandContext & context); - bool SendKeycodes(const CommandContext & context); bool SendBoxes(const CommandContext & context); void ExploreMenu( const CommandContext &context, wxMenu * pMenu, int Id, int depth ); diff --git a/src/commands/LoadCommands.cpp b/src/commands/LoadCommands.cpp index c8509d67e..8e4491dee 100644 --- a/src/commands/LoadCommands.cpp +++ b/src/commands/LoadCommands.cpp @@ -224,7 +224,7 @@ bool BuiltinCommandsModule::AutoRegisterPlugins(PluginManagerInterface & pm) // Uses Generic Registration, not Default. // Registers as TypeGeneric, not TypeEffect. DiscoverPluginsAtPath(path, ignoredErrMsg, - PluginManagerInterface::GenericRegistrationCallback); + PluginManagerInterface::AudacityCommandRegistrationCallback); } } diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index 57392b93f..5b8fe6194 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -192,7 +192,7 @@ wxString EffectManager::GetCommandDescription(const PluginID & ID) void EffectManager::GetCommandDefinition(const PluginID & ID, const CommandContext & context) { - CommandDefinitionInterface *command; + ParamsInterface *command; command = GetEffect(ID); if( !command ) command = GetAudacityCommand( ID ); @@ -909,14 +909,14 @@ const PluginID & EffectManager::GetEffectByIdentifier(const wxString & strTarget PluginManager & pm = PluginManager::Get(); // Effects OR Generic commands... - const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect | PluginTypeGeneric); + const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect | PluginTypeAudacityCommand); while (plug) { if (GetCommandIdentifier(plug->GetID()).IsSameAs(strTarget)) { return plug->GetID(); } - plug = pm.GetNextPlugin(PluginTypeEffect | PluginTypeGeneric); + plug = pm.GetNextPlugin(PluginTypeEffect | PluginTypeAudacityCommand); } return empty;; }