diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index d0ae08071..e85c5f2ce 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -13,12 +13,6 @@ \class Effect \brief Base class for many of the effects in Audacity. -*//****************************************************************//** - -\class EffectDialog -\brief New (Jun-2006) base class for effects dialogs. Likely to get -greater use in future. - *//*******************************************************************/ #include "../Audacity.h" @@ -37,7 +31,6 @@ greater use in future. #include "../LabelTrack.h" #include "../Mix.h" #include "../PluginManager.h" -#include "../Project.h" #include "../ProjectAudioManager.h" #include "../ProjectSettings.h" #include "../ShuttleGui.h" @@ -2392,98 +2385,6 @@ int Effect::MessageBox( const TranslatableString& message, return AudacityMessageBox( message, title, style, mUIParent ); } -BEGIN_EVENT_TABLE(EffectDialog, wxDialogWrapper) - EVT_BUTTON(wxID_OK, EffectDialog::OnOk) -END_EVENT_TABLE() - -EffectDialog::EffectDialog(wxWindow * parent, - const TranslatableString & title, - int type, - int flags, - int additionalButtons) -: wxDialogWrapper(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, flags) -{ - mType = type; - mAdditionalButtons = additionalButtons; -} - -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); - S.AddStandardButtons(buttons|mAdditionalButtons); - } - S.EndVerticalLay(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); -} - -/// This is a virtual function which will be overridden to -/// provide the actual parameters that we want for each -/// kind of dialog. -void EffectDialog::PopulateOrExchange(ShuttleGui & WXUNUSED(S)) -{ - return; -} - -bool EffectDialog::TransferDataToWindow() -{ - ShuttleGui S(this, eIsSettingToDialog); - PopulateOrExchange(S); - - return true; -} - -bool EffectDialog::TransferDataFromWindow() -{ - ShuttleGui S(this, eIsGettingFromDialog); - PopulateOrExchange(S); - - return true; -} - -bool EffectDialog::Validate() -{ - return true; -} - -void EffectDialog::OnPreview(wxCommandEvent & WXUNUSED(evt)) -{ - return; -} - -void EffectDialog::OnOk(wxCommandEvent & WXUNUSED(evt)) -{ - // On wxGTK (wx2.8.12), the default action is still executed even if - // the button is disabled. This appears to affect all wxDialogs, not - // just our Effects dialogs. So, this is a only temporary workaround - // for legacy effects that disable the OK button. Hopefully this has - // been corrected in wx3. - if (FindWindow(wxID_OK)->IsEnabled() && Validate() && TransferDataFromWindow()) - { - EndModal(true); - } - - return; -} - /////////////////////////////////////////////////////////////////////////////// // // EffectPresetsDialog diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 14bf8a028..7d0342ab5 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -547,36 +547,6 @@ private: #define ID_EFFECT_PREVIEW ePreviewID -// Base dialog for regular effect -class AUDACITY_DLL_API EffectDialog /* not final */ : public wxDialogWrapper -{ -public: - // constructors and destructors - EffectDialog(wxWindow * parent, - const TranslatableString & title, - int type = 0, - int flags = wxDEFAULT_DIALOG_STYLE, - int additionalButtons = 0); - - void Init(); - - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - bool Validate() override; - - // NEW virtuals: - virtual void PopulateOrExchange(ShuttleGui & S); - virtual void OnPreview(wxCommandEvent & evt); - virtual void OnOk(wxCommandEvent & evt); - -private: - int mType; - int mAdditionalButtons; - - DECLARE_EVENT_TABLE() - wxDECLARE_NO_COPY_CLASS(EffectDialog); -}; - class EffectPresetsDialog final : public wxDialogWrapper { public: diff --git a/src/effects/EffectUI.cpp b/src/effects/EffectUI.cpp index 98e0a7127..0f9957cc5 100644 --- a/src/effects/EffectUI.cpp +++ b/src/effects/EffectUI.cpp @@ -2003,3 +2003,96 @@ wxDialog *EffectUI::DialogFactory( wxWindow &parent, EffectHostInterface *pHost, return true; } + +/////////////////////////////////////////////////////////////////////////////// +BEGIN_EVENT_TABLE(EffectDialog, wxDialogWrapper) + EVT_BUTTON(wxID_OK, EffectDialog::OnOk) +END_EVENT_TABLE() + +EffectDialog::EffectDialog(wxWindow * parent, + const TranslatableString & title, + int type, + int flags, + int additionalButtons) +: wxDialogWrapper(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, flags) +{ + mType = type; + mAdditionalButtons = additionalButtons; +} + +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); + S.AddStandardButtons(buttons|mAdditionalButtons); + } + S.EndVerticalLay(); + + Layout(); + Fit(); + SetMinSize(GetSize()); + Center(); +} + +/// This is a virtual function which will be overridden to +/// provide the actual parameters that we want for each +/// kind of dialog. +void EffectDialog::PopulateOrExchange(ShuttleGui & WXUNUSED(S)) +{ + return; +} + +bool EffectDialog::TransferDataToWindow() +{ + ShuttleGui S(this, eIsSettingToDialog); + PopulateOrExchange(S); + + return true; +} + +bool EffectDialog::TransferDataFromWindow() +{ + ShuttleGui S(this, eIsGettingFromDialog); + PopulateOrExchange(S); + + return true; +} + +bool EffectDialog::Validate() +{ + return true; +} + +void EffectDialog::OnPreview(wxCommandEvent & WXUNUSED(evt)) +{ + return; +} + +void EffectDialog::OnOk(wxCommandEvent & WXUNUSED(evt)) +{ + // On wxGTK (wx2.8.12), the default action is still executed even if + // the button is disabled. This appears to affect all wxDialogs, not + // just our Effects dialogs. So, this is a only temporary workaround + // for legacy effects that disable the OK button. Hopefully this has + // been corrected in wx3. + if (FindWindow(wxID_OK)->IsEnabled() && Validate() && TransferDataFromWindow()) + { + EndModal(true); + } + + return; +} diff --git a/src/effects/EffectUI.h b/src/effects/EffectUI.h index 38f87d78f..2a178d030 100644 --- a/src/effects/EffectUI.h +++ b/src/effects/EffectUI.h @@ -230,4 +230,36 @@ namespace EffectUI { } +class ShuttleGui; + +// Obsolescent dialog still used only in Noise Reduction/Removal +class AUDACITY_DLL_API EffectDialog /* not final */ : public wxDialogWrapper +{ +public: + // constructors and destructors + EffectDialog(wxWindow * parent, + const TranslatableString & title, + int type = 0, + int flags = wxDEFAULT_DIALOG_STYLE, + int additionalButtons = 0); + + void Init(); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + bool Validate() override; + + // NEW virtuals: + virtual void PopulateOrExchange(ShuttleGui & S); + virtual void OnPreview(wxCommandEvent & evt); + virtual void OnOk(wxCommandEvent & evt); + +private: + int mType; + int mAdditionalButtons; + + DECLARE_EVENT_TABLE() + wxDECLARE_NO_COPY_CLASS(EffectDialog); +}; + #endif // __AUDACITY_EFFECTUI_H__ diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index 9b6aeaa11..afa67e677 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -43,6 +43,7 @@ #include "LoadEffects.h" #include "EffectManager.h" +#include "EffectUI.h" #include "../ShuttleGui.h" #include "../widgets/HelpSystem.h" diff --git a/src/effects/NoiseRemoval.h b/src/effects/NoiseRemoval.h index 7e4fa8408..5419e6a84 100644 --- a/src/effects/NoiseRemoval.h +++ b/src/effects/NoiseRemoval.h @@ -19,6 +19,7 @@ #if !defined(EXPERIMENTAL_NOISE_REDUCTION) #include "Effect.h" +#include "EffectUI.h" class wxButton; class wxSizer;