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

Rewrite overload of TieChoice that took wxString& instead of int& ...

... let it take TranslatableString& instead.

It was used only in AudioUnitEffect.cpp.
This commit is contained in:
Paul Licameli 2019-12-26 14:35:34 -05:00
parent e7783f4fde
commit d396472c9f
3 changed files with 23 additions and 22 deletions

View File

@ -1705,11 +1705,17 @@ wxSlider * ShuttleGuiBase::TieVSlider(
wxChoice * ShuttleGuiBase::TieChoice(
const TranslatableString &Prompt,
wxString &Selected,
TranslatableString &Selected,
const TranslatableStrings &choices )
{
WrappedType WrappedRef( Selected );
return DoTieChoice( Prompt, WrappedRef, choices );
int Index = make_iterator_range( choices ).index( Selected );
WrappedType WrappedRef( Index );
auto result = DoTieChoice( Prompt, WrappedRef, choices );
if ( Index >= 0 && Index < choices.size() )
Selected = choices[ Index ];
else
Selected = {};
return result;
}
wxChoice * ShuttleGuiBase::TieChoice(

View File

@ -410,7 +410,8 @@ public:
wxCheckBox * TieCheckBoxOnRight( const TranslatableString & Prompt, bool & Var );
wxChoice * TieChoice(
const TranslatableString &Prompt, wxString &Selected, const TranslatableStrings &choices );
const TranslatableString &Prompt,
TranslatableString &Selected, const TranslatableStrings &choices );
wxChoice * TieChoice(
const TranslatableString &Prompt, int &Selected, const TranslatableStrings &choices );

View File

@ -344,7 +344,7 @@ private:
EffectHostInterface *mHost;
bool mUseLatency;
wxString mUIType;
TranslatableString mUIType;
DECLARE_EVENT_TABLE()
};
@ -359,9 +359,13 @@ AudioUnitEffectOptionsDialog::AudioUnitEffectOptionsDialog(wxWindow * parent, Ef
mHost = host;
mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true);
mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), mUIType, wxT("Full"));
mUIType = wxGetTranslation(mUIType);
// Expect one of three string values from the config file
wxString uiType;
mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), uiType, wxT("Full"));
// Get the localization of the string for display to the user
mUIType = TranslatableString{ uiType, {} };
ShuttleGui S(this, eIsCreating);
PopulateOrExchange(S);
@ -438,21 +442,11 @@ void AudioUnitEffectOptionsDialog::OnOk(wxCommandEvent & WXUNUSED(evt))
ShuttleGui S(this, eIsGettingFromDialog);
PopulateOrExchange(S);
if (mUIType == _("Full"))
{
mUIType = wxT("Full");
}
else if (mUIType == _("Generic"))
{
mUIType = wxT("Generic");
}
else if (mUIType == _("Basic"))
{
mUIType = wxT("Basic");
}
// un-translate the type
auto uiType = mUIType.MSGID().GET();
mHost->SetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency);
mHost->SetSharedConfig(wxT("Options"), wxT("UIType"), mUIType);
mHost->SetSharedConfig(wxT("Options"), wxT("UIType"), uiType);
EndModal(wxID_OK);
}