1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-27 15:08:39 +01:00

No more functor objects; all command handler functions take same args

This commit is contained in:
Paul Licameli
2017-08-19 10:15:32 -04:00
parent 77c392d29c
commit ab6de1181d
16 changed files with 596 additions and 681 deletions

View File

@@ -224,7 +224,7 @@ namespace {
wxString label;
wxString status;
CommandFlag flags;
void (Scrubber::*memFn)();
void (Scrubber::*memFn)(const CommandContext&);
bool seek;
bool (Scrubber::*StatusTest)() const;
@@ -921,19 +921,19 @@ void Scrubber::OnScrubOrSeek(bool seek)
scrubbingToolBar->RegenerateTooltips();
}
void Scrubber::OnScrub()
void Scrubber::OnScrub(const CommandContext&)
{
OnScrubOrSeek(false);
CheckMenuItems();
}
void Scrubber::OnSeek()
void Scrubber::OnSeek(const CommandContext&)
{
OnScrubOrSeek(true);
CheckMenuItems();
}
void Scrubber::OnToggleScrubRuler()
void Scrubber::OnToggleScrubRuler(const CommandContext&)
{
mProject->GetRulerPanel()->OnToggleScrubRuler();
const auto toolbar = mProject->GetToolManager()->GetToolBar(ScrubbingBarID);
@@ -1014,13 +1014,13 @@ void Scrubber::AddMenuItems()
for (const auto &item : menuItems) {
if (item.StatusTest)
cm->AddCheck(item.name, wxGetTranslation(item.label),
findme, FNT(Scrubber, this, item.memFn),
findme, static_cast<CommandFunctorPointer>(item.memFn),
false,
item.flags, item.flags);
else
// The start item
cm->AddItem(item.name, wxGetTranslation(item.label),
findme, FNT(Scrubber, this, item.memFn),
findme, static_cast<CommandFunctorPointer>(item.memFn),
item.flags, item.flags);
}
cm->EndSubMenu();

View File

@@ -18,9 +18,11 @@ Paul Licameli split from TrackPanel.cpp
#include "../../Experimental.h"
#include "../../widgets/Overlay.h"
#include "../../commands/CommandFunctors.h"
#include "../../../include/audacity/Types.h"
class AudacityProject;
extern AudacityProject *GetActiveProject();
// Conditionally compile either a separate thead, or else use a timer in the main
// thread, to poll the mouse and update scrubbing speed and direction. The advantage of
@@ -123,13 +125,14 @@ public:
void PopulatePopupMenu(wxMenu &menu);
void OnScrubOrSeek(bool seek);
void OnScrub();
void OnSeek();
void OnToggleScrubRuler();
void OnScrub(const CommandContext&);
void OnSeek(const CommandContext&);
void OnToggleScrubRuler(const CommandContext&);
// Convenience wrapper for the above
template<void (Scrubber::*pfn)()> void Thunk(wxCommandEvent &dummy)
{ (this->*pfn)(); }
template<void (Scrubber::*pfn)(const CommandContext&)>
void Thunk(wxCommandEvent &dummy)
{ (this->*pfn)(*GetActiveProject()); }
// A string to put in the leftmost part of the status bar
// when scrub or seek is in progress, or else empty.