1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 00:20:06 +02:00

IdentInterfaceSymbol to distinguish internal vs visible enum settings

This commit is contained in:
Paul Licameli 2018-03-26 22:03:45 -04:00
parent 595cf05d42
commit 2065eebff6
21 changed files with 205 additions and 198 deletions

View File

@ -50,6 +50,8 @@
#include <wx/intl.h> #include <wx/intl.h>
#include <algorithm> #include <algorithm>
#include "IdentInterface.h"
/** /**
\brief CommandParameters, derived from wxFileConfig, is essentially doing \brief CommandParameters, derived from wxFileConfig, is essentially doing
@ -162,7 +164,7 @@ public:
using ObsoleteMap = std::pair< wxString, size_t >; using ObsoleteMap = std::pair< wxString, size_t >;
bool ReadEnum(const wxString & key, int *pi, bool ReadEnum(const wxString & key, int *pi,
const wxString choices[], size_t nChoices, const IdentInterfaceSymbol choices[], size_t nChoices,
const ObsoleteMap obsoletes[] = nullptr, const ObsoleteMap obsoletes[] = nullptr,
size_t nObsoletes = 0) const size_t nObsoletes = 0) const
{ {
@ -172,7 +174,7 @@ public:
return false; return false;
} }
*pi = std::find( choices, choices + nChoices, *pi = std::find( choices, choices + nChoices,
s ) - choices; IdentInterfaceSymbol{ s, {} } ) - choices;
if (*pi == nChoices) if (*pi == nChoices)
*pi = -1; *pi = -1;
if (*pi < 0 && obsoletes) { if (*pi < 0 && obsoletes) {
@ -187,7 +189,7 @@ public:
} }
bool ReadEnum(const wxString & key, int *pi, int defVal, bool ReadEnum(const wxString & key, int *pi, int defVal,
const wxString choices[], size_t nChoices, const IdentInterfaceSymbol choices[], size_t nChoices,
const ObsoleteMap obsoletes[] = nullptr, const ObsoleteMap obsoletes[] = nullptr,
size_t nObsoletes = 0) const size_t nObsoletes = 0) const
{ {
@ -199,14 +201,14 @@ public:
} }
bool WriteEnum(const wxString & key, int value, bool WriteEnum(const wxString & key, int value,
const wxString choices[], size_t nChoices) const IdentInterfaceSymbol choices[], size_t nChoices)
{ {
if (value < 0 || value >= nChoices) if (value < 0 || value >= nChoices)
{ {
return false; return false;
} }
return wxFileConfig::Write(key, choices[value]); return wxFileConfig::Write(key, choices[value].Internal());
} }
bool ReadAndVerify(const wxString & key, float *val, float defVal, float min, float max) const bool ReadAndVerify(const wxString & key, float *val, float defVal, float min, float max) const
@ -246,7 +248,7 @@ public:
} }
bool ReadAndVerify(const wxString & key, int *val, int defVal, bool ReadAndVerify(const wxString & key, int *val, int defVal,
const wxString choices[], size_t nChoices, const IdentInterfaceSymbol choices[], size_t nChoices,
const ObsoleteMap obsoletes[] = nullptr, const ObsoleteMap obsoletes[] = nullptr,
size_t nObsoletes = 0) const size_t nObsoletes = 0) const
{ {

View File

@ -31,6 +31,7 @@ and on Mac OS X for the filesystem.
#include "FileNames.h" #include "FileNames.h"
#include "widgets/ErrorDialog.h" #include "widgets/ErrorDialog.h"
#include "Internat.h" #include "Internat.h"
#include "../include/audacity/IdentInterface.h"
// in order for the static member variables to exist, they must appear here // in order for the static member variables to exist, they must appear here
// (_outside_) the class definition, in order to be allocated some storage. // (_outside_) the class definition, in order to be allocated some storage.
@ -298,3 +299,12 @@ wxString Internat::StripAccelerators(const wxString &s)
} }
return result; return result;
} }
wxArrayString LocalizedStrings(
const IdentInterfaceSymbol strings[], size_t nStrings)
{
wxArrayString results;
std::transform( strings, strings + nStrings, std::back_inserter(results),
std::mem_fun_ref( &IdentInterfaceSymbol::Translation ) );
return results;
}

View File

@ -169,20 +169,9 @@ private:
#define UTF8CTOWX(X) wxString((X), wxConvUTF8) #define UTF8CTOWX(X) wxString((X), wxConvUTF8)
#define LAT1CTOWX(X) wxString((X), wxConvISO8859_1) #define LAT1CTOWX(X) wxString((X), wxConvISO8859_1)
inline wxArrayString LocalizedStrings(const wxString strings[], size_t nStrings) class IdentInterfaceSymbol;
{ wxArrayString LocalizedStrings(
wxArrayString results; const IdentInterfaceSymbol strings[], size_t nStrings);
std::transform( strings, strings + nStrings, std::back_inserter(results),
GetCustomTranslation );
return results;
}
inline wxArrayString LocalizedStrings(const wxArrayString &strings)
{
if (strings.empty())
return {};
return LocalizedStrings( &strings[0], strings.size() );
}
// This object pairs an internal string, maybe empty, with a translated string. // This object pairs an internal string, maybe empty, with a translated string.
// Any internal string may be written to configuration or other files and, // Any internal string may be written to configuration or other files and,

View File

@ -343,7 +343,7 @@ void ShuttleParams::Define( float & var, const wxChar * key, const float vdef
void ShuttleParams::Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ){;}; void ShuttleParams::Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ){;};
void ShuttleParams::Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ){;}; void ShuttleParams::Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ){;};
void ShuttleParams::Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ){;}; void ShuttleParams::Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ){;};
void ShuttleParams::DefineEnum( int &var, const wxChar * key, const int vdefault, const wxString strings[], size_t nStrings ){;}; void ShuttleParams::DefineEnum( int &var, const wxChar * key, const int vdefault, const IdentInterfaceSymbol strings[], size_t nStrings ){;};
@ -403,10 +403,10 @@ void ShuttleGetAutomation::Define( wxString &var, const wxChar * key, const wxSt
} }
void ShuttleGetAutomation::DefineEnum( int &var, const wxChar * key, const int vdefault, const wxString strings[], size_t nStrings ) void ShuttleGetAutomation::DefineEnum( int &var, const wxChar * key, const int vdefault, const IdentInterfaceSymbol strings[], size_t nStrings )
{ {
if( !ShouldSet() ) return; if( !ShouldSet() ) return;
mpEap->Write(key, strings[var]); mpEap->Write(key, strings[var].Internal());
} }
@ -513,7 +513,7 @@ void ShuttleSetAutomation::Define( wxString &var, const wxChar * key, const wxSt
} }
void ShuttleSetAutomation::DefineEnum( int &var, const wxChar * key, const int vdefault, const wxString strings[], size_t nStrings ) void ShuttleSetAutomation::DefineEnum( int &var, const wxChar * key, const int vdefault, const IdentInterfaceSymbol strings[], size_t nStrings )
{ {
CouldGet( key ); CouldGet( key );
if( !bOK ) if( !bOK )
@ -630,7 +630,7 @@ void ShuttleGetDefinition::Define( wxString &var, const wxChar * key, const wxSt
void ShuttleGetDefinition::DefineEnum( int &var, void ShuttleGetDefinition::DefineEnum( int &var,
const wxChar * key, const int vdefault, const wxChar * key, const int vdefault,
const wxString strings[], size_t nStrings ) const IdentInterfaceSymbol strings[], size_t nStrings )
{ {
StartStruct(); StartStruct();
AddItem( wxString(key), "key" ); AddItem( wxString(key), "key" );
@ -638,11 +638,11 @@ void ShuttleGetDefinition::DefineEnum( int &var,
if( IsOptional() ) if( IsOptional() )
AddItem( "unchanged", "default" ); AddItem( "unchanged", "default" );
else else
AddItem( strings[vdefault], "default" ); AddItem( strings[vdefault].Internal(), "default" );
StartField( "enum" ); StartField( "enum" );
StartArray(); StartArray();
for( size_t i = 0; i < nStrings; i++ ) for( size_t i = 0; i < nStrings; i++ )
AddItem( strings[i] ); AddItem( strings[i].Internal() );
EndArray(); EndArray();
EndField(); EndField();
EndStruct(); EndStruct();

View File

@ -12,7 +12,9 @@
#define __AUDACITY_SHUTTLE__ #define __AUDACITY_SHUTTLE__
#include "commands/CommandTargets.h" #include "commands/CommandTargets.h"
#include "../include/audacity/IdentInterface.h"
class IdentInterfaceSymbol;
class WrappedType; class WrappedType;
class Shuttle /* not final */ { class Shuttle /* not final */ {
@ -76,7 +78,7 @@ public:
virtual void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl=1.0f ); virtual void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl=1.0f );
virtual void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin="", const wxString vmax="", const wxString vscl="" ); virtual void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin="", const wxString vmax="", const wxString vscl="" );
virtual void DefineEnum( int &var, const wxChar * key, const int vdefault, virtual void DefineEnum( int &var, const wxChar * key, const int vdefault,
const wxString strings[], size_t nStrings ); const IdentInterfaceSymbol strings[], size_t nStrings );
}; };
/**************************************************************************//** /**************************************************************************//**
@ -94,7 +96,7 @@ public:
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override; void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override; void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
void DefineEnum( int &var, const wxChar * key, const int vdefault, void DefineEnum( int &var, const wxChar * key, const int vdefault,
const wxString strings[], size_t nStrings ) override; const IdentInterfaceSymbol strings[], size_t nStrings ) override;
}; };
/**************************************************************************//** /**************************************************************************//**
@ -118,7 +120,7 @@ public:
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override; void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override; void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
void DefineEnum( int &var, const wxChar * key, const int vdefault, void DefineEnum( int &var, const wxChar * key, const int vdefault,
const wxString strings[], size_t nStrings ) override; const IdentInterfaceSymbol strings[], size_t nStrings ) override;
}; };
/**************************************************************************//** /**************************************************************************//**
@ -139,7 +141,7 @@ public:
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override; void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override; void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
void DefineEnum( int &var, const wxChar * key, const int vdefault, void DefineEnum( int &var, const wxChar * key, const int vdefault,
const wxString strings[], size_t nStrings ) override; const IdentInterfaceSymbol strings[], size_t nStrings ) override;
}; };
@ -176,7 +178,7 @@ public:
const wxString WXUNUSED(vmin), const wxString WXUNUSED(vmax), const wxString WXUNUSED(vscl) ) const wxString WXUNUSED(vmin), const wxString WXUNUSED(vmax), const wxString WXUNUSED(vscl) )
override { var = vdefault;}; override { var = vdefault;};
void DefineEnum( int &var, const wxChar * WXUNUSED(key), const int vdefault, void DefineEnum( int &var, const wxChar * WXUNUSED(key), const int vdefault,
const wxString WXUNUSED(strings) [], size_t WXUNUSED( nStrings ) ) const IdentInterfaceSymbol WXUNUSED(strings) [], size_t WXUNUSED( nStrings ) )
override { var = vdefault;}; override { var = vdefault;};
}; };

View File

@ -38,12 +38,12 @@ enum kCoordTypes
nCoordTypes nCoordTypes
}; };
static const wxString kCoordTypeStrings[nCoordTypes] = static const IdentInterfaceSymbol kCoordTypeStrings[nCoordTypes] =
{ {
XO("Panel"), { XO("Panel") },
XO("App"), { XO("App") },
XO("Track0"), { XO("Track0") },
XO("Track1"), { XO("Track1") },
}; };

View File

@ -55,17 +55,17 @@ enum {
nTypes nTypes
}; };
static const wxString kTypes[nTypes] = static const IdentInterfaceSymbol kTypes[nTypes] =
{ {
XO("Commands"), { XO("Commands") },
XO("Commands+"), { XO("Commands+") },
XO("Menus"), { XO("Menus") },
XO("Preferences"), { XO("Preferences") },
XO("Tracks"), { XO("Tracks") },
XO("Clips"), { XO("Clips") },
XO("Envelopes"), { XO("Envelopes") },
XO("Labels"), { XO("Labels") },
XO("Boxes") { XO("Boxes") },
}; };
enum { enum {
@ -75,11 +75,11 @@ enum {
nFormats nFormats
}; };
static const wxString kFormats[nFormats] = static const IdentInterfaceSymbol kFormats[nFormats] =
{ {
XO("JSON"), { XO("JSON") },
XO("LISP"), { XO("LISP") },
XO("Brief") { XO("Brief") }
}; };

View File

@ -26,11 +26,11 @@
#include "CommandContext.h" #include "CommandContext.h"
const int nTypes =3; const int nTypes =3;
static const wxString kTypes[nTypes] = static const IdentInterfaceSymbol kTypes[nTypes] =
{ {
XO("Tracks"), { XO("Tracks") },
XO("Clips"), { XO("Clips") },
XO("Labels") { XO("Labels") },
}; };

View File

@ -46,48 +46,50 @@ small calculations of rectangles.
#include "CommandContext.h" #include "CommandContext.h"
static const wxString kCaptureWhatStrings[ ScreenshotCommand::nCaptureWhats ] = static const IdentInterfaceSymbol
kCaptureWhatStrings[ ScreenshotCommand::nCaptureWhats ] =
{ {
XO("Window"), { XO("Window") },
XO("Full_Window"), { XO("Full_Window") },
XO("Window_Plus"), { XO("Window_Plus") },
XO("Fullscreen"), { XO("Fullscreen") },
XO("Toolbars"), { XO("Toolbars") },
XO("Effects"), { XO("Effects") },
XO("Scriptables"), { XO("Scriptables") },
XO("Preferences"), { XO("Preferences") },
XO("Selectionbar"), { XO("Selectionbar") },
XO("Spectral_Selection"), { XO("Spectral_Selection") },
XO("Tools"), { XO("Tools") },
XO("Transport"), { XO("Transport") },
XO("Mixer"), { XO("Mixer") },
XO("Meter"), { XO("Meter") },
XO("Play_Meter"), { XO("Play_Meter") },
XO("Record_Meter"), { XO("Record_Meter") },
XO("Edit"), { XO("Edit") },
XO("Device"), { XO("Device") },
XO("Scrub"), { XO("Scrub") },
XO("Transcription"), { XO("Transcription") },
XO("Trackpanel"), { XO("Trackpanel") },
XO("Ruler"), { XO("Ruler") },
XO("Tracks"), { XO("Tracks") },
XO("First_Track"), { XO("First_Track") },
XO("First_Two_Tracks"), { XO("First_Two_Tracks") },
XO("First_Three_Tracks"), { XO("First_Three_Tracks") },
XO("First_Four_Tracks"), { XO("First_Four_Tracks") },
XO("Second_Track"), { XO("Second_Track") },
XO("Tracks_Plus"), { XO("Tracks_Plus") },
XO("First_Track_Plus"), { XO("First_Track_Plus") },
XO("All_Tracks"), { XO("All_Tracks") },
XO("All_Tracks_Plus"), { XO("All_Tracks_Plus") },
}; };
static const wxString kBackgroundStrings[ ScreenshotCommand::nBackgrounds ] = static const IdentInterfaceSymbol
kBackgroundStrings[ ScreenshotCommand::nBackgrounds ] =
{ {
XO("Blue"), { XO("Blue") },
XO("White"), { XO("White") },
XO("None") { XO("None") },
}; };
@ -627,7 +629,7 @@ void ScreenshotCommand::GetDerivedParams()
// Build a suitable filename // Build a suitable filename
mFileName = MakeFileName(mFilePath, mFileName = MakeFileName(mFilePath,
GetCustomTranslation( kCaptureWhatStrings[ mCaptureMode ] )); kCaptureWhatStrings[ mCaptureMode ].Translation() );
if (mBack == kBlue) if (mBack == kBlue)
{ {
@ -777,7 +779,7 @@ wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * pa
wxString ScreenshotCommand::WindowFileName(AudacityProject * proj, wxTopLevelWindow *w){ wxString ScreenshotCommand::WindowFileName(AudacityProject * proj, wxTopLevelWindow *w){
if (w != proj && w->GetTitle() != wxT("")) { if (w != proj && w->GetTitle() != wxT("")) {
mFileName = MakeFileName(mFilePath, mFileName = MakeFileName(mFilePath,
GetCustomTranslation( kCaptureWhatStrings[ mCaptureMode ] ) + kCaptureWhatStrings[ mCaptureMode ].Translation() +
(wxT("-") + w->GetTitle() + wxT("-"))); (wxT("-") + w->GetTitle() + wxT("-")));
} }
return mFileName; return mFileName;

View File

@ -44,14 +44,14 @@ explicitly code all three.
// Relative to project and relative to selection cover MOST options, since you can already // Relative to project and relative to selection cover MOST options, since you can already
// set a selection to a clip. // set a selection to a clip.
const int nRelativeTos =6; const int nRelativeTos =6;
static const wxString kRelativeTo[nRelativeTos] = static const IdentInterfaceSymbol kRelativeTo[nRelativeTos] =
{ {
XO("Project Start"), { XO("Project Start") },
XO("Project"), { XO("Project") },
XO("Project End"), { XO("Project End") },
XO("Selection Start"), { XO("Selection Start") },
XO("Selection"), { XO("Selection") },
XO("Selection End") { XO("Selection End") }
}; };
bool SelectTimeCommand::DefineParams( ShuttleParams & S ){ bool SelectTimeCommand::DefineParams( ShuttleParams & S ){
@ -167,12 +167,12 @@ bool SelectFrequenciesCommand::Apply(const CommandContext & context){
} }
const int nModes =3; const int nModes =3;
static const wxString kModes[nModes] = static const IdentInterfaceSymbol kModes[nModes] =
{ {
/* i18n-hint verb, imperative */ /* i18n-hint verb, imperative */
XO("Set"), { XO("Set") },
XO("Add"), { XO("Add") },
XO("Remove") { XO("Remove") },
}; };
bool SelectTracksCommand::DefineParams( ShuttleParams & S ){ bool SelectTracksCommand::DefineParams( ShuttleParams & S ){

View File

@ -38,12 +38,12 @@ enum kColours
nColours nColours
}; };
static const wxString kColourStrings[nColours] = static const IdentInterfaceSymbol kColourStrings[nColours] =
{ {
XO("Color0"), { XO("Color0") },
XO("Color1"), { XO("Color1") },
XO("Color2"), { XO("Color2") },
XO("Color3"), { XO("Color3") },
}; };

View File

@ -236,12 +236,12 @@ enum kColours
nColours nColours
}; };
static const wxString kColourStrings[nColours] = static const IdentInterfaceSymbol kColourStrings[nColours] =
{ {
XO("Color0"), { XO("Color0") },
XO("Color1"), { XO("Color1") },
XO("Color2"), { XO("Color2") },
XO("Color3"), { XO("Color3") },
}; };
@ -252,10 +252,10 @@ enum kDisplayTypes
nDisplayTypes nDisplayTypes
}; };
static const wxString kDisplayTypeStrings[nDisplayTypes] = static const IdentInterfaceSymbol kDisplayTypeStrings[nDisplayTypes] =
{ {
XO("Waveform"), { XO("Waveform") },
XO("Spectrogram"), { XO("Spectrogram") },
}; };
enum kScaleTypes enum kScaleTypes
@ -265,10 +265,10 @@ enum kScaleTypes
nScaleTypes nScaleTypes
}; };
static const wxString kScaleTypeStrings[nScaleTypes] = static const IdentInterfaceSymbol kScaleTypeStrings[nScaleTypes] =
{ {
XO("Linear"), { XO("Linear") },
XO("dB"), { XO("dB") },
}; };
enum kZoomTypes enum kZoomTypes
@ -279,11 +279,11 @@ enum kZoomTypes
nZoomTypes nZoomTypes
}; };
static const wxString kZoomTypeStrings[nZoomTypes] = static const IdentInterfaceSymbol kZoomTypeStrings[nZoomTypes] =
{ {
XO("Reset"), { XO("Reset") },
XO("Times2"), { XO("Times2") },
XO("HalfWave"), { XO("HalfWave") },
}; };
bool SetTrackVisualsCommand::DefineParams( ShuttleParams & S ){ bool SetTrackVisualsCommand::DefineParams( ShuttleParams & S ){

View File

@ -57,19 +57,19 @@ enum kTableType
nTableTypes nTableTypes
}; };
static const wxString kTableTypeStrings[nTableTypes] = static const IdentInterfaceSymbol kTableTypeStrings[nTableTypes] =
{ {
XO("Hard Clipping"), { XO("Hard Clipping") },
XO("Soft Clipping"), { XO("Soft Clipping") },
XO("Soft Overdrive"), { XO("Soft Overdrive") },
XO("Medium Overdrive"), { XO("Medium Overdrive") },
XO("Hard Overdrive"), { XO("Hard Overdrive") },
XO("Cubic Curve (odd harmonics)"), { XO("Cubic Curve (odd harmonics)") },
XO("Even Harmonics"), { XO("Even Harmonics") },
XO("Expand and Compress"), { XO("Expand and Compress") },
XO("Leveller"), { XO("Leveller") },
XO("Rectifier Distortion"), { XO("Rectifier Distortion") },
XO("Hard Limiter 1413") { XO("Hard Limiter 1413") }
}; };
// Define keys, defaults, minimums, and maximums for the effect parameters // Define keys, defaults, minimums, and maximums for the effect parameters
@ -293,7 +293,8 @@ bool EffectDistortion::DefineParams( ShuttleParams & S ){
bool EffectDistortion::GetAutomationParameters(CommandParameters & parms) bool EffectDistortion::GetAutomationParameters(CommandParameters & parms)
{ {
parms.Write(KEY_TableTypeIndx, kTableTypeStrings[mParams.mTableChoiceIndx]); parms.Write(KEY_TableTypeIndx,
kTableTypeStrings[mParams.mTableChoiceIndx].Internal());
parms.Write(KEY_DCBlock, mParams.mDCBlock); parms.Write(KEY_DCBlock, mParams.mDCBlock);
parms.Write(KEY_Threshold_dB, mParams.mThreshold_dB); parms.Write(KEY_Threshold_dB, mParams.mThreshold_dB);
parms.Write(KEY_NoiseFloor, mParams.mNoiseFloor); parms.Write(KEY_NoiseFloor, mParams.mNoiseFloor);

View File

@ -144,12 +144,12 @@ enum kInterpolations
#define EQCURVES_REVISION 0 #define EQCURVES_REVISION 0
#define UPDATE_ALL 0 // 0 = merge NEW presets only, 1 = Update all factory presets. #define UPDATE_ALL 0 // 0 = merge NEW presets only, 1 = Update all factory presets.
static const wxString kInterpStrings[nInterpolations] = static const IdentInterfaceSymbol kInterpStrings[nInterpolations] =
{ {
/* i18n-hint: Technical term for a kind of curve.*/ /* i18n-hint: Technical term for a kind of curve.*/
XO("B-spline"), { XO("B-spline") },
XO("Cosine"), { XO("Cosine") },
XO("Cubic") { XO("Cubic") }
}; };
static const double kThirdOct[] = static const double kThirdOct[] =

View File

@ -35,11 +35,11 @@ enum kTypes
nTypes nTypes
}; };
static const wxString kTypeStrings[nTypes] = static const IdentInterfaceSymbol kTypeStrings[nTypes] =
{ {
XO("White"), { XO("White") },
XO("Pink"), { XO("Pink") },
XO("Brownian") { XO("Brownian") }
}; };
// Define keys, defaults, minimums, and maximums for the effect parameters // Define keys, defaults, minimums, and maximums for the effect parameters
@ -169,7 +169,7 @@ bool EffectNoise::DefineParams( ShuttleParams & S ){
bool EffectNoise::GetAutomationParameters(CommandParameters & parms) bool EffectNoise::GetAutomationParameters(CommandParameters & parms)
{ {
parms.Write(KEY_Type, kTypeStrings[mType]); parms.Write(KEY_Type, kTypeStrings[mType].Internal());
parms.Write(KEY_Amp, mAmp); parms.Write(KEY_Amp, mAmp);
return true; return true;

View File

@ -86,14 +86,14 @@ enum kTypes
nTypes nTypes
}; };
static const wxString kTypeStrings[nTypes] = static const IdentInterfaceSymbol kTypeStrings[nTypes] =
{ {
/*i18n-hint: Butterworth is the name of the person after whom the filter type is named.*/ /*i18n-hint: Butterworth is the name of the person after whom the filter type is named.*/
XO("Butterworth"), { XO("Butterworth") },
/*i18n-hint: Chebyshev is the name of the person after whom the filter type is named.*/ /*i18n-hint: Chebyshev is the name of the person after whom the filter type is named.*/
XO("Chebyshev Type I"), { XO("Chebyshev Type I") },
/*i18n-hint: Chebyshev is the name of the person after whom the filter type is named.*/ /*i18n-hint: Chebyshev is the name of the person after whom the filter type is named.*/
XO("Chebyshev Type II") { XO("Chebyshev Type II") }
}; };
enum kSubTypes enum kSubTypes
@ -103,10 +103,10 @@ enum kSubTypes
nSubTypes nSubTypes
}; };
static const wxString kSubTypeStrings[nSubTypes] = static const IdentInterfaceSymbol kSubTypeStrings[nSubTypes] =
{ {
XO("Lowpass"), { XO("Lowpass") },
XO("Highpass") { XO("Highpass") }
}; };
// Define keys, defaults, minimums, and maximums for the effect parameters // Define keys, defaults, minimums, and maximums for the effect parameters
@ -252,8 +252,8 @@ bool EffectScienFilter::DefineParams( ShuttleParams & S ){
bool EffectScienFilter::GetAutomationParameters(CommandParameters & parms) bool EffectScienFilter::GetAutomationParameters(CommandParameters & parms)
{ {
parms.Write(KEY_Type, kTypeStrings[mFilterType]); parms.Write(KEY_Type, kTypeStrings[mFilterType].Internal());
parms.Write(KEY_Subtype, kSubTypeStrings[mFilterSubtype]); parms.Write(KEY_Subtype, kSubTypeStrings[mFilterSubtype].Internal());
parms.Write(KEY_Order, mOrder); parms.Write(KEY_Order, mOrder);
parms.WriteFloat(KEY_Cutoff, mCutoff); parms.WriteFloat(KEY_Cutoff, mCutoff);
parms.WriteFloat(KEY_Passband, mRipple); parms.WriteFloat(KEY_Passband, mRipple);

View File

@ -39,10 +39,10 @@ enum kInterpolations
nInterpolations nInterpolations
}; };
static const wxString kInterStrings[nInterpolations] = static const IdentInterfaceSymbol kInterStrings[nInterpolations] =
{ {
XO("Linear"), { XO("Linear") },
XO("Logarithmic") { XO("Logarithmic") }
}; };
enum kWaveforms enum kWaveforms
@ -54,12 +54,12 @@ enum kWaveforms
nWaveforms nWaveforms
}; };
static const wxString kWaveStrings[nWaveforms] = static const IdentInterfaceSymbol kWaveStrings[nWaveforms] =
{ {
XO("Sine"), { XO("Sine") },
XO("Square"), { XO("Square") },
XO("Sawtooth"), { XO("Sawtooth") },
XO("Square, no alias") { XO("Square, no alias") }
}; };
// Define keys, defaults, minimums, and maximums for the effect parameters // Define keys, defaults, minimums, and maximums for the effect parameters
@ -284,8 +284,8 @@ bool EffectToneGen::GetAutomationParameters(CommandParameters & parms)
parms.Write(KEY_Amplitude, mAmplitude[0]); parms.Write(KEY_Amplitude, mAmplitude[0]);
} }
parms.Write(KEY_Waveform, kWaveStrings[mWaveform]); parms.Write(KEY_Waveform, kWaveStrings[mWaveform].Internal());
parms.Write(KEY_Interp, kInterStrings[mInterpolation]); parms.Write(KEY_Interp, kInterStrings[mInterpolation].Internal());
return true; return true;
} }

View File

@ -38,23 +38,23 @@ class Enums {
public: public:
static const size_t NumDbChoices; static const size_t NumDbChoices;
static const double Db2Signal[]; static const double Db2Signal[];
static const wxString DbChoices[]; static const IdentInterfaceSymbol DbChoices[];
}; };
const wxString Enums::DbChoices[] = { const IdentInterfaceSymbol Enums::DbChoices[] = {
wxT("-20 dB"), { wxT("-20 dB") },
wxT("-25 dB"), { wxT("-25 dB") },
wxT("-30 dB"), { wxT("-30 dB") },
wxT("-35 dB"), { wxT("-35 dB") },
wxT("-40 dB"), { wxT("-40 dB") },
wxT("-45 dB"), { wxT("-45 dB") },
wxT("-50 dB"), { wxT("-50 dB") },
wxT("-55 dB"), { wxT("-55 dB") },
wxT("-60 dB"), { wxT("-60 dB") },
wxT("-65 dB"), { wxT("-65 dB") },
wxT("-70 dB"), { wxT("-70 dB") },
wxT("-75 dB"), { wxT("-75 dB") },
wxT("-80 dB") { wxT("-80 dB") }
}; };
const double Enums::Db2Signal[] = const double Enums::Db2Signal[] =
@ -77,10 +77,10 @@ enum kActions
nActions nActions
}; };
static const wxString kActionStrings[nActions] = static const IdentInterfaceSymbol kActionStrings[nActions] =
{ {
XO("Truncate Detected Silence"), { XO("Truncate Detected Silence") },
XO("Compress Excess Silence") { XO("Compress Excess Silence") }
}; };
static CommandParameters::ObsoleteMap kObsoleteActions[] = { static CommandParameters::ObsoleteMap kObsoleteActions[] = {
@ -186,8 +186,8 @@ bool EffectTruncSilence::DefineParams( ShuttleParams & S ){
bool EffectTruncSilence::GetAutomationParameters(CommandParameters & parms) bool EffectTruncSilence::GetAutomationParameters(CommandParameters & parms)
{ {
parms.Write(KEY_DbIndex, Enums::DbChoices[mTruncDbChoiceIndex]); parms.Write(KEY_DbIndex, Enums::DbChoices[mTruncDbChoiceIndex].Internal());
parms.Write(KEY_ActIndex, kActionStrings[mActionIndex]); parms.Write(KEY_ActIndex, kActionStrings[mActionIndex].Internal());
parms.Write(KEY_Minimum, mInitialAllowedSilence); parms.Write(KEY_Minimum, mInitialAllowedSilence);
parms.Write(KEY_Truncate, mTruncLongestAllowedSilence); parms.Write(KEY_Truncate, mTruncLongestAllowedSilence);
parms.Write(KEY_Compress, mSilenceCompressPercent); parms.Write(KEY_Compress, mSilenceCompressPercent);

View File

@ -1481,16 +1481,16 @@ wxString NyquistEffect::EscapeString(const wxString & inStr)
return str; return str;
} }
wxArrayString NyquistEffect::ParseChoice(const wxString & text) std::vector<IdentInterfaceSymbol> NyquistEffect::ParseChoice(const wxString & text)
{ {
std::vector<IdentInterfaceSymbol> results;
if (text[0] == wxT('(')) { if (text[0] == wxT('(')) {
// New style: expecting a Lisp-like list of strings // New style: expecting a Lisp-like list of strings
Tokenizer tzer; Tokenizer tzer;
tzer.Tokenize(text, true, 1, 1); tzer.Tokenize(text, true, 1, 1);
auto &choices = tzer.tokens; auto &choices = tzer.tokens;
for (auto &choice : choices) for (auto &choice : choices)
choice = UnQuote(choice); results.push_back( { UnQuote(choice) } );
return choices;
} }
else { else {
// Old style: expecting a comma-separated list of // Old style: expecting a comma-separated list of
@ -1501,9 +1501,9 @@ wxArrayString NyquistEffect::ParseChoice(const wxString & text)
wxT(",") wxT(",")
); );
for (auto &choice : choices) for (auto &choice : choices)
choice = choice.Trim(true).Trim(false); results.push_back( { choice.Trim(true).Trim(false) } );
return choices;
} }
return results;
} }
void NyquistEffect::RedirectOutput() void NyquistEffect::RedirectOutput()
@ -2266,7 +2266,7 @@ bool NyquistEffect::TransferDataToEffectWindow()
if (ctrl.type == NYQ_CTRL_CHOICE) if (ctrl.type == NYQ_CTRL_CHOICE)
{ {
const auto count = ctrl.choices.GetCount(); const auto count = ctrl.choices.size();
int val = (int)ctrl.val; int val = (int)ctrl.val;
if (val < 0 || val >= (int)count) if (val < 0 || val >= (int)count)
@ -2430,7 +2430,8 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
{ {
S.AddSpace(10, 10); S.AddSpace(10, 10);
auto choices = LocalizedStrings(ctrl.choices); auto choices =
LocalizedStrings(ctrl.choices.data(), ctrl.choices.size());
S.Id(ID_Choice + i).AddChoice( {}, wxT(""), &choices); S.Id(ID_Choice + i).AddChoice( {}, wxT(""), &choices);
} }
else else

View File

@ -57,7 +57,7 @@ public:
wxString var; wxString var;
wxString name; wxString name;
wxString label; wxString label;
wxArrayString choices; // translatable std::vector<IdentInterfaceSymbol> choices;
wxString valStr; wxString valStr;
wxString lowStr; wxString lowStr;
wxString highStr; wxString highStr;
@ -143,7 +143,7 @@ private:
static wxString NyquistToWxString(const char *nyqString); static wxString NyquistToWxString(const char *nyqString);
wxString EscapeString(const wxString & inStr); wxString EscapeString(const wxString & inStr);
static wxArrayString ParseChoice(const wxString & text); static std::vector<IdentInterfaceSymbol> ParseChoice(const wxString & text);
static int StaticGetCallback(float *buffer, int channel, static int StaticGetCallback(float *buffer, int channel,
long start, long len, long totlen, long start, long len, long totlen,

View File

@ -180,7 +180,7 @@ bool VampEffect::GetAutomationParameters(CommandParameters & parms)
mParameters[p].quantizeStep == 1.0 && mParameters[p].quantizeStep == 1.0 &&
!mParameters[p].valueNames.empty()) !mParameters[p].valueNames.empty())
{ {
wxArrayString choices; std::vector<IdentInterfaceSymbol> choices;
int val = 0; int val = 0;
for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++) for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++)
@ -227,7 +227,7 @@ bool VampEffect::SetAutomationParameters(CommandParameters & parms)
mParameters[p].quantizeStep == 1.0 && mParameters[p].quantizeStep == 1.0 &&
!mParameters[p].valueNames.empty()) !mParameters[p].valueNames.empty())
{ {
wxArrayString choices; std::vector<IdentInterfaceSymbol> choices;
int val; int val;
for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++) for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++)
@ -273,7 +273,7 @@ bool VampEffect::SetAutomationParameters(CommandParameters & parms)
mParameters[p].quantizeStep == 1.0 && mParameters[p].quantizeStep == 1.0 &&
!mParameters[p].valueNames.empty()) !mParameters[p].valueNames.empty())
{ {
wxArrayString choices; std::vector<IdentInterfaceSymbol> choices;
int val = 0; int val = 0;
for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++) for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++)