Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EffectUIHost Class Referencefinal

#include <EffectUI.h>

Inheritance diagram for EffectUIHost:
[legend]
Collaboration diagram for EffectUIHost:
[legend]

Public Member Functions

 EffectUIHost (wxWindow *parent, AudacityProject &project, EffectPlugin &effect, EffectUIClientInterface &client, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, const std::shared_ptr< RealtimeEffectState > &pPriorState={})
 
virtual ~EffectUIHost ()
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
int ShowModal () override
 
bool Initialize ()
 
EffectUIValidatorGetValidator () const
 
bool HandleCommandKeystrokes () override
 
void SetClosed ()
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 
- Public Member Functions inherited from TopLevelKeystrokeHandlingWindow
virtual ~TopLevelKeystrokeHandlingWindow ()
 
virtual bool HandleCommandKeystrokes ()
 

Private Member Functions

std::shared_ptr< EffectInstanceInitializeInstance ()
 
wxPanel * BuildButtonBar (wxWindow *parent, bool graphicalUI)
 
void BuildButtonBar (ShuttleGui &S, bool graphicalUI)
 
void OnInitDialog (wxInitDialogEvent &evt)
 
void OnErase (wxEraseEvent &evt)
 
void OnPaint (wxPaintEvent &evt)
 
void OnClose (wxCloseEvent &evt)
 
void OnApply (wxCommandEvent &evt)
 
void DoCancel ()
 
void OnCancel (wxCommandEvent &evt)
 
void OnDebug (wxCommandEvent &evt)
 
void OnMenu (wxCommandEvent &evt)
 
void OnEnable (wxCommandEvent &evt)
 
void OnPlay (wxCommandEvent &evt)
 
void OnPlayback (AudioIOEvent)
 
void OnCapture (AudioIOEvent)
 
void OnUserPreset (wxCommandEvent &evt)
 
void OnFactoryPreset (wxCommandEvent &evt)
 
void OnDeletePreset (wxCommandEvent &evt)
 
void OnSaveAs (wxCommandEvent &evt)
 
void OnImport (wxCommandEvent &evt)
 
void OnExport (wxCommandEvent &evt)
 
void OnOptions (wxCommandEvent &evt)
 
void OnDefaults (wxCommandEvent &evt)
 
void OnIdle (wxIdleEvent &evt)
 
void OnCharHook (wxKeyEvent &evt)
 
bool IsOpenedFromEffectPanel () const
 
void UpdateControls ()
 
wxBitmap CreateBitmap (const char *const xpm[], bool up, bool pusher)
 
void LoadUserPresets ()
 
void CleanupRealtime ()
 
void StopPlayback ()
 

Private Attributes

Observer::Subscription mAudioIOSubscription
 
Observer::Subscription mEffectStateSubscription
 
AudacityProjectmProject
 
wxWindow *const mParent
 
EffectPluginmEffectUIHost
 
EffectUIClientInterfacemClient
 
const EffectPlugin::EffectSettingsAccessPtr mpGivenAccess
 
EffectPlugin::EffectSettingsAccessPtr mpAccess
 
EffectPlugin::EffectSettingsAccessPtr mpAccess2
 
std::weak_ptr< RealtimeEffectStatemwState {}
 
std::shared_ptr< RealtimeEffectStatempTempProjectState {}
 
RegistryPaths mUserPresets
 
bool mInitialized { false }
 
const bool mSupportsRealtime
 
bool mIsGUI {}
 
bool mIsBatch {}
 
wxButton * mApplyBtn {}
 
wxButton * mMenuBtn {}
 
wxButton * mEnableBtn {}
 
wxButton * mDebugBtn {}
 
wxButton * mPlayToggleBtn {}
 
wxBitmap mRealtimeEnabledBM
 
wxBitmap mRealtimeDisabledBM
 
bool mEnabled { true }
 
bool mDisableTransport { true }
 
bool mPlaying {}
 
bool mCapturing {}
 
SelectedRegion mRegion
 
double mPlayPos { 0.0 }
 
bool mDismissed {}
 
const bool mHadPriorState
 
const std::shared_ptr< EffectInstancempInstance
 
const EffectOutputs *const mpOutputs
 
std::unique_ptr< EffectUIValidatormpValidator
 

Detailed Description

Definition at line 42 of file EffectUI.h.

Constructor & Destructor Documentation

◆ EffectUIHost()

EffectUIHost::EffectUIHost ( wxWindow *  parent,
AudacityProject project,
EffectPlugin effect,
EffectUIClientInterface client,
std::shared_ptr< EffectInstance > &  pInstance,
EffectSettingsAccess access,
const std::shared_ptr< RealtimeEffectState > &  pPriorState = {} 
)

Definition at line 227 of file EffectUI.cpp.

232: wxDialogWrapper(parent, wxID_ANY, effect.GetDefinition().GetName(),
233 wxDefaultPosition, wxDefaultSize,
234 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX)
235, mEffectUIHost{ effect }
236, mClient{ client }
237// Grab a pointer to the access object,
238// extending its lifetime while this remains:
239, mpGivenAccess{ access.shared_from_this() }
241, mwState{ pPriorState }
242, mProject{ project }
243, mParent{ parent }
245, mHadPriorState{ (pPriorState != nullptr) }
247, mpOutputs{ pPriorState ? pPriorState->GetOutputs() : nullptr }
248{
249 // Assign the out parameter
250 pInstance = mpInstance;
251#if defined(__WXMAC__)
252 // Make sure the effect window actually floats above the main window
253 [ [((NSView *)GetHandle()) window] setLevel:NSFloatingWindowLevel];
254#endif
255
256 SetName( effect.GetDefinition().GetName() );
257
258 // This style causes Validate() and TransferDataFromWindow() to visit
259 // sub-windows recursively, applying any wxValidators
260 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
261}
TranslatableString GetName() const
virtual const EffectSettingsManager & GetDefinition() const =0
EffectPlugin & mEffectUIHost
Definition: EffectUI.h:120
const EffectPlugin::EffectSettingsAccessPtr mpGivenAccess
Definition: EffectUI.h:123
AudacityProject & mProject
Definition: EffectUI.h:118
EffectPlugin::EffectSettingsAccessPtr mpAccess
Definition: EffectUI.h:124
const EffectOutputs *const mpOutputs
Definition: EffectUI.h:163
EffectUIClientInterface & mClient
Definition: EffectUI.h:121
const bool mHadPriorState
Definition: EffectUI.h:155
std::shared_ptr< EffectInstance > InitializeInstance()
Definition: EffectUI.cpp:1106
const bool mSupportsRealtime
Definition: EffectUI.h:132
const std::shared_ptr< EffectInstance > mpInstance
Definition: EffectUI.h:162
std::weak_ptr< RealtimeEffectState > mwState
Definition: EffectUI.h:126
wxWindow *const mParent
Definition: EffectUI.h:119

References EffectPlugin::GetDefinition(), ComponentInterface::GetName(), mpInstance, and wxDialogWrapper::SetName().

Here is the call graph for this function:

◆ ~EffectUIHost()

EffectUIHost::~EffectUIHost ( )
virtual

Definition at line 263 of file EffectUI.cpp.

264{
265 if (mpValidator)
266 mpValidator->Disconnect();
267 DestroyChildren();
268 wxASSERT(mClosed);
269}
std::unique_ptr< EffectUIValidator > mpValidator
Definition: EffectUI.h:165

References mpValidator.

Member Function Documentation

◆ BuildButtonBar() [1/2]

void EffectUIHost::BuildButtonBar ( ShuttleGui S,
bool  graphicalUI 
)
private

Definition at line 340 of file EffectUI.cpp.

341{
342 mIsGUI = graphicalUI;
344
345 constexpr int margin = 3;
346
347 S.StartPanel();
348 {
349 S.SetBorder( margin );
350
351 S.StartHorizontalLay(wxEXPAND, 0);
352 {
354 {
356 .Position(wxALIGN_CENTER | wxTOP | wxBOTTOM)
357 .Name(XO("Enable"))
358 .AddBitmapButton(mEnabled ? mRealtimeEnabledBM : mRealtimeDisabledBM);
359 }
360
361 mMenuBtn = S.Id( kMenuID )
362 .ToolTip(XO("Manage presets and options"))
363 .AddButton( XO("Presets && settings"), wxALIGN_CENTER | wxTOP | wxBOTTOM );
364
365 S.AddSpace(1, 0, 1);
366
367 if (!mIsBatch)
368 {
370 {
372 {
374 .ToolTip(XO("Start and stop preview"))
375 .AddButton( { },
376 wxALIGN_CENTER | wxTOP | wxBOTTOM );
377 }
378 }
379 else if (
382 {
384 .ToolTip(XO("Preview effect"))
385 .AddButton( { },
386 wxALIGN_CENTER | wxTOP | wxBOTTOM );
387 }
388 if(mPlayToggleBtn != nullptr)
389 {
390 //wxButton does not implement GetSizeFromText
391 //set button minimum size so that largest text fits
392 mPlayToggleBtn->SetLabel(_("Stop &Preview"));
393 auto a = mPlayToggleBtn->GetBestSize();
394 mPlayToggleBtn->SetLabel(_("&Preview"));
395 auto b = mPlayToggleBtn->GetBestSize();
396 mPlayToggleBtn->SetMinSize(a.x > b.x ? a : b);
397 }
398 }
399
401 {
402 mApplyBtn = S.Id(wxID_APPLY)
403 .AddButton( XXO("&Apply"),
404 wxALIGN_CENTER | wxTOP | wxBOTTOM );
405 mApplyBtn->SetDefault();
406 }
407
409 {
410 mDebugBtn = S.Id(eDebugID)
411 .AddButton( XXO("Debu&g"),
412 wxALIGN_CENTER | wxTOP | wxBOTTOM );
413 }
414 }
415 S.EndHorizontalLay();
416 }
417 S.EndPanel();
418}
@ EffectTypeAnalyze
@ EffectTypeTool
static const int kPlayID
Definition: EffectUI.cpp:131
static const int kEnableID
Definition: EffectUI.cpp:130
static const int kMenuID
Definition: EffectUI.cpp:129
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:75
@ eDebugID
Definition: ShuttleGui.h:616
#define S(N)
Definition: ToChars.cpp:64
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual bool EnablesDebug() const
Whether the effect dialog should have a Debug button; default, always false.
virtual bool IsBatchProcessing() const =0
wxButton * mEnableBtn
Definition: EffectUI.h:138
bool mIsBatch
Definition: EffectUI.h:134
wxButton * mMenuBtn
Definition: EffectUI.h:137
std::shared_ptr< RealtimeEffectState > mpTempProjectState
Definition: EffectUI.h:128
bool mIsGUI
Definition: EffectUI.h:133
wxButton * mPlayToggleBtn
Definition: EffectUI.h:140
wxButton * mApplyBtn
Definition: EffectUI.h:136
bool mEnabled
Definition: EffectUI.h:145
wxButton * mDebugBtn
Definition: EffectUI.h:139
bool IsOpenedFromEffectPanel() const
Definition: EffectUI.cpp:1020
wxBitmap mRealtimeDisabledBM
Definition: EffectUI.h:143
wxBitmap mRealtimeEnabledBM
Definition: EffectUI.h:142

References _, eDebugID, EffectTypeAnalyze, EffectTypeTool, EffectDefinitionInterface::EnablesDebug(), EffectPlugin::GetDefinition(), EffectDefinitionInterface::GetType(), EffectPlugin::IsBatchProcessing(), IsOpenedFromEffectPanel(), kEnableID, kMenuID, kPlayID, mApplyBtn, mDebugBtn, mEffectUIHost, mEnableBtn, mEnabled, mIsBatch, mIsGUI, mMenuBtn, mPlayToggleBtn, mpTempProjectState, mRealtimeDisabledBM, mRealtimeEnabledBM, mSupportsRealtime, S, XO(), and XXO().

Here is the call graph for this function:

◆ BuildButtonBar() [2/2]

wxPanel * EffectUIHost::BuildButtonBar ( wxWindow *  parent,
bool  graphicalUI 
)
private

Referenced by Initialize().

Here is the caller graph for this function:

◆ CleanupRealtime()

void EffectUIHost::CleanupRealtime ( )
private

Definition at line 1170 of file EffectUI.cpp.

1171{
1173
1175 if (!IsOpenedFromEffectPanel()) {
1178 mpTempProjectState.reset();
1179 /*
1180 ProjectHistory::Get(mProject).PushState(
1181 XO("Removed %s effect").Format(mpState->GetEffect()->GetName()),
1182 XO("Removed Effect"),
1183 UndoPush::NONE
1184 );
1185 */
1186 }
1187 mInitialized = false;
1188 }
1189}
static AudioIO * Get()
Definition: AudioIO.cpp:147
void RemoveState(AudacityProject &project, Track *pTrack, std::shared_ptr< RealtimeEffectState > pState)
Forwards to RealtimeEffectManager::RemoveState with proper init scope.
Definition: AudioIO.cpp:390
Observer::Subscription mAudioIOSubscription
Definition: EffectUI.h:116
Observer::Subscription mEffectStateSubscription
Definition: EffectUI.h:116
bool mInitialized
Definition: EffectUI.h:131
void Reset() noexcept
Breaks the connection (constant time)
Definition: Observer.cpp:101

References AudioIO::Get(), IsOpenedFromEffectPanel(), mAudioIOSubscription, mEffectStateSubscription, mInitialized, mProject, mpTempProjectState, mSupportsRealtime, AudioIO::RemoveState(), and Observer::Subscription::Reset().

Referenced by OnClose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateBitmap()

wxBitmap EffectUIHost::CreateBitmap ( const char *const  xpm[],
bool  up,
bool  pusher 
)
private

Definition at line 1025 of file EffectUI.cpp.

1026{
1027 wxMemoryDC dc;
1028 wxBitmap pic(xpm);
1029
1030 wxBitmap mod(pic.GetWidth() + 6, pic.GetHeight() + 6, 24);
1031 dc.SelectObject(mod);
1032
1033#if defined(__WXGTK__)
1034 wxColour newColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND);
1035#else
1036 wxColour newColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
1037#endif
1038
1039 dc.SetBackground(wxBrush(newColour));
1040 dc.Clear();
1041
1042 int offset = 3;
1043 if (pusher)
1044 {
1045 if (!up)
1046 {
1047 offset += 1;
1048 }
1049 }
1050
1051 dc.DrawBitmap(pic, offset, offset, true);
1052
1053 dc.SelectObject(wxNullBitmap);
1054
1055 return mod;
1056}

◆ DoCancel()

void EffectUIHost::DoCancel ( )
private

Definition at line 605 of file EffectUI.cpp.

606{
607 if (!mDismissed) {
608 if (!mHadPriorState) {
609 // For the destructive effect dialog only
610 // Restore effect state from last updated preferences
611 mpAccess->ModifySettings([&](EffectSettings &settings) {
612 // ignore failure
613 return mEffectUIHost.GetDefinition().LoadUserPreset(
614 CurrentSettingsGroup(), settings).value_or(nullptr);
615 });
616 }
617 if (IsModal())
618 EndModal(0);
619 else
620 Hide();
621
622 mDismissed = true;
623 }
624}
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
static Settings & settings()
Definition: TrackInfo.cpp:87
bool mDismissed
Definition: EffectUI.h:154
Externalized state of a plug-in.

References CurrentSettingsGroup(), EffectPlugin::GetDefinition(), mDismissed, mEffectUIHost, mHadPriorState, mpAccess, and settings().

Referenced by OnCancel(), and OnClose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetValidator()

EffectUIValidator * EffectUIHost::GetValidator ( ) const
inline

Definition at line 65 of file EffectUI.h.

65{ return mpValidator.get(); }

References mpValidator.

◆ HandleCommandKeystrokes()

bool EffectUIHost::HandleCommandKeystrokes ( )
overridevirtual

By default returns true, meaning that keystrokes should be handled by associated CommandManager.

Reimplemented from TopLevelKeystrokeHandlingWindow.

Definition at line 480 of file EffectUI.cpp.

481{
482 return !IsModal();
483}

◆ Initialize()

bool EffectUIHost::Initialize ( )

Definition at line 420 of file EffectUI.cpp.

421{
422 mEnabled = mpAccess->Get().extra.GetActive();
423
424 mRealtimeEnabledBM = theTheme.Bitmap(bmpEffectOn);
425 mRealtimeDisabledBM = theTheme.Bitmap(bmpEffectOff);
426
427 // Build a "host" dialog, framing a panel that the client fills in.
428 // The frame includes buttons to preview, apply, load and save presets, etc.
429 EffectPanel *w {};
430 ShuttleGui S{ this, eIsCreating };
431 {
432 // Make the panel for the client
433 Destroy_ptr<EffectPanel> uw{ safenew EffectPanel( S.GetParent() ) };
434 RTL_WORKAROUND(uw.get());
435
436 // Try to give the window a sensible default/minimum size
437 uw->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),
438 mParent->GetSize().GetHeight() / 2));
439
440 // Let the client add things to the panel
441 ShuttleGui S1{ uw.get(), eIsCreating };
443 if (!mpValidator)
444 return false;
445
446 BuildButtonBar(S, mpValidator->IsGraphicalUI());
447
448 S.StartHorizontalLay( wxEXPAND );
449 {
450 S.Prop( 1 )
451 .Position(wxEXPAND)
452 .AddWindow((w = uw.release()));
453 }
454 S.EndHorizontalLay();
455 }
456
457 Layout();
458 Fit();
459 Center();
460
462
463 w->SetAccept(!mIsGUI);
464
465 if (!mIsGUI)
466 {
467 w->SetFocus();
468 }
469 else if (!IsOpenedFromEffectPanel())
470 {
471 mApplyBtn->SetFocus();
472 }
473
475
476 SetMinSize(GetSize());
477 return true;
478}
#define RTL_WORKAROUND(pWnd)
Definition: GUISettings.h:20
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:162
@ eIsCreating
Definition: ShuttleGui.h:39
THEME_API Theme theTheme
Definition: Theme.cpp:82
virtual std::unique_ptr< EffectUIValidator > PopulateUI(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)=0
Adds controls to a panel that is given as the parent window of S
void UpdateControls()
Definition: EffectUI.cpp:1058
wxPanel * BuildButtonBar(wxWindow *parent, bool graphicalUI)
void LoadUserPresets()
Definition: EffectUI.cpp:1094
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
wxBitmap & Bitmap(int iIndex)

References ThemeBase::Bitmap(), BuildButtonBar(), eIsCreating, IsOpenedFromEffectPanel(), LoadUserPresets(), mApplyBtn, mClient, mEnabled, mIsGUI, mpAccess, mParent, mpInstance, mpOutputs, mpValidator, mRealtimeDisabledBM, mRealtimeEnabledBM, EffectUIClientInterface::PopulateUI(), RTL_WORKAROUND, S, safenew, theTheme, and UpdateControls().

Here is the call graph for this function:

◆ InitializeInstance()

std::shared_ptr< EffectInstance > EffectUIHost::InitializeInstance ( )
private

Definition at line 1106 of file EffectUI.cpp.

1107{
1108 // We are still constructing and the return initializes a const member
1109 std::shared_ptr<EffectInstance> result;
1110
1111 auto mpState = mwState.lock();
1112
1113 bool priorState = (mpState != nullptr);
1114 if (!priorState) {
1115 auto gAudioIO = AudioIO::Get();
1116 mDisableTransport = !gAudioIO->IsAvailable(mProject);
1117 mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice
1118 mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0 && !gAudioIO->IsMonitoring();
1119 }
1120
1122 if (!priorState)
1123 mwState = mpState = mpTempProjectState =
1125 if (mpState) {
1126 // Find the right instance to connect to the dialog
1127 if (!result)
1128 result = mpState->GetInstance();
1129
1130 mpAccess2 = mpState->GetAccess();
1131 if (!(mpAccess2->IsSameAs(*mpAccess)))
1132 // Decorate the given access object
1133 mpAccess = std::make_shared<EffectSettingsAccessTee>(
1135
1136 mEffectStateSubscription = mpState->Subscribe([this](RealtimeEffectStateChange state) {
1139
1141 });
1142 }
1143
1144 if (!priorState) {
1146 switch (event.type) {
1147 case AudioIOEvent::PLAYBACK:
1148 OnPlayback(event); break;
1149 case AudioIOEvent::CAPTURE:
1150 OnCapture(event); break;
1151 default:
1152 break;
1153 }
1154 });
1155 }
1156
1157 mInitialized = true;
1158 }
1159 else {
1160 result = mEffectUIHost.MakeInstance();
1161 if (auto pInstanceEx =
1162 std::dynamic_pointer_cast<EffectInstanceEx>(result)
1163 ; pInstanceEx && !pInstanceEx->Init())
1164 result.reset();
1165 }
1166
1167 return result;
1168}
static PluginID GetID(EffectPlugin &effect)
Definition: EffectUI.cpp:33
RealtimeEffectStateChange
std::shared_ptr< RealtimeEffectState > AddState(AudacityProject &project, Track *pTrack, const PluginID &id)
Forwards to RealtimeEffectManager::AddState with proper init scope.
Definition: AudioIO.cpp:369
virtual std::shared_ptr< EffectInstance > MakeInstance() const =0
Make an object maintaining short-term state of an Effect.
bool mCapturing
Definition: EffectUI.h:149
bool mPlaying
Definition: EffectUI.h:148
bool mDisableTransport
Definition: EffectUI.h:147
EffectPlugin::EffectSettingsAccessPtr mpAccess2
Definition: EffectUI.h:125
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
enum AudioIOEvent::Type type

References AudioIO::AddState(), EffectOn, AudioIO::Get(), GetID(), EffectInstanceFactory::MakeInstance(), mAudioIOSubscription, mCapturing, mDisableTransport, mEffectStateSubscription, mEffectUIHost, mEnableBtn, mEnabled, mInitialized, mpAccess, mpAccess2, mPlaying, mProject, mpTempProjectState, mRealtimeDisabledBM, mRealtimeEnabledBM, mSupportsRealtime, mwState, Observer::Publisher< Message, NotifyAll >::Subscribe(), AudioIOEvent::type, and UpdateControls().

Here is the call graph for this function:

◆ IsOpenedFromEffectPanel()

bool EffectUIHost::IsOpenedFromEffectPanel ( ) const
private

Definition at line 1020 of file EffectUI.cpp.

1021{
1022 return (mpTempProjectState == nullptr && mSupportsRealtime);
1023}

References mpTempProjectState, and mSupportsRealtime.

Referenced by BuildButtonBar(), CleanupRealtime(), Initialize(), OnCharHook(), and UpdateControls().

Here is the caller graph for this function:

◆ LoadUserPresets()

void EffectUIHost::LoadUserPresets ( )
private

Definition at line 1094 of file EffectUI.cpp.

1095{
1096 mUserPresets.clear();
1097
1100
1101 std::sort( mUserPresets.begin(), mUserPresets.end() );
1102
1103 return;
1104}
RegistryPath UserPresetsGroup(const RegistryPath &name)
Compute part of a registry path, given a name which may be empty.
RegistryPaths mUserPresets
Definition: EffectUI.h:130
bool GetConfigSubgroups(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group, RegistryPaths &subgroups)

References PluginSettings::GetConfigSubgroups(), EffectPlugin::GetDefinition(), mEffectUIHost, mUserPresets, PluginSettings::Private, and UserPresetsGroup().

Referenced by Initialize(), OnDeletePreset(), OnImport(), OnMenu(), and OnSaveAs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnApply()

void EffectUIHost::OnApply ( wxCommandEvent &  evt)
private

Definition at line 540 of file EffectUI.cpp.

541{
542 auto &project = mProject;
543
544 // On wxGTK (wx2.8.12), the default action is still executed even if
545 // the button is disabled. This appears to affect all wxDialogs, not
546 // just our Effects dialogs. So, this is a only temporary workaround
547 // for legacy effects that disable the OK button. Hopefully this has
548 // been corrected in wx3.
549 if (!mApplyBtn->IsEnabled())
550 {
551 return;
552 }
553
554 if (mPlaying)
555 StopPlayback();
556
557 // Honor the "select all if none" preference...a little hackish, but whatcha gonna do...
558 if (!mIsBatch &&
562 {
563 auto flags = AlwaysEnabledFlag;
564 bool allowed =
567 flags,
569 if (!allowed)
570 return;
571 }
572
573 if (!TransferDataFromWindow() ||
574 // This is the main place where there is a side-effect on the config
575 // file to remember the last-used settings of an effect, just before
576 // applying the effect destructively.
579 return;
580
581 if (IsModal())
582 {
583 mDismissed = true;
584
585 EndModal(evt.GetId());
586
587 Close();
588
589 return;
590 }
591
592 // Progress dialog no longer yields, so this "shouldn't" be necessary (yet to be proven
593 // for sure), but it is a nice visual cue that something is going on.
594 mApplyBtn->Disable();
595 auto cleanup = finally( [&] { mApplyBtn->Enable(); } );
596
597 CommandContext context( project );
598 // This is absolute hackage...but easy and I can't think of another way just now.
599 //
600 // It should callback to the EffectManager to kick off the processing
603}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
@ EffectTypeGenerate
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
virtual bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const =0
Save settings in the configuration file as a user-named preset.
void StopPlayback()
Definition: EffectUI.cpp:1191
bool TransferDataFromWindow() override
Definition: EffectUI.cpp:285
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:69
bool ReportIfActionNotAllowed(const TranslatableString &Name, CommandFlag &flags, CommandFlag flagsRqd)
Definition: Menus.cpp:637
bool isPoint() const
Definition: ViewInfo.h:39
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:217
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:234
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1241

References AlwaysEnabledFlag, CurrentSettingsGroup(), EffectUI::DoEffect(), EffectTypeGenerate, EffectTypeTool, ViewInfo::Get(), MenuManager::Get(), EffectPlugin::GetDefinition(), GetID(), ComponentInterface::GetName(), EffectDefinitionInterface::GetType(), NotifyingSelectedRegion::isPoint(), EffectManager::kConfigured, mApplyBtn, mDismissed, mEffectUIHost, mIsBatch, mpAccess, mPlaying, mProject, MenuManager::ReportIfActionNotAllowed(), EffectSettingsManager::SaveUserPreset(), ViewInfo::selectedRegion, StopPlayback(), TimeSelectedFlag(), TransferDataFromWindow(), and WaveTracksSelectedFlag().

Referenced by OnDebug().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCancel()

void EffectUIHost::OnCancel ( wxCommandEvent &  evt)
private

Definition at line 626 of file EffectUI.cpp.

627{
628 DoCancel();
629 Close();
630}
void DoCancel()
Definition: EffectUI.cpp:605

References DoCancel().

Referenced by OnCharHook().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCapture()

void EffectUIHost::OnCapture ( AudioIOEvent  evt)
private

Definition at line 817 of file EffectUI.cpp.

818{
819 if (evt.on) {
820 if (evt.pProject != &mProject)
821 mDisableTransport = true;
822 else
823 mCapturing = true;
824 }
825 else {
826 mDisableTransport = false;
827 mCapturing = false;
828 }
830}
bool on
Definition: AudioIO.h:77
AudacityProject * pProject
Definition: AudioIO.h:71

References mCapturing, mDisableTransport, mProject, AudioIOEvent::on, AudioIOEvent::pProject, and UpdateControls().

Here is the call graph for this function:

◆ OnCharHook()

void EffectUIHost::OnCharHook ( wxKeyEvent &  evt)
private

Definition at line 1002 of file EffectUI.cpp.

1003{
1004 if (!IsEscapeKey(evt))
1005 {
1006 evt.Skip();
1007 return;
1008 }
1009
1011 Close();
1012 else
1013 {
1014 wxCommandEvent cancelEvt { wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL };
1015
1016 OnCancel(cancelEvt);
1017 }
1018}
wxEVT_COMMAND_BUTTON_CLICKED
void OnCancel(wxCommandEvent &evt)
Definition: EffectUI.cpp:626

References IsOpenedFromEffectPanel(), OnCancel(), and wxEVT_COMMAND_BUTTON_CLICKED.

Here is the call graph for this function:

◆ OnClose()

void EffectUIHost::OnClose ( wxCloseEvent &  evt)
private

Definition at line 521 of file EffectUI.cpp.

522{
523 if (mPlaying)
524 StopPlayback();
525
526 DoCancel();
528
529 if (mpValidator)
530 mpValidator->OnClose();
531
532 Hide();
533 Destroy();
534
535#if wxDEBUG_LEVEL
536 mClosed = true;
537#endif
538}
void CleanupRealtime()
Definition: EffectUI.cpp:1170

References CleanupRealtime(), DoCancel(), mPlaying, mpValidator, and StopPlayback().

Here is the call graph for this function:

◆ OnDebug()

void EffectUIHost::OnDebug ( wxCommandEvent &  evt)
private

Definition at line 632 of file EffectUI.cpp.

633{
634 OnApply(evt);
635}
void OnApply(wxCommandEvent &evt)
Definition: EffectUI.cpp:540

References OnApply().

Here is the call graph for this function:

◆ OnDefaults()

void EffectUIHost::OnDefaults ( wxCommandEvent &  evt)
private

Definition at line 984 of file EffectUI.cpp.

985{
986 mpAccess->ModifySettings([&](EffectSettings &settings){
987 // ignore failure
988 return mEffectUIHost.GetDefinition().LoadFactoryDefaults(settings)
989 .value_or(nullptr);
990 });
992 return;
993}
bool TransferDataToWindow() override
Definition: EffectUI.cpp:275

References EffectPlugin::GetDefinition(), mEffectUIHost, mpAccess, settings(), and TransferDataToWindow().

Here is the call graph for this function:

◆ OnDeletePreset()

void EffectUIHost::OnDeletePreset ( wxCommandEvent &  evt)
private

Definition at line 856 of file EffectUI.cpp.

857{
858 auto preset = mUserPresets[evt.GetId() - kDeletePresetID];
859
860 int res = AudacityMessageBox(
861 XO("Are you sure you want to delete \"%s\"?").Format( preset ),
862 XO("Delete Preset"),
863 wxICON_QUESTION | wxYES_NO);
864 if (res == wxYES)
865 {
868 }
869
871
872 return;
873}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static const int kDeletePresetID
Definition: EffectUI.cpp:135
EffectReverbSettings preset
Definition: Reverb.cpp:45
Abstract base class used in importing a file.
bool RemoveConfigSubgroup(const EffectDefinitionInterface &ident, PluginSettings::ConfigurationType type, const RegistryPath &group)

References AudacityMessageBox(), EffectPlugin::GetDefinition(), kDeletePresetID, LoadUserPresets(), mEffectUIHost, mUserPresets, preset, PluginSettings::Private, PluginSettings::RemoveConfigSubgroup(), UserPresetsGroup(), and XO().

Here is the call graph for this function:

◆ OnEnable()

void EffectUIHost::OnEnable ( wxCommandEvent &  evt)
private

Definition at line 740 of file EffectUI.cpp.

741{
743
744 auto mpState = mwState.lock();
745 if (mpState)
746 mpState->SetActive(mEnabled);
747
749}

References mEnabled, mwState, and UpdateControls().

Here is the call graph for this function:

◆ OnErase()

void EffectUIHost::OnErase ( wxEraseEvent &  evt)
private

Definition at line 509 of file EffectUI.cpp.

510{
511 // Ignore it
512}

◆ OnExport()

void EffectUIHost::OnExport ( wxCommandEvent &  evt)
private

Definition at line 967 of file EffectUI.cpp.

968{
969 // may throw
970 // exceptions are handled in AudacityApp::OnExceptionInMainLoop
973
974 return;
975}
virtual void ExportPresets(const EffectSettings &settings) const =0

References EffectUIClientInterface::ExportPresets(), mClient, mpAccess, and TransferDataFromWindow().

Here is the call graph for this function:

◆ OnFactoryPreset()

void EffectUIHost::OnFactoryPreset ( wxCommandEvent &  evt)
private

ignore failure

Definition at line 845 of file EffectUI.cpp.

846{
847 mpAccess->ModifySettings([&](EffectSettings &settings){
849 return mEffectUIHost.GetDefinition().LoadFactoryPreset(
850 evt.GetId() - kFactoryPresetsID, settings).value_or(nullptr);
851 });
853 return;
854}
static const int kFactoryPresetsID
Definition: EffectUI.cpp:136

References EffectPlugin::GetDefinition(), kFactoryPresetsID, mEffectUIHost, mpAccess, settings(), and TransferDataToWindow().

Here is the call graph for this function:

◆ OnIdle()

void EffectUIHost::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 995 of file EffectUI.cpp.

996{
997 evt.Skip();
998 if (mpAccess)
999 mpAccess->Flush();
1000}

References mpAccess.

◆ OnImport()

void EffectUIHost::OnImport ( wxCommandEvent &  evt)
private

Definition at line 955 of file EffectUI.cpp.

956{
957 mpAccess->ModifySettings([&](EffectSettings &settings){
958 // ignore failure
959 return mClient.ImportPresets(settings).value_or(nullptr);
960 });
963
964 return;
965}
virtual OptionalMessage ImportPresets(EffectSettings &settings)=0

References EffectUIClientInterface::ImportPresets(), LoadUserPresets(), mClient, mpAccess, settings(), and TransferDataToWindow().

Here is the call graph for this function:

◆ OnInitDialog()

void EffectUIHost::OnInitDialog ( wxInitDialogEvent &  evt)
private

Definition at line 486 of file EffectUI.cpp.

487{
488 // Do default handling
489 wxDialogWrapper::OnInitDialog(evt);
490
491#if wxCHECK_VERSION(3, 0, 0)
492 //#warning "check to see if this still needed in wx3"
493#endif
494
495 // Pure hackage coming down the pike...
496 //
497 // I have no idea why, but if a wxTextCtrl is the first control in the
498 // panel, then its contents will not be automatically selected when the
499 // dialog is displayed.
500 //
501 // So, we do the selection manually.
502 wxTextCtrl *focused = wxDynamicCast(FindFocus(), wxTextCtrl);
503 if (focused)
504 {
505 focused->SelectAll();
506 }
507}

◆ OnMenu()

void EffectUIHost::OnMenu ( wxCommandEvent &  evt)
private

Definition at line 648 of file EffectUI.cpp.

649{
650 wxMenu menu;
651 menu.Bind(wxEVT_MENU, [](auto&){}, kUserPresetsDummyID);
652 menu.Bind(wxEVT_MENU, [](auto&){}, kDeletePresetDummyID);
654
655 if (mUserPresets.size() == 0)
656 {
657 menu.Append(kUserPresetsDummyID, _("User Presets"))->Enable(false);
658 }
659 else
660 {
661 auto sub = std::make_unique<wxMenu>();
662 for (size_t i = 0, cnt = mUserPresets.size(); i < cnt; i++)
663 {
664 sub->Append(kUserPresetsID + i, mUserPresets[i]);
665 }
666 menu.Append(0, _("User Presets"), sub.release());
667 }
668
669 menu.Append(kSaveAsID, _("Save Preset..."));
670
671 if (mUserPresets.size() == 0)
672 {
673 menu.Append(kDeletePresetDummyID, _("Delete Preset"))->Enable(false);
674 }
675 else
676 {
677 auto sub = std::make_unique<wxMenu>();
678 for (size_t i = 0, cnt = mUserPresets.size(); i < cnt; i++)
679 {
680 sub->Append(kDeletePresetID + i, mUserPresets[i]);
681 }
682 menu.Append(0, _("Delete Preset"), sub.release());
683 }
684
685 menu.AppendSeparator();
686
688
689 {
690 auto sub = std::make_unique<wxMenu>();
691 sub->Append(kDefaultsID, _("Defaults"));
692 if (factory.size() > 0)
693 {
694 sub->AppendSeparator();
695 for (size_t i = 0, cnt = factory.size(); i < cnt; i++)
696 {
697 auto label = factory[i];
698 if (label.empty())
699 {
700 label = _("None");
701 }
702
703 sub->Append(kFactoryPresetsID + i, label);
704 }
705 }
706 menu.Append(0, _("Factory Presets"), sub.release());
707 }
708
709 menu.AppendSeparator();
710 menu.Append(kImportID, _("Import..."))->Enable(mClient.CanExportPresets());
711 menu.Append(kExportID, _("Export..."))->Enable(mClient.CanExportPresets());
712 menu.AppendSeparator();
713 menu.Append(kOptionsID, _("Options..."))->Enable(mClient.HasOptions());
714 menu.AppendSeparator();
715
716 {
717 auto sub = std::make_unique<wxMenu>();
718
719 auto &definition = mEffectUIHost.GetDefinition();
720 sub->Append(kDummyID, wxString::Format(_("Type: %s"),
721 ::wxGetTranslation( definition.GetFamily().Translation() )));
722 sub->Append(kDummyID, wxString::Format(_("Name: %s"), definition.GetName().Translation()));
723 sub->Append(kDummyID, wxString::Format(_("Version: %s"),
724 GetVersionForDisplay(definition)));
725 sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), definition.GetVendor().Translation()));
726 sub->Append(kDummyID, wxString::Format(_("Description: %s"), definition.GetDescription().Translation()));
727 sub->Bind(wxEVT_MENU, [](auto&){}, kDummyID);
728
729 menu.Append(0, _("About"), sub.release());
730 }
731
732 wxWindow *btn = FindWindow(kMenuID);
733 wxRect r = btn->GetRect();
734 BasicMenu::Handle{ &menu }.Popup(
736 { r.GetLeft(), r.GetBottom() }
737 );
738}
static const int kImportID
Definition: EffectUI.cpp:123
static const int kExportID
Definition: EffectUI.cpp:124
static const int kOptionsID
Definition: EffectUI.cpp:126
static const int kDefaultsID
Definition: EffectUI.cpp:125
static const int kDummyID
Definition: EffectUI.cpp:121
static const int kSaveAsID
Definition: EffectUI.cpp:122
static const int kUserPresetsDummyID
Definition: EffectUI.cpp:127
static const int kDeletePresetDummyID
Definition: EffectUI.cpp:128
static const int kUserPresetsID
Definition: EffectUI.cpp:134
TranslatableString label
Definition: TagsEditor.cpp:164
void Popup(const BasicUI::WindowPlacement &window, const Point &pos={})
Display the menu at pos, invoke at most one action, then hide it.
Definition: BasicMenu.cpp:209
virtual RegistryPaths GetFactoryPresets() const =0
Report names of factory presets.
virtual bool CanExportPresets()=0
virtual bool HasOptions()=0
wxString GetVersionForDisplay(const EffectDefinitionInterface &definition)
Definition: EffectUI.cpp:638
static RegisteredToolbarFactory factory
Window placement information for wxWidgetsBasicUI can be constructed from a wxWindow pointer.

References _, EffectUIClientInterface::CanExportPresets(), TranslatableString::empty(), cloud::factory, EffectPlugin::GetDefinition(), EffectSettingsManager::GetFactoryPresets(), anonymous_namespace{EffectUI.cpp}::GetVersionForDisplay(), EffectUIClientInterface::HasOptions(), kDefaultsID, kDeletePresetDummyID, kDeletePresetID, kDummyID, kExportID, kFactoryPresetsID, kImportID, kMenuID, kOptionsID, kSaveAsID, kUserPresetsDummyID, kUserPresetsID, label, LoadUserPresets(), mClient, mEffectUIHost, mUserPresets, and BasicMenu::Handle::Popup().

Here is the call graph for this function:

◆ OnOptions()

void EffectUIHost::OnOptions ( wxCommandEvent &  evt)
private

Definition at line 977 of file EffectUI.cpp.

978{
980
981 return;
982}
virtual void ShowOptions()=0

References mClient, and EffectUIClientInterface::ShowOptions().

Here is the call graph for this function:

◆ OnPaint()

void EffectUIHost::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 514 of file EffectUI.cpp.

515{
516 wxPaintDC dc(this);
517
518 dc.Clear();
519}

◆ OnPlay()

void EffectUIHost::OnPlay ( wxCommandEvent &  evt)
private

Definition at line 751 of file EffectUI.cpp.

752{
754 {
756 return;
757
759
760 return;
761 }
762
763 if (mPlaying)
764 {
765 StopPlayback();
766 }
767 else
768 {
769 auto &viewInfo = ViewInfo::Get( mProject );
770 const auto &selectedRegion = viewInfo.selectedRegion;
771 const auto &playRegion = viewInfo.playRegion;
772 if ( playRegion.Active() )
773 {
774 mRegion.setTimes(playRegion.GetStart(), playRegion.GetEnd());
775 mPlayPos = mRegion.t0();
776 }
777 else if (selectedRegion.t0() != mRegion.t0() ||
778 selectedRegion.t1() != mRegion.t1())
779 {
780 mRegion = selectedRegion;
781 mPlayPos = mRegion.t0();
782 }
783
784 if (mPlayPos > mRegion.t1())
785 {
786 mPlayPos = mRegion.t1();
787 }
788
789 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
790 projectAudioManager.PlayPlayRegion(
794 }
795}
virtual void Preview(EffectSettingsAccess &access, bool dryOnly)=0
SelectedRegion mRegion
Definition: EffectUI.h:151
double mPlayPos
Definition: EffectUI.h:152
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
static ProjectAudioManager & Get(AudacityProject &project)
Defines a selected portion of a project.
double t1() const
bool setTimes(double t0, double t1)
double t0() const

References ViewInfo::Get(), ProjectAudioManager::Get(), ProjectAudioIO::GetDefaultOptions(), mEffectUIHost, mpAccess, mPlaying, mPlayPos, mProject, mRegion, mSupportsRealtime, normalPlay, EffectPlugin::Preview(), SelectedRegion::setTimes(), StopPlayback(), SelectedRegion::t0(), SelectedRegion::t1(), and TransferDataFromWindow().

Here is the call graph for this function:

◆ OnPlayback()

void EffectUIHost::OnPlayback ( AudioIOEvent  evt)
private

Definition at line 797 of file EffectUI.cpp.

798{
799 if (evt.on) {
800 if (evt.pProject != &mProject)
801 mDisableTransport = true;
802 else
803 mPlaying = true;
804 }
805 else {
806 mDisableTransport = false;
807 mPlaying = false;
808 }
809
810 if (mPlaying) {
812 mPlayPos = mRegion.t0();
813 }
815}

References ViewInfo::Get(), mDisableTransport, mPlaying, mPlayPos, mProject, mRegion, AudioIOEvent::on, AudioIOEvent::pProject, ViewInfo::selectedRegion, SelectedRegion::t0(), and UpdateControls().

Here is the call graph for this function:

◆ OnSaveAs()

void EffectUIHost::OnSaveAs ( wxCommandEvent &  evt)
private

Definition at line 875 of file EffectUI.cpp.

876{
877 wxTextCtrl *text;
878 wxString name;
879 wxDialogWrapper dlg(this, wxID_ANY, XO("Save Preset"));
880
881 ShuttleGui S(&dlg, eIsCreating);
882
883 S.StartPanel();
884 {
885 S.StartVerticalLay(1);
886 {
887 S.StartHorizontalLay(wxALIGN_LEFT, 0);
888 {
889 text = S.AddTextBox(XXO("Preset name:"), name, 30);
890 }
891 S.EndHorizontalLay();
892 S.SetBorder(10);
893 S.AddStandardButtons();
894 }
895 S.EndVerticalLay();
896 }
897 S.EndPanel();
898
899 dlg.SetSize(dlg.GetSizer()->GetMinSize());
900 dlg.Center();
901 dlg.Fit();
902
903 while (true)
904 {
905 int rc = dlg.ShowModal();
906
907 if (rc != wxID_OK)
908 {
909 break;
910 }
911
912 name = text->GetValue();
913 if (name.empty())
914 {
916 this,
917 XO("You must specify a name"),
918 XO("Save Preset") );
919 md.Center();
920 md.ShowModal();
921 continue;
922 }
923
924 if ( make_iterator_range( mUserPresets ).contains( name ) )
925 {
927 this,
928 XO("Preset already exists.\n\nReplace?"),
929 XO("Save Preset"),
930 wxYES_NO | wxCANCEL | wxICON_EXCLAMATION );
931 md.Center();
932 int choice = md.ShowModal();
933 if (choice == wxID_CANCEL)
934 {
935 break;
936 }
937
938 if (choice == wxID_NO)
939 {
940 continue;
941 }
942 }
943
948
949 break;
950 }
951
952 return;
953}
const TranslatableString name
Definition: Distortion.cpp:74
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:431
Wrap wxMessageDialog so that caption IS translatable.

References eIsCreating, TranslatableString::empty(), EffectPlugin::GetDefinition(), LoadUserPresets(), make_iterator_range(), mEffectUIHost, mpAccess, mUserPresets, name, S, EffectSettingsManager::SaveUserPreset(), TransferDataFromWindow(), UserPresetsGroup(), XO(), and XXO().

Here is the call graph for this function:

◆ OnUserPreset()

void EffectUIHost::OnUserPreset ( wxCommandEvent &  evt)
private

Definition at line 832 of file EffectUI.cpp.

833{
834 int preset = evt.GetId() - kUserPresetsID;
835
836 mpAccess->ModifySettings([&](EffectSettings &settings){
837 // ignore failure
838 return mEffectUIHost.GetDefinition().LoadUserPreset(
839 UserPresetsGroup(mUserPresets[preset]), settings).value_or(nullptr);
840 });
842 return;
843}

References EffectPlugin::GetDefinition(), kUserPresetsID, mEffectUIHost, mpAccess, mUserPresets, preset, settings(), TransferDataToWindow(), and UserPresetsGroup().

Here is the call graph for this function:

◆ SetClosed()

void EffectUIHost::SetClosed ( )
inline

Definition at line 69 of file EffectUI.h.

69 {
70#if wxDEBUG_LEVEL
71 mClosed = true;
72#endif
73 }

◆ ShowModal()

int EffectUIHost::ShowModal ( )
override

Definition at line 324 of file EffectUI.cpp.

325{
327 {
328 mApplyBtn->SetLabel(XXO("&Generate").Translation());
329 }
330
331 Layout();
332
333 return wxDialogWrapper::ShowModal();
334}

References EffectTypeGenerate, EffectPlugin::GetDefinition(), EffectDefinitionInterface::GetType(), mApplyBtn, mEffectUIHost, and XXO().

Here is the call graph for this function:

◆ StopPlayback()

void EffectUIHost::StopPlayback ( )
private

Definition at line 1191 of file EffectUI.cpp.

1192{
1193 if (!mPlaying)
1194 return;
1195
1196 auto gAudioIO = AudioIO::Get();
1197 mPlayPos = gAudioIO->GetStreamTime();
1198 auto& projectAudioManager = ProjectAudioManager::Get(mProject);
1199 projectAudioManager.Stop();
1200}

References AudioIO::Get(), ProjectAudioManager::Get(), mPlaying, mPlayPos, and mProject.

Referenced by OnApply(), OnClose(), and OnPlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferDataFromWindow()

bool EffectUIHost::TransferDataFromWindow ( )
override

Do validations of any wxValidator objects

Do transfers of any wxValidator objects

Do other custom validation and transfer actions

Definition at line 285 of file EffectUI.cpp.

286{
288 if (!wxDialogWrapper::Validate())
289 return false;
290
292 if (!wxDialogWrapper::TransferDataFromWindow())
293 return false;
294
296 if (!mpValidator->ValidateUI())
297 return false;
298
299 // Transfer-from takes non-const reference to settings
300 bool result = true;
301 mpAccess->ModifySettings([&](EffectSettings &settings){
302 // Allow other transfers, and reassignment of settings
304 if (result) {
305 auto &definition = mEffectUIHost.GetDefinition();
306 if (definition.GetType() == EffectTypeGenerate) {
307 const auto seconds = settings.extra.GetDuration();
308 // Updating of the last-used generator duration in the config
309 SetConfig(definition, PluginSettings::Private,
310 CurrentSettingsGroup(), EffectSettingsExtra::DurationKey(),
311 seconds);
312 }
313 }
314 return nullptr;
315 });
316 mpAccess->Flush();
317 return result;
318}
virtual bool TransferDataFromWindow(EffectSettings &settings)=0
Update the given settings from controls.

References EffectTypeGenerate, EffectPlugin::GetDefinition(), mEffectUIHost, mpAccess, mpValidator, settings(), and EffectPlugin::TransferDataFromWindow().

Referenced by OnApply(), OnExport(), OnPlay(), and OnSaveAs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferDataToWindow()

bool EffectUIHost::TransferDataToWindow ( )
override

Do other appearance updates

Do validators

Definition at line 275 of file EffectUI.cpp.

276{
277 // Transfer-to takes const reference to settings
280 mpValidator->UpdateUI() &&
282 wxDialogWrapper::TransferDataToWindow();
283}
virtual bool TransferDataToWindow(const EffectSettings &settings)=0
Update controls for the settings.

References mEffectUIHost, mpAccess, mpValidator, and EffectPlugin::TransferDataToWindow().

Referenced by OnDefaults(), OnFactoryPreset(), OnImport(), and OnUserPreset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateControls()

void EffectUIHost::UpdateControls ( )
private

Definition at line 1058 of file EffectUI.cpp.

1059{
1060 if (mIsBatch)
1061 {
1062 return;
1063 }
1064
1066 {
1068 return;
1069 }
1070
1071 mApplyBtn->Enable(!mCapturing);
1072
1074 {
1076
1077 if (mPlaying)
1078 {
1079 /* i18n-hint: The access key "&P" should be the same in
1080 "Stop &Preview" and "Start &Preview" */
1081 mPlayToggleBtn->SetLabel(_("Stop &Preview"));
1082 mPlayToggleBtn->Refresh();
1083 }
1084 else
1085 {
1086 /* i18n-hint: The access key "&P" should be the same in
1087 "Stop &Preview" and "Start &Preview" */
1088 mPlayToggleBtn->SetLabel(_("&Preview"));
1089 mPlayToggleBtn->Refresh();
1090 }
1091 }
1092}

References _, IsOpenedFromEffectPanel(), mApplyBtn, mCapturing, mDisableTransport, mEnableBtn, mEnabled, mIsBatch, mPlaying, mPlayToggleBtn, mRealtimeDisabledBM, mRealtimeEnabledBM, and mSupportsRealtime.

Referenced by Initialize(), InitializeInstance(), OnCapture(), OnEnable(), and OnPlayback().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mApplyBtn

wxButton* EffectUIHost::mApplyBtn {}
private

Definition at line 136 of file EffectUI.h.

Referenced by BuildButtonBar(), Initialize(), OnApply(), ShowModal(), and UpdateControls().

◆ mAudioIOSubscription

Observer::Subscription EffectUIHost::mAudioIOSubscription
private

Definition at line 116 of file EffectUI.h.

Referenced by CleanupRealtime(), and InitializeInstance().

◆ mCapturing

bool EffectUIHost::mCapturing {}
private

Definition at line 149 of file EffectUI.h.

Referenced by InitializeInstance(), OnCapture(), and UpdateControls().

◆ mClient

EffectUIClientInterface& EffectUIHost::mClient
private

Definition at line 121 of file EffectUI.h.

Referenced by Initialize(), OnExport(), OnImport(), OnMenu(), and OnOptions().

◆ mDebugBtn

wxButton* EffectUIHost::mDebugBtn {}
private

Definition at line 139 of file EffectUI.h.

Referenced by BuildButtonBar().

◆ mDisableTransport

bool EffectUIHost::mDisableTransport { true }
private

Definition at line 147 of file EffectUI.h.

Referenced by InitializeInstance(), OnCapture(), OnPlayback(), and UpdateControls().

◆ mDismissed

bool EffectUIHost::mDismissed {}
private

Definition at line 154 of file EffectUI.h.

Referenced by DoCancel(), and OnApply().

◆ mEffectStateSubscription

Observer::Subscription EffectUIHost::mEffectStateSubscription
private

Definition at line 116 of file EffectUI.h.

Referenced by CleanupRealtime(), and InitializeInstance().

◆ mEffectUIHost

EffectPlugin& EffectUIHost::mEffectUIHost
private

◆ mEnableBtn

wxButton* EffectUIHost::mEnableBtn {}
private

Definition at line 138 of file EffectUI.h.

Referenced by BuildButtonBar(), InitializeInstance(), and UpdateControls().

◆ mEnabled

bool EffectUIHost::mEnabled { true }
private

Definition at line 145 of file EffectUI.h.

Referenced by BuildButtonBar(), Initialize(), InitializeInstance(), OnEnable(), and UpdateControls().

◆ mHadPriorState

const bool EffectUIHost::mHadPriorState
private

Definition at line 155 of file EffectUI.h.

Referenced by DoCancel().

◆ mInitialized

bool EffectUIHost::mInitialized { false }
private

Definition at line 131 of file EffectUI.h.

Referenced by CleanupRealtime(), and InitializeInstance().

◆ mIsBatch

bool EffectUIHost::mIsBatch {}
private

Definition at line 134 of file EffectUI.h.

Referenced by BuildButtonBar(), OnApply(), and UpdateControls().

◆ mIsGUI

bool EffectUIHost::mIsGUI {}
private

Definition at line 133 of file EffectUI.h.

Referenced by BuildButtonBar(), and Initialize().

◆ mMenuBtn

wxButton* EffectUIHost::mMenuBtn {}
private

Definition at line 137 of file EffectUI.h.

Referenced by BuildButtonBar().

◆ mpAccess

EffectPlugin::EffectSettingsAccessPtr EffectUIHost::mpAccess
private

◆ mpAccess2

EffectPlugin::EffectSettingsAccessPtr EffectUIHost::mpAccess2
private

Definition at line 125 of file EffectUI.h.

Referenced by InitializeInstance().

◆ mParent

wxWindow* const EffectUIHost::mParent
private

Definition at line 119 of file EffectUI.h.

Referenced by Initialize().

◆ mpGivenAccess

const EffectPlugin::EffectSettingsAccessPtr EffectUIHost::mpGivenAccess
private
Invariant
not null

Definition at line 123 of file EffectUI.h.

◆ mpInstance

const std::shared_ptr<EffectInstance> EffectUIHost::mpInstance
private

Definition at line 162 of file EffectUI.h.

Referenced by EffectUIHost(), and Initialize().

◆ mPlaying

bool EffectUIHost::mPlaying {}
private

◆ mPlayPos

double EffectUIHost::mPlayPos { 0.0 }
private

Definition at line 152 of file EffectUI.h.

Referenced by OnPlay(), OnPlayback(), and StopPlayback().

◆ mPlayToggleBtn

wxButton* EffectUIHost::mPlayToggleBtn {}
private

Definition at line 140 of file EffectUI.h.

Referenced by BuildButtonBar(), and UpdateControls().

◆ mpOutputs

const EffectOutputs* const EffectUIHost::mpOutputs
private

Definition at line 163 of file EffectUI.h.

Referenced by Initialize().

◆ mProject

AudacityProject& EffectUIHost::mProject
private

◆ mpTempProjectState

std::shared_ptr<RealtimeEffectState> EffectUIHost::mpTempProjectState {}
private

◆ mpValidator

std::unique_ptr<EffectUIValidator> EffectUIHost::mpValidator
private

◆ mRealtimeDisabledBM

wxBitmap EffectUIHost::mRealtimeDisabledBM
private

Definition at line 143 of file EffectUI.h.

Referenced by BuildButtonBar(), Initialize(), InitializeInstance(), and UpdateControls().

◆ mRealtimeEnabledBM

wxBitmap EffectUIHost::mRealtimeEnabledBM
private

Definition at line 142 of file EffectUI.h.

Referenced by BuildButtonBar(), Initialize(), InitializeInstance(), and UpdateControls().

◆ mRegion

SelectedRegion EffectUIHost::mRegion
private

Definition at line 151 of file EffectUI.h.

Referenced by OnPlay(), and OnPlayback().

◆ mSupportsRealtime

const bool EffectUIHost::mSupportsRealtime
private

◆ mUserPresets

RegistryPaths EffectUIHost::mUserPresets
private

Definition at line 130 of file EffectUI.h.

Referenced by LoadUserPresets(), OnDeletePreset(), OnMenu(), OnSaveAs(), and OnUserPreset().

◆ mwState

std::weak_ptr<RealtimeEffectState> EffectUIHost::mwState {}
private

Definition at line 126 of file EffectUI.h.

Referenced by InitializeInstance(), and OnEnable().


The documentation for this class was generated from the following files: