1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 22:12:58 +02:00

Context menu for scrubbing in the ruler

This commit is contained in:
Paul Licameli
2016-04-26 11:09:34 -04:00
parent c12993a53b
commit 3d222bcd87
6 changed files with 107 additions and 46 deletions

View File

@@ -10,6 +10,7 @@
#define __AUDACITY_COMMAND_FUNCTORS__
#include <wx/string.h>
#include <wx/event.h>
#include "../MemoryX.h"
class wxEvent;
@@ -61,6 +62,24 @@ private:
const audCommandKeyFunction<OBJ> mCommandKeyFunction;
};
// This allows functions to be used either by command manager or by a wxMenu popup,
// but the functions MUST ignore the argument!
template<typename OBJ>
using audCommandPopupFunction = void (OBJ::*)(wxCommandEvent&);
template<typename OBJ>
class PopupFunctor final : public CommandFunctor
{
public:
explicit PopupFunctor(OBJ *This, audCommandPopupFunction<OBJ> pfn)
: mThis{ This }, mCommandPopupFunction{ pfn } {}
void operator () (int, const wxEvent *) override
{ wxCommandEvent dummy; (mThis->*mCommandPopupFunction) (dummy); }
private:
OBJ *const mThis;
const audCommandPopupFunction<OBJ> mCommandPopupFunction;
};
template<typename OBJ>
using audCommandListFunction = void (OBJ::*)(int);
@@ -108,6 +127,11 @@ inline CommandFunctorPointer MakeFunctor(OBJ *This,
audCommandKeyFunction<OBJ> pfn)
{ return CommandFunctorPointer{ safenew KeyFunctor<OBJ>{ This, pfn } }; }
template<typename OBJ>
inline CommandFunctorPointer MakeFunctor(OBJ *This,
audCommandPopupFunction<OBJ> pfn)
{ return CommandFunctorPointer{ safenew PopupFunctor<OBJ>{ This, pfn } }; }
template<typename OBJ>
inline CommandFunctorPointer MakeFunctor(OBJ *This,
audCommandListFunction<OBJ> pfn)