1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-28 00:55:50 +01:00

Rewrite AddChoice and TieChoice calls...

... either lifting or inlining array-of-string computations, so fewer statements
are mixed among ShuttleGui method calls
This commit is contained in:
Paul Licameli
2019-02-22 15:15:19 -05:00
parent f07d33f4b5
commit f846c25806
15 changed files with 183 additions and 187 deletions

View File

@@ -1003,6 +1003,8 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate,
ShuttleGui S(&d, eIsCreating);
wxString text;
int selected = -1;
S.StartVerticalLay();
{
S.SetBorder(10);
@@ -1022,30 +1024,26 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate,
}
S.EndHorizontalLay();
wxArrayStringEx choices;
int selected = -1;
for (int i = 0; sampRates[i] > 0; i++)
{
int label = sampRates[i];
if (label >= lowrate && label <= highrate)
{
wxString name = wxString::Format(wxT("%d"),label);
choices.push_back(name);
if (label <= rate)
{
selected = i;
}
}
}
if (selected == -1)
selected = 0;
S.StartHorizontalLay(wxALIGN_CENTER, false);
{
choice = S.AddChoice(_("Sample Rates"),
choices,
selected);
[&]{
wxArrayStringEx choices;
for (int i = 0; sampRates[i] > 0; i++)
{
int label = sampRates[i];
if (label >= lowrate && label <= highrate)
{
wxString name = wxString::Format(wxT("%d"),label);
choices.push_back(name);
if (label <= rate)
selected = i;
}
}
return choices;
}(),
std::max( 0, selected )
);
}
S.EndHorizontalLay();
}