1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 16:39:30 +02:00

Uniformity of signatures of all command handler functions

This commit is contained in:
Paul Licameli 2018-01-05 10:09:23 -05:00
commit 9a58ead5c8
20 changed files with 741 additions and 754 deletions

View File

@ -1570,7 +1570,7 @@ bool AudacityApp::OnInit()
// Mainly this is to tell users of ALPHAS who don't know that they have an ALPHA.
// Disabled for now, after discussion.
// project->MayCheckForUpdates();
project->OnHelpWelcome();
project->OnHelpWelcome(*project);
}
// JKC 10-Sep-2007: Enable monitoring from the start.
@ -1663,7 +1663,7 @@ void AudacityApp::OnKeyDown(wxKeyEvent &event)
gAudioIO->GetNumCaptureChannels() == 0) ||
scrubbing)
// ESC out of other play (but not record)
project->OnStop();
project->OnStop(*project);
else
event.Skip();
}

View File

@ -611,7 +611,7 @@ bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com
if (EffectManager::Get().SetEffectParameters(ID, params))
{
// and apply the effect...
res = project->OnEffect(ID, AudacityProject::OnEffectFlags::kConfigured |
res = project->DoEffect(ID, AudacityProject::OnEffectFlags::kConfigured |
AudacityProject::OnEffectFlags::kSkipState |
AudacityProject::OnEffectFlags::kDontRepeatLast);
}

View File

@ -362,7 +362,7 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
auto success = GuardedCall< bool >( [&] {
project->Import(files[i]);
project->ZoomAfterImport(nullptr);
project->OnSelectAll();
project->OnSelectAll(*project);
if (!mBatchCommands.ApplyChain())
return false;
@ -377,10 +377,10 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
UndoManager *um = project->GetUndoManager();
um->ClearStates();
project->OnSelectAll();
project->OnRemoveTracks();
project->OnSelectAll(*project);
project->OnRemoveTracks(*project);
}
project->OnRemoveTracks();
project->OnRemoveTracks(*project);
// Under Linux an EndModal() here crashes (Bug #1221).
// But sending a close message instead is OK.

File diff suppressed because it is too large Load Diff

View File

@ -53,115 +53,115 @@ double NearestZeroCrossing(double t0);
// Selecting a tool from the keyboard
void SetTool(int tool);
void OnSelectTool();
void OnZoomTool();
void OnEnvelopeTool();
void OnTimeShiftTool();
void OnDrawTool();
void OnMultiTool();
void OnSelectTool(const CommandContext &);
void OnZoomTool(const CommandContext &);
void OnEnvelopeTool(const CommandContext &);
void OnTimeShiftTool(const CommandContext &);
void OnDrawTool(const CommandContext &);
void OnMultiTool(const CommandContext &);
void OnNextTool();
void OnPrevTool();
void OnNextTool(const CommandContext &);
void OnPrevTool(const CommandContext &);
public:
// Audio I/O Commands
void OnStop();
void OnPause();
void OnRecord();
void OnRecord2ndChoice();
void OnStopSelect();
void OnSkipStart();
void OnSkipEnd();
void OnSeekLeftShort();
void OnSeekRightShort();
void OnSeekLeftLong();
void OnSeekRightLong();
void OnStop(const CommandContext &);
void OnPause(const CommandContext &);
void OnRecord(const CommandContext &);
void OnRecord2ndChoice(const CommandContext &);
void OnStopSelect(const CommandContext &);
void OnSkipStart(const CommandContext &);
void OnSkipEnd(const CommandContext &);
void OnSeekLeftShort(const CommandContext &);
void OnSeekRightShort(const CommandContext &);
void OnSeekLeftLong(const CommandContext &);
void OnSeekRightLong(const CommandContext &);
// Different posibilities for playing sound
bool MakeReadyToPlay(bool loop = false, bool cutpreview = false); // Helper function that sets button states etc.
void OnPlayStop();
void OnPlayStop(const CommandContext &);
bool DoPlayStopSelect(bool click, bool shift);
void OnPlayStopSelect();
void OnPlayOneSecond();
void OnPlayToSelection();
void OnPlayBeforeSelectionStart();
void OnPlayAfterSelectionStart();
void OnPlayBeforeSelectionEnd();
void OnPlayAfterSelectionEnd();
void OnPlayBeforeAndAfterSelectionStart();
void OnPlayBeforeAndAfterSelectionEnd();
void OnPlayLooped();
void OnPlayCutPreview();
void OnPlayStopSelect(const CommandContext &);
void OnPlayOneSecond(const CommandContext &);
void OnPlayToSelection(const CommandContext &);
void OnPlayBeforeSelectionStart(const CommandContext &);
void OnPlayAfterSelectionStart(const CommandContext &);
void OnPlayBeforeSelectionEnd(const CommandContext &);
void OnPlayAfterSelectionEnd(const CommandContext &);
void OnPlayBeforeAndAfterSelectionStart(const CommandContext &);
void OnPlayBeforeAndAfterSelectionEnd(const CommandContext &);
void OnPlayLooped(const CommandContext &);
void OnPlayCutPreview(const CommandContext &);
// Wave track control
void OnTrackPan();
void OnTrackPanLeft();
void OnTrackPanRight();
void OnTrackGain();
void OnTrackGainInc();
void OnTrackGainDec();
void OnTrackMenu();
void OnTrackMute();
void OnTrackSolo();
void OnTrackClose();
void OnTrackMoveUp();
void OnTrackMoveDown();
void OnTrackMoveTop();
void OnTrackMoveBottom();
void OnTrackPan(const CommandContext &);
void OnTrackPanLeft(const CommandContext &);
void OnTrackPanRight(const CommandContext &);
void OnTrackGain(const CommandContext &);
void OnTrackGainInc(const CommandContext &);
void OnTrackGainDec(const CommandContext &);
void OnTrackMenu(const CommandContext &);
void OnTrackMute(const CommandContext &);
void OnTrackSolo(const CommandContext &);
void OnTrackClose(const CommandContext &);
void OnTrackMoveUp(const CommandContext &);
void OnTrackMoveDown(const CommandContext &);
void OnTrackMoveTop(const CommandContext &);
void OnTrackMoveBottom(const CommandContext &);
enum MoveChoice { OnMoveUpID, OnMoveDownID, OnMoveTopID, OnMoveBottomID };
void MoveTrack(Track* target, MoveChoice choice);
// Device control
void OnInputDevice();
void OnOutputDevice();
void OnAudioHost();
void OnInputChannels();
void OnInputDevice(const CommandContext &);
void OnOutputDevice(const CommandContext &);
void OnAudioHost(const CommandContext &);
void OnInputChannels(const CommandContext &);
// Mixer control
void OnOutputGain();
void OnInputGain();
void OnOutputGainInc();
void OnOutputGainDec();
void OnInputGainInc();
void OnInputGainDec();
void OnOutputGain(const CommandContext &);
void OnInputGain(const CommandContext &);
void OnOutputGainInc(const CommandContext &);
void OnOutputGainDec(const CommandContext &);
void OnInputGainInc(const CommandContext &);
void OnInputGainDec(const CommandContext &);
// Transcription control
void OnPlayAtSpeed();
void OnPlayAtSpeedLooped();
void OnPlayAtSpeedCutPreview();
void OnSetPlaySpeed();
void OnPlaySpeedInc();
void OnPlaySpeedDec();
void OnPlayAtSpeed(const CommandContext &);
void OnPlayAtSpeedLooped(const CommandContext &);
void OnPlayAtSpeedCutPreview(const CommandContext &);
void OnSetPlaySpeed(const CommandContext &);
void OnPlaySpeedInc(const CommandContext &);
void OnPlaySpeedDec(const CommandContext &);
// Moving track focus commands
void OnPrevTrack( bool shift );
void OnNextTrack( bool shift );
void OnCursorUp();
void OnCursorDown();
void OnFirstTrack();
void OnLastTrack();
void OnCursorUp(const CommandContext &);
void OnCursorDown(const CommandContext &);
void OnFirstTrack(const CommandContext &);
void OnLastTrack(const CommandContext &);
// Selection-Editing Commands
void OnShiftUp();
void OnShiftDown();
void OnToggle();
void OnShiftUp(const CommandContext &);
void OnShiftDown(const CommandContext &);
void OnToggle(const CommandContext &);
void HandleListSelection(Track *t, bool shift, bool ctrl, bool modifyState);
void OnCursorLeft(const wxEvent * evt);
void OnCursorRight(const wxEvent * evt);
void OnSelExtendLeft(const wxEvent * evt);
void OnSelExtendRight(const wxEvent * evt);
void OnSelContractLeft(const wxEvent * evt);
void OnSelContractRight(const wxEvent * evt);
void OnCursorLeft(const CommandContext &);
void OnCursorRight(const CommandContext &);
void OnSelExtendLeft(const CommandContext &);
void OnSelExtendRight(const CommandContext &);
void OnSelContractLeft(const CommandContext &);
void OnSelContractRight(const CommandContext &);
public:
static double OnClipMove
@ -169,127 +169,127 @@ static double OnClipMove
TrackList &trackList, bool syncLocked, bool right);
void DoClipLeftOrRight(bool right, bool keyUp );
void OnClipLeft(const wxEvent* evt);
void OnClipRight(const wxEvent* evt);
void OnClipLeft(const CommandContext &);
void OnClipRight(const CommandContext &);
void OnCursorShortJumpLeft();
void OnCursorShortJumpRight();
void OnCursorLongJumpLeft();
void OnCursorLongJumpRight();
void OnSelSetExtendLeft();
void OnSelSetExtendRight();
void OnCursorShortJumpLeft(const CommandContext &);
void OnCursorShortJumpRight(const CommandContext &);
void OnCursorLongJumpLeft(const CommandContext &);
void OnCursorLongJumpRight(const CommandContext &);
void OnSelSetExtendLeft(const CommandContext &);
void OnSelSetExtendRight(const CommandContext &);
void OnSetLeftSelection();
void OnSetRightSelection();
void OnSetLeftSelection(const CommandContext &);
void OnSetRightSelection(const CommandContext &);
void OnSelToStart();
void OnSelToEnd();
void OnSelToStart(const CommandContext &);
void OnSelToEnd(const CommandContext &);
void OnMoveToNextLabel();
void OnMoveToPrevLabel();
void OnMoveToNextLabel(const CommandContext &);
void OnMoveToPrevLabel(const CommandContext &);
void OnMoveToLabel(bool next);
void OnZeroCrossing();
void OnZeroCrossing(const CommandContext &);
void OnLockPlayRegion();
void OnUnlockPlayRegion();
void OnLockPlayRegion(const CommandContext &);
void OnUnlockPlayRegion(const CommandContext &);
double GetTime(const Track *t);
void OnSortTime();
void OnSortName();
void OnSortTime(const CommandContext &);
void OnSortName(const CommandContext &);
void OnSnapToOff();
void OnSnapToNearest();
void OnSnapToPrior();
void OnFullScreen();
void OnSnapToOff(const CommandContext &);
void OnSnapToNearest(const CommandContext &);
void OnSnapToPrior(const CommandContext &);
void OnFullScreen(const CommandContext &);
static void DoMacMinimize(AudacityProject *project);
void OnMacMinimize();
void OnMacMinimizeAll();
void OnMacZoom();
void OnMacBringAllToFront();
void OnMacMinimize(const CommandContext &);
void OnMacMinimizeAll(const CommandContext &);
void OnMacZoom(const CommandContext &);
void OnMacBringAllToFront(const CommandContext &);
// File Menu
void OnNew();
void OnOpen();
void OnClose();
void OnSave();
void OnSaveAs();
void OnNew(const CommandContext &);
void OnOpen(const CommandContext &);
void OnClose(const CommandContext &);
void OnSave(const CommandContext &);
void OnSaveAs(const CommandContext &);
#ifdef USE_LIBVORBIS
void OnSaveCompressed();
void OnSaveCompressed(const CommandContext &);
#endif
void OnCheckDependencies();
void OnCheckDependencies(const CommandContext &);
void OnExport(const wxString & Format);
void OnExportAudio();
void OnExportMp3();
void OnExportWav();
void OnExportOgg();
void OnExportSelection();
void OnExportMultiple();
void OnExportLabels();
void OnExportMIDI();
void OnExportAudio(const CommandContext &);
void OnExportMp3(const CommandContext &);
void OnExportWav(const CommandContext &);
void OnExportOgg(const CommandContext &);
void OnExportSelection(const CommandContext &);
void OnExportMultiple(const CommandContext &);
void OnExportLabels(const CommandContext &);
void OnExportMIDI(const CommandContext &);
void OnPreferences();
void OnPreferences(const CommandContext &);
void OnPageSetup();
void OnPrint();
void OnPageSetup(const CommandContext &);
void OnPrint(const CommandContext &);
void OnExit();
void OnExit(const CommandContext &);
// Edit Menu
public:
void OnUndo();
void OnRedo();
void OnUndo(const CommandContext &);
void OnRedo(const CommandContext &);
private:
static void FinishCopy(const Track *n, Track *dest);
static void FinishCopy(const Track *n, Track::Holder &&dest, TrackList &list);
public:
void OnCut();
void OnSplitCut();
void OnCopy();
void OnCut(const CommandContext &);
void OnSplitCut(const CommandContext &);
void OnCopy(const CommandContext &);
void OnPaste();
void OnPaste(const CommandContext &);
private:
bool HandlePasteText(); // Handle text paste (into active label), if any. Return true if pasted.
bool HandlePasteNothingSelected(); // Return true if nothing selected, regardless of paste result.
public:
void OnPasteNewLabel();
void OnPasteOver();
void OnTrim();
void OnPasteNewLabel(const CommandContext &);
void OnPasteOver(const CommandContext &);
void OnTrim(const CommandContext &);
void OnDelete();
void OnSplitDelete();
void OnSilence();
void OnDelete(const CommandContext &);
void OnSplitDelete(const CommandContext &);
void OnSilence(const CommandContext &);
void OnSplit();
void OnSplitNew();
void OnJoin();
void OnDisjoin();
void OnDuplicate();
void OnSplit(const CommandContext &);
void OnSplitNew(const CommandContext &);
void OnJoin(const CommandContext &);
void OnDisjoin(const CommandContext &);
void OnDuplicate(const CommandContext &);
void OnCutLabels();
void OnSplitCutLabels();
void OnCopyLabels();
void OnDeleteLabels();
void OnSplitDeleteLabels();
void OnSilenceLabels();
void OnSplitLabels();
void OnJoinLabels();
void OnDisjoinLabels();
void OnCutLabels(const CommandContext &);
void OnSplitCutLabels(const CommandContext &);
void OnCopyLabels(const CommandContext &);
void OnDeleteLabels(const CommandContext &);
void OnSplitDeleteLabels(const CommandContext &);
void OnSilenceLabels(const CommandContext &);
void OnSplitLabels(const CommandContext &);
void OnJoinLabels(const CommandContext &);
void OnDisjoinLabels(const CommandContext &);
void OnSelectTimeAndTracks(bool bAllTime, bool bAllTracks);
void OnSelectAllTime();
void OnSelectAllTracks();
void OnSelectAll();
void OnSelectSomething();
void OnSelectNone();
void OnSelectAllTime(const CommandContext &);
void OnSelectAllTracks(const CommandContext &);
void OnSelectAll(const CommandContext &);
void OnSelectSomething(const CommandContext &);
void OnSelectNone(const CommandContext &);
private:
int CountSelectedWaveTracks();
int CountSelectedTracks();
@ -298,15 +298,15 @@ public:
// For toggling of spectral seletion
double mLastF0;
double mLastF1;
void OnToggleSpectralSelection();
void OnToggleSpectralSelection(const CommandContext &);
void DoNextPeakFrequency(bool up);
void OnNextHigherPeakFrequency();
void OnNextLowerPeakFrequency();
void OnNextHigherPeakFrequency(const CommandContext &);
void OnNextLowerPeakFrequency(const CommandContext &);
#endif
void OnSelectCursorEnd();
void OnSelectStartCursor();
void OnSelectPrevClipBoundaryToCursor();
void OnSelectCursorToNextClipBoundary();
void OnSelectCursorEnd(const CommandContext &);
void OnSelectStartCursor(const CommandContext &);
void OnSelectPrevClipBoundaryToCursor(const CommandContext &);
void OnSelectCursorToNextClipBoundary(const CommandContext &);
void OnSelectClipBoundary(bool next);
struct FoundTrack {
const WaveTrack* waveTrack;
@ -325,92 +325,92 @@ FoundClip FindNextClip(const WaveTrack* wt, double t0, double t1);
FoundClip FindPrevClip(const WaveTrack* wt, double t0, double t1);
int FindClips(double t0, double t1, bool next, std::vector<FoundClip>& results);
bool ChannelsHaveSameClipBoundaries(const WaveTrack* wt);
void OnSelectPrevClip();
void OnSelectNextClip();
void OnSelectPrevClip(const CommandContext &);
void OnSelectNextClip(const CommandContext &);
void OnSelectClip(bool next);
void OnSelectCursorStoredCursor();
void OnSelectSyncLockSel();
void OnSelectCursorStoredCursor(const CommandContext &);
void OnSelectSyncLockSel(const CommandContext &);
// View Menu
void OnZoomIn();
void OnZoomOut();
// void OnZoomToggle();
void OnZoomNormal();
void OnZoomFit();
void OnZoomFitV();
void OnZoomIn(const CommandContext &);
void OnZoomOut(const CommandContext &);
// void OnZoomToggle(const CommandContext &);
void OnZoomNormal(const CommandContext &);
void OnZoomFit(const CommandContext &);
void OnZoomFitV(const CommandContext &);
void DoZoomFitV();
void OnZoomSel();
void OnGoSelStart();
void OnGoSelEnd();
void OnZoomSel(const CommandContext &);
void OnGoSelStart(const CommandContext &);
void OnGoSelEnd(const CommandContext &);
void OnExpandAllTracks();
void OnCollapseAllTracks();
void OnExpandAllTracks(const CommandContext &);
void OnCollapseAllTracks(const CommandContext &);
void OnPanTracks(float PanValue);
void OnPanLeft();
void OnPanRight();
void OnPanCenter();
void OnPanLeft(const CommandContext &);
void OnPanRight(const CommandContext &);
void OnPanCenter(const CommandContext &);
void OnMuteAllTracks();
void OnUnMuteAllTracks();
void OnMuteAllTracks(const CommandContext &);
void OnUnMuteAllTracks(const CommandContext &);
void OnShowClipping();
void OnShowExtraMenus();
void OnShowClipping(const CommandContext &);
void OnShowExtraMenus(const CommandContext &);
void OnHistory();
void OnHistory(const CommandContext &);
void OnKaraoke();
void OnMixerBoard();
void OnKaraoke(const CommandContext &);
void OnMixerBoard(const CommandContext &);
void OnPlotSpectrum();
void OnContrast();
void OnPlotSpectrum(const CommandContext &);
void OnContrast(const CommandContext &);
void OnShowTransportToolBar();
void OnShowDeviceToolBar();
void OnShowEditToolBar();
void OnShowMeterToolBar();
void OnShowRecordMeterToolBar();
void OnShowPlayMeterToolBar();
void OnShowMixerToolBar();
void OnShowSelectionToolBar();
void OnShowTransportToolBar(const CommandContext &);
void OnShowDeviceToolBar(const CommandContext &);
void OnShowEditToolBar(const CommandContext &);
void OnShowMeterToolBar(const CommandContext &);
void OnShowRecordMeterToolBar(const CommandContext &);
void OnShowPlayMeterToolBar(const CommandContext &);
void OnShowMixerToolBar(const CommandContext &);
void OnShowSelectionToolBar(const CommandContext &);
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
void OnShowSpectralSelectionToolBar();
void OnShowSpectralSelectionToolBar(const CommandContext &);
#endif
void OnShowScrubbingToolBar();
void OnShowToolsToolBar();
void OnShowTranscriptionToolBar();
void OnResetToolBars();
void OnShowScrubbingToolBar(const CommandContext &);
void OnShowToolsToolBar(const CommandContext &);
void OnShowTranscriptionToolBar(const CommandContext &);
void OnResetToolBars(const CommandContext &);
// Transport Menu
void OnSoundActivated();
void OnToggleSoundActivated();
void OnTogglePinnedHead();
void OnTogglePlayRecording();
void OnToggleSWPlaythrough();
void OnSoundActivated(const CommandContext &);
void OnToggleSoundActivated(const CommandContext &);
void OnTogglePinnedHead(const CommandContext &);
void OnTogglePlayRecording(const CommandContext &);
void OnToggleSWPlaythrough(const CommandContext &);
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
void OnToggleAutomatedInputLevelAdjustment();
void OnToggleAutomatedInputLevelAdjustment(const CommandContext &);
#endif
void OnRescanDevices();
void OnRescanDevices(const CommandContext &);
// Import Submenu
void OnImport();
void OnImportLabels();
void OnImportMIDI();
void OnImport(const CommandContext &);
void OnImportLabels(const CommandContext &);
void OnImportMIDI(const CommandContext &);
// return null on failure; if success, return the given project, or a NEW
// one, if the given was null; create no NEW project if failure
static AudacityProject *DoImportMIDI(
AudacityProject *pProject, const wxString &fileName);
void OnImportRaw();
void OnImportRaw(const CommandContext &);
void OnEditMetadata();
void OnEditMetadata(const CommandContext &);
bool DoEditMetadata(const wxString &title, const wxString &shortUndoDescription, bool force);
void OnMixAndRender();
void OnMixAndRenderToNewTrack();
void OnMixAndRender(const CommandContext &);
void OnMixAndRenderToNewTrack(const CommandContext &);
void HandleMixAndRender(bool toNewTrack);
private:
@ -418,15 +418,15 @@ private:
bool mCursorPositionHasBeenStored{false};
double mCursorPositionStored;
public:
void OnSelectionSave();
void OnSelectionRestore();
void OnCursorPositionStore();
void OnSelectionSave(const CommandContext &);
void OnSelectionRestore(const CommandContext &);
void OnCursorPositionStore(const CommandContext &);
void OnCursorTrackStart();
void OnCursorTrackEnd();
void OnCursorSelStart();
void OnCursorSelEnd();
struct FoundClipBoundary : FoundTrack {
void OnCursorTrackStart(const CommandContext &);
void OnCursorTrackEnd(const CommandContext &);
void OnCursorSelStart(const CommandContext &);
void OnCursorSelEnd(const CommandContext &);
struct FoundClipBoundary : FoundTrack {
int nFound; // 0, 1, or 2
double time;
int index1;
@ -439,35 +439,35 @@ FoundClipBoundary FindPrevClipBoundary(const WaveTrack* wt, double time);
double AdjustForFindingStartTimes(const std::vector<const WaveClip*>& clips, double time);
double AdjustForFindingEndTimes(const std::vector<const WaveClip*>& clips, double time);
int FindClipBoundaries(double time, bool next, std::vector<FoundClipBoundary>& results);
void OnCursorNextClipBoundary();
void OnCursorPrevClipBoundary();
void OnCursorNextClipBoundary(const CommandContext &);
void OnCursorPrevClipBoundary(const CommandContext &);
void OnCursorClipBoundary(bool next);
static wxString ClipBoundaryMessage(const std::vector<FoundClipBoundary>& results);
void OnAlignNoSync(int index);
void OnAlign(int index);
void OnAlignNoSync(const CommandContext &);
void OnAlign(const CommandContext &);
//void OnAlignMoveSel(int index);
void HandleAlign(int index, bool moveSel);
size_t mAlignLabelsCount;
#ifdef EXPERIMENTAL_SCOREALIGN
void OnScoreAlign();
void OnScoreAlign(const CommandContext &);
#endif // EXPERIMENTAL_SCOREALIGN
// Tracks menu
void OnNewWaveTrack();
void OnNewStereoTrack();
void OnNewLabelTrack();
void OnNewTimeTrack();
void OnTimerRecord();
void OnRemoveTracks();
void OnMoveSelectionWithTracks();
void OnSyncLock();
void OnAddLabel();
void OnAddLabelPlaying();
void OnNewWaveTrack(const CommandContext &);
void OnNewStereoTrack(const CommandContext &);
void OnNewLabelTrack(const CommandContext &);
void OnNewTimeTrack(const CommandContext &);
void OnTimerRecord(const CommandContext &);
void OnRemoveTracks(const CommandContext &);
void OnMoveSelectionWithTracks(const CommandContext &);
void OnSyncLock(const CommandContext &);
void OnAddLabel(const CommandContext &);
void OnAddLabelPlaying(const CommandContext &);
void DoEditLabels(LabelTrack *lt = nullptr, int index = -1);
void OnEditLabels();
void OnToggleTypeToCreateLabel();
void OnEditLabels(const CommandContext &);
void OnToggleTypeToCreateLabel(const CommandContext &);
// Effect Menu
@ -484,52 +484,53 @@ public:
static const int kDontRepeatLast = 0x04;
};
bool OnEffect(const PluginID & ID, int flags = OnEffectFlags::kNone);
void OnRepeatLastEffect(int index);
void OnApplyChain();
void OnEditChains();
void OnStereoToMono(int index);
bool DoEffect(const PluginID & ID, int flags);
void OnEffect(const CommandContext &);
void OnRepeatLastEffect(const CommandContext &);
void OnApplyChain(const CommandContext &);
void OnEditChains(const CommandContext &);
void OnStereoToMono(const CommandContext &);
void OnManagePluginsMenu(EffectType Type);
static void RebuildAllMenuBars();
void OnManageGenerators();
void OnManageEffects();
void OnManageAnalyzers();
void OnManageGenerators(const CommandContext &);
void OnManageEffects(const CommandContext &);
void OnManageAnalyzers(const CommandContext &);
// Help Menu
void OnAbout();
void OnQuickHelp();
void OnManual();
void OnCheckForUpdates();
void OnAbout(const CommandContext &);
void OnQuickHelp(const CommandContext &);
void OnManual(const CommandContext &);
void OnCheckForUpdates(const CommandContext &);
void MayCheckForUpdates();
void OnShowLog();
void OnHelpWelcome();
void OnBenchmark();
void OnShowLog(const CommandContext &);
void OnHelpWelcome(const CommandContext &);
void OnBenchmark(const CommandContext &);
#if defined(EXPERIMENTAL_CRASH_REPORT)
void OnCrashReport();
void OnCrashReport(const CommandContext &);
#endif
void OnScreenshot();
void OnAudioDeviceInfo();
void OnScreenshot(const CommandContext &);
void OnAudioDeviceInfo(const CommandContext &);
#ifdef EXPERIMENTAL_MIDI_OUT
void OnMidiDeviceInfo();
void OnMidiDeviceInfo(const CommandContext &);
#endif
//
void OnSeparator();
void OnSeparator(const CommandContext &);
// Keyboard navigation
void NextOrPrevFrame(bool next);
void PrevFrame();
void NextFrame();
void PrevFrame(const CommandContext &);
void NextFrame(const CommandContext &);
void PrevWindow();
void NextWindow();
void PrevWindow(const CommandContext &);
void NextWindow(const CommandContext &);
void OnResample();
void OnResample(const CommandContext &);
private:
void OnCursorLeft(bool shift, bool ctrl, bool keyup = false);

View File

@ -45,19 +45,19 @@ void AudacityProject::DoMacMinimize(AudacityProject *project)
}
}
void AudacityProject::OnMacMinimize()
void AudacityProject::OnMacMinimize(const CommandContext &)
{
DoMacMinimize(this);
}
void AudacityProject::OnMacMinimizeAll()
void AudacityProject::OnMacMinimizeAll(const CommandContext &)
{
for (const auto project : gAudacityProjects) {
DoMacMinimize(project.get());
}
}
void AudacityProject::OnMacZoom()
void AudacityProject::OnMacZoom(const CommandContext &)
{
auto window = this;
auto topWindow = static_cast<wxTopLevelWindow*>(window);
@ -77,7 +77,7 @@ void AudacityProject::OnMacZoom()
}
}
void AudacityProject::OnMacBringAllToFront()
void AudacityProject::OnMacBringAllToFront(const CommandContext &)
{
// Reall this de-miniaturizes all, which is not exactly the standard
// behavior.

View File

@ -2319,7 +2319,7 @@ bool AudacityProject::TryToMakeActionAllowed
// This was 'OnSelectAll'. Changing it to OnSelectSomething means if
// selecting all tracks is enough, we just do that.
OnSelectSomething();
OnSelectSomething(*this);
flags = GetUpdateFlags();
bAllowed = ((flags & mask) == (flagsRqd & mask));
return bAllowed;
@ -3235,7 +3235,7 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory)
mTrackPanel->Refresh(true);
*/
closed = true;
this->OnClose();
this->OnClose(*this);
return;
}
else if (status & FSCKstatus_CHANGED)
@ -4217,7 +4217,7 @@ void AudacityProject::AddImportedTracks(const wxString &fileName,
void AudacityProject::ZoomAfterImport(Track *pTrack)
{
OnZoomFit();
OnZoomFit(*this);
mTrackPanel->SetFocus();
RedrawProject();
@ -4289,7 +4289,7 @@ bool AudacityProject::Import(const wxString &fileName, WaveTrackArray* pTrackArr
//TODO: All we want is a SelectAll()
SelectNone();
SelectAllIfNone();
OnEffect(EffectManager::Get().GetEffectByIdentifier(wxT("Normalize")),
DoEffect(EffectManager::Get().GetEffectByIdentifier(wxT("Normalize")),
OnEffectFlags::kConfigured);
}
@ -5373,7 +5373,7 @@ void AudacityProject::OnAudioIOStopRecording()
// Reset timer record
if (IsTimerRecordCancelled())
{
OnUndo();
OnUndo(*this);
ResetTimerRecordFlag();
}

View File

@ -517,7 +517,7 @@ int TimerRecordDialog::RunWaitDialog()
return POST_TIMER_RECORD_CANCEL_WAIT;
} else {
// Record for specified time.
pProject->OnRecord();
pProject->OnRecord(*pProject);
bool bIsRecording = true;
wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection());
@ -563,7 +563,7 @@ int TimerRecordDialog::RunWaitDialog()
// Must do this AFTER the timer project dialog has been deleted to ensure the application
// responds to the AUDIOIO events...see not about bug #334 in the ProgressDialog constructor.
pProject->OnStop();
pProject->OnStop(*pProject);
// Let the caller handle cancellation or failure from recording progress.
if (updateResult == ProgressResult::Cancelled || updateResult == ProgressResult::Failed)

View File

@ -13,140 +13,52 @@
#include <wx/event.h>
#include "../MemoryX.h"
class AudacityProject;
class wxEvtHandler;
// Base class for objects, to whose member functions, the CommandManager will
// dispatch.
//
// It, or a subclass of it, must be the first base class of the object, and the
// first base class of that base class, etc., for the same reason that
// wxEvtHandler must be first (that is, the downcast from a pointer to the base
// to a pointer to the object, must be a vacuous operation).
//
// In fact, then, we just make it an alias of wxEvtHandler, in case you really
// need to inherit from wxEvtHandler for other reasons, and otherwise you
// couldn't satisfy the requirement for both base classes at once.
using CommandHandlerObject = wxEvtHandler;
// First of two function pointers registered with each command: an extractor
// of the handler object from the AudacityProject
using CommandHandlerFinder = CommandHandlerObject &(*)(AudacityProject&);
class wxEvent;
typedef wxString PluginID;
class AUDACITY_DLL_API CommandFunctor /* not final */
{
public:
CommandFunctor(){};
virtual ~CommandFunctor(){};
virtual void operator()(int index, const wxEvent *e) = 0;
using CommandParameter = wxString;
struct CommandContext {
CommandContext(
AudacityProject &p
, const wxEvent *e = nullptr
, int ii = 0
, const CommandParameter &param = {}
)
: project{ p }
, pEvt{ e }
, index{ ii }
, parameter{ param }
{}
AudacityProject &project;
const wxEvent *pEvt;
int index;
CommandParameter parameter;
};
using CommandFunctorPointer = std::shared_ptr <CommandFunctor>;
// Define functor subclasses that dispatch to the correct call sequence on
// member functions of AudacityProject (or other class!)
template<typename OBJ>
using audCommandFunction = void (OBJ::*)();
template<typename OBJ>
class VoidFunctor final : public CommandFunctor
{
public:
explicit VoidFunctor(OBJ *This, audCommandFunction<OBJ> pfn)
: mThis{ This }, mCommandFunction{ pfn } {}
void operator () (int, const wxEvent *) override
{ (mThis->*mCommandFunction) (); }
private:
OBJ *const mThis;
const audCommandFunction<OBJ> mCommandFunction;
};
template<typename OBJ>
using audCommandKeyFunction = void (OBJ::*)(const wxEvent *);
template<typename OBJ>
class KeyFunctor final : public CommandFunctor
{
public:
explicit KeyFunctor(OBJ *This, audCommandKeyFunction<OBJ> pfn)
: mThis{ This }, mCommandKeyFunction{ pfn } {}
void operator () (int, const wxEvent *evt) override
{ (mThis->*mCommandKeyFunction) (evt); }
private:
OBJ *const mThis;
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);
template<typename OBJ>
class ListFunctor final : public CommandFunctor
{
public:
explicit ListFunctor(OBJ *This, audCommandListFunction<OBJ> pfn)
: mThis{ This }, mCommandListFunction{ pfn } {}
void operator () (int index, const wxEvent *) override
{ (mThis->*mCommandListFunction)(index); }
private:
OBJ *const mThis;
const audCommandListFunction<OBJ> mCommandListFunction;
};
template<typename OBJ>
using audCommandPluginFunction = bool (OBJ::*)(const PluginID &, int);
template<typename OBJ>
class PluginFunctor final : public CommandFunctor
{
public:
explicit PluginFunctor(OBJ *This, const PluginID &id, audCommandPluginFunction<OBJ> pfn)
: mPluginID{ id }, mThis{ This }, mCommandPluginFunction{ pfn } {}
void operator () (int, const wxEvent *) override
{ (mThis->*mCommandPluginFunction)
(mPluginID,
0 // AudacityProject::OnEffectFlags::kNone
); }
private:
const PluginID mPluginID;
OBJ *const mThis;
const audCommandPluginFunction<OBJ> mCommandPluginFunction;
};
// Now define an overloaded factory function
template<typename OBJ>
inline CommandFunctorPointer MakeFunctor(OBJ *This,
audCommandFunction<OBJ> pfn)
{ return CommandFunctorPointer{ safenew VoidFunctor<OBJ>{ This, pfn } }; }
template<typename OBJ>
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)
{ return CommandFunctorPointer{ safenew ListFunctor<OBJ>{ This, pfn } }; }
template<typename OBJ>
inline CommandFunctorPointer MakeFunctor(OBJ *This, const PluginID &id,
audCommandPluginFunction<OBJ> pfn)
{ return CommandFunctorPointer{ safenew PluginFunctor<OBJ>{ This, id, pfn } }; }
// Now define the macro abbreviations that call the factory
#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 FNS(X, S) FNTS(AudacityProject, this, & AudacityProject :: X, S)
// Second of two function pointers registered with each command: a pointer
// to a member function of the handler object
using CommandFunctorPointer =
void (CommandHandlerObject::*)(const CommandContext &);
#endif

View File

@ -694,7 +694,8 @@ void CommandManager::ClearCurrentMenu()
/// given functor will be called
void CommandManager::InsertItem(const wxString & name,
const wxString & label_in,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxString & after,
int checkmark)
{
@ -744,7 +745,7 @@ void CommandManager::InsertItem(const wxString & name,
}
}
CommandListEntry *entry = NewIdentifier(name, label_in, menu, callback, false, 0, 0);
CommandListEntry *entry = NewIdentifier(name, label_in, menu, finder, callback, false, 0, 0);
int ID = entry->id;
wxString label = GetLabel(entry);
@ -763,40 +764,49 @@ void CommandManager::InsertItem(const wxString & name,
void CommandManager::AddCheck(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
int checkmark)
{
AddItem(name, label, callback, wxT(""), NoFlagsSpecifed, NoFlagsSpecifed, checkmark);
AddItem(name, label, finder, callback, wxT(""),
NoFlagsSpecifed, NoFlagsSpecifed, checkmark);
}
void CommandManager::AddCheck(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
int checkmark,
CommandFlag flags,
CommandMask mask)
{
AddItem(name, label, callback, wxT(""), flags, mask, checkmark);
AddItem(name, label, finder, callback, wxT(""), flags, mask, checkmark);
}
void CommandManager::AddItem(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
CommandFlag flags,
CommandMask mask)
CommandMask mask,
const CommandParameter &parameter)
{
AddItem(name, label, callback, wxT(""), flags, mask);
AddItem(name, label, finder, callback, wxT(""), flags, mask, -1, parameter);
}
void CommandManager::AddItem(const wxChar *name,
const wxChar *label_in,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxChar *accel,
CommandFlag flags,
CommandMask mask,
int checkmark)
int checkmark,
const CommandParameter &parameter)
{
CommandListEntry *entry = NewIdentifier(name, label_in, accel, CurrentMenu(), callback, false, 0, 0);
CommandListEntry *entry =
NewIdentifier(name, label_in, accel, CurrentMenu(), finder, callback,
false, 0, 0, parameter);
int ID = entry->id;
wxString label = GetLabelWithDisabledAccel(entry);
@ -824,12 +834,14 @@ void CommandManager::AddItem(const wxChar *name,
/// all of the items at once.
void CommandManager::AddItemList(const wxString & name,
const wxArrayString & labels,
const CommandFunctorPointer &callback)
CommandHandlerFinder finder,
CommandFunctorPointer callback)
{
for (size_t i = 0, cnt = labels.GetCount(); i < cnt; i++) {
CommandListEntry *entry = NewIdentifier(name,
labels[i],
CurrentMenu(),
finder,
callback,
true,
i,
@ -844,21 +856,23 @@ void CommandManager::AddItemList(const wxString & name,
/// given function pointer will be called (via the CommandManagerListener)
void CommandManager::AddCommand(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
CommandFlag flags,
CommandMask mask)
{
AddCommand(name, label, callback, wxT(""), flags, mask);
AddCommand(name, label, finder, callback, wxT(""), flags, mask);
}
void CommandManager::AddCommand(const wxChar *name,
const wxChar *label_in,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxChar *accel,
CommandFlag flags,
CommandMask mask)
{
NewIdentifier(name, label_in, accel, NULL, callback, false, 0, 0);
NewIdentifier(name, label_in, accel, NULL, finder, callback, false, 0, 0, {});
if (flags != NoFlagsSpecifed || mask != NoFlagsSpecifed) {
SetCommandFlags(name, flags, mask);
@ -867,10 +881,13 @@ void CommandManager::AddCommand(const wxChar *name,
void CommandManager::AddGlobalCommand(const wxChar *name,
const wxChar *label_in,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxChar *accel)
{
CommandListEntry *entry = NewIdentifier(name, label_in, accel, NULL, callback, false, 0, 0);
CommandListEntry *entry =
NewIdentifier(name, label_in, accel, NULL, finder, callback,
false, 0, 0, {});
entry->enabled = false;
entry->isGlobal = true;
@ -904,7 +921,8 @@ int CommandManager::NextIdentifier(int ID)
CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
const wxString & label,
wxMenu *menu,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
int index,
int count)
@ -913,20 +931,23 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
label.BeforeFirst(wxT('\t')),
label.AfterFirst(wxT('\t')),
menu,
finder,
callback,
multi,
index,
count);
count, {});
}
CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
const wxString & label,
const wxString & accel,
wxMenu *menu,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
int index,
int count)
int count,
const CommandParameter &parameter)
{
// If we have the identifier already, reuse it.
CommandListEntry *prev = mCommandNameHash[name];
@ -956,6 +977,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
mCurrentID = NextIdentifier(mCurrentID);
entry->id = mCurrentID;
entry->parameter = parameter;
#if defined(__WXMAC__)
if (name == wxT("Preferences"))
@ -973,6 +995,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
entry->labelPrefix = labelPrefix;
entry->labelTop = wxMenuItem::GetLabelText(mCurrentMenuName);
entry->menu = menu;
entry->finder = finder;
entry->callback = callback;
entry->multi = multi;
entry->index = index;
@ -1447,11 +1470,11 @@ bool CommandManager::HandleCommandEntry(const CommandListEntry * entry,
if (!entry || !entry->enabled)
return false;
auto proj = GetActiveProject();
auto combinedMask = (mask & entry->mask);
if (combinedMask) {
AudacityProject * proj;
proj = GetActiveProject();
wxASSERT( proj );
if( !proj )
return false;
@ -1469,7 +1492,9 @@ bool CommandManager::HandleCommandEntry(const CommandListEntry * entry,
return true;
}
(*(entry->callback))(entry->index, evt);
CommandContext context{ *proj, evt, entry->index, entry->parameter };
auto &handler = entry->finder(*proj);
(handler.*(entry->callback))(context);
return true;
}
@ -1536,7 +1561,7 @@ bool CommandManager::HandleTextualCommand(const wxString & Str, CommandFlag flag
{
if (em.GetEffectIdentifier(plug->GetID()).IsSameAs(Str))
{
return proj->OnEffect(plug->GetID(), AudacityProject::OnEffectFlags::kConfigured);
return proj->DoEffect(plug->GetID(), AudacityProject::OnEffectFlags::kConfigured);
}
plug = pm.GetNextPlugin(PluginTypeEffect);
}

View File

@ -64,7 +64,9 @@ struct CommandListEntry
wxString labelPrefix;
wxString labelTop;
wxMenu *menu;
CommandHandlerFinder finder;
CommandFunctorPointer callback;
CommandParameter parameter;
bool multi;
int index;
int count;
@ -124,39 +126,47 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
void InsertItem(const wxString & name,
const wxString & label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxString & after,
int checkmark = -1);
void AddItemList(const wxString & name,
const wxArrayString & labels,
const CommandFunctorPointer &callback);
CommandHandlerFinder finder,
CommandFunctorPointer callback);
void AddCheck(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
int checkmark = 0);
void AddCheck(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
int checkmark,
CommandFlag flags,
CommandMask mask);
void AddItem(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
CommandFlag flags = NoFlagsSpecifed,
CommandMask mask = NoFlagsSpecifed);
CommandMask mask = NoFlagsSpecifed,
const CommandParameter &parameter = {});
void AddItem(const wxChar *name,
const wxChar *label_in,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxChar *accel,
CommandFlag flags = NoFlagsSpecifed,
CommandMask mask = NoFlagsSpecifed,
int checkmark = -1);
int checkmark = -1,
const CommandParameter &parameter = {});
void AddSeparator();
@ -164,20 +174,23 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
// keyboard shortcut.
void AddCommand(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
CommandFlag flags = NoFlagsSpecifed,
CommandMask mask = NoFlagsSpecifed);
void AddCommand(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxChar *accel,
CommandFlag flags = NoFlagsSpecifed,
CommandMask mask = NoFlagsSpecifed);
void AddGlobalCommand(const wxChar *name,
const wxChar *label,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
const wxChar *accel);
//
// Command masks
@ -282,7 +295,8 @@ protected:
CommandListEntry *NewIdentifier(const wxString & name,
const wxString & label,
wxMenu *menu,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
int index,
int count);
@ -290,10 +304,12 @@ protected:
const wxString & label,
const wxString & accel,
wxMenu *menu,
const CommandFunctorPointer &callback,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
int index,
int count);
int count,
const CommandParameter &parameter);
//
// Executing commands

View File

@ -44,7 +44,8 @@ bool OpenProjectCommand::Apply(CommandExecutionContext context)
wxString oldFileName = context.GetProject()->GetFileName();
if(fileName == wxEmptyString)
{
context.GetProject()->OnOpen();
auto project = context.GetProject();
project->OnOpen(*project);
}
else
{

View File

@ -61,12 +61,14 @@ bool SelectCommand::Apply(CommandExecutionContext context)
if (mode.IsSameAs(wxT("None")))
{
// select none
context.GetProject()->OnSelectNone();
auto project = context.GetProject();
project->OnSelectNone(*project);
}
else if (mode.IsSameAs(wxT("All")))
{
// select all
context.GetProject()->OnSelectAll();
auto project = context.GetProject();
project->OnSelectAll(*project);
}
else if (mode.IsSameAs(wxT("Range")))
{

View File

@ -765,7 +765,7 @@ bool Effect::Apply()
// This is absolute hackage...but easy and I can't think of another way just now.
//
// It should callback to the EffectManager to kick off the processing
return GetActiveProject()->OnEffect(GetID(), AudacityProject::OnEffectFlags::kConfigured);
return GetActiveProject()->DoEffect(GetID(), AudacityProject::OnEffectFlags::kConfigured);
}
void Effect::Preview()

View File

@ -26,7 +26,6 @@
#include "../Project.h"
#include "../BatchCommandDialog.h"
#include "../ShuttleGui.h"
#include "../Menus.h"
#include "../toolbars/ToolManager.h"
BEGIN_EVENT_TABLE(BatchPrefs, PrefsPanel)

View File

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

View File

@ -224,7 +224,7 @@ namespace {
wxString label;
wxString status;
CommandFlag flags;
void (Scrubber::*memFn)(wxCommandEvent&);
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(wxCommandEvent&)
void Scrubber::OnScrub(const CommandContext&)
{
OnScrubOrSeek(false);
CheckMenuItems();
}
void Scrubber::OnSeek(wxCommandEvent&)
void Scrubber::OnSeek(const CommandContext&)
{
OnScrubOrSeek(true);
CheckMenuItems();
}
void Scrubber::OnToggleScrubRuler(wxCommandEvent&)
void Scrubber::OnToggleScrubRuler(const CommandContext&)
{
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)
@ -1000,6 +1002,10 @@ bool Scrubber::CanScrub() const
return cm->GetEnabled(menuItems[ 0 ].name);
}
// To supply the "finder" argument
static CommandHandlerObject &findme(AudacityProject &project)
{ return project.GetScrubber(); }
void Scrubber::AddMenuItems()
{
auto cm = mProject->GetCommandManager();
@ -1008,13 +1014,13 @@ void Scrubber::AddMenuItems()
for (const auto &item : menuItems) {
if (item.StatusTest)
cm->AddCheck(item.name, wxGetTranslation(item.label),
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),
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,9 +125,14 @@ public:
void PopulatePopupMenu(wxMenu &menu);
void OnScrubOrSeek(bool seek);
void OnScrub(wxCommandEvent&);
void OnSeek(wxCommandEvent&);
void OnToggleScrubRuler(wxCommandEvent&);
void OnScrub(const CommandContext&);
void OnSeek(const CommandContext&);
void OnToggleScrubRuler(const CommandContext&);
// Convenience wrapper for the above
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.

View File

@ -150,7 +150,8 @@ void MultiDialog::OnOK(wxCommandEvent & WXUNUSED(event))
void MultiDialog::OnShowLog(wxCommandEvent & WXUNUSED(event))
{
GetActiveProject()->OnShowLog();
auto project = GetActiveProject();
project->OnShowLog(*project);
}

View File

@ -89,7 +89,6 @@ array of Ruler::Label.
#include "../TimeTrack.h"
#include "../TrackPanel.h"
#include "../TrackPanelCellIterator.h"
#include "../Menus.h"
#include "../NumberScale.h"
#include "../Prefs.h"
#include "../Snap.h"
@ -2415,7 +2414,7 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
bool switchToQP = (zone == StatusChoice::EnteringQP && mQuickPlayEnabled);
if (switchToQP && evt.LeftDown()) {
// We can't stop scrubbing yet (see comments in Bug 1391), but we can pause it.
mProject->OnPause();
mProject->OnPause(*mProject);
// Don't return, fall through
}
else if (scrubber.IsPaused())
@ -2554,7 +2553,7 @@ void AdornedRulerPanel::HandleQPClick(wxMouseEvent &evt, wxCoord mousePosX)
// Temporarily unlock locked play region
if (mPlayRegionLock && evt.LeftDown()) {
//mPlayRegionLock = true;
mProject->OnUnlockPlayRegion();
mProject->OnUnlockPlayRegion(*mProject);
}
mLeftDownClickUnsnapped = mQuickPlayPosUnsnapped;
@ -2734,7 +2733,7 @@ void AdornedRulerPanel::HandleQPRelease(wxMouseEvent &evt)
if (mPlayRegionLock) {
// Restore Locked Play region
SetPlayRegion(mOldPlayRegionStart, mOldPlayRegionEnd);
mProject->OnLockPlayRegion();
mProject->OnLockPlayRegion(*mProject);
// and release local lock
mPlayRegionLock = false;
}
@ -2845,10 +2844,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(*mProject);
}
void AdornedRulerPanel::OnToggleScrubRuler(/*wxCommandEvent&*/)
@ -2903,7 +2902,7 @@ void AdornedRulerPanel::UpdateButtonStates()
void AdornedRulerPanel::OnTogglePinnedState(wxCommandEvent & /*event*/)
{
mProject->OnTogglePinnedHead();
mProject->OnTogglePinnedHead(*mProject);
UpdateButtonStates();
}
@ -3042,9 +3041,9 @@ void AdornedRulerPanel::OnAutoScroll(wxCommandEvent&)
void AdornedRulerPanel::OnLockPlayRegion(wxCommandEvent&)
{
if (mProject->IsPlayRegionLocked())
mProject->OnUnlockPlayRegion();
mProject->OnUnlockPlayRegion(*mProject);
else
mProject->OnLockPlayRegion();
mProject->OnLockPlayRegion(*mProject);
}