mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-01 15:43:44 +02:00
Reimplement TieNumberAsChoice and fix some comments...
... Make the array of integer choices optional, and call through to the non-deprecated overload of TieChoice, which uses strings. In 2.3.3 this function is only used in the Quality preferences dialog.
This commit is contained in:
parent
0493aaccee
commit
dc3e872ca6
@ -1912,7 +1912,7 @@ wxChoice *ShuttleGuiBase::TieChoice(
|
||||
/// between gui and stack variable and stack variable and shuttle.
|
||||
/// @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 Default The default internal string value for this control
|
||||
/// @param Choices An array of choices that appear on screen.
|
||||
/// @param InternalChoices The corresponding values (as a string array)
|
||||
wxChoice * ShuttleGuiBase::TieChoice(
|
||||
@ -1976,18 +1976,33 @@ wxChoice * ShuttleGuiBase::TieChoice(
|
||||
/// 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 Default The default integer value for this control
|
||||
/// @param Choices An array of choices that appear on screen.
|
||||
/// @param InternalChoices The corresponding values (as an integer array)
|
||||
/// @param pInternalChoices The corresponding values (as an integer array)
|
||||
/// if null, then use 0, 1, 2, ...
|
||||
wxChoice * ShuttleGuiBase::TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayStringEx & Choices,
|
||||
const std::vector<int> & InternalChoices)
|
||||
const std::vector<int> * pInternalChoices)
|
||||
{
|
||||
auto fn = [](int arg){ return wxString::Format( "%d", arg ); };
|
||||
wxArrayStringEx InternalChoices;
|
||||
if ( pInternalChoices )
|
||||
InternalChoices =
|
||||
transform_container<wxArrayStringEx>(*pInternalChoices, fn);
|
||||
else
|
||||
for ( int ii = 0; ii < Choices.size(); ++ii )
|
||||
InternalChoices.push_back( fn( ii ) );
|
||||
|
||||
return ShuttleGuiBase::TieChoice(
|
||||
Prompt, SettingName, Default, Choices, InternalChoices );
|
||||
Prompt,
|
||||
SettingName,
|
||||
fn( Default ),
|
||||
Choices,
|
||||
InternalChoices
|
||||
);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------//
|
||||
|
@ -256,9 +256,7 @@ public:
|
||||
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).
|
||||
// commonly used values, but the choice is not necessarily exhaustive.
|
||||
// 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.
|
||||
@ -267,7 +265,7 @@ public:
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayStringEx & Choices,
|
||||
const std::vector<int> & InternalChoices );
|
||||
const std::vector<int> * pInternalChoices = nullptr );
|
||||
|
||||
virtual wxTextCtrl * TieTextBox(
|
||||
const wxString &Prompt,
|
||||
|
@ -226,7 +226,7 @@ public:
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayStringEx & Choices,
|
||||
const std::vector<int> & InternalChoices) override;
|
||||
const std::vector<int> * pInternalChoices) override;
|
||||
|
||||
wxTextCtrl * TieTextBox(
|
||||
const wxString &Prompt,
|
||||
@ -343,7 +343,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
|
||||
const wxString &SettingName,
|
||||
const int Default,
|
||||
const wxArrayStringEx & Choices,
|
||||
const std::vector<int> & InternalChoices)
|
||||
const std::vector<int> * pInternalChoices)
|
||||
{
|
||||
// Come here for controls that present non-exhaustive choices among some
|
||||
// numbers, with an associated control that allows arbitrary entry of an
|
||||
@ -355,7 +355,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
|
||||
AddItem( Default, "default" );
|
||||
EndStruct();
|
||||
return ShuttleGui::TieNumberAsChoice(
|
||||
Prompt, SettingName, Default, Choices, InternalChoices );
|
||||
Prompt, SettingName, Default, Choices, pInternalChoices );
|
||||
}
|
||||
wxTextCtrl * ShuttleGuiGetDefinition::TieTextBox(
|
||||
const wxString &Prompt,
|
||||
|
@ -157,7 +157,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
wxT("/SamplingRate/DefaultProjectSampleRate"),
|
||||
AudioIOBase::GetOptimalSupportedSampleRate(),
|
||||
mSampleRateNames,
|
||||
mSampleRateLabels);
|
||||
&mSampleRateLabels);
|
||||
|
||||
// Now do the edit box...
|
||||
mOtherSampleRate = S.TieNumericTextBox( {},
|
||||
|
Loading…
x
Reference in New Issue
Block a user