mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 08:09:32 +02:00
EffectUIClientInterface::PopulateUI takes ShuttleGui &
This commit is contained in:
parent
eff5b2ef92
commit
1c84932dfa
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -858,54 +858,57 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
wxPanel *buttonPanel = safenew wxPanelWrapper(this, wxID_ANY);
|
||||
wxPanel *const bar = safenew wxPanelWrapper(buttonPanel, wxID_ANY);
|
||||
|
||||
|
||||
// This fools NVDA into not saying "Panel" when the dialog gets focus
|
||||
bar->SetName(wxT("\a"));
|
||||
bar->SetLabel(wxT("\a"));
|
||||
|
||||
|
||||
{
|
||||
auto bs = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
|
||||
|
||||
|
||||
mSupportsRealtime = mEffect && mEffect->SupportsRealtime();
|
||||
mIsGUI = mClient->IsGraphicalUI();
|
||||
mIsBatch = (mEffect && mEffect->IsBatchProcessing()) ||
|
||||
(mCommand && mCommand->IsBatchProcessing());
|
||||
|
||||
(mCommand && mCommand->IsBatchProcessing());
|
||||
|
||||
wxBitmapButton *bb;
|
||||
|
||||
|
||||
int margin = 0;
|
||||
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
margin = 3; // I'm sure it's needed because of the order things are created...
|
||||
#endif
|
||||
|
||||
|
||||
if (!mIsGUI)
|
||||
{
|
||||
wxASSERT(bar); // To justify safenew
|
||||
@ -925,9 +928,9 @@ bool EffectUIHost::Initialize()
|
||||
bs->Add(mMenuBtn);
|
||||
}
|
||||
mMenuBtn->SetToolTip(_("Manage presets and options"));
|
||||
|
||||
|
||||
bs->Add(5, 5);
|
||||
|
||||
|
||||
if (!mIsBatch)
|
||||
{
|
||||
if (!mIsGUI)
|
||||
@ -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"));
|
||||
@ -972,7 +975,7 @@ bool EffectUIHost::Initialize()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mSupportsRealtime)
|
||||
{
|
||||
if (!mIsGUI)
|
||||
@ -996,7 +999,7 @@ bool EffectUIHost::Initialize()
|
||||
bs->Add(mRewindBtn);
|
||||
}
|
||||
mRewindBtn->SetToolTip(_("Skip backward"));
|
||||
|
||||
|
||||
if (!mIsGUI)
|
||||
{
|
||||
wxASSERT(bar); // To justify safenew
|
||||
@ -1018,19 +1021,19 @@ bool EffectUIHost::Initialize()
|
||||
bs->Add(mFFwdBtn);
|
||||
}
|
||||
mFFwdBtn->SetToolTip(_("Skip forward"));
|
||||
|
||||
|
||||
bs->Add(5, 5);
|
||||
|
||||
|
||||
mEnableCb = safenew wxCheckBox(bar, kEnableID, _("&Enable"));
|
||||
mEnableCb->SetValue(mEnabled);
|
||||
mEnableCb->SetName(_("Enable"));
|
||||
bs->Add(mEnableCb, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bar->SetSizerAndFit(bs.release());
|
||||
}
|
||||
|
||||
|
||||
long buttons;
|
||||
if ( mEffect && mEffect->ManualPage().empty() && mEffect->HelpPage().empty()) {
|
||||
buttons = eApplyButton + eCloseButton;
|
||||
@ -1047,33 +1050,33 @@ bool EffectUIHost::Initialize()
|
||||
wxAcceleratorTable accel(1, entries);
|
||||
this->SetAcceleratorTable(accel);
|
||||
}
|
||||
|
||||
|
||||
if (mEffect && mEffect->mUIDebug) {
|
||||
buttons += eDebugButton;
|
||||
}
|
||||
|
||||
|
||||
buttonPanel->SetSizer(CreateStdButtonSizer(buttonPanel, buttons, bar).release());
|
||||
vs->Add(buttonPanel, 0, wxEXPAND);
|
||||
|
||||
|
||||
SetSizer(vs.release());
|
||||
}
|
||||
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
Center();
|
||||
|
||||
|
||||
mApplyBtn = (wxButton *) FindWindow(wxID_APPLY);
|
||||
mCloseBtn = (wxButton *) FindWindow(wxID_CANCEL);
|
||||
|
||||
|
||||
UpdateControls();
|
||||
|
||||
|
||||
w->SetAccept(!mIsGUI);
|
||||
(!mIsGUI ? w : FindWindow(wxID_APPLY))->SetFocus();
|
||||
|
||||
|
||||
LoadUserPresets();
|
||||
|
||||
|
||||
InitializeRealtime();
|
||||
|
||||
|
||||
SetMinSize(GetSize());
|
||||
return true;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user