1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-03 22:19:07 +02:00

Effect commands store PluginID in CommandEntry parameter, not functor

This commit is contained in:
Paul Licameli 2017-08-19 06:45:23 -04:00
parent 05984e8bfb
commit 1e3ab82a01
4 changed files with 14 additions and 15 deletions

View File

@ -1875,9 +1875,9 @@ void AudacityProject::AddEffectMenuItemGroup(CommandManager *c,
wxString item = PluginManager::Get().GetPlugin(plugs[i])->GetPath(); wxString item = PluginManager::Get().GetPlugin(plugs[i])->GetPath();
c->AddItem(item, c->AddItem(item,
item, item,
FNS(OnEffect, plugs[i]), FN(OnEffect),
flags[i], flags[i],
flags[i]); flags[i], plugs[i]);
i++; i++;
} }
@ -1888,9 +1888,9 @@ void AudacityProject::AddEffectMenuItemGroup(CommandManager *c,
{ {
c->AddItem(names[i], c->AddItem(names[i],
names[i], names[i],
FNS(OnEffect, plugs[i]), FN(OnEffect),
flags[i], flags[i],
flags[i]); flags[i], plugs[i]);
} }
if (max > 0) if (max > 0)

View File

@ -127,15 +127,14 @@ template<typename OBJ>
class PluginFunctor final : public CommandFunctor class PluginFunctor final : public CommandFunctor
{ {
public: public:
explicit PluginFunctor(OBJ *This, const PluginID &id, audCommandPluginFunction<OBJ> pfn) explicit PluginFunctor(OBJ *This, audCommandPluginFunction<OBJ> pfn)
: mPluginID{ id }, mThis{ This }, mCommandPluginFunction{ pfn } {} : mThis{ This }, mCommandPluginFunction{ pfn } {}
void operator () (const CommandContext &context) override void operator () (const CommandContext &context) override
{ (mThis->*mCommandPluginFunction) { (mThis->*mCommandPluginFunction)
(mPluginID, (context.parameter,
0 // AudacityProject::OnEffectFlags::kNone 0 // AudacityProject::OnEffectFlags::kNone
); } ); }
private: private:
const PluginID mPluginID;
OBJ *const mThis; OBJ *const mThis;
const audCommandPluginFunction<OBJ> mCommandPluginFunction; const audCommandPluginFunction<OBJ> mCommandPluginFunction;
}; };
@ -162,15 +161,13 @@ inline CommandFunctorPointer MakeFunctor(OBJ *This,
{ return CommandFunctorPointer{ safenew ListFunctor<OBJ>{ This, pfn } }; } { return CommandFunctorPointer{ safenew ListFunctor<OBJ>{ This, pfn } }; }
template<typename OBJ> template<typename OBJ>
inline CommandFunctorPointer MakeFunctor(OBJ *This, const PluginID &id, inline CommandFunctorPointer MakeFunctor(OBJ *This,
audCommandPluginFunction<OBJ> pfn) audCommandPluginFunction<OBJ> pfn)
{ return CommandFunctorPointer{ safenew PluginFunctor<OBJ>{ This, id, pfn } }; } { return CommandFunctorPointer{ safenew PluginFunctor<OBJ>{ This, pfn } }; }
// Now define the macro abbreviations that call the factory // Now define the macro abbreviations that call the factory
#define FNT(OBJ, This, X) (MakeFunctor<OBJ>(This, X )) #define FNT(OBJ, This, X) (MakeFunctor<OBJ>(This, X ))
#define FNTS(OBJ, This, X, S) (MakeFunctor<OBJ>(This, (S), X ))
#define FN(X) FNT(AudacityProject, this, & AudacityProject :: X) #define FN(X) FNT(AudacityProject, this, & AudacityProject :: X)
#define FNS(X, S) FNTS(AudacityProject, this, & AudacityProject :: X, S)
#endif #endif

View File

@ -783,9 +783,10 @@ void CommandManager::AddItem(const wxChar *name,
const wxChar *label, const wxChar *label,
const CommandFunctorPointer &callback, const CommandFunctorPointer &callback,
CommandFlag flags, CommandFlag flags,
CommandMask mask) CommandMask mask,
const CommandParameter &parameter)
{ {
AddItem(name, label, callback, wxT(""), flags, mask); AddItem(name, label, callback, wxT(""), flags, mask, -1, parameter);
} }
void CommandManager::AddItem(const wxChar *name, void CommandManager::AddItem(const wxChar *name,

View File

@ -149,7 +149,8 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
const wxChar *label, const wxChar *label,
const CommandFunctorPointer &callback, const CommandFunctorPointer &callback,
CommandFlag flags = NoFlagsSpecifed, CommandFlag flags = NoFlagsSpecifed,
CommandMask mask = NoFlagsSpecifed); CommandMask mask = NoFlagsSpecifed,
const CommandParameter &parameter = {});
void AddItem(const wxChar *name, void AddItem(const wxChar *name,
const wxChar *label_in, const wxChar *label_in,