1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-23 07:58:05 +02:00

ShuttleGuiBase::DoTieChoice is no longer needed

This commit is contained in:
Paul Licameli 2019-12-26 14:39:00 -05:00
parent d396472c9f
commit 416cdbefb6
2 changed files with 6 additions and 35 deletions

View File

@ -1449,9 +1449,9 @@ wxSlider * ShuttleGuiBase::DoTieSlider(
}
wxChoice * ShuttleGuiBase::DoTieChoice(
wxChoice * ShuttleGuiBase::TieChoice(
const TranslatableString &Prompt,
WrappedType &WrappedRef,
int &Selected,
const TranslatableStrings &choices )
{
HandleOptionality( Prompt );
@ -1465,17 +1465,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice(
{
case eIsCreating:
{
if( WrappedRef.IsString() ) {
auto str = WrappedRef.ReadAsString();
auto begin = choices.begin();
auto iter = std::find_if( begin, choices.end(),
[&str]( const TranslatableString &choice ){
return str == choice.Translation(); } );
int Selected = std::distance( begin, iter );
pChoice = AddChoice( Prompt, choices, Selected );
}
else
pChoice = AddChoice( Prompt, choices, WrappedRef.ReadAsInt() );
pChoice = AddChoice( Prompt, choices, Selected );
ShuttleGui::SetMinSize(pChoice, choices);
}
break;
@ -1487,10 +1477,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice(
wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg);
pChoice = wxDynamicCast(pWnd, wxChoice);
wxASSERT( pChoice );
if( WrappedRef.IsString())
WrappedRef.WriteToAsString( pChoice->GetStringSelection());
else
WrappedRef.WriteToAsInt( pChoice->GetSelection() );
Selected = pChoice->GetSelection();
}
break;
case eIsSettingToDialog:
@ -1498,10 +1485,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice(
wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg);
pChoice = wxDynamicCast(pWnd, wxChoice);
wxASSERT( pChoice );
if( WrappedRef.IsString() )
pChoice->SetStringSelection( WrappedRef.ReadAsString() );
else
pChoice->SetSelection( WrappedRef.ReadAsInt() );
pChoice->SetSelection( Selected );
}
break;
default:
@ -1709,8 +1693,7 @@ wxChoice * ShuttleGuiBase::TieChoice(
const TranslatableStrings &choices )
{
int Index = make_iterator_range( choices ).index( Selected );
WrappedType WrappedRef( Index );
auto result = DoTieChoice( Prompt, WrappedRef, choices );
auto result = TieChoice( Prompt, Index, choices );
if ( Index >= 0 && Index < choices.size() )
Selected = choices[ Index ];
else
@ -1718,15 +1701,6 @@ wxChoice * ShuttleGuiBase::TieChoice(
return result;
}
wxChoice * ShuttleGuiBase::TieChoice(
const TranslatableString &Prompt,
int &Selected,
const TranslatableStrings &choices )
{
WrappedType WrappedRef( Selected );
return DoTieChoice( Prompt, WrappedRef, choices );
}
//-----------------------------------------------------------------------//
// ShuttleGui utility functions to look things up in a list.

View File

@ -562,9 +562,6 @@ private:
wxTextCtrl * DoTieNumericTextBox(
const TranslatableString &Prompt, WrappedType & WrappedRef, const int nChars);
wxCheckBox * DoTieCheckBox( const TranslatableString &Prompt, WrappedType & WrappedRef );
wxChoice * DoTieChoice(
const TranslatableString &Prompt, WrappedType & WrappedRef,
const TranslatableStrings & choices );
wxSlider * DoTieSlider(
const TranslatableString &Prompt,
WrappedType & WrappedRef, const int max, const int min = 0 );