1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

More use of ShuttleGui for dialogs in import and export

This commit is contained in:
Paul Licameli 2019-12-18 11:23:48 -05:00
commit 2c7e08eeec
12 changed files with 123 additions and 119 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();
}
@ -1410,43 +1408,46 @@ ExportMixerDialog::ExportMixerDialog( const TrackList *tracks, bool selectedOnly
maxNumChannels = 32;
mMixerSpec = std::make_unique<MixerSpec>(numTracks, maxNumChannels);
wxBoxSizer *vertSizer;
auto label = XO("Output Channels: %2d")
.Format( mMixerSpec->GetNumChannels() );
ShuttleGui S{ this, eIsCreating };
{
auto uVertSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
vertSizer = uVertSizer.get();
S.SetBorder( 5 );
wxWindow *mixerPanel = safenew ExportMixerPanel(this, ID_MIXERPANEL,
mMixerSpec.get(), mTrackNames,
wxDefaultPosition, wxSize(400, -1));
mixerPanel->SetName(_("Mixer Panel"));
vertSizer->Add(mixerPanel, 1, wxEXPAND | wxALL, 5);
auto mixerPanel = safenew ExportMixerPanel(
S.GetParent(), ID_MIXERPANEL, mMixerSpec.get(),
mTrackNames, wxDefaultPosition, wxSize(400, -1));
S.Prop(1)
.Name(XO("Mixer Panel"))
.Position(wxEXPAND | wxALL)
.AddWindow(mixerPanel);
S.StartHorizontalLay(wxALIGN_CENTRE | wxALL, 0);
{
auto horSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
mChannelsText = S.AddVariableText(
label.Translation(),
false, wxALIGN_LEFT | wxALL );
wxString label;
label.Printf(_("Output Channels: %2d"), mMixerSpec->GetNumChannels());
mChannelsText = safenew wxStaticText(this, -1, label);
horSizer->Add(mChannelsText, 0, wxALIGN_LEFT | wxALL, 5);
wxSlider *channels = safenew wxSliderWrapper(this, ID_SLIDER_CHANNEL,
mMixerSpec->GetNumChannels(), 1, mMixerSpec->GetMaxNumChannels(),
wxDefaultPosition, wxSize(300, -1));
channels->SetName(label);
horSizer->Add(channels, 0, wxEXPAND | wxALL, 5);
vertSizer->Add(horSizer.release(), 0, wxALIGN_CENTRE | wxALL, 5);
S
.Id(ID_SLIDER_CHANNEL)
.Name(label)
.Size({300, -1})
.Style(wxSL_HORIZONTAL)
.Position(wxEXPAND | wxALL)
.AddSlider( {},
mMixerSpec->GetNumChannels(),
mMixerSpec->GetMaxNumChannels(), 1 );
}
S.EndHorizontalLay();
vertSizer->Add(CreateStdButtonSizer(this, eCancelButton | eOkButton | eHelpButton).release(), 0, wxEXPAND);
SetAutoLayout(true);
SetSizer(uVertSizer.release());
S.AddStandardButtons( eCancelButton | eOkButton | eHelpButton );
}
vertSizer->Fit( this );
vertSizer->SetSizeHints( this );
SetAutoLayout(true);
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
SetSizeHints( 640, 480, 20000, 20000 );

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)

View File

@ -752,26 +752,25 @@ wxDialogWrapper( parent, id, title, position, size, style | wxRESIZE_BORDER )
for (wxInt32 i = 0; i < scount; i++)
mFile->SetStreamUsage(i, FALSE);
wxBoxSizer *vertSizer;
ShuttleGui S{ this, eIsCreating };
{
auto uVertSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
vertSizer = uVertSizer.get();
S.SetBorder( 5 );
const auto choices = transform_container<wxArrayStringEx>(
mFile->GetStreamInfo(),
std::mem_fn( &TranslatableString::Translation ) );
StreamList = safenew wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, choices, wxLB_EXTENDED | wxLB_ALWAYS_SB);
StreamList = S
.Style(wxLB_EXTENDED | wxLB_ALWAYS_SB)
.AddListBox(
transform_container<wxArrayStringEx>(
mFile->GetStreamInfo(),
std::mem_fn( &TranslatableString::Translation ) ) );
vertSizer->Add(StreamList, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 5);
vertSizer->Add(CreateStdButtonSizer(this, eCancelButton | eOkButton).release(), 0, wxEXPAND);
SetAutoLayout(true);
SetSizer(uVertSizer.release());
S.Prop(1)
.Position(wxEXPAND | wxALIGN_LEFT | wxALL)
.AddWindow(StreamList);
S.AddStandardButtons();
}
vertSizer->Fit( this );
SetAutoLayout(true);
GetSizer()->Fit( this );
SetSize( 400, 200 );
}

View File

@ -37,6 +37,8 @@
#include "sndfile.h"
#include "../WaveClip.h"
#include "../ShuttleGui.h"
#include "../ondemand/ODManager.h"
#include "../ondemand/ODComputeSummaryTask.h"
#include "../blockfile/ODPCMAliasBlockFile.h"
@ -318,9 +320,6 @@ static wxString AskCopyOrEdit()
wxDialogWrapper dialog( nullptr, -1, XO("Warning") );
dialog.SetName();
wxBoxSizer *vbox;
dialog.SetSizer(vbox = safenew wxBoxSizer(wxVERTICAL));
wxString clause1 = _(
"When importing uncompressed audio files you can either copy them into the project,"
" or read them directly from their current location (without copying).\n\n"
@ -340,36 +339,31 @@ static wxString AskCopyOrEdit()
"How do you want to import the current file(s)?"
);
wxStaticText *message =
safenew wxStaticText(&dialog, -1, clause1 + clause2 + clause3);
message->Wrap(500);
message->SetName(message->GetLabel());
vbox->Add(message, 1, wxALL | wxEXPAND, 10);
wxStaticBox *box = safenew wxStaticBoxWrapper(&dialog, -1, _("Choose an import method"));
box->SetName(box->GetLabel());
ShuttleGui S{ &dialog, eIsCreating };
S.SetBorder(10);
S
.Position( wxALL | wxEXPAND )
.AddUnits( clause1 + clause2 + clause3, 500);
wxRadioButton *aliasRadio;
wxRadioButton *copyRadio;
wxCheckBox *dontAskNextTimeBox;
S.StartStatic(_("Choose an import method"));
{
auto boxsizer = std::make_unique<wxStaticBoxSizer>(box, wxVERTICAL);
S.SetBorder(0);
copyRadio = safenew wxRadioButton(&dialog, -1, _("Make a &copy of the files before editing (safer)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
boxsizer->Add(copyRadio, 0, wxALL);
copyRadio->SetName(wxStripMenuCodes(copyRadio->GetLabel()));
copyRadio = S.AddRadioButton(
_("Make a &copy of the files before editing (safer)") );
aliasRadio = safenew wxRadioButton(&dialog, -1, _("Read the files &directly from the original (faster)"));
boxsizer->Add(aliasRadio, 0, wxALL);
aliasRadio->SetName(wxStripMenuCodes(aliasRadio->GetLabel()));
aliasRadio = S.AddRadioButtonToGroup(
_("Read the files &directly from the original (faster)") );
dontAskNextTimeBox = safenew wxCheckBox(&dialog, -1, _("Don't &warn again and always use my choice above"));
boxsizer->Add(dontAskNextTimeBox, 0, wxALL);
vbox->Add(boxsizer.release(), 0, wxALL, 10);
dontAskNextTimeBox = S.AddCheckBox(
_("Don't &warn again and always use my choice above"),
wxT("false"));
}
S.EndStatic();
dontAskNextTimeBox->SetName(wxStripMenuCodes(dontAskNextTimeBox->GetLabel()));
@ -377,8 +371,8 @@ static wxString AskCopyOrEdit()
wxRadioButton *prefsRadio = oldCopyPref == wxT("copy") ? copyRadio : aliasRadio;
prefsRadio->SetValue(true);
wxSizer *buttonSizer = dialog.CreateButtonSizer(wxOK | wxCANCEL);
vbox->Add(buttonSizer, 0, wxALL | wxEXPAND, 10);
S.SetBorder( 10 );
S.AddStandardButtons( eOkButton | eCancelButton );
dialog.SetSize(dialog.GetBestSize());
dialog.Layout();