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

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( 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 /// \todo This function and the next two, suitably adapted, could be
/// used by TieRadioButton. /// used by TieRadioButton.
@ -504,17 +504,20 @@ wxRadioButton * ShuttleGuiBase::DoAddRadioButton(
if ( style ) if ( style )
pRad->SetValue( true ); pRad->SetValue( true );
UpdateSizers(); UpdateSizers();
pRad->SetValue( selector == initValue );
return pRad; 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__ #ifdef __WXMAC__

View File

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

View File

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

View File

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