1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 15:53:52 +02:00

Define and use wxArrayStringEx...

reducing verbosity where there were repeated calls of Add(), and defining
move construction and assignment for efficient returns from functions
This commit is contained in:
Paul Licameli
2019-02-12 16:30:22 -05:00
parent 07a42e8e19
commit 6d5bc21d50
30 changed files with 383 additions and 262 deletions

View File

@@ -103,20 +103,21 @@ void EffectsPrefs::PopulateOrExchange(ShuttleGui & S)
{
S.StartMultiColumn(2);
{
wxArrayString visualgroups;
wxArrayString prefsgroups;
wxArrayStringEx visualgroups{
_("Sorted by Effect Name") ,
_("Sorted by Publisher and Effect Name") ,
_("Sorted by Type and Effect Name") ,
_("Grouped by Publisher") ,
_("Grouped by Type") ,
};
visualgroups.Add(_("Sorted by Effect Name"));
visualgroups.Add(_("Sorted by Publisher and Effect Name"));
visualgroups.Add(_("Sorted by Type and Effect Name"));
visualgroups.Add(_("Grouped by Publisher"));
visualgroups.Add(_("Grouped by Type"));
prefsgroups.Add(wxT("sortby:name"));
prefsgroups.Add(wxT("sortby:publisher:name"));
prefsgroups.Add(wxT("sortby:type:name"));
prefsgroups.Add(wxT("groupby:publisher"));
prefsgroups.Add(wxT("groupby:type"));
wxArrayStringEx prefsgroups{
wxT("sortby:name") ,
wxT("sortby:publisher:name") ,
wxT("sortby:type:name") ,
wxT("groupby:publisher") ,
wxT("groupby:type") ,
};
wxChoice *c = S.TieChoice(_("S&ort or Group:"),
wxT("/Effects/GroupBy"),

View File

@@ -47,32 +47,37 @@ GUIPrefs::~GUIPrefs()
{
}
void GUIPrefs::GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes)
void GUIPrefs::GetRangeChoices(
wxArrayStringEx *pChoices, wxArrayStringEx *pCodes)
{
if (pCodes) {
wxArrayString &codes = *pCodes;
codes.Clear();
codes.Add(wxT("36"));
codes.Add(wxT("48"));
codes.Add(wxT("60"));
codes.Add(wxT("72"));
codes.Add(wxT("84"));
codes.Add(wxT("96"));
codes.Add(wxT("120"));
codes.Add(wxT("145"));
auto &codes = *pCodes;
codes.clear();
codes.insert( codes.end(), {
wxT("36") ,
wxT("48") ,
wxT("60") ,
wxT("72") ,
wxT("84") ,
wxT("96") ,
wxT("120") ,
wxT("145") ,
} );
}
if (pChoices) {
wxArrayString &choices = *pChoices;
choices.Clear();
choices.Add(_("-36 dB (shallow range for high-amplitude editing)"));
choices.Add(_("-48 dB (PCM range of 8 bit samples)"));
choices.Add(_("-60 dB (PCM range of 10 bit samples)"));
choices.Add(_("-72 dB (PCM range of 12 bit samples)"));
choices.Add(_("-84 dB (PCM range of 14 bit samples)"));
choices.Add(_("-96 dB (PCM range of 16 bit samples)"));
choices.Add(_("-120 dB (approximate limit of human hearing)"));
choices.Add(_("-145 dB (PCM range of 24 bit samples)"));
auto &choices = *pChoices;
choices.clear();
choices.insert( choices.end(), {
_("-36 dB (shallow range for high-amplitude editing)") ,
_("-48 dB (PCM range of 8 bit samples)") ,
_("-60 dB (PCM range of 10 bit samples)") ,
_("-72 dB (PCM range of 12 bit samples)") ,
_("-84 dB (PCM range of 14 bit samples)") ,
_("-96 dB (PCM range of 16 bit samples)") ,
_("-120 dB (approximate limit of human hearing)") ,
_("-145 dB (PCM range of 24 bit samples)") ,
} );
}
}
@@ -81,34 +86,55 @@ void GUIPrefs::Populate()
// First any pre-processing for constructing the GUI.
GetLanguages(mLangCodes, mLangNames);
mHtmlHelpCodes.Add(wxT("Local"));
mHtmlHelpCodes.Add(wxT("FromInternet"));
mHtmlHelpCodes.clear();
auto values = {
wxT("Local") ,
wxT("FromInternet") ,
};
mHtmlHelpCodes.insert( mHtmlHelpCodes.end(), values );
mHtmlHelpChoices.Add(_("Local"));
mHtmlHelpChoices.Add(_("From Internet"));
mHtmlHelpChoices.clear();
auto values2 = {
_("Local") ,
_("From Internet") ,
};
mHtmlHelpChoices.insert( mHtmlHelpChoices.end(), values2 );
mThemeCodes.Add( wxT("classic") );
mThemeCodes.Add( wxT("light") );
mThemeCodes.Add( wxT("dark") );
mThemeCodes.Add( wxT("high-contrast") );
mThemeCodes.Add( wxT("custom") );
mThemeCodes.clear();
mThemeCodes.insert( mThemeCodes.end(), {
wxT("classic") ,
wxT("light") ,
wxT("dark") ,
wxT("high-contrast") ,
wxT("custom") ,
} );
/* i18n-hint: describing the "classic" or traditional appearance of older versions of Audacity */
mThemeChoices.Add( _("Classic") );
/* i18n-hint: Light meaning opposite of dark */
mThemeChoices.Add( _("Light") );
mThemeChoices.Add( _("Dark") );
/* i18n-hint: greater difference between foreground and background colors */
mThemeChoices.Add( _("High Contrast") );
/* i18n-hint: user defined */
mThemeChoices.Add( _("Custom") );
mThemeChoices.clear();
mThemeChoices.insert( mThemeChoices.end(), {
/* i18n-hint: describing the "classic" or traditional appearance of older versions of Audacity */
_("Classic") ,
/* i18n-hint: Light meaning opposite of dark */
_("Light") ,
_("Dark") ,
/* i18n-hint: greater difference between foreground and background colors */
_("High Contrast") ,
/* i18n-hint: user defined */
_("Custom") ,
} );
GetRangeChoices(&mRangeChoices, &mRangeCodes);
#if 0
// only for testing...
mLangCodes.Add("kg"); mLangNames.Add("Klingon");
mLangCodes.Add("ep"); mLangNames.Add("Esperanto");
mLangCodes.insert( mLangCodes.end(), {
// only for testing...
"kg" ,
"ep" ,
} );
mLangNames.insert( mLangNames.end(), {
"Klingon" ,
"Esperanto" ,
} );
#endif
//------------------------- Main section --------------------

View File

@@ -21,6 +21,7 @@
#include "PrefsPanel.h"
class ShuttleGui;
class wxArrayStringEx;
class GUIPrefs final : public PrefsPanel
{
@@ -31,22 +32,23 @@ class GUIPrefs final : public PrefsPanel
wxString HelpPageName() override;
void PopulateOrExchange(ShuttleGui & S) override;
static void GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes);
static void GetRangeChoices(
wxArrayStringEx *pChoices, wxArrayStringEx *pCodes);
private:
void Populate();
wxArrayString mLangCodes;
wxArrayString mLangNames;
wxArrayStringEx mLangCodes;
wxArrayStringEx mLangNames;
wxArrayString mHtmlHelpCodes;
wxArrayString mHtmlHelpChoices;
wxArrayStringEx mHtmlHelpCodes;
wxArrayStringEx mHtmlHelpChoices;
wxArrayString mThemeCodes;
wxArrayString mThemeChoices;
wxArrayStringEx mThemeCodes;
wxArrayStringEx mThemeChoices;
wxArrayString mRangeCodes;
wxArrayString mRangeChoices;
wxArrayStringEx mRangeCodes;
wxArrayStringEx mRangeChoices;
};
/// A PrefsPanelFactory that creates one GUIPrefs panel.

View File

@@ -95,12 +95,13 @@ void ModulePrefs::Populate()
void ModulePrefs::PopulateOrExchange(ShuttleGui & S)
{
wxArrayString StatusChoices;
StatusChoices.Add( _("Disabled" ) );
StatusChoices.Add( _("Enabled" ) );
StatusChoices.Add( _("Ask" ) );
StatusChoices.Add( _("Failed" ) );
StatusChoices.Add( _("New" ) );
wxArrayStringEx StatusChoices{
_("Disabled" ) ,
_("Enabled" ) ,
_("Ask" ) ,
_("Failed" ) ,
_("New" ) ,
};
S.SetBorder(2);
S.StartScroller();

View File

@@ -145,17 +145,19 @@ const wxArrayString &SpectrogramSettings::GetScaleNames()
{
void Populate() override
{
// Keep in correspondence with enum SpectrogramSettings::ScaleType:
mContents.Add(_("Linear"));
mContents.Add(_("Logarithmic"));
/* i18n-hint: The name of a frequency scale in psychoacoustics */
mContents.Add(_("Mel"));
/* i18n-hint: The name of a frequency scale in psychoacoustics, named for Heinrich Barkhausen */
mContents.Add(_("Bark"));
/* i18n-hint: The name of a frequency scale in psychoacoustics, abbreviates Equivalent Rectangular Bandwidth */
mContents.Add(_("ERB"));
/* i18n-hint: Time units, that is Period = 1 / Frequency */
mContents.Add(_("Period"));
mContents.insert( mContents.end(), {
// Keep in correspondence with enum SpectrogramSettings::ScaleType:
_("Linear") ,
_("Logarithmic") ,
/* i18n-hint: The name of a frequency scale in psychoacoustics */
_("Mel") ,
/* i18n-hint: The name of a frequency scale in psychoacoustics, named for Heinrich Barkhausen */
_("Bark") ,
/* i18n-hint: The name of a frequency scale in psychoacoustics, abbreviates Equivalent Rectangular Bandwidth */
_("ERB") ,
/* i18n-hint: Time units, that is Period = 1 / Frequency */
_("Period") ,
} );
}
};
@@ -170,12 +172,14 @@ const wxArrayString &SpectrogramSettings::GetAlgorithmNames()
{
void Populate() override
{
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
mContents.Add(_("Frequencies"));
/* i18n-hint: the Reassignment algorithm for spectrograms */
mContents.Add(_("Reassignment"));
/* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
mContents.Add(_("Pitch (EAC)"));
mContents.insert( mContents.end(), {
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
_("Frequencies") ,
/* i18n-hint: the Reassignment algorithm for spectrograms */
_("Reassignment") ,
/* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
_("Pitch (EAC)") ,
} );
}
};

View File

@@ -73,7 +73,7 @@ class SpectrumPrefs final : public PrefsPanel
wxTextCtrl *mRange;
wxTextCtrl *mFrequencyGain;
wxArrayString mSizeChoices;
wxArrayStringEx mSizeChoices;
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
int mZeroPaddingChoice;

View File

@@ -33,8 +33,8 @@ class TracksBehaviorsPrefs final : public PrefsPanel
void Populate();
void PopulateOrExchange(ShuttleGui & S) override;
wxArrayString mSoloCodes;
wxArrayString mSoloChoices;
wxArrayStringEx mSoloCodes;
wxArrayStringEx mSoloChoices;
};
/// A PrefsPanelFactory that creates one TracksBehaviorsPrefs panel.

View File

@@ -48,8 +48,8 @@ private:
wxChoice *mRangeChoice;
wxArrayString mScaleChoices;
wxArrayString mRangeCodes;
wxArrayString mRangeChoices;
wxArrayStringEx mRangeCodes;
wxArrayStringEx mRangeChoices;
WaveformSettings mTempSettings;

View File

@@ -110,7 +110,7 @@ void WaveformSettings::Update()
void WaveformSettings::ConvertToEnumeratedDBRange()
{
// Assumes the codes are in ascending sequence.
wxArrayString codes;
wxArrayStringEx codes;
GUIPrefs::GetRangeChoices(NULL, &codes);
int ii = 0;
for (int nn = codes.size(); ii < nn; ++ii) {
@@ -124,7 +124,7 @@ void WaveformSettings::ConvertToEnumeratedDBRange()
void WaveformSettings::ConvertToActualDBRange()
{
wxArrayString codes;
wxArrayStringEx codes;
GUIPrefs::GetRangeChoices(NULL, &codes);
long value = 0;
codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]