1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 09:00:52 +02:00

Remove the special PopupFunctor, redo it by other means...

... it was only used, so far, by the scrubber.
This commit is contained in:
Paul Licameli 2017-08-19 07:42:43 -04:00
parent 1e3ab82a01
commit d263eaa97b
5 changed files with 21 additions and 38 deletions

View File

@ -86,24 +86,6 @@ 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 () (const CommandContext &context) override
{ wxCommandEvent dummy; (mThis->*mCommandPopupFunction) (dummy); }
private:
OBJ *const mThis;
const audCommandPopupFunction<OBJ> mCommandPopupFunction;
};
template<typename OBJ>
using audCommandListFunction = void (OBJ::*)(int);
@ -150,11 +132,6 @@ 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)

View File

@ -193,13 +193,13 @@ void ScrubbingToolBar::OnButton(wxCommandEvent &event)
switch (id) {
case STBScrubID:
scrubber.OnScrub(event);
scrubber.OnScrub();
break;
case STBSeekID:
scrubber.OnSeek(event);
scrubber.OnSeek();
break;
case STBRulerID:
scrubber.OnToggleScrubRuler(event);
scrubber.OnToggleScrubRuler();
break;
default:
wxASSERT(false);

View File

@ -224,7 +224,7 @@ namespace {
wxString label;
wxString status;
CommandFlag flags;
void (Scrubber::*memFn)(wxCommandEvent&);
void (Scrubber::*memFn)();
bool seek;
bool (Scrubber::*StatusTest)() const;
@ -921,19 +921,19 @@ void Scrubber::OnScrubOrSeek(bool seek)
scrubbingToolBar->RegenerateTooltips();
}
void Scrubber::OnScrub(wxCommandEvent&)
void Scrubber::OnScrub()
{
OnScrubOrSeek(false);
CheckMenuItems();
}
void Scrubber::OnSeek(wxCommandEvent&)
void Scrubber::OnSeek()
{
OnScrubOrSeek(true);
CheckMenuItems();
}
void Scrubber::OnToggleScrubRuler(wxCommandEvent&)
void Scrubber::OnToggleScrubRuler()
{
mProject->GetRulerPanel()->OnToggleScrubRuler();
const auto toolbar = mProject->GetToolManager()->GetToolBar(ScrubbingBarID);
@ -943,10 +943,12 @@ void Scrubber::OnToggleScrubRuler(wxCommandEvent&)
enum { CMD_ID = 8000 };
#define THUNK(Name) Scrubber::Thunk<&Scrubber::Name>
BEGIN_EVENT_TABLE(Scrubber, wxEvtHandler)
EVT_MENU(CMD_ID, Scrubber::OnScrub)
EVT_MENU(CMD_ID + 1, Scrubber::OnSeek)
EVT_MENU(CMD_ID + 2, Scrubber::OnToggleScrubRuler)
EVT_MENU(CMD_ID, THUNK(OnScrub))
EVT_MENU(CMD_ID + 1, THUNK(OnSeek))
EVT_MENU(CMD_ID + 2, THUNK(OnToggleScrubRuler))
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(Scrubber::Forwarder, wxEvtHandler)

View File

@ -123,9 +123,13 @@ public:
void PopulatePopupMenu(wxMenu &menu);
void OnScrubOrSeek(bool seek);
void OnScrub(wxCommandEvent&);
void OnSeek(wxCommandEvent&);
void OnToggleScrubRuler(wxCommandEvent&);
void OnScrub();
void OnSeek();
void OnToggleScrubRuler();
// Convenience wrapper for the above
template<void (Scrubber::*pfn)()> void Thunk(wxCommandEvent &dummy)
{ (this->*pfn)(); }
// A string to put in the leftmost part of the status bar
// when scrub or seek is in progress, or else empty.

View File

@ -2845,10 +2845,10 @@ void AdornedRulerPanel::UpdateStatusBarAndTooltips(StatusChoice choice)
// This version toggles ruler state indirectly via the scrubber
// to ensure that all the places where the state is shown update.
// For example buttons and menus must update.
void AdornedRulerPanel::OnToggleScrubRulerFromMenu(wxCommandEvent& Evt)
void AdornedRulerPanel::OnToggleScrubRulerFromMenu(wxCommandEvent&)
{
auto &scrubber = mProject->GetScrubber();
scrubber.OnToggleScrubRuler( Evt );
scrubber.OnToggleScrubRuler( );
}
void AdornedRulerPanel::OnToggleScrubRuler(/*wxCommandEvent&*/)