From 6d5bc21d50a72093f5174e34400033153c5aa4bd Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 12 Feb 2019 16:30:22 -0500 Subject: [PATCH] Define and use wxArrayStringEx... reducing verbosity where there were repeated calls of Add(), and defining move construction and assignment for efficient returns from functions --- src/BatchCommands.cpp | 14 +-- src/BatchCommands.h | 3 +- src/Dependencies.cpp | 13 ++- src/FileFormats.cpp | 16 +-- src/FreqWindow.cpp | 49 ++++---- src/MemoryX.h | 57 +++++++++ src/Snap.cpp | 14 +-- src/Snap.h | 2 +- src/Theme.cpp | 13 ++- src/TimerRecordDialog.cpp | 11 +- src/TranslatableStringArray.h | 2 +- src/commands/ScreenshotCommand.cpp | 15 +-- src/commands/ScreenshotCommand.h | 2 +- src/effects/Equalization.cpp | 11 +- src/effects/NoiseReduction.cpp | 46 ++++---- src/effects/audiounits/AudioUnitEffect.cpp | 2 +- src/export/ExportFLAC.cpp | 45 ++++--- src/import/ImportRaw.cpp | 32 ++--- src/menus/TrackMenus.cpp | 29 ++--- src/prefs/EffectsPrefs.cpp | 27 ++--- src/prefs/GUIPrefs.cpp | 110 +++++++++++------- src/prefs/GUIPrefs.h | 20 ++-- src/prefs/ModulePrefs.cpp | 13 ++- src/prefs/SpectrogramSettings.cpp | 38 +++--- src/prefs/SpectrumPrefs.h | 2 +- src/prefs/TracksBehaviorsPrefs.h | 4 +- src/prefs/WaveformPrefs.h | 4 +- src/prefs/WaveformSettings.cpp | 4 +- .../wavetrack/ui/WaveTrackControls.cpp | 27 ++--- src/widgets/Meter.cpp | 20 ++-- 30 files changed, 383 insertions(+), 262 deletions(-) diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index dec8cb2e1..830ecd0a7 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -111,14 +111,14 @@ static const wxString FadeEnds = XO("Fade Ends"); static const wxString SelectToEnds = XO("Select to Ends"); -wxArrayString MacroCommands::GetNamesOfDefaultMacros() +wxArrayStringEx MacroCommands::GetNamesOfDefaultMacros() { - wxArrayString defaults; - defaults.Add( GetCustomTranslation( MP3Conversion ) ); - defaults.Add( GetCustomTranslation( FadeEnds ) ); - //Don't add this one anymore, as there is a new menu command for it. - //defaults.Add( GetCustomTranslation( SelectToEnds ) ); - return defaults; + return { + GetCustomTranslation( MP3Conversion ) , + GetCustomTranslation( FadeEnds ) , + //Don't add this one anymore, as there is a new menu command for it. + //GetCustomTranslation( SelectToEnds ) , + }; } void MacroCommands::RestoreMacro(const wxString & name) diff --git a/src/BatchCommands.h b/src/BatchCommands.h index 943b1f9d2..883c62d98 100644 --- a/src/BatchCommands.h +++ b/src/BatchCommands.h @@ -20,6 +20,7 @@ class Effect; class CommandContext; class AudacityProject; +class wxArrayStringEx; class MacroCommandsCatalog { public: @@ -81,7 +82,7 @@ class MacroCommands final { // These commands do not depend on the command list. static void MigrateLegacyChains(); static wxArrayString GetNames(); - static wxArrayString GetNamesOfDefaultMacros(); + static wxArrayStringEx GetNamesOfDefaultMacros(); static wxString GetCurrentParamsFor(const wxString & command); static wxString PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent); diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index ff330ae8f..9507cbd76 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -387,12 +387,13 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S) { S.StartHorizontalLay(wxALIGN_LEFT,0); { - wxArrayString choices; - /*i18n-hint: One of the choices of what you want Audacity to do when - * Audacity finds a project depends on another file.*/ - choices.Add(_("Ask me")); - choices.Add(_("Always copy all files (safest)")); - choices.Add(_("Never copy any files")); + wxArrayStringEx choices{ + /*i18n-hint: One of the choices of what you want Audacity to do when + * Audacity finds a project depends on another file.*/ + _("Ask me") , + _("Always copy all files (safest)") , + _("Never copy any files") , + }; mFutureActionChoice = S.Id(FutureActionChoiceID).AddChoice( _("Whenever a project depends on other files:"), diff --git a/src/FileFormats.cpp b/src/FileFormats.cpp index 8ca315384..c27bb14e7 100644 --- a/src/FileFormats.cpp +++ b/src/FileFormats.cpp @@ -206,7 +206,7 @@ bool sf_subtype_is_integer(unsigned int format) wxArrayString sf_get_all_extensions() { - wxArrayString exts; + wxArrayStringEx exts; SF_FORMAT_INFO format_info; int count, k; @@ -226,12 +226,14 @@ wxArrayString sf_get_all_extensions() // Some other extensions that are often sound files // but aren't included by libsndfile - exts.Add(wxT("aif")); // AIFF file with a DOS-style extension - exts.Add(wxT("ircam")); - exts.Add(wxT("snd")); - exts.Add(wxT("svx")); - exts.Add(wxT("svx8")); - exts.Add(wxT("sv16")); + exts.insert( exts.end(), { + wxT("aif") , // AIFF file with a DOS-style extension + wxT("ircam") , + wxT("snd") , + wxT("svx") , + wxT("svx8") , + wxT("sv16") , + } ); return exts; } diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index c8cab1f22..2872bba51 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -211,27 +211,29 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, if (!p) return; - wxArrayString algChoices; - algChoices.Add(_("Spectrum")); - algChoices.Add(_("Standard Autocorrelation")); - algChoices.Add(_("Cuberoot Autocorrelation")); - algChoices.Add(_("Enhanced Autocorrelation")); - /* i18n-hint: This is a technical term, derived from the word - * "spectrum". Do not translate it unless you are sure you - * know the correct technical word in your language. */ - algChoices.Add(_("Cepstrum")); + wxArrayStringEx algChoices{ + _("Spectrum") , + _("Standard Autocorrelation") , + _("Cuberoot Autocorrelation") , + _("Enhanced Autocorrelation") , + /* i18n-hint: This is a technical term, derived from the word + * "spectrum". Do not translate it unless you are sure you + * know the correct technical word in your language. */ + _("Cepstrum") , + }; - wxArrayString sizeChoices; - sizeChoices.Add(wxT("128")); - sizeChoices.Add(wxT("256")); - sizeChoices.Add(wxT("512")); - sizeChoices.Add(wxT("1024")); - sizeChoices.Add(wxT("2048")); - sizeChoices.Add(wxT("4096")); - sizeChoices.Add(wxT("8192")); - sizeChoices.Add(wxT("16384")); - sizeChoices.Add(wxT("32768")); - sizeChoices.Add(wxT("65536")); + wxArrayStringEx sizeChoices{ + wxT("128") , + wxT("256") , + wxT("512") , + wxT("1024") , + wxT("2048") , + wxT("4096") , + wxT("8192") , + wxT("16384") , + wxT("32768") , + wxT("65536") , + }; wxArrayString funcChoices; for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++) @@ -242,9 +244,10 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, funcChoices.push_back(wxString::Format("%s window", WindowFuncName(i) ) ); } - wxArrayString axisChoices; - axisChoices.Add(_("Linear frequency")); - axisChoices.Add(_("Log frequency")); + wxArrayStringEx axisChoices{ + _("Linear frequency") , + _("Log frequency") , + }; mFreqFont = wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); mArrowCursor = std::make_unique(wxCURSOR_ARROW); diff --git a/src/MemoryX.h b/src/MemoryX.h index 8dc362e3b..7b4b05270 100644 --- a/src/MemoryX.h +++ b/src/MemoryX.h @@ -656,4 +656,61 @@ OutContainer transform_container( InContainer &inContainer, Function &&fn ) inContainer.begin(), inContainer.end(), fn ); } +// Extend wxArrayString with move operations and construction and insertion from +// std::initializer_list +class wxArrayStringEx : public wxArrayString +{ +public: + using wxArrayString::wxArrayString; + wxArrayStringEx() = default; + + template< typename Iterator > + wxArrayStringEx( Iterator start, Iterator finish ) + { + this->reserve( std::distance( start, finish ) ); + while( start != finish ) + this->push_back( *start++ ); + } + + template< typename T > + wxArrayStringEx( std::initializer_list< T > items ) + { + this->reserve( this->size() + items.size() ); + for ( const auto &item : items ) + this->push_back( item ); + } + + // The move operations can take arguments of the base class wxArrayString + wxArrayStringEx( wxArrayString &&other ) + { + swap( other ); + } + + wxArrayStringEx &operator= ( wxArrayString &&other ) + { + if ( this != &other ) { + clear(); + swap( other ); + } + return *this; + } + + using wxArrayString::insert; + + template< typename T > + iterator insert( const_iterator pos, std::initializer_list< T > items ) + { + const auto index = pos - ((const wxArrayString*)this)->begin(); + this->wxArrayString::Insert( {}, index, items.size() ); + auto result = this->begin() + index, iter = result; + for ( auto pItem = items.begin(), pEnd = items.end(); + pItem != pEnd; + ++pItem, ++iter + ) { + *iter = *pItem; + } + return result; + } +}; + #endif // __AUDACITY_MEMORY_X_H__ diff --git a/src/Snap.cpp b/src/Snap.cpp index 4eaa8b753..c08807436 100644 --- a/src/Snap.cpp +++ b/src/Snap.cpp @@ -353,15 +353,13 @@ SnapResults SnapManager::Snap return results; } -/* static */ wxArrayString SnapManager::GetSnapLabels() +/* static */ wxArrayStringEx SnapManager::GetSnapLabels() { - wxArrayString labels; - - labels.Add(_("Off")); - labels.Add(_("Nearest")); - labels.Add(_("Prior")); - - return labels; + return wxArrayStringEx{ + _("Off") , + _("Nearest") , + _("Prior") , + }; } #include "AColor.h" diff --git a/src/Snap.h b/src/Snap.h index b33f41c81..766e169c0 100644 --- a/src/Snap.h +++ b/src/Snap.h @@ -102,7 +102,7 @@ public: double t, bool rightEdge); - static wxArrayString GetSnapLabels(); + static wxArrayStringEx GetSnapLabels(); // The two coordinates need not be ordered: static void Draw( wxDC *dc, wxInt64 snap0, wxInt64 snap1 ); diff --git a/src/Theme.cpp b/src/Theme.cpp index 5aa880d39..f7b7c87a8 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -931,12 +931,13 @@ teThemeType ThemeBase::GetFallbackThemeType(){ teThemeType ThemeBase::ThemeTypeOfTypeName( const wxString & Name ) { - wxArrayString aThemes; - aThemes.Add( "classic" ); - aThemes.Add( "dark" ); - aThemes.Add( "light" ); - aThemes.Add( "high-contrast" ); - aThemes.Add( "custom" ); + static const wxArrayStringEx aThemes{ + "classic" , + "dark" , + "light" , + "high-contrast" , + "custom" , + }; int themeIx = make_iterator_range( aThemes ).index( Name ); if( themeIx < 0 ) return GetFallbackThemeType(); diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index d7bac7f89..ca5a313cd 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -928,11 +928,12 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) S.StartMultiColumn(1, wxEXPAND); { S.SetStretchyCol( 0 ); - wxArrayString arrayOptions; - arrayOptions.Add(_("Do nothing")); - arrayOptions.Add(_("Exit Audacity")); - arrayOptions.Add(_("Restart system")); - arrayOptions.Add(_("Shutdown system")); + wxArrayStringEx arrayOptions{ + _("Do nothing") , + _("Exit Audacity") , + _("Restart system") , + _("Shutdown system") , + }; m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[0]); m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[1]); diff --git a/src/TranslatableStringArray.h b/src/TranslatableStringArray.h index 132e3cccc..2f494ddfe 100644 --- a/src/TranslatableStringArray.h +++ b/src/TranslatableStringArray.h @@ -64,6 +64,6 @@ protected: ArrayType mContents; }; -typedef TranslatableArray TranslatableStringArray; +typedef TranslatableArray TranslatableStringArray; #endif diff --git a/src/commands/ScreenshotCommand.cpp b/src/commands/ScreenshotCommand.cpp index 29bcbcd87..d75d14b38 100644 --- a/src/commands/ScreenshotCommand.cpp +++ b/src/commands/ScreenshotCommand.cpp @@ -465,7 +465,7 @@ void ScreenshotCommand::CaptureEffects( #define CAPTURE_NYQUIST_TOO // Commented out the effects that don't have dialogs. // Also any problematic ones, - const wxString EffectNames[] = { + CaptureCommands( context, { #ifdef TRICKY_CAPTURE //"Contrast...", // renamed "ContrastAnalyser", @@ -542,9 +542,7 @@ void ScreenshotCommand::CaptureEffects( "Silence Finder...", "Sound Finder...", #endif - }; - wxArrayString Commands( sizeof(EffectNames)/sizeof(EffectNames[0]), EffectNames ); - CaptureCommands( context, Commands ); + } ); } void ScreenshotCommand::CaptureScriptables( @@ -555,7 +553,7 @@ void ScreenshotCommand::CaptureScriptables( (void)&FileName;//compiler food. (void)&context; - const wxString ScriptablesNames[] = { + CaptureCommands( context, { "SelectTime", "SelectFrequencies", "SelectTracks", @@ -581,16 +579,13 @@ void ScreenshotCommand::CaptureScriptables( "Drag", "CompareAudio", "Screenshot", - }; - - wxArrayString Commands( sizeof(ScriptablesNames)/sizeof(ScriptablesNames[0]), ScriptablesNames ); - CaptureCommands( context, Commands ); + } ); } void ScreenshotCommand::CaptureCommands( - const CommandContext & context, wxArrayString & Commands ){ + const CommandContext & context, const wxArrayStringEx & Commands ){ AudacityProject * pProject = context.GetProject(); CommandManager * pMan = pProject->GetCommandManager(); wxString Str; diff --git a/src/commands/ScreenshotCommand.h b/src/commands/ScreenshotCommand.h index bb68d0f6b..87c996490 100644 --- a/src/commands/ScreenshotCommand.h +++ b/src/commands/ScreenshotCommand.h @@ -120,7 +120,7 @@ private: bool CaptureToolbar(const CommandContext & Context, ToolManager *man, int type, const wxString &name); bool CaptureDock(const CommandContext & Context, wxWindow *win, const wxString &fileName); - void CaptureCommands(const CommandContext & Context, wxArrayString &Commands ); + void CaptureCommands(const CommandContext & Context, const wxArrayStringEx &Commands ); void CaptureEffects(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName ); void CaptureScriptables(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName ); void CapturePreferences(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName ); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 47921a847..9393d3adb 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -3299,11 +3299,12 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event)) int curve = 0; // Setup list of characters that aren't allowed - wxArrayString exclude; - exclude.Add( wxT("<") ); - exclude.Add( wxT(">") ); - exclude.Add( wxT("'") ); - exclude.Add( wxT("\"") ); + wxArrayStringEx exclude{ + wxT("<") , + wxT(">") , + wxT("'") , + wxT("\"") , + }; // Get the first one to be renamed long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index 2539e1f4b..29292377b 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -1749,7 +1749,7 @@ void EffectNoiseReduction::Dialog::PopulateOrExchange(ShuttleGui & S) S.StartMultiColumn(2); { { - wxArrayString windowTypeChoices; + wxArrayStringEx windowTypeChoices; for (int ii = 0; ii < WT_N_WINDOW_TYPES; ++ii) windowTypeChoices.push_back(windowTypesInfo[ii].name); S.TieChoice(_("&Window types") + wxString(wxT(":")), @@ -1758,32 +1758,34 @@ void EffectNoiseReduction::Dialog::PopulateOrExchange(ShuttleGui & S) } { - wxArrayString windowSizeChoices; - windowSizeChoices.Add(_("8")); - windowSizeChoices.Add(_("16")); - windowSizeChoices.Add(_("32")); - windowSizeChoices.Add(_("64")); - windowSizeChoices.Add(_("128")); - windowSizeChoices.Add(_("256")); - windowSizeChoices.Add(_("512")); - windowSizeChoices.Add(_("1024")); - windowSizeChoices.Add(_("2048 (default)")); - windowSizeChoices.Add(_("4096")); - windowSizeChoices.Add(_("8192")); - windowSizeChoices.Add(_("16384")); + wxArrayStringEx windowSizeChoices{ + _("8") , + _("16") , + _("32") , + _("64") , + _("128") , + _("256") , + _("512") , + _("1024") , + _("2048 (default)") , + _("4096") , + _("8192") , + _("16384") , + }; S.TieChoice(_("Window si&ze") + wxString(wxT(":")), mTempSettings.mWindowSizeChoice, &windowSizeChoices); } { - wxArrayString stepsPerWindowChoices; - stepsPerWindowChoices.Add(_("2")); - stepsPerWindowChoices.Add(_("4 (default)")); - stepsPerWindowChoices.Add(_("8")); - stepsPerWindowChoices.Add(_("16")); - stepsPerWindowChoices.Add(_("32")); - stepsPerWindowChoices.Add(_("64")); + wxArrayStringEx stepsPerWindowChoices{ + _("2") , + _("4 (default)") , + _("8") , + _("16") , + _("32") , + _("64") , + }; S.TieChoice(_("S&teps per window") + wxString(wxT(":")), mTempSettings.mStepsPerWindowChoice, &stepsPerWindowChoices); @@ -1791,7 +1793,7 @@ void EffectNoiseReduction::Dialog::PopulateOrExchange(ShuttleGui & S) S.Id(ID_CHOICE_METHOD); { - wxArrayString methodChoices; + wxArrayStringEx methodChoices; int nn = DM_N_METHODS; #ifndef OLD_METHOD_AVAILABLE --nn; diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index aa1455467..07d982931 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -340,7 +340,7 @@ private: bool mUseLatency; wxString mUIType; - wxArrayString mUITypes; + wxArrayStringEx mUITypes; DECLARE_EVENT_TABLE() }; diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index 25ff8b031..6f840e722 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -81,20 +81,39 @@ ExportFLACOptions::~ExportFLACOptions() /// void ExportFLACOptions::PopulateOrExchange(ShuttleGui & S) { - wxArrayString flacLevelNames, flacLevelLabels; - flacLevelLabels.Add(wxT("0")); flacLevelNames.Add(_("0 (fastest)")); - flacLevelLabels.Add(wxT("1")); flacLevelNames.Add(_("1")); - flacLevelLabels.Add(wxT("2")); flacLevelNames.Add(_("2")); - flacLevelLabels.Add(wxT("3")); flacLevelNames.Add(_("3")); - flacLevelLabels.Add(wxT("4")); flacLevelNames.Add(_("4")); - flacLevelLabels.Add(wxT("5")); flacLevelNames.Add(_("5")); - flacLevelLabels.Add(wxT("6")); flacLevelNames.Add(_("6")); - flacLevelLabels.Add(wxT("7")); flacLevelNames.Add(_("7")); - flacLevelLabels.Add(wxT("8")); flacLevelNames.Add(_("8 (best)")); + wxArrayStringEx flacLevelLabels{ + wxT("0") , + wxT("1") , + wxT("2") , + wxT("3") , + wxT("4") , + wxT("5") , + wxT("6") , + wxT("7") , + wxT("8") , + }; - wxArrayString flacBitDepthNames, flacBitDepthLabels; - flacBitDepthLabels.Add(wxT("16")); flacBitDepthNames.Add(_("16 bit")); - flacBitDepthLabels.Add(wxT("24")); flacBitDepthNames.Add(_("24 bit")); + wxArrayStringEx flacLevelNames{ + _("0 (fastest)") , + _("1") , + _("2") , + _("3") , + _("4") , + _("5") , + _("6") , + _("7") , + _("8 (best)") , + }; + + wxArrayStringEx flacBitDepthLabels{ + wxT("16") , + wxT("24") , + }; + + wxArrayStringEx flacBitDepthNames{ + _("16 bit") , + _("24 bit") , + }; S.StartVerticalLay(); { diff --git a/src/import/ImportRaw.cpp b/src/import/ImportRaw.cpp index 0405d1ea0..287ce42d1 100644 --- a/src/import/ImportRaw.cpp +++ b/src/import/ImportRaw.cpp @@ -321,8 +321,6 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent, ShuttleGui S(this, eIsCreating); wxArrayString encodings; - wxArrayString endians; - wxArrayString chans; int num; int selection; int endian; @@ -354,18 +352,20 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent, } } - /* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't + wxArrayStringEx endians{ + /* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't + know the correct technical word. */ + _("No endianness") , + /* i18n-hint: Refers to byte-order. Don't translate this if you don't know the correct technical word. */ - endians.Add(_("No endianness")); - /* i18n-hint: Refers to byte-order. Don't translate this if you don't - know the correct technical word. */ - endians.Add(_("Little-endian")); - /* i18n-hint: Refers to byte-order. Don't translate this if you don't - know the correct technical word. */ - endians.Add(_("Big-endian")); - /* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't - know the correct technical word. */ - endians.Add(_("Default endianness")); + _("Little-endian") , + /* i18n-hint: Refers to byte-order. Don't translate this if you don't + know the correct technical word. */ + _("Big-endian") , + /* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't + know the correct technical word. */ + _("Default endianness") , + }; switch (mEncoding & (SF_FORMAT_ENDMASK)) { @@ -384,8 +384,10 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent, break; } - chans.Add(_("1 Channel (Mono)")); - chans.Add(_("2 Channels (Stereo)")); + wxArrayStringEx chans{ + _("1 Channel (Mono)") , + _("2 Channels (Stereo)") , + }; for (i=2; i<16; i++) { chans.push_back(wxString::Format(_("%d Channels"), i + 1)); } diff --git a/src/menus/TrackMenus.cpp b/src/menus/TrackMenus.cpp index 62845acae..6e56c08a7 100644 --- a/src/menus/TrackMenus.cpp +++ b/src/menus/TrackMenus.cpp @@ -895,24 +895,25 @@ void OnResample(const CommandContext &context) dlg.SetName(dlg.GetTitle()); ShuttleGui S(&dlg, eIsCreating); wxString rate; - wxArrayString rates; wxComboBox *cb; rate.Printf(wxT("%ld"), lrint(projectRate)); - rates.Add(wxT("8000")); - rates.Add(wxT("11025")); - rates.Add(wxT("16000")); - rates.Add(wxT("22050")); - rates.Add(wxT("32000")); - rates.Add(wxT("44100")); - rates.Add(wxT("48000")); - rates.Add(wxT("88200")); - rates.Add(wxT("96000")); - rates.Add(wxT("176400")); - rates.Add(wxT("192000")); - rates.Add(wxT("352800")); - rates.Add(wxT("384000")); + wxArrayStringEx rates{ + wxT("8000") , + wxT("11025") , + wxT("16000") , + wxT("22050") , + wxT("32000") , + wxT("44100") , + wxT("48000") , + wxT("88200") , + wxT("96000") , + wxT("176400") , + wxT("192000") , + wxT("352800") , + wxT("384000") , + }; S.StartVerticalLay(true); { diff --git a/src/prefs/EffectsPrefs.cpp b/src/prefs/EffectsPrefs.cpp index c66d187fe..a4cc7a9f5 100644 --- a/src/prefs/EffectsPrefs.cpp +++ b/src/prefs/EffectsPrefs.cpp @@ -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"), diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index 2330437a0..e87324512 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -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 -------------------- diff --git a/src/prefs/GUIPrefs.h b/src/prefs/GUIPrefs.h index 46e631f2b..b10e9ccd4 100644 --- a/src/prefs/GUIPrefs.h +++ b/src/prefs/GUIPrefs.h @@ -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. diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index 0181847c0..117511137 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -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(); diff --git a/src/prefs/SpectrogramSettings.cpp b/src/prefs/SpectrogramSettings.cpp index 5c91a4940..561e1900a 100644 --- a/src/prefs/SpectrogramSettings.cpp +++ b/src/prefs/SpectrogramSettings.cpp @@ -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)") , + } ); } }; diff --git a/src/prefs/SpectrumPrefs.h b/src/prefs/SpectrumPrefs.h index 7c6ddf96f..d3cf328ad 100644 --- a/src/prefs/SpectrumPrefs.h +++ b/src/prefs/SpectrumPrefs.h @@ -73,7 +73,7 @@ class SpectrumPrefs final : public PrefsPanel wxTextCtrl *mRange; wxTextCtrl *mFrequencyGain; - wxArrayString mSizeChoices; + wxArrayStringEx mSizeChoices; #ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS int mZeroPaddingChoice; diff --git a/src/prefs/TracksBehaviorsPrefs.h b/src/prefs/TracksBehaviorsPrefs.h index e281ecdc4..ba7eca13a 100644 --- a/src/prefs/TracksBehaviorsPrefs.h +++ b/src/prefs/TracksBehaviorsPrefs.h @@ -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. diff --git a/src/prefs/WaveformPrefs.h b/src/prefs/WaveformPrefs.h index af25fbcec..35407ff67 100644 --- a/src/prefs/WaveformPrefs.h +++ b/src/prefs/WaveformPrefs.h @@ -48,8 +48,8 @@ private: wxChoice *mRangeChoice; wxArrayString mScaleChoices; - wxArrayString mRangeCodes; - wxArrayString mRangeChoices; + wxArrayStringEx mRangeCodes; + wxArrayStringEx mRangeChoices; WaveformSettings mTempSettings; diff --git a/src/prefs/WaveformSettings.cpp b/src/prefs/WaveformSettings.cpp index 794e19fb2..51e4d0138 100644 --- a/src/prefs/WaveformSettings.cpp +++ b/src/prefs/WaveformSettings.cpp @@ -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))] diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp index 8712090ee..dbe4b7d53 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp @@ -468,23 +468,24 @@ void RateMenuTable::OnRateOther(wxCommandEvent &) dlg.SetName(dlg.GetTitle()); ShuttleGui S(&dlg, eIsCreating); wxString rate; - wxArrayString rates; wxComboBox *cb; rate.Printf(wxT("%ld"), lrint(pTrack->GetRate())); - rates.Add(wxT("8000")); - rates.Add(wxT("11025")); - rates.Add(wxT("16000")); - rates.Add(wxT("22050")); - rates.Add(wxT("44100")); - rates.Add(wxT("48000")); - rates.Add(wxT("88200")); - rates.Add(wxT("96000")); - rates.Add(wxT("176400")); - rates.Add(wxT("192000")); - rates.Add(wxT("352800")); - rates.Add(wxT("384000")); + wxArrayStringEx rates{ + wxT("8000") , + wxT("11025") , + wxT("16000") , + wxT("22050") , + wxT("44100") , + wxT("48000") , + wxT("88200") , + wxT("96000") , + wxT("176400") , + wxT("192000") , + wxT("352800") , + wxT("384000") , + }; S.StartVerticalLay(true); { diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index ffc878ae1..aed451a39 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -579,12 +579,13 @@ void MeterPanel::OnPaint(wxPaintEvent & WXUNUSED(event)) if( mIsInput && !mActive ) { destDC.SetFont( GetFont() ); - wxArrayString texts; - texts.Add( _("Click to Start Monitoring") ); - texts.Add( _("Click for Monitoring") ); - texts.Add( _("Click to Start") ); - texts.Add( _("Click") ); + wxArrayStringEx texts{ + _("Click to Start Monitoring") , + _("Click for Monitoring") , + _("Click to Start") , + _("Click") , + }; for( size_t i = 0, cnt = texts.size(); i < cnt; i++ ) { @@ -1999,10 +2000,11 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event)) if (dlg.ShowModal() == wxID_OK) { - wxArrayString style; - style.Add(wxT("AutomaticStereo")); - style.Add(wxT("HorizontalStereo")); - style.Add(wxT("VerticalStereo")); + wxArrayStringEx style{ + wxT("AutomaticStereo") , + wxT("HorizontalStereo") , + wxT("VerticalStereo") , + }; int s = 0; s = automatic->GetValue() ? 0 : s;