Specify initial radio button state in ShuttleGui method arguments

This commit is contained in:
Paul Licameli 2018-01-29 15:37:20 -05:00
parent fab756562e
commit 089b46ab64
4 changed files with 58 additions and 51 deletions

View File

@ -490,7 +490,7 @@ wxComboBox * ShuttleGuiBase::AddCombo( const wxString &Prompt, const wxString &S
wxRadioButton * ShuttleGuiBase::DoAddRadioButton(
const wxString &Prompt, int style)
const wxString &Prompt, int style, int selector, int initValue)
{
/// \todo This function and the next two, suitably adapted, could be
/// used by TieRadioButton.
@ -504,17 +504,20 @@ wxRadioButton * ShuttleGuiBase::DoAddRadioButton(
if ( style )
pRad->SetValue( true );
UpdateSizers();
pRad->SetValue( selector == initValue );
return pRad;
}
wxRadioButton * ShuttleGuiBase::AddRadioButton(const wxString &Prompt)
wxRadioButton * ShuttleGuiBase::AddRadioButton(
const wxString &Prompt, int selector, int initValue)
{
return DoAddRadioButton( Prompt, wxRB_GROUP );
return DoAddRadioButton( Prompt, wxRB_GROUP, selector, initValue );
}
wxRadioButton * ShuttleGuiBase::AddRadioButtonToGroup(const wxString &Prompt)
wxRadioButton * ShuttleGuiBase::AddRadioButtonToGroup(
const wxString &Prompt, int selector, int initValue)
{
return DoAddRadioButton( Prompt, 0 );
return DoAddRadioButton( Prompt, 0, selector, initValue );
}
#ifdef __WXMAC__

View File

@ -137,8 +137,15 @@ public:
wxSlider * AddVSlider(const wxString &Prompt, int pos, int Max);
wxSpinCtrl * AddSpinCtrl(const wxString &Prompt, int Value, int Max, int Min);
wxTreeCtrl * AddTree();
wxRadioButton * AddRadioButton( const wxString & Prompt );
wxRadioButton * AddRadioButtonToGroup( const wxString & Prompt);
// Pass the same initValue to the sequence of calls to AddRadioButton and
// AddRadioButtonToGroup.
// The radio button is filled if selector == initValue
wxRadioButton * AddRadioButton(
const wxString & Prompt, int selector = 0, int initValue = 0 );
wxRadioButton * AddRadioButtonToGroup(
const wxString & Prompt, int selector = 1, int initValue = 0 );
// Only the last button specified as default (if more than one) will be
// Always ORs the flags with wxALL (which affects borders):
wxButton * AddButton(
@ -375,7 +382,8 @@ private:
Maybe<WrappedType> mRadioValue; /// The wrapped value associated with the active radio button.
int mRadioCount; /// The index of this radio item. -1 for none.
wxString mRadioValueString; /// Unwrapped string value.
wxRadioButton * DoAddRadioButton(const wxString &Prompt, int style);
wxRadioButton * DoAddRadioButton(
const wxString &Prompt, int style, int selector, int initValue);
};
// A rarely used helper function that sets a pointer

View File

@ -1041,16 +1041,34 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
{
S.AddUnits(_("&Processing: "));
mMathProcessingType[0] = S.Id(ID_DefaultMath).
AddRadioButton(_("D&efault"));
mMathProcessingType[1] = S.Id(ID_SSE).
AddRadioButtonToGroup(_("&SSE"));
mMathProcessingType[2] = S.Id(ID_SSEThreaded).
AddRadioButtonToGroup(_("SSE &Threaded"));
mMathProcessingType[3] = S.Id(ID_AVX).
AddRadioButtonToGroup(_("A&VX"));
mMathProcessingType[4] = S.Id(ID_AVXThreaded).
AddRadioButtonToGroup(_("AV&X Threaded"));
// update the control state
int mathPath = EffectEqualization48x::GetMathPath();
int value =
(mathPath & MATH_FUNCTION_SSE)
? (mathPath & MATH_FUNCTION_THREADED)
? 2
: 1
: false // (mathPath & MATH_FUNCTION_AVX) // not implemented
? (mathPath & MATH_FUNCTION_THREADED)
? 4
: 3
: 0;
mMathProcessingType[0] = S.Id(ID_DefaultMath)
.AddRadioButton(_("D&efault"),
0, value);
mMathProcessingType[1] = S.Id(ID_SSE)
.AddRadioButtonToGroup(_("&SSE"),
1, value);
mMathProcessingType[2] = S.Id(ID_SSEThreaded)
.AddRadioButtonToGroup(_("SSE &Threaded"),
2, value);
mMathProcessingType[3] = S.Id(ID_AVX)
.AddRadioButtonToGroup(_("A&VX"),
3, value);
mMathProcessingType[4] = S.Id(ID_AVXThreaded)
.AddRadioButtonToGroup(_("AV&X Threaded"),
4, value);
if (!EffectEqualization48x::GetMathCaps()->SSE)
{
@ -1062,21 +1080,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
mMathProcessingType[3]->Disable();
mMathProcessingType[4]->Disable();
}
// update the control state
mMathProcessingType[0]->SetValue(true);
int mathPath=EffectEqualization48x::GetMathPath();
if (mathPath&MATH_FUNCTION_SSE)
{
mMathProcessingType[1]->SetValue(true);
if (mathPath&MATH_FUNCTION_THREADED)
mMathProcessingType[2]->SetValue(true);
}
if (false) //mathPath&MATH_FUNCTION_AVX) { not implemented
{
mMathProcessingType[3]->SetValue(true);
if (mathPath&MATH_FUNCTION_THREADED)
mMathProcessingType[4]->SetValue(true);
}
S.Id(ID_Bench).AddButton(_("&Bench"));
}
S.EndHorizontalLay();

View File

@ -2024,13 +2024,10 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
{
S.StartVerticalLay();
{
gradient = S.AddRadioButton(_("Gradient"));
gradient = S.AddRadioButton(_("Gradient"), true, mGradient);
gradient->SetName(_("Gradient"));
gradient->SetValue(mGradient);
rms = S.AddRadioButtonToGroup(_("RMS"));
rms = S.AddRadioButtonToGroup(_("RMS"), false, mGradient);
rms->SetName(_("RMS"));
rms->SetValue(!mGradient);
}
S.EndVerticalLay();
}
@ -2040,13 +2037,10 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
{
S.StartVerticalLay();
{
db = S.AddRadioButton(_("dB"));
db = S.AddRadioButton(_("dB"), true, mDB);
db->SetName(_("dB"));
db->SetValue(mDB);
linear = S.AddRadioButtonToGroup(_("Linear"));
linear = S.AddRadioButtonToGroup(_("Linear"), false, mDB);
linear->SetName(_("Linear"));
linear->SetValue(!mDB);
}
S.EndVerticalLay();
}
@ -2056,17 +2050,15 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
{
S.StartVerticalLay();
{
automatic = S.AddRadioButton(_("Automatic"));
automatic = S.AddRadioButton(
_("Automatic"), AutomaticStereo, mDesiredStyle);
automatic->SetName(_("Automatic"));
automatic->SetValue(mDesiredStyle == AutomaticStereo);
horizontal = S.AddRadioButtonToGroup(_("Horizontal"));
horizontal = S.AddRadioButtonToGroup(
_("Horizontal"), HorizontalStereo, mDesiredStyle);
horizontal->SetName(_("Horizontal"));
horizontal->SetValue(mDesiredStyle == HorizontalStereo);
vertical = S.AddRadioButtonToGroup(_("Vertical"));
vertical = S.AddRadioButtonToGroup(
_("Vertical"), VerticalStereo, mDesiredStyle);
vertical->SetName(_("Vertical"));
vertical->SetValue(mDesiredStyle == VerticalStereo);
}
S.EndVerticalLay();
}