1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-04-01 03:54:47 +02: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

@@ -2002,6 +2002,8 @@ int ExportMP3::AskResample(int bitrate, int rate, int lowrate, int highrate)
ShuttleGui S(&d, eIsCreating);
wxString text;
int selected = -1;
S.StartVerticalLay();
{
S.SetBorder(10);
@@ -2021,27 +2023,23 @@ int ExportMP3::AskResample(int bitrate, int rate, int lowrate, int highrate)
}
S.EndHorizontalLay();
wxArrayStringEx choices;
int selected = -1;
for (size_t ii = 0, nn = sampRates.size(); ii < nn; ++ii) {
int label = sampRates[ii];
if (label >= lowrate && label <= highrate) {
choices.push_back( wxString::Format( "%d", label ) );
if (label <= rate) {
selected = ii;
}
}
}
if (selected == -1) {
selected = 0;
}
S.StartHorizontalLay(wxALIGN_CENTER, false);
{
choice = S.AddChoice(_("Sample Rates"),
choices,
selected);
[&]{
wxArrayStringEx choices;
for (size_t ii = 0, nn = sampRates.size(); ii < nn; ++ii) {
int label = sampRates[ii];
if (label >= lowrate && label <= highrate) {
choices.push_back( wxString::Format( "%d", label ) );
if (label <= rate)
selected = ii;
}
}
return choices;
}(),
std::max( 0, selected )
);
}
S.EndHorizontalLay();
}