mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +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.
|
/// between gui and stack variable and stack variable and shuttle.
|
||||||
/// @param Prompt The prompt shown beside the control.
|
/// @param Prompt The prompt shown beside the control.
|
||||||
/// @param SettingName The setting name as stored in gPrefs
|
/// @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 Choices An array of choices that appear on screen.
|
||||||
/// @param InternalChoices The corresponding values (as a string array)
|
/// @param InternalChoices The corresponding values (as a string array)
|
||||||
wxChoice * ShuttleGuiBase::TieChoice(
|
wxChoice * ShuttleGuiBase::TieChoice(
|
||||||
@ -1976,18 +1976,33 @@ wxChoice * ShuttleGuiBase::TieChoice(
|
|||||||
/// are non-exhaustive and there is a companion control for abitrary entry.
|
/// are non-exhaustive and there is a companion control for abitrary entry.
|
||||||
/// @param Prompt The prompt shown beside the control.
|
/// @param Prompt The prompt shown beside the control.
|
||||||
/// @param SettingName The setting name as stored in gPrefs
|
/// @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 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(
|
wxChoice * ShuttleGuiBase::TieNumberAsChoice(
|
||||||
const wxString &Prompt,
|
const wxString &Prompt,
|
||||||
const wxString &SettingName,
|
const wxString &SettingName,
|
||||||
const int Default,
|
const int Default,
|
||||||
const wxArrayStringEx & Choices,
|
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(
|
return ShuttleGuiBase::TieChoice(
|
||||||
Prompt, SettingName, Default, Choices, InternalChoices );
|
Prompt,
|
||||||
|
SettingName,
|
||||||
|
fn( Default ),
|
||||||
|
Choices,
|
||||||
|
InternalChoices
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------//
|
//------------------------------------------------------------------//
|
||||||
|
@ -256,9 +256,7 @@ public:
|
|||||||
const std::vector<int> & InternalChoices );
|
const std::vector<int> & InternalChoices );
|
||||||
|
|
||||||
// This overload presents what is really a numerical setting as a choice among
|
// 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
|
// commonly used values, but the choice is not necessarily exhaustive.
|
||||||
// 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
|
// This behaves just like the previous for building dialogs, but the
|
||||||
// behavior is different when the call is intercepted for purposes of
|
// behavior is different when the call is intercepted for purposes of
|
||||||
// emitting scripting information about Preferences.
|
// emitting scripting information about Preferences.
|
||||||
@ -267,7 +265,7 @@ public:
|
|||||||
const wxString &SettingName,
|
const wxString &SettingName,
|
||||||
const int Default,
|
const int Default,
|
||||||
const wxArrayStringEx & Choices,
|
const wxArrayStringEx & Choices,
|
||||||
const std::vector<int> & InternalChoices );
|
const std::vector<int> * pInternalChoices = nullptr );
|
||||||
|
|
||||||
virtual wxTextCtrl * TieTextBox(
|
virtual wxTextCtrl * TieTextBox(
|
||||||
const wxString &Prompt,
|
const wxString &Prompt,
|
||||||
|
@ -226,7 +226,7 @@ public:
|
|||||||
const wxString &SettingName,
|
const wxString &SettingName,
|
||||||
const int Default,
|
const int Default,
|
||||||
const wxArrayStringEx & Choices,
|
const wxArrayStringEx & Choices,
|
||||||
const std::vector<int> & InternalChoices) override;
|
const std::vector<int> * pInternalChoices) override;
|
||||||
|
|
||||||
wxTextCtrl * TieTextBox(
|
wxTextCtrl * TieTextBox(
|
||||||
const wxString &Prompt,
|
const wxString &Prompt,
|
||||||
@ -343,7 +343,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
|
|||||||
const wxString &SettingName,
|
const wxString &SettingName,
|
||||||
const int Default,
|
const int Default,
|
||||||
const wxArrayStringEx & Choices,
|
const wxArrayStringEx & Choices,
|
||||||
const std::vector<int> & InternalChoices)
|
const std::vector<int> * pInternalChoices)
|
||||||
{
|
{
|
||||||
// Come here for controls that present non-exhaustive choices among some
|
// Come here for controls that present non-exhaustive choices among some
|
||||||
// numbers, with an associated control that allows arbitrary entry of an
|
// numbers, with an associated control that allows arbitrary entry of an
|
||||||
@ -355,7 +355,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
|
|||||||
AddItem( Default, "default" );
|
AddItem( Default, "default" );
|
||||||
EndStruct();
|
EndStruct();
|
||||||
return ShuttleGui::TieNumberAsChoice(
|
return ShuttleGui::TieNumberAsChoice(
|
||||||
Prompt, SettingName, Default, Choices, InternalChoices );
|
Prompt, SettingName, Default, Choices, pInternalChoices );
|
||||||
}
|
}
|
||||||
wxTextCtrl * ShuttleGuiGetDefinition::TieTextBox(
|
wxTextCtrl * ShuttleGuiGetDefinition::TieTextBox(
|
||||||
const wxString &Prompt,
|
const wxString &Prompt,
|
||||||
|
@ -157,7 +157,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
wxT("/SamplingRate/DefaultProjectSampleRate"),
|
wxT("/SamplingRate/DefaultProjectSampleRate"),
|
||||||
AudioIOBase::GetOptimalSupportedSampleRate(),
|
AudioIOBase::GetOptimalSupportedSampleRate(),
|
||||||
mSampleRateNames,
|
mSampleRateNames,
|
||||||
mSampleRateLabels);
|
&mSampleRateLabels);
|
||||||
|
|
||||||
// Now do the edit box...
|
// Now do the edit box...
|
||||||
mOtherSampleRate = S.TieNumericTextBox( {},
|
mOtherSampleRate = S.TieNumericTextBox( {},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user