diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index 3399e3405..69176b8b6 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -238,9 +238,10 @@ AboutDialog::AboutDialog(wxWindow * parent) PopulateLicensePage( S ); } S.EndNotebook(); - wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK, _("OK")); - ok->SetDefault(); - S.Prop(0).AddWindow( ok ); + + S.Id(wxID_OK) + .Prop(0) + .AddButton(_("OK"), wxALIGN_CENTER, true); Fit(); this->Centre(); diff --git a/src/AutoRecoveryDialog.cpp b/src/AutoRecoveryDialog.cpp index 2aaab046e..762e5b551 100644 --- a/src/AutoRecoveryDialog.cpp +++ b/src/AutoRecoveryDialog.cpp @@ -72,10 +72,9 @@ void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S) S.StartStatic(_("Recoverable projects")); { - mFileList = S.Id(ID_FILE_LIST).AddListControlReportMode(); - /*i18n-hint: (noun). It's the name of the project to recover.*/ - mFileList->InsertColumn(0, _("Name")); - mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE); + mFileList = S.Id(ID_FILE_LIST) + /*i18n-hint: (noun). It's the name of the project to recover.*/ + .AddListControlReportMode( { _("Name") } ); PopulateList(); } S.EndStatic(); diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp index 53bc81611..42ce5254b 100644 --- a/src/BatchProcessDialog.cpp +++ b/src/BatchProcessDialog.cpp @@ -137,8 +137,8 @@ void ApplyMacroDialog::PopulateOrExchange(ShuttleGui &S) { S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL); - mMacros = S.Id(MacrosListID).Prop(1).AddListControlReportMode(); - mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT); + mMacros = S.Id(MacrosListID).Prop(1) + .AddListControlReportMode( { _("Macro") } ); } S.EndStatic(); @@ -410,10 +410,10 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event)) S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL); - fileList = S.Id(CommandsListID).AddListControlReportMode(); + fileList = S.Id(CommandsListID) + .AddListControlReportMode( { _("File") } ); // AssignImageList takes ownership fileList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL); - fileList->InsertColumn(0, _("File"), wxLIST_FORMAT_LEFT); } S.EndStatic(); @@ -618,9 +618,9 @@ void MacrosWindow::PopulateOrExchange(ShuttleGui & S) { S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_SINGLE_SEL | wxLC_EDIT_LABELS); - mMacros = S.Id(MacrosListID).Prop(1).AddListControlReportMode(); - // i18n-hint: This is the heading for a column in the edit macros dialog - mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT); + mMacros = S.Id(MacrosListID).Prop(1) + // i18n-hint: This is the heading for a column in the edit macros dialog + .AddListControlReportMode( { _("Macro") } ); S.StartVerticalLay(wxALIGN_TOP, 0); { S.Id(AddButtonID).AddButton(_("&New")); @@ -646,16 +646,13 @@ void MacrosWindow::PopulateOrExchange(ShuttleGui & S) S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL); - mList = S.Id(CommandsListID).AddListControlReportMode(); - - //A dummy first column, which is then deleted, is a workaround - under Windows the first column - //can't be right aligned. - mList->InsertColumn(0, wxT(""), wxLIST_FORMAT_LEFT); - /* i18n-hint: This is the number of the command in the list */ - mList->InsertColumn(ItemNumberColumn + 1, _("Num"), wxLIST_FORMAT_RIGHT); - mList->InsertColumn(ActionColumn + 1, _("Command "), wxLIST_FORMAT_RIGHT); - mList->InsertColumn(ParamsColumn + 1, _("Parameters"), wxLIST_FORMAT_LEFT); - mList->DeleteColumn(0); + mList = S.Id(CommandsListID) + .AddListControlReportMode({ + /* i18n-hint: This is the number of the command in the list */ + { _("Num"), wxLIST_FORMAT_RIGHT }, + { _("Command "), wxLIST_FORMAT_RIGHT }, + { _("Parameters"), wxLIST_FORMAT_LEFT } + }); S.StartVerticalLay(wxALIGN_TOP, 0); { diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp index e33552db8..e25a43d9b 100644 --- a/src/Benchmark.cpp +++ b/src/Benchmark.cpp @@ -225,7 +225,7 @@ void BenchmarkDialog::MakeBenchmarkDialog() { S.StartHorizontalLay(wxALIGN_LEFT, false); { - S.Id(RunID).AddButton(_("Run"))->SetDefault(); + S.Id(RunID).AddButton(_("Run"), wxALIGN_CENTRE, true); S.Id(BSaveID).AddButton(_("Save")); /* i18n-hint verb; to empty or erase */ S.Id(ClearID).AddButton(_("Clear")); diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index b1f2e1319..3cf0417b3 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -356,20 +356,19 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S) S.StartStatic(_("Project Dependencies"),1); { - mFileListCtrl = S.Id(FileListID).AddListControlReportMode(); - mFileListCtrl->InsertColumn(0, _("Audio File")); - mFileListCtrl->SetColumnWidth(0, 220); - mFileListCtrl->InsertColumn(1, _("Disk Space")); - mFileListCtrl->SetColumnWidth(1, 120); + mFileListCtrl = S.Id(FileListID).AddListControlReportMode({ + { _("Audio File"), wxLIST_FORMAT_LEFT, 220 }, + { _("Disk Space"), wxLIST_FORMAT_LEFT, 120 } + }); PopulateList(); mCopySelectedFilesButton = - S.Id(CopySelectedFilesButtonID).AddButton( - _("Copy Selected Files"), - wxALIGN_LEFT); + S.Id(CopySelectedFilesButtonID) + .AddButton( + _("Copy Selected Files"), + wxALIGN_LEFT, true); mCopySelectedFilesButton->Enable( mFileListCtrl->GetSelectedItemCount() > 0); - mCopySelectedFilesButton->SetDefault(); mCopySelectedFilesButton->SetFocus(); } S.EndStatic(); @@ -396,22 +395,22 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S) { S.StartHorizontalLay(wxALIGN_LEFT,0); { - wxArrayStringEx choices{ - /*i18n-hint: One of the choices of what you want Audacity to do when - * Audacity finds a project depends on another file.*/ - _("Ask me") , - _("Always copy all files (safest)") , - _("Never copy any files") , - }; mFutureActionChoice = S.Id(FutureActionChoiceID).AddChoice( _("Whenever a project depends on other files:"), - choices, + { + /*i18n-hint: One of the choices of what you want Audacity to do when + * Audacity finds a project depends on another file.*/ + _("Ask me") , + _("Always copy all files (safest)") , + _("Never copy any files") , + }, 0 // "Ask me" ); } S.EndHorizontalLay(); - } else + } + else { mFutureActionChoice = NULL; } diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index 6de1e8676..9154f6e84 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -465,19 +465,17 @@ public: void PopulateOrExchange(ShuttleGui & S) { - wxString text; - S.SetBorder(10); S.StartVerticalLay(true); { - text.Printf(_("Audacity needs the file '%s' to import and export audio via FFmpeg."), mName); - S.AddTitle(text); + S.AddTitle( wxString::Format( + _("Audacity needs the file '%s' to import and export audio via FFmpeg."), + mName)); S.SetBorder(3); S.StartHorizontalLay(wxALIGN_LEFT, true); { - text.Printf(_("Location of '%s':"), mName); - S.AddTitle(text); + S.AddTitle( wxString::Format(_("Location of '%s':"), mName) ); } S.EndHorizontalLay(); @@ -485,8 +483,8 @@ public: S.SetStretchyCol(0); { if (mLibPath.GetFullPath().empty()) { - text.Printf(_("To find '%s', click here -->"), mName); - mPathText = S.AddTextBox( {}, text, 0); + mPathText = S.AddTextBox( {}, + wxString::Format(_("To find '%s', click here -->"), mName), 0); } else { mPathText = S.AddTextBox( {}, mLibPath.GetFullPath(), 0); @@ -586,9 +584,9 @@ To use FFmpeg import, go to Edit > Preferences > Libraries\n\ to download or locate the FFmpeg libraries." )); - int dontShowDlg = 0; - gPrefs->Read(wxT("/FFmpeg/NotFoundDontShow"),&dontShowDlg,0); - mDontShow = S.AddCheckBox(_("Do not show this warning again"),dontShowDlg); + mDontShow = S + .AddCheckBox(_("Do not show this warning again"), + gPrefs->ReadBool(wxT("/FFmpeg/NotFoundDontShow"), false) ); S.AddStandardButtons(eOkButton); } diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 92e71040b..051007f0e 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -83,12 +83,12 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): { S.StartStatic(_("&Manage History"), 1); { - mList = S.AddListControlReportMode(); - // Do this BEFORE inserting the columns. On the Mac at least, the - // columns are deleted and later InsertItem()s will cause Audacity to crash. - mList->SetSingleStyle(wxLC_SINGLE_SEL); - mList->InsertColumn(0, _("Action"), wxLIST_FORMAT_LEFT, 260); - mList->InsertColumn(1, _("Reclaimable Space"), wxLIST_FORMAT_LEFT, 125); + mList = S + .AddListControlReportMode( + { { _("Action"), wxLIST_FORMAT_LEFT, 260 }, + { _("Reclaimable Space"), wxLIST_FORMAT_LEFT, 125 } }, + wxLC_SINGLE_SEL + ); //Assign rather than set the image list, so that it is deleted later. // AssignImageList takes ownership @@ -135,7 +135,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): S.StartHorizontalLay(wxALIGN_RIGHT, false); { S.SetBorder(10); - S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault(); + S.Id(wxID_OK).AddButton(_("&OK"), wxALIGN_CENTER, true); } S.EndHorizontalLay(); } diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 238677b2b..d4a9ad6f8 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -565,16 +565,14 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S) S.EndHorizontalLay(); S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES ); - mEffects = S.Id(ID_List).AddListControlReportMode(); + mEffects = S.Id(ID_List) + .AddListControlReportMode({ _("Name"), _("State"), _("Path") }); mEffects->Bind(wxEVT_KEY_DOWN, &PluginRegistrationDialog::OnListChar, this); #if wxUSE_ACCESSIBILITY mEffects->SetAccessible(mAx = safenew CheckListAx(mEffects)); #endif - mEffects->InsertColumn(COL_Name, _("Name")); - mEffects->InsertColumn(COL_State, _("State")); - mEffects->InsertColumn(COL_Path, _("Path")); S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, 0); { @@ -671,7 +669,8 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S) // Keep dialog from getting too wide int w = r.GetWidth() - (GetClientSize().GetWidth() - mEffects->GetSize().GetWidth()); - mEffects->SetSizeHints(wxSize(wxMin(maxW, w), 200), wxSize(w, -1)); + mEffects->SetMinSize({ std::min(maxW, w), 200 }); + mEffects->SetMaxSize({ w, -1 }); RegenerateEffectsList(ID_ShowAll); diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index 012982303..b3aaac77e 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -326,12 +326,12 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S) { S.SetStretchyCol(1); - wxString dir = - gPrefs->Read(wxT("/ScreenshotPath"), - wxFileName::GetHomeDir()); mDirectoryTextBox = - S.Id(IdDirectory).AddTextBox(_("Save images to:"), - dir, 30); + S.Id(IdDirectory).AddTextBox( + _("Save images to:"), + gPrefs->Read(wxT("/ScreenshotPath"), wxFileName::GetHomeDir()), + 30 + ); S.Id(IdDirChoose).AddButton(_("Choose...")); } S.EndMultiColumn(); diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index 8729151e4..3b955ba0f 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -120,12 +120,12 @@ for registering for changes. #endif ShuttleGuiBase::ShuttleGuiBase(wxWindow * pParent, teShuttleMode ShuttleMode ) + : mpDlg{ pParent } { wxASSERT( (pParent != NULL ) || ( ShuttleMode != eIsCreating)); mpbOptionalFlag = nullptr; mpParent = pParent; mShuttleMode = ShuttleMode; - mpDlg = pParent; Init(); } @@ -348,7 +348,8 @@ wxCheckBox * ShuttleGuiBase::AddCheckBoxOnRight( const wxString &Prompt, bool Se return pCheckBox; } -wxButton * ShuttleGuiBase::AddButton(const wxString &Text, int PositionFlags) +wxButton * ShuttleGuiBase::AddButton( + const wxString &Text, int PositionFlags, bool setDefault) { UseUpId(); if( mShuttleMode != eIsCreating ) @@ -359,10 +360,13 @@ wxButton * ShuttleGuiBase::AddButton(const wxString &Text, int PositionFlags) mpWind->SetName(wxStripMenuCodes(Text)); miProp=0; UpdateSizersCore(false, PositionFlags | wxALL); + if (setDefault) + pBtn->SetDefault(); return pBtn; } -wxBitmapButton * ShuttleGuiBase::AddBitmapButton(const wxBitmap &Bitmap, int PositionFlags) +wxBitmapButton * ShuttleGuiBase::AddBitmapButton( + const wxBitmap &Bitmap, int PositionFlags, bool setDefault) { UseUpId(); if( mShuttleMode != eIsCreating ) @@ -375,6 +379,8 @@ wxBitmapButton * ShuttleGuiBase::AddBitmapButton(const wxBitmap &Bitmap, int Pos // wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); miProp=0; UpdateSizersCore(false, PositionFlags | wxALL); + if (setDefault) + pBtn->SetDefault(); return pBtn; } @@ -397,7 +403,7 @@ wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt, choices, Style( 0 ) ); - pChoice->SetSizeHints( 180,-1);// Use -1 for 'default size' - Platform specific. + pChoice->SetMinSize( { 180, -1 } );// Use -1 for 'default size' - Platform specific. #ifdef __WXMAC__ #if wxUSE_ACCESSIBILITY // so that name can be set on a standard control @@ -412,6 +418,12 @@ wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt, return pChoice; } +wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt, + const wxArrayStringEx &choices, const wxString &Selected ) +{ + return AddChoice( Prompt, choices, choices.Index( Selected ) ); +} + void ShuttleGuiBase::AddFixedText(const wxString &Str, bool bCenter) { UseUpId(); @@ -484,7 +496,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. @@ -498,17 +510,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__ @@ -684,20 +699,6 @@ wxListBox * ShuttleGuiBase::AddListBox(const wxArrayStringEx &choices, long styl } -wxListCtrl * ShuttleGuiBase::AddListControl() -{ - UseUpId(); - if( mShuttleMode != eIsCreating ) - return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxListCtrl); - wxListCtrl * pListCtrl; - SetProportions( 1 ); - mpWind = pListCtrl = safenew wxListCtrl(GetParent(), miId, - wxDefaultPosition, wxDefaultSize, Style( wxLC_ICON )); - pListCtrl->SetMinSize( wxSize( 120,150 )); - UpdateSizers(); - return pListCtrl; -} - wxGrid * ShuttleGuiBase::AddGrid() { UseUpId(); @@ -712,7 +713,30 @@ wxGrid * ShuttleGuiBase::AddGrid() return pGrid; } -wxListCtrl * ShuttleGuiBase::AddListControlReportMode() +wxListCtrl * ShuttleGuiBase::AddListControl( + std::initializer_list columns, + long listControlStyles +) +{ + UseUpId(); + if( mShuttleMode != eIsCreating ) + return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxListCtrl); + wxListCtrl * pListCtrl; + SetProportions( 1 ); + mpWind = pListCtrl = safenew wxListCtrl(GetParent(), miId, + wxDefaultPosition, wxDefaultSize, Style( wxLC_ICON )); + pListCtrl->SetMinSize( wxSize( 120,150 )); + UpdateSizers(); + + DoInsertListColumns( pListCtrl, listControlStyles, columns ); + + return pListCtrl; +} + +wxListCtrl * ShuttleGuiBase::AddListControlReportMode( + std::initializer_list columns, + long listControlStyles +) { UseUpId(); if( mShuttleMode != eIsCreating ) @@ -724,9 +748,43 @@ wxListCtrl * ShuttleGuiBase::AddListControlReportMode() Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxSUNKEN_BORDER )); // pListCtrl->SetMinSize( wxSize( 120,150 )); UpdateSizers(); + + DoInsertListColumns( pListCtrl, listControlStyles, columns ); + return pListCtrl; } +void ShuttleGuiBase::DoInsertListColumns( + wxListCtrl *pListCtrl, + long listControlStyles, + std::initializer_list columns ) +{ + // Old comment from HistoryWindow.cpp follows + // -- is it still correct for wxWidgets 3? + + // Do this BEFORE inserting the columns. On the Mac at least, the + // columns are deleted and later InsertItem()s will cause Audacity to crash. + for ( auto style = 1l; style <= listControlStyles; style <<= 1 ) + if ( (style & listControlStyles) ) + pListCtrl->SetSingleStyle(style, true); + + long iCol = 0; + bool dummyColumn = + columns.size() > 0 && begin(columns)->format == wxLIST_FORMAT_RIGHT; + + //A dummy first column, which is then deleted, is a workaround - + // under Windows the first column can't be right aligned. + if (dummyColumn) + pListCtrl->InsertColumn( iCol++, wxString{} ); + + for (auto &column : columns) + pListCtrl->InsertColumn( + iCol++, column.heading, column.format, column.width ); + + if (dummyColumn) + pListCtrl->DeleteColumn( 0 ); +} + wxTreeCtrl * ShuttleGuiBase::AddTree() { UseUpId(); @@ -947,11 +1005,11 @@ wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name ) pNotebook->AddPage( pPage, Name); - PushSizer(); SetProportions( 1 ); mpParent = pPage; pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL)); + PushSizer(); mpSizer->SetMinSize(250, 500); // UpdateSizers(); return pPage; @@ -970,11 +1028,11 @@ void ShuttleGuiBase::StartNotebookPage( const wxString & Name, wxNotebookPage * pNotebook->AddPage( pPage, Name); - PushSizer(); SetProportions( 1 ); mpParent = pPage; pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL)); + PushSizer(); mpSizer->SetMinSize(250, 500); // UpdateSizers(); } @@ -1061,6 +1119,7 @@ void ShuttleGuiBase::StartHorizontalLay( int PositionFlags, int iProp) return; miSizerProp=iProp; mpSubSizer = std::make_unique( wxHORIZONTAL ); + // PRL: wxALL has no effect because UpdateSizersCore ignores border UpdateSizersCore( false, PositionFlags | wxALL ); } @@ -1086,6 +1145,7 @@ void ShuttleGuiBase::StartVerticalLay(int PositionFlags, int iProp) return; miSizerProp=iProp; mpSubSizer = std::make_unique( wxVERTICAL ); + // PRL: wxALL has no effect because UpdateSizersCore ignores border UpdateSizersCore( false, PositionFlags | wxALL ); } @@ -1101,6 +1161,7 @@ void ShuttleGuiBase::StartMultiColumn(int nCols, int PositionFlags) if( mShuttleMode != eIsCreating ) return; mpSubSizer = std::make_unique( nCols ); + // PRL: wxALL has no effect because UpdateSizersCore ignores border UpdateSizersCore( false, PositionFlags | wxALL ); } @@ -1924,7 +1985,8 @@ wxChoice * ShuttleGuiBase::TieNumberAsChoice( const wxString &Prompt, const SettingSpec< int > &Setting, const wxArrayStringEx & Choices, - const std::vector * pInternalChoices) + const std::vector * pInternalChoices, + int iNoMatchSelector) { auto fn = [](int arg){ return wxString::Format( "%d", arg ); }; @@ -1936,7 +1998,11 @@ wxChoice * ShuttleGuiBase::TieNumberAsChoice( for ( int ii = 0; ii < Choices.size(); ++ii ) InternalChoices.push_back( fn( ii ) ); + const auto Default = Setting.GetDefault(); + + miNoMatchSelector = iNoMatchSelector; + long defaultIndex; if ( pInternalChoices ) defaultIndex = make_iterator_range( *pInternalChoices ).index( Default ); @@ -2342,7 +2408,7 @@ void ShuttleGuiBase::SetSizeHints( wxWindow *window, const wxArrayStringEx & ite maxw += 50; #endif - window->SetSizeHints( maxw, -1 ); + window->SetMinSize( { maxw, -1 } ); } void ShuttleGuiBase::SetSizeHints( const wxArrayStringEx & items ) diff --git a/src/ShuttleGui.h b/src/ShuttleGui.h index b70b463da..b21b2b0b3 100644 --- a/src/ShuttleGui.h +++ b/src/ShuttleGui.h @@ -20,6 +20,7 @@ #include #include // to inherit #include "MemoryX.h" +#include // for wxLIST_FORMAT_LEFT #include "WrappedType.h" @@ -131,27 +132,66 @@ public: void AddPrompt(const wxString &Prompt); void AddUnits(const wxString &Prompt); void AddTitle(const wxString &Prompt); + // Applies wxALL (which affects borders) only when in Flags: wxWindow * AddWindow(wxWindow * pWindow, int Flags = wxALIGN_CENTRE | wxALL ); wxSlider * AddSlider(const wxString &Prompt, int pos, int Max, int Min = 0); 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); - wxButton * AddButton( const wxString & Text, int PositionFlags = wxALIGN_CENTRE ); - wxBitmapButton * AddBitmapButton(const wxBitmap &Bitmap, int PositionFlags = wxALIGN_CENTRE); + + // 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( + const wxString & Text, int PositionFlags = wxALIGN_CENTRE, + bool setDefault = false ); + // Only the last button specified as default (if more than one) will be + // Always ORs the flags with wxALL (which affects borders): + wxBitmapButton * AddBitmapButton( + const wxBitmap &Bitmap, int PositionFlags = wxALIGN_CENTRE, + bool setDefault = false ); + // When PositionFlags is 0, applies wxALL (which affects borders), + // and either wxALIGN_CENTER (if bCenter) or else wxEXPAND wxStaticText * AddVariableText(const wxString &Str, bool bCenter = false, int PositionFlags = 0); wxTextCtrl * AddTextBox(const wxString &Caption, const wxString &Value, const int nChars); wxTextCtrl * AddNumericTextBox(const wxString &Caption, const wxString &Value, const int nChars); wxTextCtrl * AddTextWindow(const wxString &Value); wxListBox * AddListBox(const wxArrayStringEx &choices, long style = 0); - wxListCtrl * AddListControl(); - wxListCtrl * AddListControlReportMode(); + + struct ListControlColumn{ + ListControlColumn( + wxString h, int f = wxLIST_FORMAT_LEFT, int w = wxLIST_AUTOSIZE) + : heading(h), format(f), width(w) + {} + + wxString heading; + int format; + int width; + }; + wxListCtrl * AddListControl( + std::initializer_list columns = {}, + long listControlStyles = 0 + ); + wxListCtrl * AddListControlReportMode( + std::initializer_list columns = {}, + long listControlStyles = 0 + ); + wxGrid * AddGrid(); wxCheckBox * AddCheckBox( const wxString &Prompt, bool Selected); wxCheckBox * AddCheckBoxOnRight( const wxString &Prompt, bool Selected); wxComboBox * AddCombo( const wxString &Prompt, const wxString &Selected,const wxArrayStringEx & choices, long style = 0 ); - wxChoice * AddChoice( const wxString &Prompt, const wxArrayStringEx &choices, int Selected = -1 ); + wxChoice * AddChoice( const wxString &Prompt, + const wxArrayStringEx &choices, int Selected = -1 ); + wxChoice * AddChoice( const wxString &Prompt, + const wxArrayStringEx &choices, const wxString &selected ); wxMenuBar * AddMenuBar( ); wxMenu * AddMenu( const wxString & Title ); void AddIcon( wxBitmap * pBmp); @@ -184,12 +224,16 @@ public: wxNotebook * StartNotebook(); void EndNotebook(); + + // IDs of notebook pages cannot be chosen by the caller wxNotebookPage * StartNotebookPage( const wxString & Name ); void StartNotebookPage( const wxString & Name, wxNotebookPage * pPage ); + void EndNotebookPage(); wxPanel * StartInvisiblePanel(); void EndInvisiblePanel(); + // SettingName is a key in Preferences. void StartRadioButtonGroup( const ChoiceSetting &Setting ); void EndRadioButtonGroup(); @@ -248,7 +292,8 @@ public: const wxString &Prompt, const SettingSpec< int > &Setting, const wxArrayStringEx & Choices, - const std::vector * pInternalChoices = nullptr ); + const std::vector * pInternalChoices = nullptr, + int iNoMatchSelector = 0 ); virtual wxTextCtrl * TieTextBox( const wxString &Prompt, @@ -277,7 +322,6 @@ public: void SetSizeHints( int minX, int minY ); void SetBorder( int Border ) {miBorder = Border;}; void SetStyle( int Style ) {miStyle = Style;}; - void SetNoMatchSelector( int iSelector ) {miNoMatchSelector = iSelector;}; void SetSizerProportion( int iProp ) {miSizerProp = iProp;}; void SetStretchyCol( int i ); void SetStretchyRow( int i ); @@ -309,12 +353,18 @@ protected: 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 * mpDlg; + wxWindow *const mpDlg; wxSizer * pSizerStack[ nMaxNestedSizers ]; std::unique_ptr mpShuttle; /*! Controls source/destination of shuttled data. You can @@ -360,7 +410,8 @@ private: Maybe 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 @@ -420,7 +471,12 @@ public: ShuttleGui & Prop( int iProp ){ ShuttleGuiBase::Prop(iProp); return *this;}; // Has to be here too, to return a ShuttleGui and not a ShuttleGuiBase. GuiWaveTrack * AddGuiWaveTrack( const wxString & Name); AttachableScrollBar * AddAttachableScrollBar( long style = wxSB_HORIZONTAL ); - void AddStandardButtons( long buttons = eOkButton | eCancelButton, wxButton *extra = NULL ); + + // The first of these buttons, if any, that is included will be default: + // Apply, Yes, OK + void AddStandardButtons( + long buttons = eOkButton | eCancelButton, wxButton *extra = NULL ); + wxSizerItem * AddSpace( int width, int height ); wxSizerItem * AddSpace( int size ) { return AddSpace( size, size ); }; diff --git a/src/SoundActivatedRecord.cpp b/src/SoundActivatedRecord.cpp index fb2e1f050..6e4276e8d 100644 --- a/src/SoundActivatedRecord.cpp +++ b/src/SoundActivatedRecord.cpp @@ -53,9 +53,12 @@ void SoundActivatedRecord::PopulateOrExchange(ShuttleGui & S) S.StartVerticalLay(); { S.StartMultiColumn(2, wxEXPAND); - S.SetStretchyCol(1); - dBRange = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE); - S.TieSlider(_("Activation level (dB):"), {wxT("/AudioIO/SilenceLevel"), -50}, 0, -dBRange); + S.SetStretchyCol(1); + S.TieSlider( + _("Activation level (dB):"), + {wxT("/AudioIO/SilenceLevel"), -50}, + 0, -gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE) + ); S.EndMultiColumn(); } S.EndVerticalLay(); diff --git a/src/SplashDialog.cpp b/src/SplashDialog.cpp index 278d9e5a1..50a2a498f 100644 --- a/src/SplashDialog.cpp +++ b/src/SplashDialog.cpp @@ -140,10 +140,11 @@ void SplashDialog::Populate( ShuttleGui & S ) { S.SetBorder( 5 ); S.Id( DontShowID).AddCheckBox( _("Don't show this again at start up"), !bShow ); - wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK); - ok->SetDefault(); S.SetBorder( 5 ); - S.Prop(0).AddWindow( ok, wxALIGN_RIGHT| wxALL ); + + S.Id(wxID_OK) + .Prop(0) + .AddButton(_("OK"), wxALIGN_RIGHT| wxALL, true); } S.EndVerticalLay(); } diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 084be2378..db78dddfe 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -809,6 +809,12 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) int iPostTimerRecordAction = gPrefs->ReadLong("/TimerRecord/PostAction", 0); S.SetBorder(5); + using Options = NumericTextCtrl::Options; + /* i18n-hint a format string for hours, minutes, and seconds */ + auto strFormat = _("099 h 060 m 060 s"); + /* i18n-hint a format string for days, hours, minutes, and seconds */ + auto strFormat1 = _("099 days 024 h 060 m 060 s"); + S.StartMultiColumn(2, wxCENTER); { S.StartVerticalLay(true); @@ -819,8 +825,6 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) * The 'h' indicates the first number displayed is hours, the 'm' indicates the second number * displayed is minutes, and the 's' indicates that the third number displayed is seconds. */ - auto strFormat = _("099 h 060 m 060 s"); - using Options = NumericTextCtrl::Options; S.StartStatic(_("Start Date and Time"), true); { m_pDatePickerCtrl_Start = @@ -886,7 +890,6 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) * number displayed is minutes, and the 's' indicates that the fourth number displayed is * seconds. */ - auto strFormat1 = _("099 days 024 h 060 m 060 s"); m_pTimeTextCtrl_Duration = safenew NumericTextCtrl( S.GetParent(), ID_TIMETEXT_DURATION, NumericConverter::TIME, {}, 0, 44100, @@ -950,23 +953,17 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) S.StartMultiColumn(1, wxEXPAND); { S.SetStretchyCol( 0 ); - wxArrayStringEx arrayOptions{ - _("Do nothing") , - _("Exit Audacity") , - _("Restart system") , - _("Shutdown system") , - }; - - m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[0]); - m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[1]); -#ifdef __WINDOWS__ - m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[2]); - m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[3]); -#endif - m_pTimerAfterCompleteChoiceCtrl = S.AddChoice(_("After Recording completes:"), - m_sTimerAfterCompleteOptionsArray, - iPostTimerRecordAction); + { + _("Do nothing") , + _("Exit Audacity") , + #ifdef __WINDOWS__ + _("Restart system") , + _("Shutdown system") , + #endif + }, + iPostTimerRecordAction + ); } S.EndMultiColumn(); } diff --git a/src/TimerRecordDialog.h b/src/TimerRecordDialog.h index ea55ba144..5495fa303 100644 --- a/src/TimerRecordDialog.h +++ b/src/TimerRecordDialog.h @@ -146,9 +146,6 @@ private: int m_iAutoExportFilterIndex; bool m_bProjectAlreadySaved; - // Variables for After Timer Recording Option - wxArrayStringEx m_sTimerAfterCompleteOptionsArray; - DECLARE_EVENT_TABLE() }; diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index b20fa1668..60fd17842 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -209,7 +209,7 @@ public: const wxString &Prompt, const SettingSpec< int > &Setting, const wxArrayStringEx & Choices, - const std::vector * pInternalChoices) override; + const std::vector * pInternalChoices, int iNoMatchSelector ) override; wxTextCtrl * TieTextBox( const wxString &Prompt, @@ -274,7 +274,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice( const wxString &Prompt, const SettingSpec< int > &Setting, const wxArrayStringEx & Choices, - const std::vector * pInternalChoices) + const std::vector * pInternalChoices, int iNoMatchSelector) { // Come here for controls that present non-exhaustive choices among some // numbers, with an associated control that allows arbitrary entry of an @@ -286,7 +286,7 @@ wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice( AddItem( Setting.GetDefault(), "default" ); EndStruct(); return ShuttleGui::TieNumberAsChoice( - Prompt, Setting, Choices, pInternalChoices ); + Prompt, Setting, Choices, pInternalChoices, iNoMatchSelector ); } wxTextCtrl * ShuttleGuiGetDefinition::TieTextBox( const wxString &Prompt, diff --git a/src/effects/Amplify.cpp b/src/effects/Amplify.cpp index 0289023e6..946c20d64 100644 --- a/src/effects/Amplify.cpp +++ b/src/effects/Amplify.cpp @@ -207,6 +207,8 @@ void EffectAmplify::Preview(bool dryOnly) void EffectAmplify::PopulateOrExchange(ShuttleGui & S) { + enum{ precision = 3 }; // allow (a generous) 3 decimal places for Amplification (dB) + if (IsBatchProcessing()) { mPeak = 1.0; @@ -228,11 +230,10 @@ void EffectAmplify::PopulateOrExchange(ShuttleGui & S) S.StartVerticalLay(0); { - int precission = 3; // allow (a generous) 3 decimal places for Amplification (dB) // Amplitude S.StartMultiColumn(2, wxCENTER); { - FloatingPointValidator vldAmp(precission, &mAmp, NumValidatorStyle::ONE_TRAILING_ZERO); + FloatingPointValidator vldAmp(precision, &mAmp, NumValidatorStyle::ONE_TRAILING_ZERO); vldAmp.SetRange(MIN_Amp, MAX_Amp); mAmpT = S.Id(ID_Amp).AddTextBox(_("Amplification (dB):"), wxT(""), 12); mAmpT->SetValidator(vldAmp); @@ -252,13 +253,13 @@ void EffectAmplify::PopulateOrExchange(ShuttleGui & S) S.StartMultiColumn(2, wxCENTER); { // One extra decimal place so that rounding is visible to user (see: bug 958) - FloatingPointValidator vldNewPeak(precission + 1, &mNewPeak, NumValidatorStyle::ONE_TRAILING_ZERO); + FloatingPointValidator vldNewPeak(precision + 1, &mNewPeak, NumValidatorStyle::ONE_TRAILING_ZERO); double minAmp = MIN_Amp + LINEAR_TO_DB(mPeak); double maxAmp = MAX_Amp + LINEAR_TO_DB(mPeak); // min and max need same precision as what we're validating (bug 963) - minAmp = Internat::CompatibleToDouble(Internat::ToString(minAmp, precission +1)); - maxAmp = Internat::CompatibleToDouble(Internat::ToString(maxAmp, precission +1)); + minAmp = Internat::CompatibleToDouble(Internat::ToString(minAmp, precision +1)); + maxAmp = Internat::CompatibleToDouble(Internat::ToString(maxAmp, precision +1)); vldNewPeak.SetRange(minAmp, maxAmp); mNewPeakT = S.Id(ID_Peak).AddTextBox(_("New Peak Amplitude (dB):"), wxT(""), 12); diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index bffacd9b4..e3dd17b3e 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -296,6 +296,21 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) } GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, mFromVinyl); + wxASSERT(nVinyl == WXSIZEOF(kVinylStrings)); + + wxArrayStringEx vinylChoices; + for (int i = 0; i < nVinyl; i++) + { + if (i == kVinyl_NA) + { + vinylChoices.push_back(wxGetTranslation(kVinylStrings[i])); + } + else + { + vinylChoices.push_back(kVinylStrings[i]); + } + } + S.SetBorder(5); S.StartVerticalLay(0); @@ -337,23 +352,9 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute". */ S.AddUnits(_("Standard Vinyl rpm:")); - wxASSERT(nVinyl == WXSIZEOF(kVinylStrings)); - - wxArrayStringEx vinylChoices; - for (int i = 0; i < nVinyl; i++) - { - if (i == kVinyl_NA) - { - vinylChoices.push_back(wxGetTranslation(kVinylStrings[i])); - } - else - { - vinylChoices.push_back(kVinylStrings[i]); - } - } - - mpChoice_FromVinyl = - S.Id(ID_FromVinyl).AddChoice(_("from"), vinylChoices); + mpChoice_FromVinyl = S.Id(ID_FromVinyl) + /* i18n-hint: changing a quantity "from" one value "to" another */ + .AddChoice(_("from"), vinylChoices); mpChoice_FromVinyl->SetName(_("From rpm")); mpChoice_FromVinyl->SetSizeHints(100, -1); diff --git a/src/effects/ChangeTempo.cpp b/src/effects/ChangeTempo.cpp index c6daa34cb..2f8e42713 100644 --- a/src/effects/ChangeTempo.cpp +++ b/src/effects/ChangeTempo.cpp @@ -221,6 +221,8 @@ bool EffectChangeTempo::Process() void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S) { + enum { precision = 2 }; + S.StartVerticalLay(0); { S.AddSpace(0, 5); @@ -273,8 +275,7 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S) { S.StartHorizontalLay(wxALIGN_CENTER); { - int precission = 2; - FloatingPointValidator vldFromLength(precission, &m_FromLength, NumValidatorStyle::TWO_TRAILING_ZEROES); + FloatingPointValidator vldFromLength(precision, &m_FromLength, NumValidatorStyle::TWO_TRAILING_ZEROES); m_pTextCtrl_FromLength = S.Id(ID_FromLength) .AddTextBox(_("from"), wxT(""), 12); m_pTextCtrl_FromLength->SetValidator(vldFromLength); @@ -285,8 +286,8 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S) // min and max need same precision as what we're validating (bug 963) double minLength = (m_FromLength * 100.0) / (100.0 + MAX_Percentage); double maxLength = (m_FromLength * 100.0) / (100.0 + MIN_Percentage); - minLength = Internat::CompatibleToDouble(Internat::ToString(minLength, precission)); - maxLength = Internat::CompatibleToDouble(Internat::ToString(maxLength, precission)); + minLength = Internat::CompatibleToDouble(Internat::ToString(minLength, precision)); + maxLength = Internat::CompatibleToDouble(Internat::ToString(maxLength, precision)); vldToLength.SetRange(minLength, maxLength); m_pTextCtrl_ToLength = S.Id(ID_ToLength) diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 5854e5daf..7c82caaf7 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -197,6 +197,11 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, const auto &settings = ProjectSettings::Get( *p ); mProjectRate = settings.GetRate(); + const auto options = NumericTextCtrl::Options{} + .AutoPos(true) + .MenuEnabled(false) + .ReadOnly(true); + ShuttleGui S(this, eIsCreating); S.SetBorder(5); @@ -218,11 +223,6 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, S.AddFixedText( {} ); // spacer S.AddFixedText(_("Volume ")); - const auto options = NumericTextCtrl::Options{} - .AutoPos(true) - .MenuEnabled(false) - .ReadOnly(true); - //Foreground S.AddFixedText(_("&Foreground:"), false); if (S.GetMode() == eIsCreating) diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index 8d54ef567..2c5eb93ac 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -372,8 +372,9 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S) { S.StartMultiColumn(4, wxCENTER); { - auto tableTypes = LocalizedStrings(kTableTypeStrings, nTableTypes); - mTypeChoiceCtrl = S.Id(ID_Type).AddChoice(_("Distortion type:"), tableTypes); + mTypeChoiceCtrl = S.Id(ID_Type) + .AddChoice(_("Distortion type:"), + LocalizedStrings(kTableTypeStrings, nTableTypes)); mTypeChoiceCtrl->SetValidator(wxGenericValidator(&mParams.mTableChoiceIndx)); S.SetSizeHints(-1, -1); @@ -401,9 +402,10 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S) mThresholdT->SetValidator(vldThreshold); S.SetStyle(wxSL_HORIZONTAL); - double maxLin = DB_TO_LINEAR(MAX_Threshold_dB) * SCL_Threshold_dB; - double minLin = DB_TO_LINEAR(MIN_Threshold_dB) * SCL_Threshold_dB; - mThresholdS = S.Id(ID_Threshold).AddSlider( {}, 0, maxLin, minLin); + mThresholdS = S.Id(ID_Threshold) + .AddSlider( {}, 0, + DB_TO_LINEAR(MAX_Threshold_dB) * SCL_Threshold_dB, + DB_TO_LINEAR(MIN_Threshold_dB) * SCL_Threshold_dB); mThresholdS->SetName(defaultLabel(0)); S.AddSpace(20, 0); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 4087aa676..0b7db0328 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -2479,22 +2479,22 @@ EffectDialog::EffectDialog(wxWindow * parent, void EffectDialog::Init() { + long buttons = eOkButton; + if ((mType != EffectTypeAnalyze) && (mType != EffectTypeTool)) + { + buttons |= eCancelButton; + if (mType == EffectTypeProcess) + { + buttons |= ePreviewButton; + } + } + ShuttleGui S(this, eIsCreating); S.SetBorder(5); S.StartVerticalLay(true); { PopulateOrExchange(S); - - long buttons = eOkButton; - if ((mType != EffectTypeAnalyze) && (mType != EffectTypeTool)) - { - buttons |= eCancelButton; - if (mType == EffectTypeProcess) - { - buttons |= ePreviewButton; - } - } S.AddStandardButtons(buttons|mAdditionalButtons); } S.EndVerticalLay(); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 26e30e660..97be563b0 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -924,9 +924,9 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) { szrI = S.GetSizer(); - auto interpolations = - LocalizedStrings(kInterpStrings, nInterpolations); - mInterpChoice = S.Id(ID_Interp).AddChoice( {}, interpolations, 0 ); + mInterpChoice = S.Id(ID_Interp) + .AddChoice( {}, + LocalizedStrings(kInterpStrings, nInterpolations), 0 ); #if wxUSE_ACCESSIBILITY // so that name can be set on a standard control mInterpChoice->SetAccessible(safenew WindowAccessible(mInterpChoice)); @@ -995,13 +995,15 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) { S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1); { - wxArrayStringEx curves; - for (size_t i = 0, cnt = mCurves.size(); i < cnt; i++) - { - curves.push_back(mCurves[ i ].Name); - } - - mCurve = S.Id(ID_Curve).AddChoice( {}, curves ); + mCurve = S.Id(ID_Curve) + .AddChoice( {}, + [this]{ + wxArrayStringEx curves; + for (const auto &curve : mCurves) + curves.push_back(curve.Name); + return curves; + }() + ); mCurve->SetName(_("Select Curve")); } S.EndHorizontalLay(); @@ -1041,16 +1043,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 +1082,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(); @@ -1104,14 +1110,15 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) //S.GetParent()->Layout(); wxSize sz = szrV->GetMinSize(); sz += wxSize( 30, 0); - mUIParent->SetSizeHints(sz); + mUIParent->SetMinSize(sz); } else{ mPanel->Show( true ); szrV->Show(szr1, true); - mUIParent->SetSizeHints(mUIParent->GetBestSize()); + mUIParent->SetMinSize(mUIParent->GetBestSize()); } ForceRecalc(); + return; } @@ -2304,7 +2311,7 @@ void EffectEqualization::UpdateCurves() // Allow the control to resize if( mCurve ) - mCurve->SetSizeHints(-1, -1); + mCurve->SetMinSize({-1, -1}); // Set initial curve setCurve( mCurveName ); @@ -3329,8 +3336,10 @@ void EditCurvesDialog::PopulateOrExchange(ShuttleGui & S) S.StartStatic(_("&Curves"), 1); { S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES ); - mList = S.Id(CurvesListID).AddListControlReportMode(); - mList->InsertColumn(0, _("Curve Name"), wxLIST_FORMAT_RIGHT); + mList = S.Id(CurvesListID) + .AddListControlReportMode({ + { _("Curve Name"), wxLIST_FORMAT_RIGHT } + }); } S.EndStatic(); S.StartVerticalLay(0); diff --git a/src/effects/Loudness.cpp b/src/effects/Loudness.cpp index 8b9e3b495..874aa2d86 100644 --- a/src/effects/Loudness.cpp +++ b/src/effects/Loudness.cpp @@ -286,8 +286,10 @@ void EffectLoudness::PopulateOrExchange(ShuttleGui & S) S.AddVariableText(_("Normalize"), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); - auto targetChoices = LocalizedStrings(kNormalizeTargetStrings, nAlgos); - mNormalizeToCtl = S.AddChoice(wxEmptyString, targetChoices, mNormalizeTo); + mNormalizeToCtl = S.AddChoice( {}, + LocalizedStrings(kNormalizeTargetStrings, nAlgos), + mNormalizeTo + ); mNormalizeToCtl->SetValidator(wxGenericValidator(&mNormalizeTo)); S.AddVariableText(_("to"), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index d7844bfd5..6341e7ba7 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -225,8 +225,8 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S) S.StartMultiColumn(2, wxCENTER); { - auto typeChoices = LocalizedStrings(kTypeStrings, nTypes); - S.AddChoice(_("Noise type:"), typeChoices) + S + .AddChoice(_("Noise type:"), LocalizedStrings(kTypeStrings, nTypes)) ->SetValidator(wxGenericValidator(&mType)); FloatingPointValidator vldAmp(6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES); diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index f685950cd..cc8ff7f0a 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -1437,9 +1437,9 @@ struct ControlInfo { text->SetValidator(vld2); wxSlider *const slider = - S.Id(id).AddSlider( {}, 0, sliderMax); + S.Id(id) + .AddSlider( {}, 0, sliderMax); slider->SetName(sliderName()); - slider->SetRange(0, sliderMax); slider->SetSizeHints(150, -1); } @@ -1751,62 +1751,59 @@ void EffectNoiseReduction::Dialog::PopulateOrExchange(ShuttleGui & S) { S.StartMultiColumn(2); { - { - wxArrayStringEx windowTypeChoices; - for (int ii = 0; ii < WT_N_WINDOW_TYPES; ++ii) - windowTypeChoices.push_back(windowTypesInfo[ii].name); - S.TieChoice(_("&Window types") + wxString(wxT(":")), - mTempSettings.mWindowTypes, - windowTypeChoices); - } + S.TieChoice(_("&Window types") + wxString(wxT(":")), + mTempSettings.mWindowTypes, + []{ + wxArrayStringEx windowTypeChoices; + for (int ii = 0; ii < WT_N_WINDOW_TYPES; ++ii) + windowTypeChoices.push_back(windowTypesInfo[ii].name); + return windowTypeChoices; + }() + ); - { - S.TieChoice(_("Window si&ze") + wxString(wxT(":")), - mTempSettings.mWindowSizeChoice, - { - _("8") , - _("16") , - _("32") , - _("64") , - _("128") , - _("256") , - _("512") , - _("1024") , - _("2048 (default)") , - _("4096") , - _("8192") , - _("16384") , - } - ); - } + S.TieChoice(_("Window si&ze") + wxString(wxT(":")), + mTempSettings.mWindowSizeChoice, + { + _("8") , + _("16") , + _("32") , + _("64") , + _("128") , + _("256") , + _("512") , + _("1024") , + _("2048 (default)") , + _("4096") , + _("8192") , + _("16384") , + } + ); - { - S.TieChoice(_("S&teps per window") + wxString(wxT(":")), - mTempSettings.mStepsPerWindowChoice, - { - _("2") , - _("4 (default)") , - _("8") , - _("16") , - _("32") , - _("64") , - } - ); - } + S.TieChoice(_("S&teps per window") + wxString(wxT(":")), + mTempSettings.mStepsPerWindowChoice, + { + _("2") , + _("4 (default)") , + _("8") , + _("16") , + _("32") , + _("64") , + } + ); - S.Id(ID_CHOICE_METHOD); - { - wxArrayStringEx methodChoices; - int nn = DM_N_METHODS; + S.Id(ID_CHOICE_METHOD) + .TieChoice(_("Discrimination &method") + wxString(wxT(":")), + mTempSettings.mMethod, + []{ + wxArrayStringEx methodChoices; + int nn = DM_N_METHODS; #ifndef OLD_METHOD_AVAILABLE - --nn; + --nn; #endif - for (int ii = 0; ii < nn; ++ii) - methodChoices.push_back(discriminationMethodInfo[ii].name); - S.TieChoice(_("Discrimination &method") + wxString(wxT(":")), - mTempSettings.mMethod, - methodChoices); - } + for (int ii = 0; ii < nn; ++ii) + methodChoices.push_back(discriminationMethodInfo[ii].name); + return methodChoices; + }()); } S.EndMultiColumn(); diff --git a/src/effects/NoiseRemoval.cpp b/src/effects/NoiseRemoval.cpp index 328e33b0b..350a94b42 100644 --- a/src/effects/NoiseRemoval.cpp +++ b/src/effects/NoiseRemoval.cpp @@ -721,9 +721,9 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) mGainT = S.Id(ID_GAIN_TEXT).AddTextBox(_("Noise re&duction (dB):"), wxT(""), 0); S.SetStyle(wxSL_HORIZONTAL); mGainT->SetValidator(vld); - mGainS = S.Id(ID_GAIN_SLIDER).AddSlider(wxT(""), 0, GAIN_MAX); + mGainS = S.Id(ID_GAIN_SLIDER) + .AddSlider(wxT(""), 0, GAIN_MAX, GAIN_MIN); mGainS->SetName(_("Noise reduction")); - mGainS->SetRange(GAIN_MIN, GAIN_MAX); mGainS->SetSizeHints(150, -1); mSensitivityT = S.Id(ID_SENSITIVITY_TEXT).AddTextBox(_("&Sensitivity (dB):"), @@ -731,9 +731,9 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) 0); S.SetStyle(wxSL_HORIZONTAL); mSensitivityT->SetValidator(vld); - mSensitivityS = S.Id(ID_SENSITIVITY_SLIDER).AddSlider(wxT(""), 0, SENSITIVITY_MAX); + mSensitivityS = S.Id(ID_SENSITIVITY_SLIDER) + .AddSlider(wxT(""), 0, SENSITIVITY_MAX, SENSITIVITY_MIN); mSensitivityS->SetName(_("Sensitivity")); - mSensitivityS->SetRange(SENSITIVITY_MIN, SENSITIVITY_MAX); mSensitivityS->SetSizeHints(150, -1); mFreqT = S.Id(ID_FREQ_TEXT).AddTextBox(_("Fr&equency smoothing (Hz):"), @@ -741,9 +741,9 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) 0); S.SetStyle(wxSL_HORIZONTAL); mFreqT->SetValidator(vld); - mFreqS = S.Id(ID_FREQ_SLIDER).AddSlider(wxT(""), 0, FREQ_MAX); + mFreqS = S.Id(ID_FREQ_SLIDER) + .AddSlider(wxT(""), 0, FREQ_MAX, FREQ_MIN); mFreqS->SetName(_("Frequency smoothing")); - mFreqS->SetRange(FREQ_MIN, FREQ_MAX); mFreqS->SetSizeHints(150, -1); mTimeT = S.Id(ID_TIME_TEXT).AddTextBox(_("Attac&k/decay time (secs):"), @@ -751,9 +751,9 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S) 0); S.SetStyle(wxSL_HORIZONTAL); mTimeT->SetValidator(vld); - mTimeS = S.Id(ID_TIME_SLIDER).AddSlider(wxT(""), 0, TIME_MAX); + mTimeS = S.Id(ID_TIME_SLIDER) + .AddSlider(wxT(""), 0, TIME_MAX, TIME_MIN); mTimeS->SetName(_("Attack/decay time")); - mTimeS->SetRange(TIME_MIN, TIME_MAX); mTimeS->SetSizeHints(150, -1); S.AddPrompt(_("Noise:")); diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index 636367602..855dd0b25 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -299,14 +299,9 @@ void EffectNormalize::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxALIGN_LEFT, false); { - // The checkbox needs to be sized for the longer prompt, and - // which that is will depend on translation. So decide that here. - // (strictly we should count pixels, not characters). - wxString prompt1 = _("Normalize peak amplitude to"); - wxString longerPrompt = prompt1 + " "; - // Now make the checkbox. - mGainCheckBox = S.AddCheckBox(longerPrompt, - mGain); + mGainCheckBox = S + .AddCheckBox(_("Normalize peak amplitude to "), + mGain); mGainCheckBox->SetValidator(wxGenericValidator(&mGain)); mGainCheckBox->SetMinSize( mGainCheckBox->GetSize()); diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 137c8460e..450772515 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -117,6 +117,8 @@ static const EnumValueSymbol kSubTypeStrings[nSubTypes] = { XO("Highpass") } }; +static_assert(nSubTypes == WXSIZEOF(kSubTypeStrings), "size mismatch"); + // Define keys, defaults, minimums, and maximums for the effect parameters // // Name Type Key Def Min Max Scale @@ -453,19 +455,23 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) { wxASSERT(nTypes == WXSIZEOF(kTypeStrings)); - auto typeChoices = LocalizedStrings(kTypeStrings, nTypes); mFilterTypeCtl = S.Id(ID_Type) - .AddChoice(_("&Filter Type:"), typeChoices); + .AddChoice(_("&Filter Type:"), + LocalizedStrings(kTypeStrings, nTypes) + ); mFilterTypeCtl->SetValidator(wxGenericValidator(&mFilterType)); S.SetSizeHints(-1, -1); - wxArrayStringEx orders; - for (int i = 1; i <= 10; i++) - { - orders.push_back(wxString::Format(wxT("%d"), i)); - } - /*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/ - mFilterOrderCtl = S.Id(ID_Order).AddChoice(_("O&rder:"), orders); + mFilterOrderCtl = S.Id(ID_Order) + /*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/ + .AddChoice(_("O&rder:"), + []{ + wxArrayStringEx orders; + for (int i = 1; i <= 10; i++) + orders.push_back(wxString::Format(wxT("%d"), i)); + return orders; + }() + ); mFilterOrderCtl->SetValidator(wxGenericValidator(&mOrderIndex)); S.SetSizeHints(-1, -1); S.AddSpace(1, 1); @@ -479,11 +485,10 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) mRippleCtl->SetValidator(vldRipple); mRippleCtlU = S.AddVariableText(_("dB"), false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - wxASSERT(nSubTypes == WXSIZEOF(kSubTypeStrings)); - - auto subTypeChoices = LocalizedStrings(kSubTypeStrings, nSubTypes); mFilterSubTypeCtl = S.Id(ID_SubType) - .AddChoice(_("&Subtype:"), subTypeChoices); + .AddChoice(_("&Subtype:"), + LocalizedStrings(kSubTypeStrings, nSubTypes) + ); mFilterSubTypeCtl->SetValidator(wxGenericValidator(&mFilterSubtype)); S.SetSizeHints(-1, -1); diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index d0db6b5cd..f3f79c3ff 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -340,8 +340,9 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) S.StartMultiColumn(2, wxCENTER); { - auto waveforms = LocalizedStrings(kWaveStrings, nWaveforms); - wxChoice *c = S.AddChoice(_("Waveform:"), waveforms); + wxChoice *c = S + .AddChoice(_("Waveform:"), + LocalizedStrings(kWaveStrings, nWaveforms)); c->SetValidator(wxGenericValidator(&mWaveform)); if (mChirp) @@ -419,8 +420,9 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) } S.EndHorizontalLay(); - auto interpolations = LocalizedStrings(kInterStrings, nInterpolations); - c = S.AddChoice(_("Interpolation:"), interpolations); + c = S + .AddChoice(_("Interpolation:"), + LocalizedStrings(kInterStrings, nInterpolations)); c->SetValidator(wxGenericValidator(&mInterpolation)); } else diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index d7daa8d3b..cfc48eb02 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -511,8 +511,8 @@ void AudioUnitEffectExportDialog::PopulateOrExchange(ShuttleGui & S) { S.SetStyle(wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_NO_SORT_HEADER); - mList = S.AddListControlReportMode(); - mList->InsertColumn(0, _("Preset"), wxLIST_FORMAT_LEFT); + mList = S + .AddListControlReportMode( { _("Preset") } ); } S.EndStatic(); } @@ -684,9 +684,8 @@ void AudioUnitEffectImportDialog::PopulateOrExchange(ShuttleGui & S) { S.SetStyle(wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_NO_SORT_HEADER); - mList = S.AddListControlReportMode(); - mList->InsertColumn(0, _("Preset"), wxLIST_FORMAT_LEFT); - mList->InsertColumn(1, _("Location"), wxLIST_FORMAT_LEFT); + mList = S + .AddListControlReportMode( { _("Preset"), _("Location") } ); } S.EndStatic(); } diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index b4492fd71..0cc1a4177 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -1500,10 +1500,10 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) // Try to give the window a sensible default/minimum size wxSize sz1 = marginSizer->GetMinSize(); wxSize sz2 = mParent->GetMinSize(); - w->SetSizeHints(wxSize(wxMin(sz1.x, sz2.x), wxMin(sz1.y, sz2.y))); + w->SetMinSize( { std::min(sz1.x, sz2.x), std::min(sz1.y, sz2.y) } ); // And let the parent reduce to the NEW minimum if possible - mParent->SetSizeHints(-1, -1); + mParent->SetMinSize({ -1, -1 }); return true; } diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index 2206f4b6b..7ab1bab47 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -1829,10 +1829,10 @@ bool LV2Effect::BuildPlain() // Try to give the window a sensible default/minimum size wxSize sz1 = innerSizer->GetMinSize(); wxSize sz2 = mParent->GetMinSize(); - w->SetSizeHints(wxSize(-1, wxMin(sz1.y, sz2.y))); + w->SetMinSize( { -1, std::min(sz1.y, sz2.y) } ); // And let the parent reduce to the NEW minimum if possible - mParent->SetSizeHints(w->GetMinSize()); + mParent->SetMinSize(w->GetMinSize()); TransferDataToWindow(); diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 2405cd382..63ae55c18 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -2637,9 +2637,8 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S) { S.AddSpace(10, 10); - auto choices = - LocalizedStrings(ctrl.choices.data(), ctrl.choices.size()); - S.Id(ID_Choice + i).AddChoice( {}, choices ); + S.Id(ID_Choice + i).AddChoice( {}, + LocalizedStrings(ctrl.choices.data(), ctrl.choices.size())); } else if (ctrl.type == NYQ_CTRL_TIME) { diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index fc8e543e8..2407730dd 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -558,22 +558,19 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S) if (!programs.empty()) { - wxString currentProgram = wxString::FromUTF8(mPlugin->getCurrentProgram().c_str()); - - wxArrayStringEx choices; - for (size_t i = 0, cnt = programs.size(); i < cnt; i++) - { - choices.push_back(wxString::FromUTF8(programs[i].c_str())); - } - S.AddPrompt(_("Program")); S.Id(ID_Program); - mProgram = S.AddChoice( - {}, - choices, - choices.Index( currentProgram ) - ); + mProgram = S + .AddChoice( {}, + [&]{ + wxArrayStringEx choices; + for (const auto &program : programs) + choices.push_back(wxString::FromUTF8(program.c_str())); + return choices; + }(), + wxString::FromUTF8(mPlugin->getCurrentProgram().c_str()) + ); mProgram->SetName(_("Program")); mProgram->SetSizeHints(-1, -1); wxSizer *s = mProgram->GetContainingSizer(); diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index f4489915b..914e14ba9 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -533,7 +533,7 @@ ProgressResult ExportCL::Export(AudacityProject *project, S.AddTextWindow(cmd + wxT("\n\n") + output); S.StartHorizontalLay(wxALIGN_CENTER, false); { - S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault(); + S.Id(wxID_OK).AddButton(_("&OK"), wxALIGN_CENTER, true); } dlg.GetSizer()->AddSpacer(5); dlg.Layout(); diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 3e13610fc..ad49dfbd5 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -1001,7 +1001,8 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate, d.SetName(d.GetTitle()); wxChoice *choice; ShuttleGui S(&d, eIsCreating); - wxString text; + + int selected = -1; S.StartVerticalLay(); { @@ -1010,42 +1011,39 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate, { S.StartHorizontalLay(wxALIGN_CENTER, false); { - if (bitrate == 0) { - text.Printf(_("The project sample rate (%d) is not supported by the current output\nfile format. "), rate); - } - else { - text.Printf(_("The project sample rate (%d) and bit rate (%d kbps) combination is not\nsupported by the current output file format. "), rate, bitrate/1024); - } - - text += _("You may resample to one of the rates below."); - S.AddTitle(text); + S.AddTitle( + (bitrate == 0 + ? wxString::Format( + _("The project sample rate (%d) is not supported by the current output\nfile format. "), + rate) + : wxString::Format( + _("The project sample rate (%d) and bit rate (%d kbps) combination is not\nsupported by the current output file format. "), + rate, bitrate/1024)) + + _("You may resample to one of the rates below.") + ); } S.EndHorizontalLay(); - wxArrayStringEx choices; - int selected = -1; - for (int i = 0; sampRates[i] > 0; i++) - { - int label = sampRates[i]; - if (label >= lowrate && label <= highrate) - { - wxString name = wxString::Format(wxT("%d"),label); - choices.push_back(name); - if (label <= rate) - { - selected = i; - } - } - } - - if (selected == -1) - selected = 0; - S.StartHorizontalLay(wxALIGN_CENTER, false); { choice = S.AddChoice(_("Sample Rates"), - choices, - selected); + [&]{ + wxArrayStringEx choices; + for (int i = 0; sampRates[i] > 0; i++) + { + int label = sampRates[i]; + if (label >= lowrate && label <= highrate) + { + wxString name = wxString::Format(wxT("%d"),label); + choices.push_back(name); + if (label <= rate) + selected = i; + } + } + return choices; + }(), + std::max( 0, selected ) + ); } S.EndHorizontalLay(); } diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index 3847bb880..6ed86c091 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -325,6 +325,43 @@ static EnumSetting< MP3ChannelMode > MP3ChannelModeSetting{ /// void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) { + bool mono = false; + gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0); + + const wxArrayStringEx *choices = nullptr; + const std::vector< int > *codes = nullptr; + bool enable; + int defrate; + + switch( MP3RateModeSetting.ReadEnum() ) { + case MODE_SET: + choices = &setRateNames; + enable = true; + defrate = mSetRate; + break; + + case MODE_VBR: + choices = &varRateNames; + enable = true; + defrate = mVbrRate; + break; + + case MODE_ABR: + choices = &fixRateNames; + codes = &fixRateValues; + enable = false; + defrate = mAbrRate; + break; + + case MODE_CBR: + default: + choices = &fixRateNames; + codes = &fixRateValues; + enable = false; + defrate = mCbrRate; + break; + } + S.StartVerticalLay(); { S.StartHorizontalLay(wxCENTER); @@ -347,35 +384,6 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) S.EndRadioButtonGroup(); } S.EndHorizontalLay(); - - const wxArrayStringEx *choices = nullptr; - const std::vector< int > *codes = nullptr; - bool enable; - int defrate; - - if (mSET->GetValue()) { - choices = &setRateNames; - enable = true; - defrate = mSetRate; - } - else if (mVBR->GetValue()) { - choices = &varRateNames; - enable = true; - defrate = mVbrRate; - } - else if (mABR->GetValue()) { - choices = &fixRateNames; - codes = &fixRateValues; - enable = false; - defrate = mAbrRate; - } - else { - mCBR->SetValue(true); - choices = &fixRateNames; - codes = &fixRateValues; - enable = false; - defrate = mCbrRate; - } mRate = S.Id(ID_QUALITY).TieNumberAsChoice( _("Quality"), @@ -393,9 +401,6 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S) S.AddPrompt(_("Channel Mode:")); S.StartMultiColumn(3, wxEXPAND); { - bool mono = false; - gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0); - S.StartRadioButtonGroup(MP3ChannelModeSetting); { mJoint = S.TieRadioButton(); @@ -566,19 +571,17 @@ public: void PopulateOrExchange(ShuttleGui & S) { - wxString text; - S.SetBorder(10); S.StartVerticalLay(true); { - text.Printf(_("Audacity needs the file %s to create MP3s."), mName); - S.AddTitle(text); + S.AddTitle( + wxString::Format(_("Audacity needs the file %s to create MP3s."), + mName)); S.SetBorder(3); S.StartHorizontalLay(wxALIGN_LEFT, true); { - text.Printf(_("Location of %s:"), mName); - S.AddTitle(text); + S.AddTitle( wxString::Format(_("Location of %s:"), mName) ); } S.EndHorizontalLay(); @@ -587,8 +590,8 @@ public: { if (mLibPath.GetFullPath().empty()) { /* i18n-hint: There is a button to the right of the arrow.*/ - text.Printf(_("To find %s, click here -->"), mName); - mPathText = S.AddTextBox( {}, text, 0); + mPathText = S.AddTextBox( {}, + wxString::Format(_("To find %s, click here -->"), mName), 0); } else { mPathText = S.AddTextBox( {}, mLibPath.GetFullPath(), 0); @@ -2000,7 +2003,8 @@ int ExportMP3::AskResample(int bitrate, int rate, int lowrate, int highrate) d.SetName(d.GetTitle()); wxChoice *choice; ShuttleGui S(&d, eIsCreating); - wxString text; + + int selected = -1; S.StartVerticalLay(); { @@ -2009,39 +2013,36 @@ int ExportMP3::AskResample(int bitrate, int rate, int lowrate, int highrate) { S.StartHorizontalLay(wxALIGN_CENTER, false); { - if (bitrate == 0) { - text.Printf(_("The project sample rate (%d) is not supported by the MP3\nfile format. "), rate); - } - else { - text.Printf(_("The project sample rate (%d) and bit rate (%d kbps) combination is not\nsupported by the MP3 file format. "), rate, bitrate); - } - - text += _("You may resample to one of the rates below."); - S.AddTitle(text); + S.AddTitle( + ((bitrate == 0) + ? wxString::Format( + _("The project sample rate (%d) is not supported by the MP3\nfile format. "), + rate) + : wxString::Format( + _("The project sample rate (%d) and bit rate (%d kbps) combination is not\nsupported by the MP3 file format. "), + rate, bitrate)) + + _("You may resample to one of the rates below.") + ); } S.EndHorizontalLay(); - wxArrayStringEx choices; - int selected = -1; - for (size_t ii = 0, nn = sampRates.size(); ii < nn; ++ii) { - int label = sampRates[ii]; - if (label >= lowrate && label <= highrate) { - choices.push_back( wxString::Format( "%d", label ) ); - if (label <= rate) { - selected = ii; - } - } - } - - if (selected == -1) { - selected = 0; - } - S.StartHorizontalLay(wxALIGN_CENTER, false); { choice = S.AddChoice(_("Sample Rates"), - choices, - selected); + [&]{ + wxArrayStringEx choices; + for (size_t ii = 0, nn = sampRates.size(); ii < nn; ++ii) { + int label = sampRates[ii]; + if (label >= lowrate && label <= highrate) { + choices.push_back( wxString::Format( "%d", label ) ); + if (label <= rate) + selected = ii; + } + } + return choices; + }(), + std::max( 0, selected ) + ); } S.EndHorizontalLay(); } diff --git a/src/prefs/ExtImportPrefs.cpp b/src/prefs/ExtImportPrefs.cpp index cd48a99c9..62c0bf1c4 100644 --- a/src/prefs/ExtImportPrefs.cpp +++ b/src/prefs/ExtImportPrefs.cpp @@ -148,14 +148,14 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S) } S.AddWindow(RuleTable, wxEXPAND | wxALL); - PluginList = S.Id(EIPPluginList).AddListControl (); + PluginList = S.Id(EIPPluginList).AddListControl( + { { _("Importer order"), wxLIST_FORMAT_LEFT, + wxLIST_AUTOSIZE_USEHEADER } }, + wxLC_REPORT | wxLC_SINGLE_SEL + ); if (fillRuleTable) { - PluginList->SetSingleStyle (wxLC_REPORT, true); - PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true); - PluginList->InsertColumn (0, _("Importer order")); - ExtImportPrefsDropTarget *dragtarget2 {}; PluginList->SetDropTarget ( dragtarget2 = safenew ExtImportPrefsDropTarget( @@ -164,8 +164,6 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S) ); dragtarget2->SetPrefs (this); - PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE_USEHEADER); - auto &items = Importer::Get().GetImportItems(); { int i = -1; diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index ffd9deec1..abb860689 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -617,7 +617,6 @@ PrefsDialog::PrefsDialog S.EndVerticalLay(); S.AddStandardButtons(eOkButton | eCancelButton | ePreviewButton | eHelpButton); - static_cast(wxWindow::FindWindowById(wxID_OK, this))->SetDefault(); if (mUniquePage && !mUniquePage->ShowsPreviewButton()) { wxWindow *const previewButton = @@ -630,7 +629,7 @@ PrefsDialog::PrefsDialog mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem()); #endif -// mCategories->SetSizeHints(-1, -1, 790, 600); // 790 = 800 - (border * 2) +// mCategories->SetMaxSize({ 790, 600 }); // 790 = 800 - (border * 2) Layout(); Fit(); wxSize sz = GetSize(); diff --git a/src/prefs/QualityPrefs.cpp b/src/prefs/QualityPrefs.cpp index 8098e6cc5..220442239 100644 --- a/src/prefs/QualityPrefs.cpp +++ b/src/prefs/QualityPrefs.cpp @@ -146,9 +146,6 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S) S.StartMultiColumn(2); { - // If the value in Prefs isn't in the list, then we want - // the last item, 'Other...' to be shown. - S.SetNoMatchSelector(mSampleRateNames.size() - 1); // First the choice... // We make sure it uses the ID we want, so that we get changes S.Id(ID_SAMPLE_RATE_CHOICE); @@ -157,7 +154,11 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S) {wxT("/SamplingRate/DefaultProjectSampleRate"), AudioIOBase::GetOptimalSupportedSampleRate()}, mSampleRateNames, - &mSampleRateLabels); + &mSampleRateLabels, + // If the value in Prefs isn't in the list, then we want + // the last item, 'Other...' to be shown. + mSampleRateNames.GetCount() - 1 + ); // Now do the edit box... mOtherSampleRate = S.TieNumericTextBox( {}, diff --git a/src/prefs/RecordingPrefs.cpp b/src/prefs/RecordingPrefs.cpp index d3df4e19a..1c86b03f6 100644 --- a/src/prefs/RecordingPrefs.cpp +++ b/src/prefs/RecordingPrefs.cpp @@ -133,12 +133,11 @@ void RecordingPrefs::PopulateOrExchange(ShuttleGui & S) { S.SetStretchyCol(1); - int dBRange = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE); S.TieSlider(_("Le&vel (dB):"), {wxT("/AudioIO/SilenceLevel"), -50}, 0, - -dBRange); + -gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE)); } S.EndMultiColumn(); } diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index 258636e80..f42341bbd 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -843,7 +843,7 @@ void DeviceToolBar::ShowComboDialog(wxChoice *combo, const wxString &title) S.StartVerticalLay(true); { - S.StartHorizontalLay(wxCENTER, false); + S.StartHorizontalLay(wxCENTER, false); { c = S.AddChoice(combo->GetName(), inputSources, diff --git a/src/widgets/AButton.cpp b/src/widgets/AButton.cpp index 4463c89b5..0e4046718 100644 --- a/src/widgets/AButton.cpp +++ b/src/widgets/AButton.cpp @@ -271,8 +271,8 @@ void AButton::Init(wxWindow * parent, mFocusRect = GetClientRect().Deflate( 3, 3 ); mForceFocusRect = false; - SetSizeHints(mImages[0].mArr[0].GetMinSize(), - mImages[0].mArr[0].GetMaxSize()); + SetMinSize(mImages[0].mArr[0].GetMinSize()); + SetMaxSize(mImages[0].mArr[0].GetMaxSize()); #if wxUSE_ACCESSIBILITY SetName( wxT("") ); diff --git a/src/widgets/ExpandingToolBar.cpp b/src/widgets/ExpandingToolBar.cpp index 9dffd1052..f9b430cd3 100644 --- a/src/widgets/ExpandingToolBar.cpp +++ b/src/widgets/ExpandingToolBar.cpp @@ -380,7 +380,8 @@ void ExpandingToolBar::Fit() mCurrentDrawerSize = wxSize(mExtraSize.x, 0); mCurrentTotalSize = baseWindowSize; - SetSizeHints(mCurrentTotalSize, mCurrentTotalSize); + SetMinSize(mCurrentTotalSize); + SetMaxSize(mCurrentTotalSize); SetSize(mCurrentTotalSize); } @@ -434,7 +435,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize) if (mFrameParent) { // If we're in a tool window - SetSizeHints(mCurrentTotalSize, mCurrentTotalSize); + SetMinSize(mCurrentTotalSize); + SetMaxSize(mCurrentTotalSize); SetSize(mCurrentTotalSize); GetParent()->Fit(); @@ -443,7 +445,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize) if (mDialogParent) { // If we're in a dialog - SetSizeHints(mCurrentTotalSize, mCurrentTotalSize); + SetMinSize(mCurrentTotalSize); + SetMaxSize(mCurrentTotalSize); SetSize(mCurrentTotalSize); GetParent()->Fit(); @@ -457,7 +460,8 @@ void ExpandingToolBar::MoveDrawer(wxSize prevSize) mExtraPanel->Show(); } - mExtraPanel->SetSizeHints(mCurrentDrawerSize, mCurrentDrawerSize); + mExtraPanel->SetMinSize(mCurrentDrawerSize); + mExtraPanel->SetMaxSize(mCurrentDrawerSize); mExtraPanel->SetSize(mCurrentDrawerSize); if (mCurrentDrawerSize.y == 0) @@ -680,8 +684,8 @@ ToolBarGrabber::ToolBarGrabber(wxWindow *parent, images[1], magicColor); - SetSizeHints(mImageRoll[0].GetMinSize(), - mImageRoll[1].GetMaxSize()); + SetMinSize(mImageRoll[0].GetMinSize()); + SetMaxSize(mImageRoll[1].GetMaxSize()); #endif mState = 0; } @@ -1094,7 +1098,8 @@ void ToolBarArea::Fit(bool horizontal, bool vertical) maxSize != mMaxSize) { mMinSize = minSize; mMaxSize = maxSize; - SetSizeHints(mMinSize, mMaxSize); + SetMinSize(mMinSize); + SetMaxSize(mMaxSize); } if (actualSize != mActualSize) { mActualSize = actualSize; diff --git a/src/widgets/HelpSystem.cpp b/src/widgets/HelpSystem.cpp index 2dba92d16..ff190b131 100644 --- a/src/widgets/HelpSystem.cpp +++ b/src/widgets/HelpSystem.cpp @@ -189,7 +189,7 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent, S.Prop(1).AddWindow( html, wxEXPAND ); - S.Id( wxID_CANCEL ).AddButton( _("Close") )->SetDefault(); + S.Id( wxID_CANCEL ).AddButton( _("Close"), wxALIGN_CENTER, true ); } S.EndPanel(); diff --git a/src/widgets/ImageRoll.cpp b/src/widgets/ImageRoll.cpp index 917bf1151..7a4b4e667 100644 --- a/src/widgets/ImageRoll.cpp +++ b/src/widgets/ImageRoll.cpp @@ -435,8 +435,8 @@ ImageRollPanel::ImageRollPanel(wxWindow *parent, //mImageRoll(imgRoll), mLogicalFunction(wxCOPY) { -// SetSizeHints(mImageRoll.GetMinSize(), -// mImageRoll.GetMaxSize()); +// SetMinSize(mImageRoll.GetMinSize()); +// SetMaxSize(mImageRoll.GetMaxSize()); } void ImageRollPanel::SetLogicalFunction(int /*wxRasterOperationMode*/ func) diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index 85d6bc5d5..c9cdc4f45 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -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(); }