1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-15 07:50:22 +02:00

EffectUIClientInterface::PopulateUI takes ShuttleGui &

This commit is contained in:
Paul Licameli 2017-10-26 08:51:41 -04:00
parent eff5b2ef92
commit 1c84932dfa
12 changed files with 62 additions and 52 deletions

View File

@ -49,6 +49,8 @@
#include "audacity/ConfigInterface.h"
#include "audacity/EffectAutomationParameters.h" // for command automation
class ShuttleGui;
typedef enum EffectType : int
{
EffectTypeNone,
@ -231,7 +233,7 @@ public:
virtual void SetHostUI(EffectUIHostInterface *host) = 0;
virtual bool IsGraphicalUI() = 0;
virtual bool PopulateUI(wxWindow *parent) = 0;
virtual bool PopulateUI(ShuttleGui &S) = 0;
virtual bool ValidateUI() = 0;
virtual bool HideUI() = 0;
virtual bool CloseUI() = 0;

View File

@ -615,14 +615,14 @@ void Effect::SetHostUI(EffectUIHostInterface *WXUNUSED(host))
{
}
bool Effect::PopulateUI(wxWindow *parent)
bool Effect::PopulateUI(ShuttleGui &S)
{
auto parent = S.GetParent();
mUIParent = parent;
mUIParent->PushEventHandler(this);
// LoadUserPreset(GetCurrentSettingsGroup());
ShuttleGui S(mUIParent, eIsCreating);
PopulateOrExchange(S);
mUIParent->SetMinSize(mUIParent->GetSizer()->GetMinSize());

View File

@ -158,7 +158,7 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
// EffectUIClientInterface implementation
void SetHostUI(EffectUIHostInterface *host) override;
bool PopulateUI(wxWindow *parent) final;
bool PopulateUI(ShuttleGui &S) final;
bool IsGraphicalUI() override;
bool ValidateUI() override;
bool HideUI() override;

View File

@ -858,28 +858,31 @@ int EffectUIHost::ShowModal()
bool EffectUIHost::Initialize()
{
EffectPanel *w = safenew EffectPanel(this);
RTL_WORKAROUND(w);
EffectPanel *w {};
{
auto vs = std::make_unique<wxBoxSizer>(wxVERTICAL);
{
auto hs = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
Destroy_ptr<EffectPanel> uw{ safenew EffectPanel(this) };
RTL_WORKAROUND(uw.get());
// Try to give the window a sensible default/minimum size
w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),
mParent->GetSize().GetHeight() / 2));
uw->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),
mParent->GetSize().GetHeight() / 2));
auto gAudioIO = AudioIO::Get();
mDisableTransport = !gAudioIO->IsAvailable(mProject);
mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice
mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0;
if (!mClient->PopulateUI(w))
ShuttleGui S1{ uw.get(), eIsCreating };
if (!mClient->PopulateUI(S1))
{
return false;
}
hs->Add(w, 1, wxEXPAND);
hs->Add((w = uw.release()), 1, wxEXPAND);
vs->Add(hs.release(), 1, wxEXPAND);
}
@ -896,7 +899,7 @@ bool EffectUIHost::Initialize()
mSupportsRealtime = mEffect && mEffect->SupportsRealtime();
mIsGUI = mClient->IsGraphicalUI();
mIsBatch = (mEffect && mEffect->IsBatchProcessing()) ||
(mCommand && mCommand->IsBatchProcessing());
(mCommand && mCommand->IsBatchProcessing());
wxBitmapButton *bb;
@ -940,9 +943,9 @@ bool EffectUIHost::Initialize()
bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin);
}
else if (mEffect &&
(mEffect->GetType() != EffectTypeAnalyze) &&
(mEffect->GetType() != EffectTypeTool)
)
(mEffect->GetType() != EffectTypeAnalyze) &&
(mEffect->GetType() != EffectTypeTool)
)
{
wxASSERT(bar); // To justify safenew
mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("&Preview"));

View File

@ -1761,8 +1761,9 @@ void VSTEffect::SetHostUI(EffectUIHostInterface *host)
mUIHost = host;
}
bool VSTEffect::PopulateUI(wxWindow *parent)
bool VSTEffect::PopulateUI(ShuttleGui &S)
{
auto parent = S.GetParent();
mDialog = static_cast<wxDialog *>(wxGetTopLevelParent(parent));
mParent = parent;

View File

@ -167,7 +167,7 @@ class VSTEffect final : public wxEvtHandler,
// EffectUIClientInterface implementation
void SetHostUI(EffectUIHostInterface *host) override;
bool PopulateUI(wxWindow *parent) override;
bool PopulateUI(ShuttleGui &S) override;
bool IsGraphicalUI() override;
bool ValidateUI() override;
bool HideUI() override;

View File

@ -1717,10 +1717,11 @@ void AudioUnitEffect::SetHostUI(EffectUIHostInterface *host)
mUIHost = host;
}
bool AudioUnitEffect::PopulateUI(wxWindow *parent)
bool AudioUnitEffect::PopulateUI(ShuttleGui &S)
{
// OSStatus result;
auto parent = S.GetParent();
mDialog = static_cast<wxDialog *>(wxGetTopLevelParent(parent));
mParent = parent;

View File

@ -117,7 +117,7 @@ public:
// EffectUIClientInterface implementation
void SetHostUI(EffectUIHostInterface *host) override;
bool PopulateUI(wxWindow *parent) override;
bool PopulateUI(ShuttleGui &S) override;
bool IsGraphicalUI() override;
bool ValidateUI() override;
bool HideUI() override;

View File

@ -1195,8 +1195,10 @@ void LadspaEffect::SetHostUI(EffectUIHostInterface *host)
mUIHost = host;
}
bool LadspaEffect::PopulateUI(wxWindow *parent)
bool LadspaEffect::PopulateUI(ShuttleGui &S)
{
auto parent = S.GetParent();
mParent = parent;
mParent->PushEventHandler(this);

View File

@ -115,7 +115,7 @@ public:
// EffectUIClientInterface implementation
void SetHostUI(EffectUIHostInterface *host) override;
bool PopulateUI(wxWindow *parent) override;
bool PopulateUI(ShuttleGui &S) override;
bool IsGraphicalUI() override;
bool ValidateUI() override;
bool HideUI() override;

View File

@ -1548,8 +1548,9 @@ void LV2Effect::SetHostUI(EffectUIHostInterface *host)
mUIHost = host;
}
bool LV2Effect::PopulateUI(wxWindow *parent)
bool LV2Effect::PopulateUI(ShuttleGui &S)
{
auto parent = S.GetParent();
mParent = parent;
mParent->PushEventHandler(this);

View File

@ -314,7 +314,7 @@ public:
// EffectUIClientInterface implementation
void SetHostUI(EffectUIHostInterface *host) override;
bool PopulateUI(wxWindow *parent) override;
bool PopulateUI(ShuttleGui &S) override;
bool IsGraphicalUI() override;
bool ValidateUI() override;
bool HideUI() override;