mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-25 07:43:54 +02:00
Rename EnumSetting -> ChoiceSetting, EncodedEnumSetting -> EnumSetting
This commit is contained in:
@@ -368,13 +368,13 @@ void FinishPreferences()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
wxString EnumSetting::Read() const
|
wxString ChoiceSetting::Read() const
|
||||||
{
|
{
|
||||||
const auto &defaultValue = Default().Internal();
|
const auto &defaultValue = Default().Internal();
|
||||||
wxString value;
|
wxString value;
|
||||||
if ( !gPrefs->Read(mKey, &value, defaultValue) )
|
if ( !gPrefs->Read(mKey, &value, defaultValue) )
|
||||||
if (!mMigrated) {
|
if (!mMigrated) {
|
||||||
const_cast<EnumSetting*>(this)->Migrate( value );
|
const_cast<ChoiceSetting*>(this)->Migrate( value );
|
||||||
mMigrated = true;
|
mMigrated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,19 +386,19 @@ wxString EnumSetting::Read() const
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t EnumSetting::Find( const wxString &value ) const
|
size_t ChoiceSetting::Find( const wxString &value ) const
|
||||||
{
|
{
|
||||||
return size_t(
|
return size_t(
|
||||||
std::find( begin(), end(), EnumValueSymbol{ value, {} } )
|
std::find( begin(), end(), EnumValueSymbol{ value, {} } )
|
||||||
- mSymbols );
|
- mSymbols );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumSetting::Migrate( wxString &value )
|
void ChoiceSetting::Migrate( wxString &value )
|
||||||
{
|
{
|
||||||
(void)value;// Compiler food
|
(void)value;// Compiler food
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnumSetting::Write( const wxString &value )
|
bool ChoiceSetting::Write( const wxString &value )
|
||||||
{
|
{
|
||||||
auto index = Find( value );
|
auto index = Find( value );
|
||||||
if (index >= mnSymbols)
|
if (index >= mnSymbols)
|
||||||
@@ -409,7 +409,7 @@ bool EnumSetting::Write( const wxString &value )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EncodedEnumSetting::ReadInt() const
|
int EnumSetting::ReadInt() const
|
||||||
{
|
{
|
||||||
if (!mIntValues)
|
if (!mIntValues)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -419,7 +419,7 @@ int EncodedEnumSetting::ReadInt() const
|
|||||||
return mIntValues[ index ];
|
return mIntValues[ index ];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t EncodedEnumSetting::FindInt( int code ) const
|
size_t EnumSetting::FindInt( int code ) const
|
||||||
{
|
{
|
||||||
if (!mIntValues)
|
if (!mIntValues)
|
||||||
return mnSymbols;
|
return mnSymbols;
|
||||||
@@ -429,7 +429,7 @@ size_t EncodedEnumSetting::FindInt( int code ) const
|
|||||||
- mIntValues );
|
- mIntValues );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodedEnumSetting::Migrate( wxString &value )
|
void EnumSetting::Migrate( wxString &value )
|
||||||
{
|
{
|
||||||
int intValue = 0;
|
int intValue = 0;
|
||||||
if ( !mOldKey.empty() &&
|
if ( !mOldKey.empty() &&
|
||||||
@@ -447,7 +447,7 @@ void EncodedEnumSetting::Migrate( wxString &value )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EncodedEnumSetting::WriteInt( int code ) // you flush gPrefs afterward
|
bool EnumSetting::WriteInt( int code ) // you flush gPrefs afterward
|
||||||
{
|
{
|
||||||
auto index = FindInt( code );
|
auto index = FindInt( code );
|
||||||
if ( index >= mnSymbols )
|
if ( index >= mnSymbols )
|
||||||
|
|||||||
12
src/Prefs.h
12
src/Prefs.h
@@ -62,10 +62,10 @@ public:
|
|||||||
|
|
||||||
/// Packages a table of user-visible choices each with an internal code string,
|
/// Packages a table of user-visible choices each with an internal code string,
|
||||||
/// a preference key path, and a default choice
|
/// a preference key path, and a default choice
|
||||||
class EnumSetting
|
class ChoiceSetting
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EnumSetting(
|
ChoiceSetting(
|
||||||
const wxString &key,
|
const wxString &key,
|
||||||
const EnumValueSymbol symbols[], size_t nSymbols,
|
const EnumValueSymbol symbols[], size_t nSymbols,
|
||||||
size_t defaultSymbol
|
size_t defaultSymbol
|
||||||
@@ -104,14 +104,14 @@ protected:
|
|||||||
const size_t mDefaultSymbol;
|
const size_t mDefaultSymbol;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Extends EnumSetting with a corresponding table of integer codes
|
/// Extends ChoiceSetting with a corresponding table of integer codes
|
||||||
/// (generally not equal to their table positions),
|
/// (generally not equal to their table positions),
|
||||||
/// and optionally an old preference key path that stored integer codes, to be
|
/// and optionally an old preference key path that stored integer codes, to be
|
||||||
/// migrated into one that stores internal string values instead
|
/// migrated into one that stores internal string values instead
|
||||||
class EncodedEnumSetting : public EnumSetting
|
class EnumSetting : public ChoiceSetting
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EncodedEnumSetting(
|
EnumSetting(
|
||||||
const wxString &key,
|
const wxString &key,
|
||||||
const EnumValueSymbol symbols[], size_t nSymbols,
|
const EnumValueSymbol symbols[], size_t nSymbols,
|
||||||
size_t defaultSymbol,
|
size_t defaultSymbol,
|
||||||
@@ -119,7 +119,7 @@ public:
|
|||||||
const int intValues[] = nullptr, // must have same size as symbols
|
const int intValues[] = nullptr, // must have same size as symbols
|
||||||
const wxString &oldKey = wxString("")
|
const wxString &oldKey = wxString("")
|
||||||
)
|
)
|
||||||
: EnumSetting{ key, symbols, nSymbols, defaultSymbol }
|
: ChoiceSetting{ key, symbols, nSymbols, defaultSymbol }
|
||||||
, mIntValues{ intValues }
|
, mIntValues{ intValues }
|
||||||
, mOldKey{ oldKey }
|
, mOldKey{ oldKey }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ static const int intChoicesMethod[] = {
|
|||||||
|
|
||||||
static_assert( WXSIZEOF(intChoicesMethod) == numMethods, "size mismatch" );
|
static_assert( WXSIZEOF(intChoicesMethod) == numMethods, "size mismatch" );
|
||||||
|
|
||||||
EncodedEnumSetting Resample::FastMethodSetting{
|
EnumSetting Resample::FastMethodSetting{
|
||||||
fastMethodKey,
|
fastMethodKey,
|
||||||
methodNames, numMethods,
|
methodNames, numMethods,
|
||||||
fastMethodDefault,
|
fastMethodDefault,
|
||||||
@@ -91,7 +91,7 @@ EncodedEnumSetting Resample::FastMethodSetting{
|
|||||||
oldFastMethodKey
|
oldFastMethodKey
|
||||||
};
|
};
|
||||||
|
|
||||||
EncodedEnumSetting Resample::BestMethodSetting
|
EnumSetting Resample::BestMethodSetting
|
||||||
{
|
{
|
||||||
bestMethodKey,
|
bestMethodKey,
|
||||||
methodNames, numMethods,
|
methodNames, numMethods,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "SampleFormat.h"
|
#include "SampleFormat.h"
|
||||||
|
|
||||||
class EncodedEnumSetting;
|
class EnumSetting;
|
||||||
|
|
||||||
struct soxr;
|
struct soxr;
|
||||||
extern "C" void soxr_delete(soxr*);
|
extern "C" void soxr_delete(soxr*);
|
||||||
@@ -43,8 +43,8 @@ class Resample final
|
|||||||
Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor);
|
Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor);
|
||||||
~Resample();
|
~Resample();
|
||||||
|
|
||||||
static EncodedEnumSetting FastMethodSetting;
|
static EnumSetting FastMethodSetting;
|
||||||
static EncodedEnumSetting BestMethodSetting;
|
static EnumSetting BestMethodSetting;
|
||||||
|
|
||||||
/** @brief Main processing function. Resamples from the input buffer to the
|
/** @brief Main processing function. Resamples from the input buffer to the
|
||||||
* output buffer.
|
* output buffer.
|
||||||
|
|||||||
@@ -1843,18 +1843,18 @@ wxTextCtrl * ShuttleGuiBase::TieNumericTextBox(
|
|||||||
/// those as default.
|
/// those as default.
|
||||||
wxChoice *ShuttleGuiBase::TieChoice(
|
wxChoice *ShuttleGuiBase::TieChoice(
|
||||||
const wxString &Prompt,
|
const wxString &Prompt,
|
||||||
EnumSetting &enumSetting )
|
ChoiceSetting &choiceSetting )
|
||||||
{
|
{
|
||||||
// Do this to force any needed migrations first
|
// Do this to force any needed migrations first
|
||||||
enumSetting.Read();
|
choiceSetting.Read();
|
||||||
|
|
||||||
wxArrayStringEx visibleChoices, internalChoices;
|
wxArrayStringEx visibleChoices, internalChoices;
|
||||||
for (const auto &ident : enumSetting) {
|
for (const auto &ident : choiceSetting) {
|
||||||
visibleChoices.push_back( ident.Translation() );
|
visibleChoices.push_back( ident.Translation() );
|
||||||
internalChoices.push_back( ident.Internal() );
|
internalChoices.push_back( ident.Internal() );
|
||||||
}
|
}
|
||||||
return TieChoice(
|
return TieChoice(
|
||||||
Prompt, enumSetting.Key(), enumSetting.Default().Internal(),
|
Prompt, choiceSetting.Key(), choiceSetting.Default().Internal(),
|
||||||
visibleChoices, internalChoices );
|
visibleChoices, internalChoices );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
// For ShuttleGuiGetDefinitions.
|
// For ShuttleGuiGetDefinitions.
|
||||||
#include "commands/CommandTargets.h"
|
#include "commands/CommandTargets.h"
|
||||||
|
|
||||||
class EnumSetting;
|
class ChoiceSetting;
|
||||||
|
|
||||||
class wxArrayStringEx;
|
class wxArrayStringEx;
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public:
|
|||||||
// This one is defined in terms of the next and not virtual
|
// This one is defined in terms of the next and not virtual
|
||||||
virtual wxChoice *TieChoice(
|
virtual wxChoice *TieChoice(
|
||||||
const wxString &Prompt,
|
const wxString &Prompt,
|
||||||
EnumSetting &enumSetting );
|
ChoiceSetting &choiceSetting );
|
||||||
|
|
||||||
virtual wxChoice * TieChoice(
|
virtual wxChoice * TieChoice(
|
||||||
const wxString &Prompt,
|
const wxString &Prompt,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ static_assert( nChoicesFormat == WXSIZEOF(intChoicesFormat), "size mismatch" );
|
|||||||
|
|
||||||
static const size_t defaultChoiceFormat = 2; // floatSample
|
static const size_t defaultChoiceFormat = 2; // floatSample
|
||||||
|
|
||||||
static EncodedEnumSetting formatSetting{
|
static EnumSetting formatSetting{
|
||||||
wxT("/SamplingRate/DefaultProjectSampleFormatChoice"),
|
wxT("/SamplingRate/DefaultProjectSampleFormatChoice"),
|
||||||
choicesFormat, nChoicesFormat, defaultChoiceFormat,
|
choicesFormat, nChoicesFormat, defaultChoiceFormat,
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ static_assert(
|
|||||||
|
|
||||||
static const size_t defaultFastDither = 0; // none
|
static const size_t defaultFastDither = 0; // none
|
||||||
|
|
||||||
static EncodedEnumSetting fastDitherSetting{
|
static EnumSetting fastDitherSetting{
|
||||||
wxT("Quality/DitherAlgorithmChoice"),
|
wxT("Quality/DitherAlgorithmChoice"),
|
||||||
choicesDither, nChoicesDither, defaultFastDither,
|
choicesDither, nChoicesDither, defaultFastDither,
|
||||||
intChoicesDither,
|
intChoicesDither,
|
||||||
@@ -87,7 +87,7 @@ static EncodedEnumSetting fastDitherSetting{
|
|||||||
|
|
||||||
static const size_t defaultBestDither = 3; // shaped
|
static const size_t defaultBestDither = 3; // shaped
|
||||||
|
|
||||||
static EncodedEnumSetting bestDitherSetting{
|
static EnumSetting bestDitherSetting{
|
||||||
wxT("Quality/HQDitherAlgorithmChoice"),
|
wxT("Quality/HQDitherAlgorithmChoice"),
|
||||||
choicesDither, nChoicesDither, defaultBestDither,
|
choicesDither, nChoicesDither, defaultBestDither,
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ static_assert( nChoicesView == WXSIZEOF(intChoicesView), "size mismatch" );
|
|||||||
|
|
||||||
static const size_t defaultChoiceView = 0;
|
static const size_t defaultChoiceView = 0;
|
||||||
|
|
||||||
class TracksViewModeSetting : public EncodedEnumSetting {
|
class TracksViewModeSetting : public EnumSetting {
|
||||||
public:
|
public:
|
||||||
TracksViewModeSetting(
|
TracksViewModeSetting(
|
||||||
const wxString &key,
|
const wxString &key,
|
||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
const int intValues[],
|
const int intValues[],
|
||||||
const wxString &oldKey
|
const wxString &oldKey
|
||||||
)
|
)
|
||||||
: EncodedEnumSetting{
|
: EnumSetting{
|
||||||
key, symbols, nSymbols, defaultSymbol, intValues, oldKey }
|
key, symbols, nSymbols, defaultSymbol, intValues, oldKey }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
// Special logic for this preference which was twice migrated!
|
// Special logic for this preference which was twice migrated!
|
||||||
|
|
||||||
// First test for the older but not oldest key:
|
// First test for the older but not oldest key:
|
||||||
EncodedEnumSetting::Migrate(value);
|
EnumSetting::Migrate(value);
|
||||||
if (!value.empty())
|
if (!value.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ static_assert(
|
|||||||
|
|
||||||
static const size_t defaultChoiceSampleDisplay = 1;
|
static const size_t defaultChoiceSampleDisplay = 1;
|
||||||
|
|
||||||
static EncodedEnumSetting sampleDisplaySetting{
|
static EnumSetting sampleDisplaySetting{
|
||||||
wxT("/GUI/SampleViewChoice"),
|
wxT("/GUI/SampleViewChoice"),
|
||||||
choicesSampleDisplay, nChoicesSampleDisplay, defaultChoiceSampleDisplay,
|
choicesSampleDisplay, nChoicesSampleDisplay, defaultChoiceSampleDisplay,
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ static_assert( nChoicesZoom == WXSIZEOF(intChoicesZoom), "size mismatch" );
|
|||||||
|
|
||||||
static const size_t defaultChoiceZoom1 = 2; // kZoomDefault
|
static const size_t defaultChoiceZoom1 = 2; // kZoomDefault
|
||||||
|
|
||||||
static EncodedEnumSetting zoom1Setting{
|
static EnumSetting zoom1Setting{
|
||||||
wxT("/GUI/ZoomPreset1Choice"),
|
wxT("/GUI/ZoomPreset1Choice"),
|
||||||
choicesZoom, nChoicesZoom, defaultChoiceZoom1,
|
choicesZoom, nChoicesZoom, defaultChoiceZoom1,
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ static EncodedEnumSetting zoom1Setting{
|
|||||||
|
|
||||||
static const size_t defaultChoiceZoom2 = 13; // kZoom4To1
|
static const size_t defaultChoiceZoom2 = 13; // kZoom4To1
|
||||||
|
|
||||||
static EncodedEnumSetting zoom2Setting{
|
static EnumSetting zoom2Setting{
|
||||||
wxT("/GUI/ZoomPreset2Choice"),
|
wxT("/GUI/ZoomPreset2Choice"),
|
||||||
choicesZoom, nChoicesZoom, defaultChoiceZoom2,
|
choicesZoom, nChoicesZoom, defaultChoiceZoom2,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user