From 63b1803a6e71c84e1e9892206aba17f3426061f1 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 20 Oct 2017 11:48:12 -0400 Subject: [PATCH] Pass ShuttleGui& into ExportPlugin::OptionsCreate() --- src/export/Export.cpp | 20 +++++++++----------- src/export/Export.h | 4 ++-- src/export/ExportCL.cpp | 7 +++---- src/export/ExportFFmpeg.cpp | 27 ++++++++++++++++++--------- src/export/ExportFLAC.cpp | 7 +++---- src/export/ExportMP2.cpp | 7 +++---- src/export/ExportMP3.cpp | 7 +++---- src/export/ExportMultiple.cpp | 14 ++++++++++---- src/export/ExportOGG.cpp | 7 +++---- src/export/ExportPCM.cpp | 10 +++++----- 10 files changed, 59 insertions(+), 51 deletions(-) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index a94dc94a0..23507ffa9 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -220,12 +220,8 @@ bool ExportPlugin::DisplayOptions(wxWindow * WXUNUSED(parent), int WXUNUSED(form return false; } -wxWindow *ExportPlugin::OptionsCreate(wxWindow *parent, int WXUNUSED(format)) +void ExportPlugin::OptionsCreate(ShuttleGui &S, int WXUNUSED(format)) { - wxASSERT(parent); // To justify safenew - wxPanel *p = safenew wxPanelWrapper(parent, wxID_ANY); - ShuttleGui S(p, eIsCreatingFromPrefs); - S.StartHorizontalLay(wxCENTER); { S.StartHorizontalLay(wxCENTER, 0); @@ -235,8 +231,6 @@ wxWindow *ExportPlugin::OptionsCreate(wxWindow *parent, int WXUNUSED(format)) S.EndHorizontalLay(); } S.EndHorizontalLay(); - - return p; } //Create a mixer by computing the time warp factor @@ -994,17 +988,21 @@ void Exporter::CreateUserPane(wxWindow *parent) { S.StartStatic(_("Format Options"), 1); { - mBook = safenew wxSimplebook(S.GetParent()); - S.Position(wxEXPAND) - .AddWindow(mBook); + mBook = S.Position(wxEXPAND) + .StartSimplebook(); for (const auto &pPlugin : mPlugins) { for (int j = 0; j < pPlugin->GetFormatCount(); j++) { - mBook->AddPage(pPlugin->OptionsCreate(mBook, j), wxEmptyString); + // Name of simple book page is not displayed + S.StartNotebookPage( wxEmptyString ); + pPlugin->OptionsCreate(S, j); + S.EndNotebookPage(); } } + + S.EndSimplebook(); } S.EndStatic(); } diff --git a/src/export/Export.h b/src/export/Export.h index bc548dcec..a06895630 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -31,6 +31,7 @@ class Tags; class TrackList; class MixerSpec; class ProgressDialog; +class ShuttleGui; class Mixer; using WaveTrackConstArray = std::vector < std::shared_ptr < const WaveTrack > >; enum class ProgressResult : unsigned; @@ -92,8 +93,7 @@ public: virtual bool DisplayOptions(wxWindow *parent, int format = 0); - // Precondition: parent != NULL - virtual wxWindow *OptionsCreate(wxWindow *parent, int format) = 0; + virtual void OptionsCreate(ShuttleGui &S, int format) = 0; virtual bool CheckFileName(wxFileName &filename, int format = 0); /** @brief Exporter plug-ins may override this to specify the number diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index 67c1a6d4a..ae33a71a0 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -289,7 +289,7 @@ public: ExportCL(); // Required - wxWindow *OptionsCreate(wxWindow *parent, int format) override; + void OptionsCreate(ShuttleGui &S, int format) override; ProgressResult Export(AudacityProject *project, std::unique_ptr &pDialog, @@ -552,10 +552,9 @@ ProgressResult ExportCL::Export(AudacityProject *project, return updateResult; } -wxWindow *ExportCL::OptionsCreate(wxWindow *parent, int format) +void ExportCL::OptionsCreate(ShuttleGui &S, int format) { - wxASSERT(parent); // to justify safenew - return safenew ExportCLOptions(parent, format); + S.AddWindow( safenew ExportCLOptions{ S.GetParent(), format } ); } static Exporter::RegisteredExportPlugin diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index bfa580126..063070b9b 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -122,7 +122,7 @@ public: /// Creates options panel ///\param format - index of export type - wxWindow *OptionsCreate(wxWindow *parent, int format) override; + void OptionsCreate(ShuttleGui &S, int format) override; /// Check whether or not current project sample rate is compatible with the export codec bool CheckSampleRate(int rate, int lowrate, int highrate, const int *sampRates); @@ -1067,33 +1067,42 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate, return wxAtoi(choice->GetStringSelection()); } -wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format) +void ExportFFmpeg::OptionsCreate(ShuttleGui &S, int format) { - wxASSERT(parent); // to justify safenew // subformat index may not correspond directly to fmts[] index, convert it mSubFormat = AdjustFormatIndex(format); if (mSubFormat == FMT_M4A) { - return safenew ExportFFmpegAACOptions(parent, format); + S.AddWindow( + safenew ExportFFmpegAACOptions{ S.GetParent(), format } ); + return; } else if (mSubFormat == FMT_AC3) { - return safenew ExportFFmpegAC3Options(parent, format); + S.AddWindow( + safenew ExportFFmpegAC3Options{ S.GetParent(), format } ); + return; } else if (mSubFormat == FMT_AMRNB) { - return safenew ExportFFmpegAMRNBOptions(parent, format); + S.AddWindow( + safenew ExportFFmpegAMRNBOptions{ S.GetParent(), format } ); + return; } else if (mSubFormat == FMT_WMA2) { - return safenew ExportFFmpegWMAOptions(parent, format); + S.AddWindow( + safenew ExportFFmpegWMAOptions{ S.GetParent(), format } ); + return; } else if (mSubFormat == FMT_OTHER) { - return safenew ExportFFmpegCustomOptions(parent, format); + S.AddWindow( + safenew ExportFFmpegCustomOptions{ S.GetParent(), format } ); + return; } - return ExportPlugin::OptionsCreate(parent, format); + ExportPlugin::OptionsCreate(S, format); } static Exporter::RegisteredExportPlugin diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index 5ef4ba705..2c4b27cff 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -212,7 +212,7 @@ public: // Required - wxWindow *OptionsCreate(wxWindow *parent, int format) override; + void OptionsCreate(ShuttleGui &S, int format) override; ProgressResult Export(AudacityProject *project, std::unique_ptr &pDialog, unsigned channels, @@ -435,10 +435,9 @@ ProgressResult ExportFLAC::Export(AudacityProject *project, return updateResult; } -wxWindow *ExportFLAC::OptionsCreate(wxWindow *parent, int format) +void ExportFLAC::OptionsCreate(ShuttleGui &S, int format) { - wxASSERT(parent); // to justify safenew - return safenew ExportFLACOptions(parent, format); + S.AddWindow( safenew ExportFLACOptions{ S.GetParent(), format } ); } // LL: There's a bug in libflac++ 1.1.2 that prevents us from using diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index ec834b8e5..cca027ae8 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -205,7 +205,7 @@ public: // Required - wxWindow *OptionsCreate(wxWindow *parent, int format) override; + void OptionsCreate(ShuttleGui &S, int format) override; ProgressResult Export(AudacityProject *project, std::unique_ptr &pDialog, unsigned channels, @@ -377,10 +377,9 @@ ProgressResult ExportMP2::Export(AudacityProject *project, return updateResult; } -wxWindow *ExportMP2::OptionsCreate(wxWindow *parent, int format) +void ExportMP2::OptionsCreate(ShuttleGui &S, int format) { - wxASSERT(parent); // to justify safenew - return safenew ExportMP2Options(parent, format); + S.AddWindow( safenew ExportMP2Options{ S.GetParent(), format } ); } diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index 36d7c00cb..cf4c2c002 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -1654,7 +1654,7 @@ public: // Required - wxWindow *OptionsCreate(wxWindow *parent, int format) override; + void OptionsCreate(ShuttleGui &S, int format) override; ProgressResult Export(AudacityProject *project, std::unique_ptr &pDialog, unsigned channels, @@ -1992,10 +1992,9 @@ ProgressResult ExportMP3::Export(AudacityProject *project, return updateResult; } -wxWindow *ExportMP3::OptionsCreate(wxWindow *parent, int format) +void ExportMP3::OptionsCreate(ShuttleGui &S, int format) { - wxASSERT(parent); // to justify safenew - return safenew ExportMP3Options(parent, format); + S.AddWindow( safenew ExportMP3Options{ S.GetParent(), format } ); } int ExportMP3::AskResample(int bitrate, int rate, int lowrate, int highrate) diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index f8873c7b7..c3b73b8e1 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -294,19 +294,25 @@ void ExportMultipleDialog::PopulateOrExchange(ShuttleGui& S) S.AddVariableText( {}, false); S.AddPrompt(_("Options:")); - if (!mBook) + + mBook = S.Id(OptionsID) + .Style(wxBORDER_STATIC) + .StartSimplebook(); + if (S.GetMode() == eIsCreating) { - mBook = safenew wxSimplebook(S.GetParent(), OptionsID, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC); for (const auto &pPlugin : mPlugins) { for (int j = 0; j < pPlugin->GetFormatCount(); j++) { - mBook->AddPage(pPlugin->OptionsCreate(mBook, j), wxEmptyString); + // Name of simple book page is not displayed + S.StartNotebookPage( wxEmptyString ); + pPlugin->OptionsCreate(S, j); + S.EndNotebookPage(); } } mBook->ChangeSelection(mFormat->GetSelection()); } - S.AddWindow(mBook); + S.EndSimplebook(); S.AddVariableText( {}, false); S.AddVariableText( {}, false); } diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index eb66da298..ddf920c6e 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -129,7 +129,7 @@ public: ExportOGG(); // Required - wxWindow *OptionsCreate(wxWindow *parent, int format) override; + void OptionsCreate(ShuttleGui &S, int format) override; ProgressResult Export(AudacityProject *project, std::unique_ptr &pDialog, @@ -369,10 +369,9 @@ ProgressResult ExportOGG::Export(AudacityProject *project, return updateResult; } -wxWindow *ExportOGG::OptionsCreate(wxWindow *parent, int format) +void ExportOGG::OptionsCreate(ShuttleGui &S, int format) { - wxASSERT(parent); // to justify safenew - return safenew ExportOGGOptions(parent, format); + S.AddWindow( safenew ExportOGGOptions{ S.GetParent(), format } ); } bool ExportOGG::FillComment(AudacityProject *project, vorbis_comment *comment, const Tags *metadata) diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index 221f106ff..085a1018e 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -327,7 +327,7 @@ public: // Required - wxWindow *OptionsCreate(wxWindow *parent, int format) override; + void OptionsCreate(ShuttleGui &S, int format) override; ProgressResult Export(AudacityProject *project, std::unique_ptr &pDialog, unsigned channels, @@ -929,16 +929,16 @@ bool ExportPCM::AddID3Chunk( return true; } -wxWindow *ExportPCM::OptionsCreate(wxWindow *parent, int format) +void ExportPCM::OptionsCreate(ShuttleGui &S, int format) { - wxASSERT(parent); // to justify safenew // default, full user control if (format < 0 || static_cast(format) >= WXSIZEOF(kFormats)) { - return safenew ExportPCMOptions(parent, format); + S.AddWindow( safenew ExportPCMOptions{ S.GetParent(), format } ); + return; } - return ExportPlugin::OptionsCreate(parent, format); + ExportPlugin::OptionsCreate(S, format); } FileExtension ExportPCM::GetExtension(int index)