mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 23:59:37 +02:00
Define and use TieNumberAsChoice for Quality sample rate setting
This commit is contained in:
parent
24e651fe37
commit
17cc8a495f
@ -1933,6 +1933,27 @@ wxChoice * ShuttleGuiBase::TieChoice(
|
||||
return pChoice;
|
||||
}
|
||||
|
||||
/// Variant of the standard TieChoice which does the two step exchange
|
||||
/// between gui and stack variable and stack variable and shuttle.
|
||||
/// The Translated choices and default are integers, not Strings.
|
||||
/// Behaves identically to the previous, but is meant for use when the choices
|
||||
/// are non-exhaustive and there is a companion control for abitrary entry.
|
||||
/// @param Prompt The prompt shown beside the control.
|
||||
/// @param SettingName The setting name as stored in gPrefs
|
||||
/// @param Default The default value for this control (translated)
|
||||
/// @param Choices An array of choices that appear on screen.
|
||||
/// @param InternalChoices The corresponding values (as an integer array)
|
||||
wxChoice * ShuttleGuiBase::TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayString & Choices,
|
||||
const std::vector<int> & InternalChoices)
|
||||
{
|
||||
return ShuttleGuiBase::TieChoice(
|
||||
Prompt, SettingName, Default, Choices, InternalChoices );
|
||||
}
|
||||
|
||||
/// Integer specific version of StartRadioButtonGroup.
|
||||
/// All 'TieRadioButton()' enclosed must be ints.
|
||||
void ShuttleGuiBase::StartRadioButtonGroup( const wxString & SettingName, const int iDefaultValue )
|
||||
@ -2439,6 +2460,13 @@ wxChoice * ShuttleGuiGetDefinition::TieChoice(
|
||||
const wxArrayString & Choices,
|
||||
const std::vector<int> & InternalChoices)
|
||||
{
|
||||
// Should no longer come here!
|
||||
// Choice controls in Preferences that really are exhaustive choices among
|
||||
// non-numerical options must now encode the internal choices as strings,
|
||||
// not numbers.
|
||||
wxASSERT(false);
|
||||
|
||||
// But if we do get here anyway, proceed sub-optimally as before.
|
||||
StartStruct();
|
||||
AddItem( SettingName, "id" );
|
||||
AddItem( Prompt, "prompt" );
|
||||
@ -2453,6 +2481,25 @@ wxChoice * ShuttleGuiGetDefinition::TieChoice(
|
||||
EndStruct();
|
||||
return ShuttleGui::TieChoice( Prompt, SettingName, Default, Choices, InternalChoices );
|
||||
}
|
||||
wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayString & Choices,
|
||||
const std::vector<int> & InternalChoices)
|
||||
{
|
||||
// Come here for controls that present non-exhaustive choices among some
|
||||
// numbers, with an associated control that allows arbitrary entry of an
|
||||
// "Other..."
|
||||
StartStruct();
|
||||
AddItem( SettingName, "id" );
|
||||
AddItem( Prompt, "prompt" );
|
||||
AddItem( "number", "type" ); // not "enum" !
|
||||
AddItem( Default, "default" );
|
||||
EndStruct();
|
||||
return ShuttleGui::TieNumberAsChoice(
|
||||
Prompt, SettingName, Default, Choices, InternalChoices );
|
||||
}
|
||||
wxTextCtrl * ShuttleGuiGetDefinition::TieTextBox(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
|
@ -224,12 +224,30 @@ public:
|
||||
const wxString &Default,
|
||||
const wxArrayString &Choices,
|
||||
const wxArrayString & InternalChoices );
|
||||
|
||||
// This overload of TieChoice should no longer be used in Preferences!
|
||||
// Some uses do remain in export settings dialogs.
|
||||
virtual wxChoice * TieChoice(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayString & Choices,
|
||||
const std::vector<int> & InternalChoices );
|
||||
|
||||
// This overload presents what is really a numerical setting as a choice among
|
||||
// commonly used values, but the choice is not exhaustive because there is
|
||||
// also an associated control that allows entry of a user-specified value
|
||||
// that is arbitrary (within some bounds).
|
||||
// This behaves just like the previous for building dialogs, but the
|
||||
// behavior is different when the call is intercepted for purposes of
|
||||
// emitting scripting information about Preferences.
|
||||
virtual wxChoice * TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayString & Choices,
|
||||
const std::vector<int> & InternalChoices );
|
||||
|
||||
virtual wxTextCtrl * TieTextBox(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
@ -431,12 +449,22 @@ public:
|
||||
const wxString &Default,
|
||||
const wxArrayString &Choices,
|
||||
const wxArrayString & InternalChoices ) override;
|
||||
|
||||
// An assertion will be violated if this override is reached!
|
||||
wxChoice * TieChoice(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayString & Choices,
|
||||
const std::vector<int> & InternalChoices) override;
|
||||
|
||||
wxChoice * TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayString & Choices,
|
||||
const std::vector<int> & InternalChoices) override;
|
||||
|
||||
wxTextCtrl * TieTextBox(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
|
@ -181,7 +181,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
// We make sure it uses the ID we want, so that we get changes
|
||||
S.Id(ID_SAMPLE_RATE_CHOICE);
|
||||
// We make sure we have a pointer to it, so that we can drive it.
|
||||
mSampleRates = S.TieChoice( {},
|
||||
mSampleRates = S.TieNumberAsChoice( {},
|
||||
wxT("/SamplingRate/DefaultProjectSampleRate"),
|
||||
AudioIO::GetOptimalSupportedSampleRate(),
|
||||
mSampleRateNames,
|
||||
|
Loading…
x
Reference in New Issue
Block a user