mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 17:10:55 +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:
parent
1e3ab82a01
commit
d263eaa97b
@ -86,24 +86,6 @@ private:
|
|||||||
const audCommandKeyFunction<OBJ> mCommandKeyFunction;
|
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>
|
template<typename OBJ>
|
||||||
using audCommandListFunction = void (OBJ::*)(int);
|
using audCommandListFunction = void (OBJ::*)(int);
|
||||||
|
|
||||||
@ -150,11 +132,6 @@ inline CommandFunctorPointer MakeFunctor(OBJ *This,
|
|||||||
audCommandKeyFunction<OBJ> pfn)
|
audCommandKeyFunction<OBJ> pfn)
|
||||||
{ return CommandFunctorPointer{ safenew KeyFunctor<OBJ>{ This, 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>
|
template<typename OBJ>
|
||||||
inline CommandFunctorPointer MakeFunctor(OBJ *This,
|
inline CommandFunctorPointer MakeFunctor(OBJ *This,
|
||||||
audCommandListFunction<OBJ> pfn)
|
audCommandListFunction<OBJ> pfn)
|
||||||
|
@ -193,13 +193,13 @@ void ScrubbingToolBar::OnButton(wxCommandEvent &event)
|
|||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case STBScrubID:
|
case STBScrubID:
|
||||||
scrubber.OnScrub(event);
|
scrubber.OnScrub();
|
||||||
break;
|
break;
|
||||||
case STBSeekID:
|
case STBSeekID:
|
||||||
scrubber.OnSeek(event);
|
scrubber.OnSeek();
|
||||||
break;
|
break;
|
||||||
case STBRulerID:
|
case STBRulerID:
|
||||||
scrubber.OnToggleScrubRuler(event);
|
scrubber.OnToggleScrubRuler();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
|
@ -224,7 +224,7 @@ namespace {
|
|||||||
wxString label;
|
wxString label;
|
||||||
wxString status;
|
wxString status;
|
||||||
CommandFlag flags;
|
CommandFlag flags;
|
||||||
void (Scrubber::*memFn)(wxCommandEvent&);
|
void (Scrubber::*memFn)();
|
||||||
bool seek;
|
bool seek;
|
||||||
bool (Scrubber::*StatusTest)() const;
|
bool (Scrubber::*StatusTest)() const;
|
||||||
|
|
||||||
@ -921,19 +921,19 @@ void Scrubber::OnScrubOrSeek(bool seek)
|
|||||||
scrubbingToolBar->RegenerateTooltips();
|
scrubbingToolBar->RegenerateTooltips();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::OnScrub(wxCommandEvent&)
|
void Scrubber::OnScrub()
|
||||||
{
|
{
|
||||||
OnScrubOrSeek(false);
|
OnScrubOrSeek(false);
|
||||||
CheckMenuItems();
|
CheckMenuItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::OnSeek(wxCommandEvent&)
|
void Scrubber::OnSeek()
|
||||||
{
|
{
|
||||||
OnScrubOrSeek(true);
|
OnScrubOrSeek(true);
|
||||||
CheckMenuItems();
|
CheckMenuItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::OnToggleScrubRuler(wxCommandEvent&)
|
void Scrubber::OnToggleScrubRuler()
|
||||||
{
|
{
|
||||||
mProject->GetRulerPanel()->OnToggleScrubRuler();
|
mProject->GetRulerPanel()->OnToggleScrubRuler();
|
||||||
const auto toolbar = mProject->GetToolManager()->GetToolBar(ScrubbingBarID);
|
const auto toolbar = mProject->GetToolManager()->GetToolBar(ScrubbingBarID);
|
||||||
@ -943,10 +943,12 @@ void Scrubber::OnToggleScrubRuler(wxCommandEvent&)
|
|||||||
|
|
||||||
enum { CMD_ID = 8000 };
|
enum { CMD_ID = 8000 };
|
||||||
|
|
||||||
|
#define THUNK(Name) Scrubber::Thunk<&Scrubber::Name>
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(Scrubber, wxEvtHandler)
|
BEGIN_EVENT_TABLE(Scrubber, wxEvtHandler)
|
||||||
EVT_MENU(CMD_ID, Scrubber::OnScrub)
|
EVT_MENU(CMD_ID, THUNK(OnScrub))
|
||||||
EVT_MENU(CMD_ID + 1, Scrubber::OnSeek)
|
EVT_MENU(CMD_ID + 1, THUNK(OnSeek))
|
||||||
EVT_MENU(CMD_ID + 2, Scrubber::OnToggleScrubRuler)
|
EVT_MENU(CMD_ID + 2, THUNK(OnToggleScrubRuler))
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(Scrubber::Forwarder, wxEvtHandler)
|
BEGIN_EVENT_TABLE(Scrubber::Forwarder, wxEvtHandler)
|
||||||
|
@ -123,9 +123,13 @@ public:
|
|||||||
void PopulatePopupMenu(wxMenu &menu);
|
void PopulatePopupMenu(wxMenu &menu);
|
||||||
|
|
||||||
void OnScrubOrSeek(bool seek);
|
void OnScrubOrSeek(bool seek);
|
||||||
void OnScrub(wxCommandEvent&);
|
void OnScrub();
|
||||||
void OnSeek(wxCommandEvent&);
|
void OnSeek();
|
||||||
void OnToggleScrubRuler(wxCommandEvent&);
|
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
|
// A string to put in the leftmost part of the status bar
|
||||||
// when scrub or seek is in progress, or else empty.
|
// when scrub or seek is in progress, or else empty.
|
||||||
|
@ -2845,10 +2845,10 @@ void AdornedRulerPanel::UpdateStatusBarAndTooltips(StatusChoice choice)
|
|||||||
// This version toggles ruler state indirectly via the scrubber
|
// This version toggles ruler state indirectly via the scrubber
|
||||||
// to ensure that all the places where the state is shown update.
|
// to ensure that all the places where the state is shown update.
|
||||||
// For example buttons and menus must update.
|
// For example buttons and menus must update.
|
||||||
void AdornedRulerPanel::OnToggleScrubRulerFromMenu(wxCommandEvent& Evt)
|
void AdornedRulerPanel::OnToggleScrubRulerFromMenu(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
auto &scrubber = mProject->GetScrubber();
|
auto &scrubber = mProject->GetScrubber();
|
||||||
scrubber.OnToggleScrubRuler( Evt );
|
scrubber.OnToggleScrubRuler( );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnToggleScrubRuler(/*wxCommandEvent&*/)
|
void AdornedRulerPanel::OnToggleScrubRuler(/*wxCommandEvent&*/)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user