Pass ShuttleGui& into ExportPlugin::OptionsCreate()

This commit is contained in:
Paul Licameli 2017-10-20 11:48:12 -04:00
parent bed7b41af9
commit 63b1803a6e
10 changed files with 59 additions and 51 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -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<ProgressDialog> &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

View File

@ -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

View File

@ -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<ProgressDialog> &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

View File

@ -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<ProgressDialog> &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 } );
}

View File

@ -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<ProgressDialog> &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)

View File

@ -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);
}

View File

@ -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<ProgressDialog> &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)

View File

@ -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<ProgressDialog> &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<unsigned int>(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)