From ad8fafa6a0902f17bbbbb81b169439b883c704b3 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 17 Feb 2018 15:31:18 -0500 Subject: [PATCH] History window listens for events --- src/HistoryWindow.cpp | 9 ++++++++- src/HistoryWindow.h | 2 +- src/Project.cpp | 9 --------- src/menus/EditMenus.cpp | 16 ---------------- src/menus/ViewMenus.cpp | 1 - 5 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 0f0b1d9ce..6419ac540 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -31,6 +31,7 @@ undo memory so as to free up space. #include #include "AudioIO.h" +#include "AudacityApp.h" #include "../images/Arrow.xpm" #include "../images/Empty9x16.xpm" #include "HistoryWindow.h" @@ -154,6 +155,11 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, &HistoryWindow::OnAudioIO, this); + + wxTheApp->Bind(EVT_CLIPBOARD_CHANGE, &HistoryWindow::UpdateDisplay, this); + manager->Bind(EVT_UNDO_PUSHED, &HistoryWindow::UpdateDisplay, this); + manager->Bind(EVT_UNDO_MODIFIED, &HistoryWindow::UpdateDisplay, this); + manager->Bind(EVT_UNDO_RESET, &HistoryWindow::UpdateDisplay, this); } void HistoryWindow::OnAudioIO(wxCommandEvent& evt) @@ -168,8 +174,9 @@ void HistoryWindow::OnAudioIO(wxCommandEvent& evt) mDiscard->Enable(!mAudioIOBusy); } -void HistoryWindow::UpdateDisplay() +void HistoryWindow::UpdateDisplay(wxEvent& e) { + e.Skip(); if(IsShown()) DoUpdate(); } diff --git a/src/HistoryWindow.h b/src/HistoryWindow.h index 7b4f17a78..f4a15b6de 100644 --- a/src/HistoryWindow.h +++ b/src/HistoryWindow.h @@ -29,7 +29,7 @@ class HistoryWindow final : public wxDialogWrapper { public: HistoryWindow(AudacityProject * parent, UndoManager *manager); - void UpdateDisplay(); + void UpdateDisplay(wxEvent &e); private: void OnAudioIO(wxCommandEvent & evt); diff --git a/src/Project.cpp b/src/Project.cpp index fb7c9beac..6832d4f2c 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -4591,9 +4591,6 @@ void AudacityProject::InitialState() GetUndoManager()->StateSaved(); - if (mHistoryWindow) - mHistoryWindow->UpdateDisplay(); - GetMenuManager(*this).ModifyUndoMenuItems(*this); GetMenuManager(*this).UpdateMenus(*this); @@ -4629,9 +4626,6 @@ void AudacityProject::PushState(const wxString &desc, mDirty = true; - if (mHistoryWindow) - mHistoryWindow->UpdateDisplay(); - GetMenuManager(*this).ModifyUndoMenuItems(*this); GetMenuManager(*this).UpdateMenus(*this); @@ -5236,9 +5230,6 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action ) msClipT0 = regions.front().start; msClipT1 = regions.back().end; - - if (mHistoryWindow) - mHistoryWindow->UpdateDisplay(); } diff --git a/src/menus/EditMenus.cpp b/src/menus/EditMenus.cpp index 14461ee13..35059b060 100644 --- a/src/menus/EditMenus.cpp +++ b/src/menus/EditMenus.cpp @@ -1,6 +1,5 @@ #include "../AdornedRulerPanel.h" #include "../AudacityApp.h" // for EVT_CLIPBOARD_CHANGE -#include "../HistoryWindow.h" #include "../LabelTrack.h" #include "../Menus.h" #include "../MixerBoard.h" @@ -240,9 +239,6 @@ void DoUndo(AudacityProject &project) project.RedrawProject(); - if (historyWindow) - historyWindow->UpdateDisplay(); - if (mixerBoard) // Mixer board may need to change for selection state and pan/gain mixerBoard->Refresh(); @@ -283,9 +279,6 @@ void OnRedo(const CommandContext &context) project.RedrawProject(); - if (historyWindow) - historyWindow->UpdateDisplay(); - if (mixerBoard) // Mixer board may need to change for selection state and pan/gain mixerBoard->Refresh(); @@ -377,9 +370,6 @@ void OnCut(const CommandContext &context) ruler->DrawOverlays( true ); project.RedrawProject(); - - if (historyWindow) - historyWindow->UpdateDisplay(); } void OnDelete(const CommandContext &context) @@ -424,9 +414,6 @@ void OnCopy(const CommandContext &context) //Make sure the menus/toolbar states get updated trackPanel->Refresh(false); - - if (historyWindow) - historyWindow->UpdateDisplay(); } void OnPaste(const CommandContext &context) @@ -766,9 +753,6 @@ void OnSplitCut(const CommandContext &context) project.PushState(_("Split-cut to the clipboard"), _("Split Cut")); project.RedrawProject(); - - if (historyWindow) - historyWindow->UpdateDisplay(); } void OnSplitDelete(const CommandContext &context) diff --git a/src/menus/ViewMenus.cpp b/src/menus/ViewMenus.cpp index f76974fe3..e2b2acc41 100644 --- a/src/menus/ViewMenus.cpp +++ b/src/menus/ViewMenus.cpp @@ -191,7 +191,6 @@ void OnHistory(const CommandContext &context) auto historyWindow = project.GetHistoryWindow(true); historyWindow->Show(); historyWindow->Raise(); - historyWindow->UpdateDisplay(); } void OnKaraoke(const CommandContext &context)