1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +02:00

Replace ShuttleGui::SetNoMatchSelector with arg in TieNumberAsChoice

This commit is contained in:
Paul Licameli 2017-10-28 12:13:46 -04:00
parent 5616137a8b
commit f20e4786e9
4 changed files with 16 additions and 10 deletions

View File

@ -1924,7 +1924,8 @@ wxChoice * ShuttleGuiBase::TieNumberAsChoice(
const wxString &Prompt,
const SettingSpec< int > &Setting,
const wxArrayStringEx & Choices,
const std::vector<int> * pInternalChoices)
const std::vector<int> * pInternalChoices,
int iNoMatchSelector)
{
auto fn = [](int arg){ return wxString::Format( "%d", arg ); };
@ -1936,7 +1937,11 @@ wxChoice * ShuttleGuiBase::TieNumberAsChoice(
for ( int ii = 0; ii < Choices.size(); ++ii )
InternalChoices.push_back( fn( ii ) );
const auto Default = Setting.GetDefault();
miNoMatchSelector = iNoMatchSelector;
long defaultIndex;
if ( pInternalChoices )
defaultIndex = make_iterator_range( *pInternalChoices ).index( Default );

View File

@ -248,7 +248,8 @@ public:
const wxString &Prompt,
const SettingSpec< int > &Setting,
const wxArrayStringEx & Choices,
const std::vector<int> * pInternalChoices = nullptr );
const std::vector<int> * pInternalChoices = nullptr,
int iNoMatchSelector = 0 );
virtual wxTextCtrl * TieTextBox(
const wxString &Prompt,
@ -277,7 +278,6 @@ public:
void SetSizeHints( int minX, int minY );
void SetBorder( int Border ) {miBorder = Border;};
void SetStyle( int Style ) {miStyle = Style;};
void SetNoMatchSelector( int iSelector ) {miNoMatchSelector = iSelector;};
void SetSizerProportion( int iProp ) {miSizerProp = iProp;};
void SetStretchyCol( int i );
void SetStretchyRow( int i );

View File

@ -209,7 +209,7 @@ public:
const wxString &Prompt,
const SettingSpec< int > &Setting,
const wxArrayStringEx & Choices,
const std::vector<int> * pInternalChoices) override;
const std::vector<int> * pInternalChoices, int iNoMatchSelector ) override;
wxTextCtrl * TieTextBox(
const wxString &Prompt,
@ -274,7 +274,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
const wxString &Prompt,
const SettingSpec< int > &Setting,
const wxArrayStringEx & Choices,
const std::vector<int> * pInternalChoices)
const std::vector<int> * pInternalChoices, int iNoMatchSelector)
{
// Come here for controls that present non-exhaustive choices among some
// numbers, with an associated control that allows arbitrary entry of an
@ -286,7 +286,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
AddItem( Setting.GetDefault(), "default" );
EndStruct();
return ShuttleGui::TieNumberAsChoice(
Prompt, Setting, Choices, pInternalChoices );
Prompt, Setting, Choices, pInternalChoices, iNoMatchSelector );
}
wxTextCtrl * ShuttleGuiGetDefinition::TieTextBox(
const wxString &Prompt,

View File

@ -146,9 +146,6 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2);
{
// If the value in Prefs isn't in the list, then we want
// the last item, 'Other...' to be shown.
S.SetNoMatchSelector(mSampleRateNames.size() - 1);
// First the choice...
// We make sure it uses the ID we want, so that we get changes
S.Id(ID_SAMPLE_RATE_CHOICE);
@ -157,7 +154,11 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
{wxT("/SamplingRate/DefaultProjectSampleRate"),
AudioIOBase::GetOptimalSupportedSampleRate()},
mSampleRateNames,
&mSampleRateLabels);
&mSampleRateLabels,
// If the value in Prefs isn't in the list, then we want
// the last item, 'Other...' to be shown.
mSampleRateNames.GetCount() - 1
);
// Now do the edit box...
mOtherSampleRate = S.TieNumericTextBox( {},