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

View File

@ -31,6 +31,7 @@ and on Mac OS X for the filesystem.
#include "FileNames.h"
#include "widgets/ErrorDialog.h"
#include "Internat.h"
#include "../include/audacity/IdentInterface.h"
// in order for the static member variables to exist, they must appear here
// (_outside_) the class definition, in order to be allocated some storage.
@ -298,3 +299,12 @@ wxString Internat::StripAccelerators(const wxString &s)
}
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 LAT1CTOWX(X) wxString((X), wxConvISO8859_1)
inline wxArrayString LocalizedStrings(const wxString strings[], size_t nStrings)
{
wxArrayString results;
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() );
}
class IdentInterfaceSymbol;
wxArrayString LocalizedStrings(
const IdentInterfaceSymbol strings[], size_t nStrings);
// This object pairs an internal string, maybe empty, with a translated string.
// 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 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::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;
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 );
if( !bOK )
@ -630,7 +630,7 @@ void ShuttleGetDefinition::Define( wxString &var, const wxChar * key, const wxSt
void ShuttleGetDefinition::DefineEnum( int &var,
const wxChar * key, const int vdefault,
const wxString strings[], size_t nStrings )
const IdentInterfaceSymbol strings[], size_t nStrings )
{
StartStruct();
AddItem( wxString(key), "key" );
@ -638,11 +638,11 @@ void ShuttleGetDefinition::DefineEnum( int &var,
if( IsOptional() )
AddItem( "unchanged", "default" );
else
AddItem( strings[vdefault], "default" );
AddItem( strings[vdefault].Internal(), "default" );
StartField( "enum" );
StartArray();
for( size_t i = 0; i < nStrings; i++ )
AddItem( strings[i] );
AddItem( strings[i].Internal() );
EndArray();
EndField();
EndStruct();

View File

@ -12,7 +12,9 @@
#define __AUDACITY_SHUTTLE__
#include "commands/CommandTargets.h"
#include "../include/audacity/IdentInterface.h"
class IdentInterfaceSymbol;
class WrappedType;
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( 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,
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( 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,
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( 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,
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( 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,
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) )
override { var = 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;};
};

View File

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

View File

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

View File

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

View File

@ -46,48 +46,50 @@ small calculations of rectangles.
#include "CommandContext.h"
static const wxString kCaptureWhatStrings[ ScreenshotCommand::nCaptureWhats ] =
static const IdentInterfaceSymbol
kCaptureWhatStrings[ ScreenshotCommand::nCaptureWhats ] =
{
XO("Window"),
XO("Full_Window"),
XO("Window_Plus"),
XO("Fullscreen"),
XO("Toolbars"),
XO("Effects"),
XO("Scriptables"),
XO("Preferences"),
XO("Selectionbar"),
XO("Spectral_Selection"),
XO("Tools"),
XO("Transport"),
XO("Mixer"),
XO("Meter"),
XO("Play_Meter"),
XO("Record_Meter"),
XO("Edit"),
XO("Device"),
XO("Scrub"),
XO("Transcription"),
XO("Trackpanel"),
XO("Ruler"),
XO("Tracks"),
XO("First_Track"),
XO("First_Two_Tracks"),
XO("First_Three_Tracks"),
XO("First_Four_Tracks"),
XO("Second_Track"),
XO("Tracks_Plus"),
XO("First_Track_Plus"),
XO("All_Tracks"),
XO("All_Tracks_Plus"),
{ XO("Window") },
{ XO("Full_Window") },
{ XO("Window_Plus") },
{ XO("Fullscreen") },
{ XO("Toolbars") },
{ XO("Effects") },
{ XO("Scriptables") },
{ XO("Preferences") },
{ XO("Selectionbar") },
{ XO("Spectral_Selection") },
{ XO("Tools") },
{ XO("Transport") },
{ XO("Mixer") },
{ XO("Meter") },
{ XO("Play_Meter") },
{ XO("Record_Meter") },
{ XO("Edit") },
{ XO("Device") },
{ XO("Scrub") },
{ XO("Transcription") },
{ XO("Trackpanel") },
{ XO("Ruler") },
{ XO("Tracks") },
{ XO("First_Track") },
{ XO("First_Two_Tracks") },
{ XO("First_Three_Tracks") },
{ XO("First_Four_Tracks") },
{ XO("Second_Track") },
{ XO("Tracks_Plus") },
{ XO("First_Track_Plus") },
{ XO("All_Tracks") },
{ XO("All_Tracks_Plus") },
};
static const wxString kBackgroundStrings[ ScreenshotCommand::nBackgrounds ] =
static const IdentInterfaceSymbol
kBackgroundStrings[ ScreenshotCommand::nBackgrounds ] =
{
XO("Blue"),
XO("White"),
XO("None")
{ XO("Blue") },
{ XO("White") },
{ XO("None") },
};
@ -627,7 +629,7 @@ void ScreenshotCommand::GetDerivedParams()
// Build a suitable filename
mFileName = MakeFileName(mFilePath,
GetCustomTranslation( kCaptureWhatStrings[ mCaptureMode ] ));
kCaptureWhatStrings[ mCaptureMode ].Translation() );
if (mBack == kBlue)
{
@ -777,7 +779,7 @@ wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * pa
wxString ScreenshotCommand::WindowFileName(AudacityProject * proj, wxTopLevelWindow *w){
if (w != proj && w->GetTitle() != wxT("")) {
mFileName = MakeFileName(mFilePath,
GetCustomTranslation( kCaptureWhatStrings[ mCaptureMode ] ) +
kCaptureWhatStrings[ mCaptureMode ].Translation() +
(wxT("-") + w->GetTitle() + wxT("-")));
}
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
// set a selection to a clip.
const int nRelativeTos =6;
static const wxString kRelativeTo[nRelativeTos] =
static const IdentInterfaceSymbol kRelativeTo[nRelativeTos] =
{
XO("Project Start"),
XO("Project"),
XO("Project End"),
XO("Selection Start"),
XO("Selection"),
XO("Selection End")
{ XO("Project Start") },
{ XO("Project") },
{ XO("Project End") },
{ XO("Selection Start") },
{ XO("Selection") },
{ XO("Selection End") }
};
bool SelectTimeCommand::DefineParams( ShuttleParams & S ){
@ -167,12 +167,12 @@ bool SelectFrequenciesCommand::Apply(const CommandContext & context){
}
const int nModes =3;
static const wxString kModes[nModes] =
static const IdentInterfaceSymbol kModes[nModes] =
{
/* i18n-hint verb, imperative */
XO("Set"),
XO("Add"),
XO("Remove")
{ XO("Set") },
{ XO("Add") },
{ XO("Remove") },
};
bool SelectTracksCommand::DefineParams( ShuttleParams & S ){

View File

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

View File

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

View File

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

View File

@ -144,12 +144,12 @@ enum kInterpolations
#define EQCURVES_REVISION 0
#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.*/
XO("B-spline"),
XO("Cosine"),
XO("Cubic")
{ XO("B-spline") },
{ XO("Cosine") },
{ XO("Cubic") }
};
static const double kThirdOct[] =

View File

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

View File

@ -86,14 +86,14 @@ enum kTypes
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.*/
XO("Butterworth"),
{ XO("Butterworth") },
/*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.*/
XO("Chebyshev Type II")
{ XO("Chebyshev Type II") }
};
enum kSubTypes
@ -103,10 +103,10 @@ enum kSubTypes
nSubTypes
};
static const wxString kSubTypeStrings[nSubTypes] =
static const IdentInterfaceSymbol kSubTypeStrings[nSubTypes] =
{
XO("Lowpass"),
XO("Highpass")
{ XO("Lowpass") },
{ XO("Highpass") }
};
// Define keys, defaults, minimums, and maximums for the effect parameters
@ -252,8 +252,8 @@ bool EffectScienFilter::DefineParams( ShuttleParams & S ){
bool EffectScienFilter::GetAutomationParameters(CommandParameters & parms)
{
parms.Write(KEY_Type, kTypeStrings[mFilterType]);
parms.Write(KEY_Subtype, kSubTypeStrings[mFilterSubtype]);
parms.Write(KEY_Type, kTypeStrings[mFilterType].Internal());
parms.Write(KEY_Subtype, kSubTypeStrings[mFilterSubtype].Internal());
parms.Write(KEY_Order, mOrder);
parms.WriteFloat(KEY_Cutoff, mCutoff);
parms.WriteFloat(KEY_Passband, mRipple);

View File

@ -39,10 +39,10 @@ enum kInterpolations
nInterpolations
};
static const wxString kInterStrings[nInterpolations] =
static const IdentInterfaceSymbol kInterStrings[nInterpolations] =
{
XO("Linear"),
XO("Logarithmic")
{ XO("Linear") },
{ XO("Logarithmic") }
};
enum kWaveforms
@ -54,12 +54,12 @@ enum kWaveforms
nWaveforms
};
static const wxString kWaveStrings[nWaveforms] =
static const IdentInterfaceSymbol kWaveStrings[nWaveforms] =
{
XO("Sine"),
XO("Square"),
XO("Sawtooth"),
XO("Square, no alias")
{ XO("Sine") },
{ XO("Square") },
{ XO("Sawtooth") },
{ XO("Square, no alias") }
};
// 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_Waveform, kWaveStrings[mWaveform]);
parms.Write(KEY_Interp, kInterStrings[mInterpolation]);
parms.Write(KEY_Waveform, kWaveStrings[mWaveform].Internal());
parms.Write(KEY_Interp, kInterStrings[mInterpolation].Internal());
return true;
}

View File

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

View File

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

View File

@ -57,7 +57,7 @@ public:
wxString var;
wxString name;
wxString label;
wxArrayString choices; // translatable
std::vector<IdentInterfaceSymbol> choices;
wxString valStr;
wxString lowStr;
wxString highStr;
@ -143,7 +143,7 @@ private:
static wxString NyquistToWxString(const char *nyqString);
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,
long start, long len, long totlen,

View File

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