From 20ace313fab492b22809b73471a87e6483498b76 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Sun, 14 Feb 2021 01:25:52 -0600 Subject: [PATCH] Bug 1872 - Most Non-Modal dialogs do not update buttons when language changed --- src/AudacityLogger.cpp | 13 ++++++ src/AudacityLogger.h | 9 ++++- src/BatchProcessDialog.cpp | 20 ++++++---- src/BatchProcessDialog.h | 8 +++- src/FreqWindow.cpp | 81 +++++++++++++++++++++++++++++++------- src/FreqWindow.h | 9 ++++- src/HistoryWindow.cpp | 69 ++++++++++++++++++++++---------- src/HistoryWindow.h | 10 ++++- src/LyricsWindow.cpp | 35 ++++++++++++---- src/LyricsWindow.h | 11 +++++- src/MixerBoard.cpp | 31 ++++++++++++--- src/MixerBoard.h | 3 ++ src/Screenshot.cpp | 59 ++++++++++++++++++--------- 13 files changed, 279 insertions(+), 79 deletions(-) diff --git a/src/AudacityLogger.cpp b/src/AudacityLogger.cpp index ed9113035..68d7401a7 100644 --- a/src/AudacityLogger.cpp +++ b/src/AudacityLogger.cpp @@ -294,3 +294,16 @@ void AudacityLogger::OnSave(wxCommandEvent & WXUNUSED(e)) } } +void AudacityLogger::UpdatePrefs() +{ + if (mFrame) { + bool shown = mFrame->IsShown(); + if (shown) { + Show(false); + } + mFrame.reset(); + if (shown) { + Show(true); + } + } +} \ No newline at end of file diff --git a/src/AudacityLogger.h b/src/AudacityLogger.h index 42eec016c..1d5d35626 100644 --- a/src/AudacityLogger.h +++ b/src/AudacityLogger.h @@ -19,13 +19,17 @@ #include "Experimental.h" #include "MemoryX.h" +#include "Prefs.h" #include // to inherit #include // to inherit wxEvtHandler class wxFrame; class wxTextCtrl; -class AudacityLogger final : public wxEvtHandler, public wxLog { +class AudacityLogger final : public wxEvtHandler, + public wxLog, + public PrefsListener +{ public: // Get the singleton instance or null @@ -52,6 +56,9 @@ class AudacityLogger final : public wxEvtHandler, public wxLog { void OnClear(wxCommandEvent & e); void OnSave(wxCommandEvent & e); + // PrefsListener implementation + void UpdatePrefs() override; + Destroy_ptr mFrame; wxTextCtrl *mText; wxString mBuffer; diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp index fc05e62b1..9e3d729ee 100644 --- a/src/BatchProcessDialog.cpp +++ b/src/BatchProcessDialog.cpp @@ -66,6 +66,9 @@ #include "widgets/WindowAccessible.h" #endif +#define MacrosPaletteTitle XO("Macros Palette") +#define ManageMacrosTitle XO("Manage Macros") + #define MacrosListID 7001 #define CommandsListID 7002 #define ApplyToProjectID 7003 @@ -82,7 +85,7 @@ END_EVENT_TABLE() ApplyMacroDialog::ApplyMacroDialog( wxWindow * parent, AudacityProject &project, bool bInherited): - wxDialogWrapper(parent, wxID_ANY, XO("Macros Palette"), + wxDialogWrapper(parent, wxID_ANY, MacrosPaletteTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , mMacroCommands{ project } @@ -93,8 +96,8 @@ ApplyMacroDialog::ApplyMacroDialog( mbExpanded = false; if( bInherited ) return; - SetLabel(XO("Macros Palette")); // Provide visual label - SetName(XO("Macros Palette")); // Provide audible label + SetLabel(MacrosPaletteTitle); // Provide visual label + SetName(MacrosPaletteTitle); // Provide audible label Populate(); } @@ -758,9 +761,6 @@ void MacrosWindow::UpdateMenus() void MacrosWindow::UpdateDisplay( bool bExpanded ) { - if( bExpanded == mbExpanded ) - return; - if( !SaveChanges() ) return; @@ -1318,5 +1318,11 @@ void MacrosWindow::OnKeyDown(wxKeyEvent &event) TranslatableString MacrosWindow::WindowTitle() const { - return mbExpanded ? XO("Manage Macros") : XO("Macros Palette"); + return mbExpanded ? ManageMacrosTitle : MacrosPaletteTitle; +} + +// PrefsListener implementation +void MacrosWindow::UpdatePrefs() +{ + UpdateDisplay(mbExpanded); } diff --git a/src/BatchProcessDialog.h b/src/BatchProcessDialog.h index 60fe5d3e5..6909cf0ac 100644 --- a/src/BatchProcessDialog.h +++ b/src/BatchProcessDialog.h @@ -15,6 +15,7 @@ #include #include "BatchCommands.h" +#include "Prefs.h" class wxWindow; class wxTextCtrl; @@ -47,7 +48,6 @@ class ApplyMacroDialog : public wxDialogWrapper { void ApplyMacroToProject( int iMacro, bool bHasGui=true ); void ApplyMacroToProject( const CommandID & MacroID, bool bHasGui=true ); - // These will be reused in the derived class... wxListCtrl *mList; wxListCtrl *mMacros; @@ -69,7 +69,8 @@ protected: DECLARE_EVENT_TABLE() }; -class MacrosWindow final : public ApplyMacroDialog +class MacrosWindow final : public ApplyMacroDialog, + public PrefsListener { public: MacrosWindow( @@ -125,6 +126,9 @@ private: void InsertCommandAt(int item); bool SaveChanges(); + // PrefsListener implementation + void UpdatePrefs() override; + AudacityProject &mProject; wxButton *mRemove; diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index f8c1479e1..0b66a2343 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -89,6 +89,8 @@ the mouse around. #include "widgets/WindowAccessible.h" #endif +#define FrequencyAnalysisTitle XO("Frequency Analysis") + DEFINE_EVENT_TYPE(EVT_FREQWINDOW_RECALC); enum { @@ -197,6 +199,27 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id, mRate = 0; mDataLen = 0; + gPrefs->Read(wxT("/FrequencyPlotDialog/DrawGrid"), &mDrawGrid, true); + gPrefs->Read(wxT("/FrequencyPlotDialog/SizeChoice"), &mSize, 3); + + int alg; + gPrefs->Read(wxT("/FrequencyPlotDialog/AlgChoice"), &alg, 0); + mAlg = static_cast(alg); + + gPrefs->Read(wxT("/FrequencyPlotDialog/FuncChoice"), &mFunc, 3); + gPrefs->Read(wxT("/FrequencyPlotDialog/AxisChoice"), &mAxis, 1); + + Populate(); +} + +FrequencyPlotDialog::~FrequencyPlotDialog() +{ +} + +void FrequencyPlotDialog::Populate() +{ + SetTitle(FrequencyAnalysisTitle); + TranslatableStrings algChoices{ XO("Spectrum") , XO("Standard Autocorrelation") , @@ -240,20 +263,11 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id, mArrowCursor = std::make_unique(wxCURSOR_ARROW); mCrossCursor = std::make_unique(wxCURSOR_CROSS); - gPrefs->Read(wxT("/FrequencyPlotDialog/DrawGrid"), &mDrawGrid, true); - long size; - gPrefs->Read(wxT("/FrequencyPlotDialog/SizeChoice"), &mSize, 3); // reinterpret one of the verbatim strings above as a number sizeChoices[mSize].MSGID().GET().ToLong(&size); mWindowSize = size; - int alg; - gPrefs->Read(wxT("/FrequencyPlotDialog/AlgChoice"), &alg, 0); - mAlg = static_cast(alg); - - gPrefs->Read(wxT("/FrequencyPlotDialog/FuncChoice"), &mFunc, 3); - gPrefs->Read(wxT("/FrequencyPlotDialog/AxisChoice"), &mAxis, 1); gPrefs->Read(ENV_DB_KEY, &dBRange, ENV_DB_RANGE); if(dBRange < 90.) dBRange = 90.; @@ -532,10 +546,6 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id, #endif } -FrequencyPlotDialog::~FrequencyPlotDialog() -{ -} - void FrequencyPlotDialog::OnGetURL(wxCommandEvent & WXUNUSED(event)) { // Original help page is back on-line (March 2016), but the manual should be more reliable. @@ -1106,6 +1116,49 @@ void FrequencyPlotDialog::OnRecalc(wxCommandEvent & WXUNUSED(event)) Recalc(); } +void FrequencyPlotDialog::UpdatePrefs() +{ + bool shown = IsShown(); + if (shown) { + Show(false); + } + + auto zoomSlider = mZoomSlider->GetValue(); + auto drawGrid = mGridOnOff->GetValue(); + auto sizeChoice = mSizeChoice->GetStringSelection(); + auto algChoice = mAlgChoice->GetSelection(); + auto funcChoice = mFuncChoice->GetSelection(); + auto axisChoice = mAxisChoice->GetSelection(); + + SetSizer(nullptr); + DestroyChildren(); + + Populate(); + + mZoomSlider->SetValue(zoomSlider); + + mDrawGrid = drawGrid; + mGridOnOff->SetValue(drawGrid); + + long windowSize = 0; + sizeChoice.ToLong(&windowSize); + mWindowSize = windowSize; + mSizeChoice->SetStringSelection(sizeChoice); + + mAlg = static_cast(algChoice); + mAlgChoice->SetSelection(algChoice); + + mFunc = funcChoice; + mFuncChoice->SetSelection(funcChoice); + + mAxis = axisChoice; + mAxisChoice->SetSelection(axisChoice); + + if (shown) { + Show(true); + } +} + BEGIN_EVENT_TABLE(FreqPlot, wxWindow) EVT_ERASE_BACKGROUND(FreqPlot::OnErase) EVT_PAINT(FreqPlot::OnPaint) @@ -1149,7 +1202,7 @@ AudacityProject::AttachedWindows::RegisteredFactory sFrequencyWindowKey{ []( AudacityProject &parent ) -> wxWeakRef< wxWindow > { auto &window = ProjectWindow::Get( parent ); return safenew FrequencyPlotDialog( - &window, -1, parent, XO("Frequency Analysis"), + &window, -1, parent, FrequencyAnalysisTitle, wxPoint{ 150, 150 } ); } diff --git a/src/FreqWindow.h b/src/FreqWindow.h index 3d52b8251..755beb996 100644 --- a/src/FreqWindow.h +++ b/src/FreqWindow.h @@ -14,6 +14,7 @@ #include #include // member variable #include // to inherit +#include "Prefs.h" #include "SampleFormat.h" #include "SpectrumAnalyst.h" #include "widgets/wxPanelWrapper.h" // to inherit @@ -52,7 +53,8 @@ private: DECLARE_EVENT_TABLE() }; -class FrequencyPlotDialog final : public wxDialogWrapper +class FrequencyPlotDialog final : public wxDialogWrapper, + public PrefsListener { public: FrequencyPlotDialog(wxWindow *parent, wxWindowID id, @@ -63,6 +65,8 @@ public: bool Show( bool show = true ) override; private: + void Populate(); + void GetAudio(); void PlotMouseEvent(wxMouseEvent & event); @@ -88,6 +92,9 @@ private: void DrawPlot(); void DrawBackground(wxMemoryDC & dc); + // PrefsListener implementation + void UpdatePrefs() override; + private: bool mDrawGrid; int mSize; diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 04501c549..dea40b396 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -67,8 +67,10 @@ BEGIN_EVENT_TABLE(HistoryDialog, wxDialogWrapper) EVT_BUTTON(wxID_HELP, HistoryDialog::OnGetURL) END_EVENT_TABLE() +#define HistoryTitle XO("History") + HistoryDialog::HistoryDialog(AudacityProject *parent, UndoManager *manager): - wxDialogWrapper(FindProjectFrame( parent ), wxID_ANY, XO("History"), + wxDialogWrapper(FindProjectFrame( parent ), wxID_ANY, HistoryTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { @@ -79,13 +81,33 @@ HistoryDialog::HistoryDialog(AudacityProject *parent, UndoManager *manager): mSelected = 0; mAudioIOBusy = false; - auto imageList = std::make_unique(9, 16); - imageList->Add(wxIcon(empty9x16_xpm)); - imageList->Add(wxIcon(arrow_xpm)); - //------------------------- Main section -------------------- // Construct the GUI. ShuttleGui S(this, eIsCreating); + Populate(S); + + wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, + &HistoryDialog::OnAudioIO, + this); + + wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, + &HistoryDialog::OnAudioIO, + this); + + Clipboard::Get().Bind( + EVT_CLIPBOARD_CHANGE, &HistoryDialog::UpdateDisplay, this); + parent->Bind(EVT_UNDO_PUSHED, &HistoryDialog::UpdateDisplay, this); + parent->Bind(EVT_UNDO_MODIFIED, &HistoryDialog::UpdateDisplay, this); + parent->Bind(EVT_UNDO_OR_REDO, &HistoryDialog::UpdateDisplay, this); + parent->Bind(EVT_UNDO_RESET, &HistoryDialog::UpdateDisplay, this); + parent->Bind(EVT_UNDO_PURGE, &HistoryDialog::UpdateDisplay, this); +} + +void HistoryDialog::Populate(ShuttleGui & S) +{ + auto imageList = std::make_unique(9, 16); + imageList->Add(wxIcon(empty9x16_xpm)); + imageList->Add(wxIcon(arrow_xpm)); S.SetBorder(5); S.StartVerticalLay(true); @@ -150,26 +172,11 @@ HistoryDialog::HistoryDialog(AudacityProject *parent, UndoManager *manager): S.EndVerticalLay(); // ----------------------- End of main section -------------- + Layout(); Fit(); SetMinSize(GetSize()); mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1)); mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - - wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, - &HistoryDialog::OnAudioIO, - this); - - wxTheApp->Bind(EVT_AUDIOIO_CAPTURE, - &HistoryDialog::OnAudioIO, - this); - - Clipboard::Get().Bind( - EVT_CLIPBOARD_CHANGE, &HistoryDialog::UpdateDisplay, this); - parent->Bind(EVT_UNDO_PUSHED, &HistoryDialog::UpdateDisplay, this); - parent->Bind(EVT_UNDO_MODIFIED, &HistoryDialog::UpdateDisplay, this); - parent->Bind(EVT_UNDO_OR_REDO, &HistoryDialog::UpdateDisplay, this); - parent->Bind(EVT_UNDO_RESET, &HistoryDialog::UpdateDisplay, this); - parent->Bind(EVT_UNDO_PURGE, &HistoryDialog::UpdateDisplay, this); } void HistoryDialog::OnAudioIO(wxCommandEvent& evt) @@ -378,6 +385,26 @@ void HistoryDialog::OnSize(wxSizeEvent & WXUNUSED(event)) mList->EnsureVisible(mSelected); } +// PrefsListener implementation +void HistoryDialog::UpdatePrefs() +{ + bool shown = IsShown(); + if (shown) { + Show(false); + } + + SetSizer(nullptr); + DestroyChildren(); + + SetTitle(HistoryTitle); + ShuttleGui S(this, eIsCreating); + Populate(S); + + if (shown) { + Show(true); + } +} + // Remaining code hooks this add-on into the application #include "commands/CommandContext.h" #include "commands/CommandManager.h" diff --git a/src/HistoryWindow.h b/src/HistoryWindow.h index f61c1912c..49b3509e1 100644 --- a/src/HistoryWindow.h +++ b/src/HistoryWindow.h @@ -11,6 +11,7 @@ #ifndef __AUDACITY_HISTORY_WINDOW__ #define __AUDACITY_HISTORY_WINDOW__ +#include "Prefs.h" #include "widgets/wxPanelWrapper.h" // to inherit class wxButton; @@ -22,7 +23,9 @@ class AudacityProject; class ShuttleGui; class UndoManager; -class HistoryDialog final : public wxDialogWrapper { +class HistoryDialog final : public wxDialogWrapper, + public PrefsListener +{ public: HistoryDialog(AudacityProject * parent, UndoManager *manager); @@ -32,6 +35,8 @@ class HistoryDialog final : public wxDialogWrapper { bool Show( bool show = true ) override; private: + void Populate(ShuttleGui & S); + void OnAudioIO(wxCommandEvent & evt); void DoUpdate(); void UpdateLevels(); @@ -46,6 +51,9 @@ class HistoryDialog final : public wxDialogWrapper { void OnCompact(wxCommandEvent & event); void OnGetURL(wxCommandEvent & event); + // PrefsListener implementation + void UpdatePrefs() override; + AudacityProject *mProject; UndoManager *mManager; wxListCtrl *mList; diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index 157501190..a01a4443e 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -16,6 +16,7 @@ #include "Prefs.h" // for RTL_WORKAROUND #include "Project.h" #include "ProjectAudioIO.h" +#include "ProjectFileIO.h" #include "ViewInfo.h" #include @@ -32,6 +33,8 @@ #include #endif +#define AudacityKaraokeTitle XO("Audacity Karaoke%s") + enum { kID_RadioButton_BouncingBall = 10101, kID_RadioButton_Highlight, @@ -46,13 +49,7 @@ END_EVENT_TABLE() const wxSize gSize = wxSize(LYRICS_DEFAULT_WIDTH, LYRICS_DEFAULT_HEIGHT); LyricsWindow::LyricsWindow(AudacityProject *parent) - : wxFrame( &GetProjectFrame( *parent ), -1, - wxString::Format(_("Audacity Karaoke%s"), - ((parent->GetProjectName().empty()) ? - wxT("") : - wxString::Format( - wxT(" - %s"), - parent->GetProjectName()))), + : wxFrame( &GetProjectFrame( *parent ), -1, {}, wxPoint(100, 300), gSize, //v Bug in wxFRAME_FLOAT_ON_PARENT: // If both the project frame and LyricsWindow are minimized and you restore LyricsWindow, @@ -68,6 +65,14 @@ LyricsWindow::LyricsWindow(AudacityProject *parent) // #endif mProject = parent; + SetWindowTitle(); + auto titleChanged = [&](wxCommandEvent &evt) + { + SetWindowTitle(); + evt.Skip(); + }; + wxTheApp->Bind( EVT_PROJECT_TITLE_CHANGE, titleChanged ); + // loads either the XPM or the windows resource, depending on the platform #if !defined(__WXMAC__) && !defined(__WXX11__) { @@ -169,6 +174,22 @@ void LyricsWindow::OnTimer(wxCommandEvent &event) event.Skip(); } +void LyricsWindow::SetWindowTitle() +{ + wxString name = mProject->GetProjectName(); + if (!name.empty()) + { + name.Prepend(wxT(" - ")); + } + + SetTitle(AudacityKaraokeTitle.Format(name).Translation()); +} + +void LyricsWindow::UpdatePrefs() +{ + SetWindowTitle(); +} + // Remaining code hooks this add-on into the application #include "commands/CommandContext.h" #include "commands/CommandManager.h" diff --git a/src/LyricsWindow.h b/src/LyricsWindow.h index ed30428cf..1c86bacf8 100644 --- a/src/LyricsWindow.h +++ b/src/LyricsWindow.h @@ -14,10 +14,14 @@ #include // to inherit +#include "Prefs.h" + class AudacityProject; class LyricsPanel; -class LyricsWindow final : public wxFrame { +class LyricsWindow final : public wxFrame, + public PrefsListener +{ public: LyricsWindow(AudacityProject* parent); @@ -31,6 +35,11 @@ class LyricsWindow final : public wxFrame { void OnStyle_Highlight(wxCommandEvent &evt); void OnTimer(wxCommandEvent &event); + void SetWindowTitle(); + + // PrefsListener implementation + void UpdatePrefs() override; + AudacityProject *mProject; LyricsPanel *mLyricsPanel; diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 8f8e7c50b..f07fd3b3d 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -39,6 +39,7 @@ #include "ProjectAudioIO.h" #include "ProjectAudioManager.h" #include "ProjectHistory.h" +#include "ProjectFileIO.h" #include "ProjectSettings.h" #include "ProjectWindow.h" #include "SelectUtilities.h" @@ -61,6 +62,8 @@ #include "commands/CommandManager.h" +#define AudacityMixerBoardTitle XO("Audacity Mixer Board%s") + // class MixerTrackSlider BEGIN_EVENT_TABLE(MixerTrackSlider, ASlider) @@ -1405,15 +1408,19 @@ const wxSize kDefaultSize = wxSize(MIXER_BOARD_MIN_WIDTH, MIXER_BOARD_MIN_HEIGHT); MixerBoardFrame::MixerBoardFrame(AudacityProject* parent) -: wxFrame( &GetProjectFrame( *parent ), -1, - wxString::Format(_("Audacity Mixer Board%s"), - ((parent->GetProjectName().empty()) ? - wxT("") : - wxString::Format(wxT(" - %s"), - parent->GetProjectName()))), +: wxFrame( &GetProjectFrame( *parent ), -1, {}, wxDefaultPosition, kDefaultSize, wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT) + , mProject(parent) { + SetWindowTitle(); + auto titleChanged = [&](wxCommandEvent &evt) + { + SetWindowTitle(); + evt.Skip(); + }; + wxTheApp->Bind( EVT_PROJECT_TITLE_CHANGE, titleChanged ); + mMixerBoard = safenew MixerBoard(parent, this, wxDefaultPosition, kDefaultSize); this->SetSizeHints(MIXER_BOARD_MIN_WIDTH, MIXER_BOARD_MIN_HEIGHT); @@ -1487,6 +1494,18 @@ void MixerBoardFrame::Recreate( AudacityProject *pProject ) mMixerBoard->SetSize( siz ); this->SetSize( siz2 ); + SetWindowTitle(); +} + +void MixerBoardFrame::SetWindowTitle() +{ + wxString name = mProject->GetProjectName(); + if (!name.empty()) + { + name.Prepend(wxT(" - ")); + } + + SetTitle(AudacityMixerBoardTitle.Format(name).Translation()); } // Remaining code hooks this add-on into the application diff --git a/src/MixerBoard.h b/src/MixerBoard.h index b74691c0e..a67f8cf16 100644 --- a/src/MixerBoard.h +++ b/src/MixerBoard.h @@ -279,6 +279,9 @@ private: void OnSize(wxSizeEvent &evt); void OnKeyEvent(wxKeyEvent &evt); + void SetWindowTitle(); + + AudacityProject *mProject; public: MixerBoard* mMixerBoard; diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index 1db301e40..c587c56a0 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -52,11 +52,14 @@ class OldStyleCommandType; class ScreenFrameTimer; //////////////////////////////////////////////////////////////////////////////// +#define ScreenCaptureFrameTitle XO("Screen Capture Frame") // ANSWER-ME: Should this derive from wxDialogWrapper instead? -class ScreenshotBigDialog final : public wxFrame +class ScreenshotBigDialog final : public wxFrame, + public PrefsListener { public: + // constructors and destructors ScreenshotBigDialog( wxWindow *parent, wxWindowID id, AudacityProject &project); @@ -96,6 +99,9 @@ class ScreenshotBigDialog final : public wxFrame void OnMedTracks(wxCommandEvent & event); void OnTallTracks(wxCommandEvent & event); + // PrefsListener implementation + void UpdatePrefs() override; + AudacityProject &mProject; std::unique_ptr CreateCommand(); @@ -278,7 +284,7 @@ std::unique_ptr ScreenshotBigDialog::CreateCommand() ScreenshotBigDialog::ScreenshotBigDialog( wxWindow * parent, wxWindowID id, AudacityProject &project) -: wxFrame(parent, id, _("Screen Capture Frame"), +: wxFrame(parent, id, ScreenCaptureFrameTitle.Translation(), wxDefaultPosition, wxDefaultSize, #if !defined(__WXMSW__) @@ -503,26 +509,30 @@ void ScreenshotBigDialog::PopulateOrExchange(ShuttleGui & S) bool ScreenshotBigDialog::ProcessEvent(wxEvent & e) { - int id = e.GetId(); - - // If split into two parts to make for easier breakpoint - // when testing timer. - if (mDelayCheckBox && - mDelayCheckBox->GetValue() && - e.IsCommandEvent() && - e.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) + if (!IsFrozen()) { - if( id >= IdAllDelayedEvents && id <= IdLastDelayedEvent && - e.GetEventObject() != NULL) { - mTimer = std::make_unique(this, e); - mTimer->Start(5000, true); - return true; + int id = e.GetId(); + + // If split into two parts to make for easier breakpoint + // when testing timer. + if (mDelayCheckBox && + mDelayCheckBox->GetValue() && + e.IsCommandEvent() && + e.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) + { + if( id >= IdAllDelayedEvents && id <= IdLastDelayedEvent && + e.GetEventObject() != NULL) { + mTimer = std::make_unique(this, e); + mTimer->Start(5000, true); + return true; + } + } + + if (e.IsCommandEvent() && e.GetEventObject() == NULL) { + e.SetEventObject(this); } } - if (e.IsCommandEvent() && e.GetEventObject() == NULL) { - e.SetEventObject(this); - } return wxFrame::ProcessEvent(e); } @@ -790,3 +800,16 @@ void ScreenshotBigDialog::OnTallTracks(wxCommandEvent & WXUNUSED(event)) { SizeTracks(85); } + +void ScreenshotBigDialog::UpdatePrefs() +{ + Freeze(); + + SetSizer(nullptr); + DestroyChildren(); + + SetTitle(ScreenCaptureFrameTitle.Translation()); + Populate(); + + Thaw(); +}