diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp index d979bd078..df5a9ba0c 100644 --- a/src/Benchmark.cpp +++ b/src/Benchmark.cpp @@ -216,8 +216,8 @@ void BenchmarkDialog::MakeBenchmarkDialog() mText = S.Id(StaticTextID) /* i18n-hint noun */ .Name(XO("Output")) + .MinSize( { 500, 200 } ) .AddTextWindow(wxT("")); - mText->SetSizeHints(wxSize(500,200)); // S.SetBorder(10); diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index daa8201e7..af8a8a516 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -310,9 +310,9 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.EndVerticalLay(); mFreqPlot = safenew FreqPlot(this, wxID_ANY); - mFreqPlot->SetMinSize(wxSize(wxDefaultCoord, FREQ_WINDOW_HEIGHT)); - S.Prop(1); - S.AddWindow(mFreqPlot, wxEXPAND); + S.Prop(1) + .MinSize( { wxDefaultCoord, FREQ_WINDOW_HEIGHT } ) + .AddWindow(mFreqPlot, wxEXPAND); S.StartHorizontalLay(wxEXPAND, 0); { @@ -448,14 +448,14 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.AddSpace(5); mAlgChoice = S.Id(FreqAlgChoiceID).Focus() + .MinSize( { wxDefaultCoord, wxDefaultCoord } ) .AddChoice(_("&Algorithm:"), algChoices, mAlg); - S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); S.AddSpace(5); mSizeChoice = S.Id(FreqSizeChoiceID) + .MinSize( { wxDefaultCoord, wxDefaultCoord } ) .AddChoice(_("&Size:"), sizeChoices, mSize); - S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); S.AddSpace(5); @@ -471,15 +471,15 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.AddSpace(5); mFuncChoice = S.Id(FreqFuncChoiceID) + .MinSize( { wxDefaultCoord, wxDefaultCoord } ) .AddChoice(_("&Function:"), funcChoices, mFunc); - S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); mFuncChoice->MoveAfterInTabOrder(mSizeChoice); S.AddSpace(5); mAxisChoice = S.Id(FreqAxisChoiceID) + .MinSize( { wxDefaultCoord, wxDefaultCoord } ) .AddChoice(_("&Axis:"), axisChoices, mAxis); - S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); mAxisChoice->MoveAfterInTabOrder(mFuncChoice); S.AddSpace(5); diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 0f717b273..c314ec4f4 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -84,6 +84,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): S.StartStatic(_("&Manage History"), 1); { mList = S + .MinSize() .AddListControlReportMode( { { _("Action"), wxLIST_FORMAT_LEFT, 260 }, { _("Reclaimable Space"), wxLIST_FORMAT_LEFT, 125 } }, @@ -139,7 +140,6 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): S.EndVerticalLay(); // ----------------------- End of main section -------------- - mList->SetMinSize(mList->GetSize()); Fit(); SetMinSize(GetSize()); mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1)); diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index d508793d2..992e988ff 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -184,14 +184,6 @@ void ShuttleGuiBase::ResetId() miIdNext = 3000; } -/// Used to modify an already placed Window. -void ShuttleGuiBase::SetSizeHints( int minX, int minY ) -{ - if( mShuttleMode != eIsCreating ) - return; - mpLastWind->SetSizeHints( minX, minY ); -} - /// Used to modify an already placed FlexGridSizer to make a column stretchy. void ShuttleGuiBase::SetStretchyCol( int i ) @@ -1460,6 +1452,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice( } else pChoice = AddChoice( Prompt, choices, WrappedRef.ReadAsInt() ); + ShuttleGui::SetMinSize(pChoice, choices); } break; // IF setting internal storage from the controls. @@ -1497,7 +1490,6 @@ wxChoice * ShuttleGuiBase::DoTieChoice( wxASSERT( false ); break; } - SetSizeHints(choices); return pChoice; } @@ -2086,6 +2078,11 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt) for (auto &pair : mItem.mRootConnections) mpWind->Connect( pair.first, pair.second, nullptr, mpDlg ); + if( mItem.mUseBestSize ) + mpWind->SetMinSize( mpWind->GetBestSize() ); + else if( mItem.mHasMinSize ) + mpWind->SetMinSize( mItem.mMinSize ); + // Reset to defaults mItem = {}; } @@ -2107,7 +2104,7 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt) mpSizer = pSubSizer; PushSizer(); } - mpLastWind = mpWind; + mpWind = NULL; miProp = 0; miSizerProp =0; @@ -2398,7 +2395,7 @@ wxSizerItem * ShuttleGui::AddSpace( int width, int height ) return mpSizer->Add( width, height, miProp); } -void ShuttleGuiBase::SetSizeHints( wxWindow *window, const wxArrayStringEx & items ) +void ShuttleGui::SetMinSize( wxWindow *window, const wxArrayStringEx & items ) { int maxw = 0; @@ -2429,10 +2426,16 @@ void ShuttleGuiBase::SetSizeHints( wxWindow *window, const wxArrayStringEx & ite window->SetMinSize( { maxw, -1 } ); } -void ShuttleGuiBase::SetSizeHints( const wxArrayStringEx & items ) +/* +void ShuttleGui::SetMinSize( wxWindow *window, const std::vector & items ) { - if( mShuttleMode != eIsCreating ) - return; + wxArrayStringEx strs; - SetSizeHints( mpLastWind, items ); + for( size_t i = 0; i < items.size(); i++ ) + { + strs.Add( wxString::Format( wxT("%d"), items[i] ) ); + } + + SetMinSize( window, strs ); } +*/ diff --git a/src/ShuttleGui.h b/src/ShuttleGui.h index ff0f04e7c..c6676da39 100644 --- a/src/ShuttleGui.h +++ b/src/ShuttleGui.h @@ -203,6 +203,18 @@ struct Item { return std::move( *this ); } + Item&& MinSize() && // set best size as min size + { + mUseBestSize = true; + return std::move ( *this ); + } + + Item&& MinSize( wxSize sz ) && + { + mMinSize = sz; mHasMinSize = true; + return std::move ( *this ); + } + std::function< void(wxWindow*) > mValidatorSetter; TranslatableString mToolTip; TranslatableString mName; @@ -212,8 +224,13 @@ struct Item { long miStyle{}; + wxSize mMinSize{ -1, -1 }; + bool mHasMinSize{ false }; + bool mUseBestSize{ false }; + bool mFocused { false }; bool mDisabled { false }; + }; } @@ -419,7 +436,6 @@ public: const int max, const int min); //-- End of variants. - void SetSizeHints( int minX, int minY ); void SetBorder( int Border ) {miBorder = Border;}; void SetSizerProportion( int iProp ) {miSizerProp = iProp;}; void SetStretchyCol( int i ); @@ -451,18 +467,12 @@ protected: long GetStyle( long Style ); private: - void SetSizeHints( const wxArrayStringEx & items ); - void DoInsertListColumns( wxListCtrl *pListCtrl, long listControlStyles, std::initializer_list columns ); -public: - static void SetSizeHints( wxWindow *window, const wxArrayStringEx & items ); - protected: - wxWindow * mpLastWind; wxWindow *const mpDlg; wxSizer * pSizerStack[ nMaxNestedSizers ]; @@ -647,6 +657,11 @@ public: return *this; } + ShuttleGui &MinSize() // set best size as min size + { std::move( mItem ).MinSize(); return *this; } + ShuttleGui &MinSize( wxSize sz ) + { std::move( mItem ).MinSize( sz ); return *this; } + GuiWaveTrack * AddGuiWaveTrack( const wxString & Name); AttachableScrollBar * AddAttachableScrollBar( long style = wxSB_HORIZONTAL ); @@ -658,6 +673,11 @@ public: wxSizerItem * AddSpace( int width, int height ); wxSizerItem * AddSpace( int size ) { return AddSpace( size, size ); }; + // Calculate width of a choice control adequate for the items, maybe after + // the dialog is created but the items change. + static void SetMinSize( wxWindow *window, const wxArrayStringEx & items ); + // static void SetMinSize( wxWindow *window, const std::vector & items ); + teShuttleMode GetMode() { return mShuttleMode; }; }; diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index 0d5717d36..9e146532f 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -278,24 +278,24 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S) m_pChoice_FromPitch = S.Id(ID_FromPitch) /* i18n-hint: changing a quantity "from" one value "to" another */ .Name(XO("from")) + .MinSize( { 80, -1 } ) .AddChoice(_("from"), pitch); - m_pChoice_FromPitch->SetSizeHints(80, -1); m_pSpin_FromOctave = S.Id(ID_FromOctave) .Name(XO("from Octave")) + .MinSize( { 50, -1 } ) .AddSpinCtrl( {}, m_nFromOctave, INT_MAX, INT_MIN); - m_pSpin_FromOctave->SetSizeHints(50, -1); m_pChoice_ToPitch = S.Id(ID_ToPitch) /* i18n-hint: changing a quantity "from" one value "to" another */ .Name(XO("to")) + .MinSize( { 80, -1 } ) .AddChoice(_("to"), pitch); - m_pChoice_ToPitch->SetSizeHints(80, -1); m_pSpin_ToOctave = S.Id(ID_ToOctave) .Name(XO("to Octave")) + .MinSize( { 50, -1 } ) .AddSpinCtrl( {}, m_nToOctave, INT_MAX, INT_MIN); - m_pSpin_ToOctave->SetSizeHints(50, -1); } S.EndMultiColumn(); diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index cc253b596..df5782102 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -349,15 +349,15 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) mpChoice_FromVinyl = S.Id(ID_FromVinyl) .Name(XO("From rpm")) + .MinSize( { 100, -1 } ) /* i18n-hint: changing a quantity "from" one value "to" another */ .AddChoice(_("from"), vinylChoices); - mpChoice_FromVinyl->SetSizeHints(100, -1); mpChoice_ToVinyl = S.Id(ID_ToVinyl) /* i18n-hint: changing a quantity "from" one value "to" another */ .Name(XO("To rpm")) + .MinSize( { 100, -1 } ) .AddChoice(_("to"), vinylChoices); - mpChoice_ToVinyl->SetSizeHints(100, -1); } S.EndMultiColumn(); diff --git a/src/effects/ClickRemoval.cpp b/src/effects/ClickRemoval.cpp index f1f36761d..d7dfaf2cb 100644 --- a/src/effects/ClickRemoval.cpp +++ b/src/effects/ClickRemoval.cpp @@ -351,8 +351,8 @@ void EffectClickRemoval::PopulateOrExchange(ShuttleGui & S) .Name(XO("Threshold")) .Style(wxSL_HORIZONTAL) .Validator(&mThresholdLevel) + .MinSize( { 150, -1 } ) .AddSlider( {}, mThresholdLevel, MAX_Threshold, MIN_Threshold); - mThreshS->SetMinSize(wxSize(150, -1)); // Click width mWidthT = S.Id(ID_Width) @@ -366,8 +366,8 @@ void EffectClickRemoval::PopulateOrExchange(ShuttleGui & S) .Name(XO("Max Spike Width")) .Style(wxSL_HORIZONTAL) .Validator(&mClickWidth) + .MinSize( { 150, -1 } ) .AddSlider( {}, mClickWidth, MAX_Width, MIN_Width); - mWidthS->SetMinSize(wxSize(150, -1)); } S.EndMultiColumn(); diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index 289c1e681..4c0f01cbd 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -213,8 +213,9 @@ void EffectCompressor::PopulateOrExchange(ShuttleGui & S) mThresholdDB, mNoiseFloorDB, mRatio); - mPanel->SetMinSize(wxSize(400, 200)); - S.Prop(true).AddWindow(mPanel, wxEXPAND | wxALL); + S.Prop(true) + .MinSize( { 400, 200 } ) + .AddWindow(mPanel, wxEXPAND | wxALL); S.SetBorder(5); } S.EndHorizontalLay(); diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index 627832f8b..045970686 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -367,10 +367,10 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S) S.StartMultiColumn(4, wxCENTER); { mTypeChoiceCtrl = S.Id(ID_Type) + .MinSize( { -1, -1 } ) .Validator(&mParams.mTableChoiceIndx) .AddChoice(_("Distortion type:"), LocalizedStrings(kTableTypeStrings, nTableTypes)); - S.SetSizeHints(-1, -1); mDCBlockCheckBox = S.Id(ID_DCBlock).AddCheckBox(_("DC blocking filter"), DEF_DCBlock); diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index 76d72e713..06c25eb0e 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -355,11 +355,11 @@ void EffectDtmf::PopulateOrExchange(ShuttleGui & S) S.AddFixedText(_("Tone/silence ratio:"), false); mDtmfDutyCycleS = S.Id(ID_DutyCycle) .Style(wxSL_HORIZONTAL | wxEXPAND) + .MinSize( { -1, -1 } ) .AddSlider( {}, dtmfDutyCycle * SCL_DutyCycle, MAX_DutyCycle * SCL_DutyCycle, MIN_DutyCycle * SCL_DutyCycle); - S.SetSizeHints(-1,-1); } S.EndMultiColumn(); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 9dea2b622..560e06bd7 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -789,8 +789,9 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) mPanel = safenew EqualizationPanel(parent, wxID_ANY, this); S.Prop(1); - S.AddWindow(mPanel, wxEXPAND ); - S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); + S + .MinSize( { wxDefaultCoord, wxDefaultCoord } ) + .AddWindow(mPanel, wxEXPAND ); S.SetBorder(5); S.StartVerticalLay(); diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index bba839b23..fcc4a6d15 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -1440,8 +1440,8 @@ struct ControlInfo { S.Id(id) .Name( sliderName ) .Style(wxSL_HORIZONTAL) + .MinSize( { 150, -1 } ) .AddSlider( {}, 0, sliderMax); - slider->SetSizeHints(150, -1); } MemberPointer field; diff --git a/src/effects/NoiseRemoval.cpp b/src/effects/NoiseRemoval.cpp index 07161276b..269a6d911 100644 --- a/src/effects/NoiseRemoval.cpp +++ b/src/effects/NoiseRemoval.cpp @@ -724,8 +724,8 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) mGainS = S.Id(ID_GAIN_SLIDER) .Name(XO("Noise reduction")) .Style(wxSL_HORIZONTAL) + .MinSize( { 150, -1 } ) .AddSlider(wxT(""), 0, GAIN_MAX, GAIN_MIN); - mGainS->SetSizeHints(150, -1); mSensitivityT = S.Id(ID_SENSITIVITY_TEXT) .Validator(wxFILTER_NUMERIC) @@ -733,8 +733,8 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) mSensitivityS = S.Id(ID_SENSITIVITY_SLIDER) .Name(XO("Sensitivity")) .Style(wxSL_HORIZONTAL) + .MinSize( { 150, -1 } ) .AddSlider(wxT(""), 0, SENSITIVITY_MAX, SENSITIVITY_MIN); - mSensitivityS->SetSizeHints(150, -1); mFreqT = S.Id(ID_FREQ_TEXT) .Validator(wxFILTER_NUMERIC) @@ -742,8 +742,8 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) mFreqS = S.Id(ID_FREQ_SLIDER) .Name(XO("Frequency smoothing")) .Style(wxSL_HORIZONTAL) + .MinSize( { 150, -1 } ) .AddSlider(wxT(""), 0, FREQ_MAX, FREQ_MIN); - mFreqS->SetSizeHints(150, -1); mTimeT = S.Id(ID_TIME_TEXT) .Validator(wxFILTER_NUMERIC) @@ -751,8 +751,8 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) mTimeS = S.Id(ID_TIME_SLIDER) .Name(XO("Attack/decay time")) .Style(wxSL_HORIZONTAL) + .MinSize( { 150, -1 } ) .AddSlider(wxT(""), 0, TIME_MAX, TIME_MIN); - mTimeS->SetSizeHints(150, -1); S.AddPrompt(_("Noise:")); mKeepSignal = S.Id(ID_RADIOBUTTON_KEEPSIGNAL) diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index b15a21f0c..fad9f2a4d 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -300,10 +300,10 @@ void EffectNormalize::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxALIGN_LEFT, false); { mGainCheckBox = S + .MinSize() .Validator(&mGain) .AddCheckBox(_("Normalize peak amplitude to "), mGain); - mGainCheckBox->SetMinSize( mGainCheckBox->GetSize()); mLevelTextCtrl = S .Name(XO("Peak amplitude dB")) diff --git a/src/effects/Phaser.cpp b/src/effects/Phaser.cpp index a7e8a2390..99d87ec71 100644 --- a/src/effects/Phaser.cpp +++ b/src/effects/Phaser.cpp @@ -264,9 +264,9 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S) mStagesS = S.Id(ID_Stages) .Name(XO("Stages")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Stages * SCL_Stages, MAX_Stages * SCL_Stages, MIN_Stages * SCL_Stages); mStagesS->SetLineSize(2); - mStagesS->SetMinSize(wxSize(100, -1)); mDryWetT = S.Id(ID_DryWet) .Validator>( @@ -276,8 +276,8 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S) mDryWetS = S.Id(ID_DryWet) .Name(XO("Dry Wet")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_DryWet * SCL_DryWet, MAX_DryWet * SCL_DryWet, MIN_DryWet * SCL_DryWet); - mDryWetS->SetMinSize(wxSize(100, -1)); mFreqT = S.Id(ID_Freq) .Validator>( @@ -287,8 +287,8 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S) mFreqS = S.Id(ID_Freq) .Name(XO("LFO frequency in hertz")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Freq * SCL_Freq, MAX_Freq * SCL_Freq, 0.0); - mFreqS ->SetMinSize(wxSize(100, -1)); mPhaseT = S.Id(ID_Phase) .Validator>( @@ -298,9 +298,9 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S) mPhaseS = S.Id(ID_Phase) .Name(XO("LFO start phase in degrees")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Phase * SCL_Phase, MAX_Phase * SCL_Phase, MIN_Phase * SCL_Phase); mPhaseS->SetLineSize(10); - mPhaseS->SetMinSize(wxSize(100, -1)); mDepthT = S.Id(ID_Depth) .Validator>( @@ -310,8 +310,8 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S) mDepthS = S.Id(ID_Depth) .Name(XO("Depth in percent")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth); - mDepthS->SetMinSize(wxSize(100, -1)); mFeedbackT = S.Id(ID_Feedback) .Validator>( @@ -321,9 +321,9 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S) mFeedbackS = S.Id(ID_Feedback) .Name(XO("Feedback in percent")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Feedback * SCL_Feedback, MAX_Feedback * SCL_Feedback, MIN_Feedback * SCL_Feedback); mFeedbackS->SetLineSize(10); - mFeedbackS->SetMinSize(wxSize(100, -1)); mOutGainT = S.Id(ID_OutGain) .Validator>( @@ -333,8 +333,8 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S) mOutGainS = S.Id(ID_OutGain) .Name(XO("Output gain (dB)")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_OutGain * SCL_OutGain, MAX_OutGain * SCL_OutGain, MIN_OutGain * SCL_OutGain); - mOutGainS->SetMinSize(wxSize(100, -1)); } S.EndMultiColumn(); } diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 04b8e11f9..162886f89 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -398,9 +398,9 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) ); S.SetBorder(5); - S.Prop(1); - S.AddWindow(mPanel, wxEXPAND | wxRIGHT); - S.SetSizeHints(-1, -1); + S.Prop(1) + .MinSize( { -1, -1 } ) + .AddWindow(mPanel, wxEXPAND | wxRIGHT); S.StartVerticalLay(); { @@ -460,14 +460,15 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) mFilterTypeCtl = S.Id(ID_Type) .Focus() .Validator(&mFilterType) + .MinSize( { -1, -1 } ) .AddChoice(_("&Filter Type:"), LocalizedStrings(kTypeStrings, nTypes) ); - S.SetSizeHints(-1, -1); mFilterOrderCtl = S.Id(ID_Order) .Validator(&mOrderIndex) /*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/ + .MinSize( { -1, -1 } ) .AddChoice(_("O&rder:"), []{ wxArrayStringEx orders; @@ -476,7 +477,6 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) return orders; }() ); - S.SetSizeHints(-1, -1); S.AddSpace(1, 1); mRippleCtlP = S.AddVariableText(_("&Passband Ripple:"), false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); @@ -490,11 +490,11 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) mFilterSubTypeCtl = S.Id(ID_SubType) .Validator(&mFilterSubtype) + .MinSize( { -1, -1 } ) .AddChoice(_("&Subtype:"), LocalizedStrings(kSubTypeStrings, nSubTypes) ); - S.SetSizeHints(-1, -1); - + mCutoffCtl = S.Id(ID_Cutoff) .Name(XO("Cutoff (Hz)")) .Validator>( diff --git a/src/effects/ScoreAlignDialog.cpp b/src/effects/ScoreAlignDialog.cpp index 73fe8eaab..c7f866dc7 100644 --- a/src/effects/ScoreAlignDialog.cpp +++ b/src/effects/ScoreAlignDialog.cpp @@ -101,9 +101,9 @@ ScoreAlignDialog::ScoreAlignDialog(ScoreAlignParams ¶ms) mFramePeriodSlider = S.Id(ID_FRAMEPERIOD) .Name(XO("Frame Period")) .Style(wxSL_HORIZONTAL) + .MinSize( { 300, -1 } ) .AddSlider(wxT(""), /*pos*/ (int) (p.mFramePeriod * 100 + 0.5), /*max*/ 50, /*min*/ 5); - S.SetSizeHints(300, -1); mFramePeriodText = S.AddVariableText(SA_DFT_FRAME_PERIOD_TEXT, true, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index 4b0c22587..c86faf0d9 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -780,9 +780,10 @@ void EffectTruncSilence::PopulateOrExchange(ShuttleGui & S) { // Action choices auto actionChoices = LocalizedStrings(kActionStrings, nActions); - mActionChoice = S.Validator(&mActionIndex) + mActionChoice = S + .Validator(&mActionIndex) + .MinSize( { -1, -1 } ) .AddChoice( {}, actionChoices ); - S.SetSizeHints(-1, -1); } S.EndHorizontalLay(); S.StartMultiColumn(3, wxALIGN_CENTER_HORIZONTAL); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 95303273e..654d267cd 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -823,10 +823,10 @@ void VSTEffectOptionsDialog::PopulateOrExchange(ShuttleGui & S) wxTextCtrl *t; t = S.Validator>( &mBufferSize, NumValidatorStyle::DEFAULT, 8, 1048576 * 1) + .MinSize( { 100, -1 } ) .TieNumericTextBox(_("&Buffer Size (8 to 1048576 samples):"), mBufferSize, 12); - t->SetMinSize(wxSize(100, -1)); } S.EndHorizontalLay(); } diff --git a/src/effects/Wahwah.cpp b/src/effects/Wahwah.cpp index e8079610f..f03e2be96 100644 --- a/src/effects/Wahwah.cpp +++ b/src/effects/Wahwah.cpp @@ -248,8 +248,8 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S) mFreqS = S.Id(ID_Freq) .Name(XO("LFO frequency in hertz")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Freq * SCL_Freq, MAX_Freq * SCL_Freq, MIN_Freq * SCL_Freq); - mFreqS->SetMinSize(wxSize(100, -1)); mPhaseT = S.Id(ID_Phase) .Validator>( @@ -259,9 +259,9 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S) mPhaseS = S.Id(ID_Phase) .Name(XO("LFO start phase in degrees")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Phase * SCL_Phase, MAX_Phase * SCL_Phase, MIN_Phase * SCL_Phase); mPhaseS->SetLineSize(10); - mPhaseS->SetMinSize(wxSize(100, -1)); mDepthT = S.Id(ID_Depth) .Validator>( @@ -271,8 +271,8 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S) mDepthS = S.Id(ID_Depth) .Name(XO("Depth in percent")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth); - mDepthS->SetMinSize(wxSize(100, -1)); mResT = S.Id(ID_Res) .Validator>( @@ -282,8 +282,8 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S) mResS = S.Id(ID_Res) .Name(XO("Resonance")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_Res * SCL_Res, MAX_Res * SCL_Res, MIN_Res * SCL_Res); - mResS->SetMinSize(wxSize(100, -1)); mFreqOfsT = S.Id(ID_FreqOfs) .Validator>( @@ -293,8 +293,8 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S) mFreqOfsS = S.Id(ID_FreqOfs) .Name(XO("Wah frequency offset in percent")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_FreqOfs * SCL_FreqOfs, MAX_FreqOfs * SCL_FreqOfs, MIN_FreqOfs * SCL_FreqOfs); - mFreqOfsT->SetMinSize(wxSize(100, -1)); mOutGainT = S.Id(ID_OutGain) .Validator>( @@ -304,8 +304,8 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S) mOutGainS = S.Id(ID_OutGain) .Name(XO("Output gain (dB)")) .Style(wxSL_HORIZONTAL) + .MinSize( { 100, -1 } ) .AddSlider( {}, DEF_OutGain * SCL_OutGain, MAX_OutGain * SCL_OutGain, MIN_OutGain * SCL_OutGain); - mOutGainS->SetMinSize(wxSize(100, -1)); } S.EndMultiColumn(); } diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 07ea13865..6c7d148ce 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -2587,8 +2587,9 @@ void NyquistEffect::BuildPromptWindow(ShuttleGui & S) S.StartHorizontalLay(wxEXPAND, 1); { - mCommandText = S.Focus().AddTextWindow(wxT("")); - mCommandText->SetMinSize(wxSize(500, 200)); + mCommandText = S.Focus() + .MinSize( { 500, 200 } ) + .AddTextWindow(wxT("")); } S.EndHorizontalLay(); @@ -2735,8 +2736,8 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S) { S.Id(ID_Slider + i) .Style(wxSL_HORIZONTAL) + .MinSize( { 150, -1 } ) .AddSlider( {}, 0, ctrl.ticks, 0); - S.SetSizeHints(150, -1); } } diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index 95a380f85..b02b6315b 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -562,6 +562,7 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S) S.Id(ID_Program); mProgram = S.Name(XO("Program")) + .MinSize( { -1, -1 } ) .AddChoice( {}, [&]{ wxArrayStringEx choices; @@ -571,7 +572,6 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S) }(), wxString::FromUTF8(mPlugin->getCurrentProgram().c_str()) ); - mProgram->SetSizeHints(-1, -1); wxSizer *s = mProgram->GetContainingSizer(); s->GetItem(mProgram)->SetFlag(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL); @@ -638,8 +638,9 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S) S.Id(ID_Choices + p); mChoices[p] = S.ToolTip( TranslatableString{ tip } ) .Name( TranslatableString{ labelText } ) + .MinSize( { -1, -1 } ) .AddChoice( {}, choices, selected ); - mChoices[p]->SetSizeHints(-1, -1); + wxSizer *s = mChoices[p]->GetContainingSizer(); s->GetItem(mChoices[p])->SetFlag(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL); @@ -675,9 +676,9 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S) mSliders[p] = S.ToolTip( TranslatableString{ tip } ) .Name( TranslatableString{ labelText } ) .Style(wxSL_HORIZONTAL) + .MinSize( { 150, -1 } ) .AddSlider( {}, 0, 1000, 0); - mSliders[p]->SetSizeHints(150, -1); - + str = Internat::ToDisplayString(mParameters[p].maxValue); S.AddUnits(str); } diff --git a/src/export/ExportFFmpegDialogs.cpp b/src/export/ExportFFmpegDialogs.cpp index be2614aef..b12bcb03f 100644 --- a/src/export/ExportFFmpegDialogs.cpp +++ b/src/export/ExportFFmpegDialogs.cpp @@ -1611,8 +1611,8 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S) mProfileChoice = S.Id(FEProfileID) .ToolTip(XO("AAC Profile\nLow Complexity - default\nMost players won't play anything other than LC")) + .MinSize( { 100, -1 } ) .TieChoice(_("Profile:"), AACProfiles); - mProfileChoice->SetSizeHints( 100,-1); } S.EndMultiColumn(); } @@ -1635,13 +1635,13 @@ void ExportFFmpegOptions::PopulateOrExchange(ShuttleGui & S) mPredictionOrderMethodChoice = S.Id(FEPredOrderID) .ToolTip(XO("Prediction Order Method\nEstimate - fastest, lower compression\nLog search - slowest, best compression\nFull search - default")) + .MinSize( { 100, -1 } ) .TieNumberAsChoice( _("PdO Method:"), {wxT("/FileFormats/FFmpegPredOrderMethod"), 4}, // Full search PredictionOrderMethodNames ); - mPredictionOrderMethodChoice->SetSizeHints( 100,-1); mMinPredictionOrderSpin = S.Id(FEMinPredID) .ToolTip(XO("Minimal prediction order\nOptional\n-1 - default\nmin - 0\nmax - 32 (with LPC) or 4 (without LPC)")) diff --git a/src/prefs/DevicePrefs.cpp b/src/prefs/DevicePrefs.cpp index 58b513337..2883521ad 100644 --- a/src/prefs/DevicePrefs.cpp +++ b/src/prefs/DevicePrefs.cpp @@ -315,9 +315,8 @@ void DevicePrefs::OnHost(wxCommandEvent & e) } } - ShuttleGui S(this, eIsCreating); - S.SetSizeHints(mPlay, mPlay->GetStrings()); - S.SetSizeHints(mRecord, mRecord->GetStrings()); + ShuttleGui::SetMinSize(mPlay, mPlay->GetStrings()); + ShuttleGui::SetMinSize(mRecord, mRecord->GetStrings()); OnDevice(e); } @@ -381,8 +380,7 @@ void DevicePrefs::OnDevice(wxCommandEvent & WXUNUSED(event)) mChannels->SetSelection(0); } - ShuttleGui S(this, eIsCreating); - S.SetSizeHints(mChannels, channelnames); + ShuttleGui::SetMinSize(mChannels, channelnames); Layout(); } diff --git a/src/prefs/EffectsPrefs.cpp b/src/prefs/EffectsPrefs.cpp index f293b2842..eff25f371 100644 --- a/src/prefs/EffectsPrefs.cpp +++ b/src/prefs/EffectsPrefs.cpp @@ -199,8 +199,9 @@ void EffectsPrefs::PopulateOrExchange(ShuttleGui & S) { S.StartMultiColumn(2); { - wxChoice *c = S.TieChoice( _("S&ort or Group:"), EffectsGroupBy); - if( c ) c->SetMinSize(c->GetBestSize()); + wxChoice *c = S + .MinSize() + .TieChoice( _("S&ort or Group:"), EffectsGroupBy); S.TieIntegerTextBox(_("&Maximum effects per group (0 to disable):"), {wxT("/Effects/MaxPerGroup"), diff --git a/src/prefs/MidiIOPrefs.cpp b/src/prefs/MidiIOPrefs.cpp index d97e8413d..d7c4a19ef 100644 --- a/src/prefs/MidiIOPrefs.cpp +++ b/src/prefs/MidiIOPrefs.cpp @@ -256,10 +256,9 @@ void MidiIOPrefs::OnHost(wxCommandEvent & WXUNUSED(e)) mRecord->SetSelection(0); } #endif - ShuttleGui S(this, eIsCreating); - S.SetSizeHints(mPlay, playnames); + ShuttleGui::SetMinSize(mPlay, playnames); #ifdef EXPERIMENTAL_MIDI_IN - S.SetSizeHints(mRecord, recordnames); + ShuttleGui::SetMinSize(mRecord, recordnames); #endif // OnDevice(e); }