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 {}
 
std::unique_ptr< EffectUIValidatormpValidator
 
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
 

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 211 of file EffectUI.cpp.

216: wxDialogWrapper(parent, wxID_ANY, effect.GetDefinition().GetName(),
217 wxDefaultPosition, wxDefaultSize,
218 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX)
219, mEffectUIHost{ effect }
220, mClient{ client }
221// Grab a pointer to the access object,
222// extending its lifetime while this remains:
223, mpGivenAccess{ access.shared_from_this() }
225, mwState{ pPriorState }
226, mProject{ project }
227, mParent{ parent }
229, mHadPriorState{ (pPriorState != nullptr) }
231{
232 // Assign the out parameter
233 pInstance = mpInstance;
234#if defined(__WXMAC__)
235 // Make sure the effect window actually floats above the main window
236 [ [((NSView *)GetHandle()) window] setLevel:NSFloatingWindowLevel];
237#endif
238
239 SetName( effect.GetDefinition().GetName() );
240
241 // This style causes Validate() and TransferDataFromWindow() to visit
242 // sub-windows recursively, applying any wxValidators
243 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
244}
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
EffectUIClientInterface & mClient
Definition: EffectUI.h:121
const bool mHadPriorState
Definition: EffectUI.h:156
std::shared_ptr< EffectInstance > InitializeInstance()
Definition: EffectUI.cpp:1082
const bool mSupportsRealtime
Definition: EffectUI.h:133
const std::shared_ptr< EffectInstance > mpInstance
Definition: EffectUI.h:163
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 246 of file EffectUI.cpp.

247{
248 if (mpValidator)
249 mpValidator->Disconnect();
250 DestroyChildren();
251 wxASSERT(mClosed);
252}
std::unique_ptr< EffectUIValidator > mpValidator
Definition: EffectUI.h:129

References mpValidator.

Member Function Documentation

◆ BuildButtonBar() [1/2]

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

Definition at line 322 of file EffectUI.cpp.

323{
324 mIsGUI = graphicalUI;
326
327 constexpr int margin = 3;
328
329 S.StartPanel();
330 {
331 S.SetBorder( margin );
332
333 S.StartHorizontalLay(wxEXPAND, 0);
334 {
336 {
338 .Position(wxALIGN_CENTER | wxTOP | wxBOTTOM)
339 .Name(XO("Enable"))
340 .AddBitmapButton(mEnabled ? mRealtimeEnabledBM : mRealtimeDisabledBM);
341 }
342
343 mMenuBtn = S.Id( kMenuID )
344 .ToolTip(XO("Manage presets and options"))
345 .AddButton( XO("Presets && settings"), wxALIGN_CENTER | wxTOP | wxBOTTOM );
346
347 S.AddSpace(1, 0, 1);
348
349 if (!mIsBatch)
350 {
352 {
354 {
356 .ToolTip(XO("Start and stop preview"))
357 .AddButton( { },
358 wxALIGN_CENTER | wxTOP | wxBOTTOM );
359 }
360 }
361 else if (
364 {
366 .ToolTip(XO("Preview effect"))
367 .AddButton( { },
368 wxALIGN_CENTER | wxTOP | wxBOTTOM );
369 }
370 if(mPlayToggleBtn != nullptr)
371 {
372 //wxButton does not implement GetSizeFromText
373 //set button minimum size so that largest text fits
374 mPlayToggleBtn->SetLabel(_("Stop &Preview"));
375 auto a = mPlayToggleBtn->GetBestSize();
376 mPlayToggleBtn->SetLabel(_("&Preview"));
377 auto b = mPlayToggleBtn->GetBestSize();
378 mPlayToggleBtn->SetMinSize(a.x > b.x ? a : b);
379 }
380 }
381
383 {
384 mApplyBtn = S.Id(wxID_APPLY)
385 .AddButton( XXO("&Apply"),
386 wxALIGN_CENTER | wxTOP | wxBOTTOM );
387 mApplyBtn->SetDefault();
388 }
389
391 {
392 mDebugBtn = S.Id(eDebugID)
393 .AddButton( XXO("Debu&g"),
394 wxALIGN_CENTER | wxTOP | wxBOTTOM );
395 }
396 }
397 S.EndHorizontalLay();
398 }
399 S.EndPanel();
400}
@ EffectTypeAnalyze
@ EffectTypeTool
static const int kPlayID
Definition: EffectUI.cpp:129
static const int kEnableID
Definition: EffectUI.cpp:128
static const int kMenuID
Definition: EffectUI.cpp:127
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
#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:139
bool mIsBatch
Definition: EffectUI.h:135
wxButton * mMenuBtn
Definition: EffectUI.h:138
std::shared_ptr< RealtimeEffectState > mpTempProjectState
Definition: EffectUI.h:128
bool mIsGUI
Definition: EffectUI.h:134
wxButton * mPlayToggleBtn
Definition: EffectUI.h:141
wxButton * mApplyBtn
Definition: EffectUI.h:137
bool mEnabled
Definition: EffectUI.h:146
wxButton * mDebugBtn
Definition: EffectUI.h:140
bool IsOpenedFromEffectPanel() const
Definition: EffectUI.cpp:996
wxBitmap mRealtimeDisabledBM
Definition: EffectUI.h:144
wxBitmap mRealtimeEnabledBM
Definition: EffectUI.h:143

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 1147 of file EffectUI.cpp.

1148{
1150
1152 if (!IsOpenedFromEffectPanel()) {
1155 mpTempProjectState.reset();
1156 /*
1157 ProjectHistory::Get(mProject).PushState(
1158 XO("Removed %s effect").Format(mpState->GetEffect()->GetName()),
1159 XO("Removed Effect"),
1160 UndoPush::NONE
1161 );
1162 */
1163 }
1164 mInitialized = false;
1165 }
1166}
static AudioIO * Get()
Definition: AudioIO.cpp:133
void RemoveState(AudacityProject &project, Track *pTrack, std::shared_ptr< RealtimeEffectState > pState)
Forwards to RealtimeEffectManager::RemoveState with proper init scope.
Definition: AudioIO.cpp:373
Observer::Subscription mAudioIOSubscription
Definition: EffectUI.h:116
Observer::Subscription mEffectStateSubscription
Definition: EffectUI.h:116
bool mInitialized
Definition: EffectUI.h:132
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 1001 of file EffectUI.cpp.

1002{
1003 wxMemoryDC dc;
1004 wxBitmap pic(xpm);
1005
1006 wxBitmap mod(pic.GetWidth() + 6, pic.GetHeight() + 6, 24);
1007 dc.SelectObject(mod);
1008
1009#if defined(__WXGTK__)
1010 wxColour newColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND);
1011#else
1012 wxColour newColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
1013#endif
1014
1015 dc.SetBackground(wxBrush(newColour));
1016 dc.Clear();
1017
1018 int offset = 3;
1019 if (pusher)
1020 {
1021 if (!up)
1022 {
1023 offset += 1;
1024 }
1025 }
1026
1027 dc.DrawBitmap(pic, offset, offset, true);
1028
1029 dc.SelectObject(wxNullBitmap);
1030
1031 return mod;
1032}

◆ DoCancel()

void EffectUIHost::DoCancel ( )
private

Definition at line 587 of file EffectUI.cpp.

588{
589 if (!mDismissed) {
590 if (!mHadPriorState) {
591 // For the destructive effect dialog only
592 // Restore effect state from last updated preferences
593 mpAccess->ModifySettings([&](EffectSettings &settings) {
595 .LoadUserPreset(CurrentSettingsGroup(), settings);
596 });
597 }
598 if (IsModal())
599 EndModal(0);
600 else
601 Hide();
602
603 mDismissed = true;
604 }
605}
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:155
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 462 of file EffectUI.cpp.

463{
464 return !IsModal();
465}

◆ Initialize()

bool EffectUIHost::Initialize ( )

Definition at line 402 of file EffectUI.cpp.

403{
404 mEnabled = mpAccess->Get().extra.GetActive();
405
406 mRealtimeEnabledBM = theTheme.Bitmap(bmpEffectOn);
407 mRealtimeDisabledBM = theTheme.Bitmap(bmpEffectOff);
408
409 // Build a "host" dialog, framing a panel that the client fills in.
410 // The frame includes buttons to preview, apply, load and save presets, etc.
411 EffectPanel *w {};
412 ShuttleGui S{ this, eIsCreating };
413 {
414 // Make the panel for the client
415 Destroy_ptr<EffectPanel> uw{ safenew EffectPanel( S.GetParent() ) };
416 RTL_WORKAROUND(uw.get());
417
418 // Try to give the window a sensible default/minimum size
419 uw->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),
420 mParent->GetSize().GetHeight() / 2));
421
422 // Let the client add things to the panel
423 ShuttleGui S1{ uw.get(), eIsCreating };
425 if (!mpValidator)
426 return false;
427
428 BuildButtonBar(S, mpValidator->IsGraphicalUI());
429
430 S.StartHorizontalLay( wxEXPAND );
431 {
432 S.Prop( 1 )
433 .Position(wxEXPAND)
434 .AddWindow((w = uw.release()));
435 }
436 S.EndHorizontalLay();
437 }
438
439 Layout();
440 Fit();
441 Center();
442
444
445 w->SetAccept(!mIsGUI);
446
447 if (!mIsGUI)
448 {
449 w->SetFocus();
450 }
451 else if (!IsOpenedFromEffectPanel())
452 {
453 mApplyBtn->SetFocus();
454 }
455
457
458 SetMinSize(GetSize());
459 return true;
460}
#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)=0
Adds controls to a panel that is given as the parent window of S
void UpdateControls()
Definition: EffectUI.cpp:1034
wxPanel * BuildButtonBar(wxWindow *parent, bool graphicalUI)
void LoadUserPresets()
Definition: EffectUI.cpp:1070
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, 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 1082 of file EffectUI.cpp.

1083{
1084 // We are still constructing and the return initializes a const member
1085 std::shared_ptr<EffectInstance> result;
1086
1087 auto mpState = mwState.lock();
1088
1089 bool priorState = (mpState != nullptr);
1090 if (!priorState) {
1091 auto gAudioIO = AudioIO::Get();
1092 mDisableTransport = !gAudioIO->IsAvailable(mProject);
1093 mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice
1094 mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0 && !gAudioIO->IsMonitoring();
1095 }
1096
1098 if (!priorState)
1099 mwState = mpState = mpTempProjectState =
1101 if (mpState) {
1102 // Find the right instance to connect to the dialog
1103 if (!result) {
1104 result = mpState->GetInstance();
1105 if (result && !result->Init())
1106 result.reset();
1107 }
1108
1109 mpAccess2 = mpState->GetAccess();
1110 if (!(mpAccess2->IsSameAs(*mpAccess)))
1111 // Decorate the given access object
1112 mpAccess = std::make_shared<EffectSettingsAccessTee>(
1114
1115 mEffectStateSubscription = mpState->Subscribe([this](RealtimeEffectStateChange state) {
1118
1120 });
1121 }
1122
1123 if (!priorState) {
1125 switch (event.type) {
1126 case AudioIOEvent::PLAYBACK:
1127 OnPlayback(event); break;
1128 case AudioIOEvent::CAPTURE:
1129 OnCapture(event); break;
1130 default:
1131 break;
1132 }
1133 });
1134 }
1135
1136 mInitialized = true;
1137 }
1138 else {
1139 result = mEffectUIHost.MakeInstance();
1140 if (result && !result->Init())
1141 result.reset();
1142 }
1143
1144 return result;
1145}
static PluginID GetID(EffectPlugin &effect)
Definition: EffectUI.cpp:31
RealtimeEffectStateChange
std::shared_ptr< RealtimeEffectState > AddState(AudacityProject &project, Track *pTrack, const PluginID &id)
Forwards to RealtimeEffectManager::AddState with proper init scope.
Definition: AudioIO.cpp:352
virtual std::shared_ptr< EffectInstance > MakeInstance() const =0
Make an object maintaining short-term state of an Effect.
bool mCapturing
Definition: EffectUI.h:150
bool mPlaying
Definition: EffectUI.h:149
bool mDisableTransport
Definition: EffectUI.h:148
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 996 of file EffectUI.cpp.

997{
998 return (mpTempProjectState == nullptr && mSupportsRealtime);
999}

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 1070 of file EffectUI.cpp.

1071{
1072 mUserPresets.clear();
1073
1076
1077 std::sort( mUserPresets.begin(), mUserPresets.end() );
1078
1079 return;
1080}
RegistryPath UserPresetsGroup(const RegistryPath &name)
Compute part of a registry path, given a name which may be empty.
RegistryPaths mUserPresets
Definition: EffectUI.h:131
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 522 of file EffectUI.cpp.

523{
524 auto &project = mProject;
525
526 // On wxGTK (wx2.8.12), the default action is still executed even if
527 // the button is disabled. This appears to affect all wxDialogs, not
528 // just our Effects dialogs. So, this is a only temporary workaround
529 // for legacy effects that disable the OK button. Hopefully this has
530 // been corrected in wx3.
531 if (!mApplyBtn->IsEnabled())
532 {
533 return;
534 }
535
536 if (mPlaying)
537 StopPlayback();
538
539 // Honor the "select all if none" preference...a little hackish, but whatcha gonna do...
540 if (!mIsBatch &&
544 {
545 auto flags = AlwaysEnabledFlag;
546 bool allowed =
549 flags,
551 if (!allowed)
552 return;
553 }
554
555 if (!TransferDataFromWindow() ||
556 // This is the main place where there is a side-effect on the config
557 // file to remember the last-used settings of an effect, just before
558 // applying the effect destructively.
561 return;
562
563 if (IsModal())
564 {
565 mDismissed = true;
566
567 EndModal(evt.GetId());
568
569 Close();
570
571 return;
572 }
573
574 // Progress dialog no longer yields, so this "shouldn't" be necessary (yet to be proven
575 // for sure), but it is a nice visual cue that something is going on.
576 mApplyBtn->Disable();
577 auto cleanup = finally( [&] { mApplyBtn->Enable(); } );
578
579 CommandContext context( project );
580 // This is absolute hackage...but easy and I can't think of another way just now.
581 //
582 // It should callback to the EffectManager to kick off the processing
585}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:35
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:1168
bool TransferDataFromWindow() override
Definition: EffectUI.cpp:268
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:71
bool ReportIfActionNotAllowed(const TranslatableString &Name, CommandFlag &flags, CommandFlag flagsRqd)
Definition: Menus.cpp:705
bool isPoint() const
Definition: ViewInfo.h:39
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1218

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 607 of file EffectUI.cpp.

608{
609 DoCancel();
610 Close();
611}
void DoCancel()
Definition: EffectUI.cpp:587

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 798 of file EffectUI.cpp.

799{
800 if (evt.on) {
801 if (evt.pProject != &mProject)
802 mDisableTransport = true;
803 else
804 mCapturing = true;
805 }
806 else {
807 mDisableTransport = false;
808 mCapturing = false;
809 }
811}
bool on
Definition: AudioIO.h:75
AudacityProject * pProject
Definition: AudioIO.h:69

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 978 of file EffectUI.cpp.

979{
980 if (!IsEscapeKey(evt))
981 {
982 evt.Skip();
983 return;
984 }
985
987 Close();
988 else
989 {
990 wxCommandEvent cancelEvt { wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL };
991
992 OnCancel(cancelEvt);
993 }
994}
wxEVT_COMMAND_BUTTON_CLICKED
void OnCancel(wxCommandEvent &evt)
Definition: EffectUI.cpp:607

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 503 of file EffectUI.cpp.

504{
505 if (mPlaying)
506 StopPlayback();
507
508 DoCancel();
510
511 if (mpValidator)
512 mpValidator->OnClose();
513
514 Hide();
515 Destroy();
516
517#if wxDEBUG_LEVEL
518 mClosed = true;
519#endif
520}
void CleanupRealtime()
Definition: EffectUI.cpp:1147

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 613 of file EffectUI.cpp.

614{
615 OnApply(evt);
616}
void OnApply(wxCommandEvent &evt)
Definition: EffectUI.cpp:522

References OnApply().

Here is the call graph for this function:

◆ OnDefaults()

void EffectUIHost::OnDefaults ( wxCommandEvent &  evt)
private

Definition at line 962 of file EffectUI.cpp.

963{
964 mpAccess->ModifySettings([&](EffectSettings &settings){
965 mEffectUIHost.GetDefinition().LoadFactoryDefaults(settings);
966 });
968 return;
969}
bool TransferDataToWindow() override
Definition: EffectUI.cpp:258

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 835 of file EffectUI.cpp.

836{
837 auto preset = mUserPresets[evt.GetId() - kDeletePresetID];
838
839 int res = AudacityMessageBox(
840 XO("Are you sure you want to delete \"%s\"?").Format( preset ),
841 XO("Delete Preset"),
842 wxICON_QUESTION | wxYES_NO);
843 if (res == wxYES)
844 {
847 }
848
850
851 return;
852}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static const int kDeletePresetID
Definition: EffectUI.cpp:133
EffectReverbSettings preset
Definition: Reverb.cpp:46
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 721 of file EffectUI.cpp.

722{
724
725 auto mpState = mwState.lock();
726 if (mpState)
727 mpState->SetActive(mEnabled);
728
730}

References mEnabled, mwState, and UpdateControls().

Here is the call graph for this function:

◆ OnErase()

void EffectUIHost::OnErase ( wxEraseEvent &  evt)
private

Definition at line 491 of file EffectUI.cpp.

492{
493 // Ignore it
494}

◆ OnExport()

void EffectUIHost::OnExport ( wxCommandEvent &  evt)
private

Definition at line 945 of file EffectUI.cpp.

946{
947 // may throw
948 // exceptions are handled in AudacityApp::OnExceptionInMainLoop
951
952 return;
953}
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

Definition at line 825 of file EffectUI.cpp.

826{
827 mpAccess->ModifySettings([&](EffectSettings &settings){
829 .LoadFactoryPreset(evt.GetId() - kFactoryPresetsID, settings);
830 });
832 return;
833}
static const int kFactoryPresetsID
Definition: EffectUI.cpp:134

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 971 of file EffectUI.cpp.

972{
973 evt.Skip();
974 if (mpAccess)
975 mpAccess->Flush();
976}

References mpAccess.

◆ OnImport()

void EffectUIHost::OnImport ( wxCommandEvent &  evt)
private

Definition at line 934 of file EffectUI.cpp.

935{
936 mpAccess->ModifySettings([&](EffectSettings &settings){
938 });
941
942 return;
943}
virtual void 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 468 of file EffectUI.cpp.

469{
470 // Do default handling
471 wxDialogWrapper::OnInitDialog(evt);
472
473#if wxCHECK_VERSION(3, 0, 0)
474 //#warning "check to see if this still needed in wx3"
475#endif
476
477 // Pure hackage coming down the pike...
478 //
479 // I have no idea why, but if a wxTextCtrl is the first control in the
480 // panel, then its contents will not be automatically selected when the
481 // dialog is displayed.
482 //
483 // So, we do the selection manually.
484 wxTextCtrl *focused = wxDynamicCast(FindFocus(), wxTextCtrl);
485 if (focused)
486 {
487 focused->SelectAll();
488 }
489}

◆ OnMenu()

void EffectUIHost::OnMenu ( wxCommandEvent &  evt)
private

Definition at line 629 of file EffectUI.cpp.

630{
631 wxMenu menu;
632 menu.Bind(wxEVT_MENU, [](auto&){}, kUserPresetsDummyID);
633 menu.Bind(wxEVT_MENU, [](auto&){}, kDeletePresetDummyID);
635
636 if (mUserPresets.size() == 0)
637 {
638 menu.Append(kUserPresetsDummyID, _("User Presets"))->Enable(false);
639 }
640 else
641 {
642 auto sub = std::make_unique<wxMenu>();
643 for (size_t i = 0, cnt = mUserPresets.size(); i < cnt; i++)
644 {
645 sub->Append(kUserPresetsID + i, mUserPresets[i]);
646 }
647 menu.Append(0, _("User Presets"), sub.release());
648 }
649
650 menu.Append(kSaveAsID, _("Save Preset..."));
651
652 if (mUserPresets.size() == 0)
653 {
654 menu.Append(kDeletePresetDummyID, _("Delete Preset"))->Enable(false);
655 }
656 else
657 {
658 auto sub = std::make_unique<wxMenu>();
659 for (size_t i = 0, cnt = mUserPresets.size(); i < cnt; i++)
660 {
661 sub->Append(kDeletePresetID + i, mUserPresets[i]);
662 }
663 menu.Append(0, _("Delete Preset"), sub.release());
664 }
665
666 menu.AppendSeparator();
667
669
670 {
671 auto sub = std::make_unique<wxMenu>();
672 sub->Append(kDefaultsID, _("Defaults"));
673 if (factory.size() > 0)
674 {
675 sub->AppendSeparator();
676 for (size_t i = 0, cnt = factory.size(); i < cnt; i++)
677 {
678 auto label = factory[i];
679 if (label.empty())
680 {
681 label = _("None");
682 }
683
684 sub->Append(kFactoryPresetsID + i, label);
685 }
686 }
687 menu.Append(0, _("Factory Presets"), sub.release());
688 }
689
690 menu.AppendSeparator();
691 menu.Append(kImportID, _("Import..."))->Enable(mClient.CanExportPresets());
692 menu.Append(kExportID, _("Export..."))->Enable(mClient.CanExportPresets());
693 menu.AppendSeparator();
694 menu.Append(kOptionsID, _("Options..."))->Enable(mClient.HasOptions());
695 menu.AppendSeparator();
696
697 {
698 auto sub = std::make_unique<wxMenu>();
699
700 auto &definition = mEffectUIHost.GetDefinition();
701 sub->Append(kDummyID, wxString::Format(_("Type: %s"),
702 ::wxGetTranslation( definition.GetFamily().Translation() )));
703 sub->Append(kDummyID, wxString::Format(_("Name: %s"), definition.GetName().Translation()));
704 sub->Append(kDummyID, wxString::Format(_("Version: %s"),
705 GetVersionForDisplay(definition)));
706 sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), definition.GetVendor().Translation()));
707 sub->Append(kDummyID, wxString::Format(_("Description: %s"), definition.GetDescription().Translation()));
708 sub->Bind(wxEVT_MENU, [](auto&){}, kDummyID);
709
710 menu.Append(0, _("About"), sub.release());
711 }
712
713 wxWindow *btn = FindWindow(kMenuID);
714 wxRect r = btn->GetRect();
715 BasicMenu::Handle{ &menu }.Popup(
717 { r.GetLeft(), r.GetBottom() }
718 );
719}
static const int kImportID
Definition: EffectUI.cpp:121
static const int kExportID
Definition: EffectUI.cpp:122
static const int kOptionsID
Definition: EffectUI.cpp:124
static const int kDefaultsID
Definition: EffectUI.cpp:123
static const int kDummyID
Definition: EffectUI.cpp:119
static const int kSaveAsID
Definition: EffectUI.cpp:120
static const int kUserPresetsDummyID
Definition: EffectUI.cpp:125
static const int kDeletePresetDummyID
Definition: EffectUI.cpp:126
static const int kUserPresetsID
Definition: EffectUI.cpp:132
TranslatableString label
Definition: TagsEditor.cpp:163
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:619
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 955 of file EffectUI.cpp.

956{
958
959 return;
960}
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 496 of file EffectUI.cpp.

497{
498 wxPaintDC dc(this);
499
500 dc.Clear();
501}

◆ OnPlay()

void EffectUIHost::OnPlay ( wxCommandEvent &  evt)
private

Definition at line 732 of file EffectUI.cpp.

733{
735 {
737 return;
738
740
741 return;
742 }
743
744 if (mPlaying)
745 {
746 StopPlayback();
747 }
748 else
749 {
750 auto &viewInfo = ViewInfo::Get( mProject );
751 const auto &selectedRegion = viewInfo.selectedRegion;
752 const auto &playRegion = viewInfo.playRegion;
753 if ( playRegion.Active() )
754 {
755 mRegion.setTimes(playRegion.GetStart(), playRegion.GetEnd());
756 mPlayPos = mRegion.t0();
757 }
758 else if (selectedRegion.t0() != mRegion.t0() ||
759 selectedRegion.t1() != mRegion.t1())
760 {
761 mRegion = selectedRegion;
762 mPlayPos = mRegion.t0();
763 }
764
765 if (mPlayPos > mRegion.t1())
766 {
767 mPlayPos = mRegion.t1();
768 }
769
770 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
771 projectAudioManager.PlayPlayRegion(
775 }
776}
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool newDefault)
virtual void Preview(EffectSettingsAccess &access, bool dryOnly)=0
SelectedRegion mRegion
Definition: EffectUI.h:152
double mPlayPos
Definition: EffectUI.h:153
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 DefaultPlayOptions(), ViewInfo::Get(), ProjectAudioManager::Get(), 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 778 of file EffectUI.cpp.

779{
780 if (evt.on) {
781 if (evt.pProject != &mProject)
782 mDisableTransport = true;
783 else
784 mPlaying = true;
785 }
786 else {
787 mDisableTransport = false;
788 mPlaying = false;
789 }
790
791 if (mPlaying) {
793 mPlayPos = mRegion.t0();
794 }
796}

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 854 of file EffectUI.cpp.

855{
856 wxTextCtrl *text;
857 wxString name;
858 wxDialogWrapper dlg(this, wxID_ANY, XO("Save Preset"));
859
860 ShuttleGui S(&dlg, eIsCreating);
861
862 S.StartPanel();
863 {
864 S.StartVerticalLay(1);
865 {
866 S.StartHorizontalLay(wxALIGN_LEFT, 0);
867 {
868 text = S.AddTextBox(XXO("Preset name:"), name, 30);
869 }
870 S.EndHorizontalLay();
871 S.SetBorder(10);
872 S.AddStandardButtons();
873 }
874 S.EndVerticalLay();
875 }
876 S.EndPanel();
877
878 dlg.SetSize(dlg.GetSizer()->GetMinSize());
879 dlg.Center();
880 dlg.Fit();
881
882 while (true)
883 {
884 int rc = dlg.ShowModal();
885
886 if (rc != wxID_OK)
887 {
888 break;
889 }
890
891 name = text->GetValue();
892 if (name.empty())
893 {
895 this,
896 XO("You must specify a name"),
897 XO("Save Preset") );
898 md.Center();
899 md.ShowModal();
900 continue;
901 }
902
903 if ( make_iterator_range( mUserPresets ).contains( name ) )
904 {
906 this,
907 XO("Preset already exists.\n\nReplace?"),
908 XO("Save Preset"),
909 wxYES_NO | wxCANCEL | wxICON_EXCLAMATION );
910 md.Center();
911 int choice = md.ShowModal();
912 if (choice == wxID_CANCEL)
913 {
914 break;
915 }
916
917 if (choice == wxID_NO)
918 {
919 continue;
920 }
921 }
922
927
928 break;
929 }
930
931 return;
932}
const TranslatableString name
Definition: Distortion.cpp:82
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 813 of file EffectUI.cpp.

814{
815 int preset = evt.GetId() - kUserPresetsID;
816
817 mpAccess->ModifySettings([&](EffectSettings &settings){
819 .LoadUserPreset(UserPresetsGroup(mUserPresets[preset]), settings);
820 });
822 return;
823}

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 306 of file EffectUI.cpp.

307{
309 {
310 mApplyBtn->SetLabel(XXO("&Generate").Translation());
311 }
312
313 Layout();
314
315 return wxDialogWrapper::ShowModal();
316}

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 1168 of file EffectUI.cpp.

1169{
1170 if (!mPlaying)
1171 return;
1172
1173 auto gAudioIO = AudioIO::Get();
1174 mPlayPos = gAudioIO->GetStreamTime();
1175 auto& projectAudioManager = ProjectAudioManager::Get(mProject);
1176 projectAudioManager.Stop();
1177}

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 268 of file EffectUI.cpp.

269{
271 if (!wxDialogWrapper::Validate())
272 return false;
273
275 if (!wxDialogWrapper::TransferDataFromWindow())
276 return false;
277
279 if (!mpValidator->ValidateUI())
280 return false;
281
282 // Transfer-from takes non-const reference to settings
283 bool result = true;
284 mpAccess->ModifySettings([&](EffectSettings &settings){
285 // Allow other transfers, and reassignment of settings
287 if (result) {
288 auto &definition = mEffectUIHost.GetDefinition();
289 if (definition.GetType() == EffectTypeGenerate) {
290 const auto seconds = settings.extra.GetDuration();
291 // Updating of the last-used generator duration in the config
292 SetConfig(definition, PluginSettings::Private,
293 CurrentSettingsGroup(), EffectSettingsExtra::DurationKey(),
294 seconds);
295 }
296 }
297 });
298 mpAccess->Flush();
299 return result;
300}
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 258 of file EffectUI.cpp.

259{
260 // Transfer-to takes const reference to settings
263 mpValidator->UpdateUI() &&
265 wxDialogWrapper::TransferDataToWindow();
266}
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 1034 of file EffectUI.cpp.

1035{
1036 if (mIsBatch)
1037 {
1038 return;
1039 }
1040
1042 {
1044 return;
1045 }
1046
1047 mApplyBtn->Enable(!mCapturing);
1048
1050 {
1052
1053 if (mPlaying)
1054 {
1055 /* i18n-hint: The access key "&P" should be the same in
1056 "Stop &Preview" and "Start &Preview" */
1057 mPlayToggleBtn->SetLabel(_("Stop &Preview"));
1058 mPlayToggleBtn->Refresh();
1059 }
1060 else
1061 {
1062 /* i18n-hint: The access key "&P" should be the same in
1063 "Stop &Preview" and "Start &Preview" */
1064 mPlayToggleBtn->SetLabel(_("&Preview"));
1065 mPlayToggleBtn->Refresh();
1066 }
1067 }
1068}

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 137 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 150 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 140 of file EffectUI.h.

Referenced by BuildButtonBar().

◆ mDisableTransport

bool EffectUIHost::mDisableTransport { true }
private

Definition at line 148 of file EffectUI.h.

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

◆ mDismissed

bool EffectUIHost::mDismissed {}
private

Definition at line 155 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 139 of file EffectUI.h.

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

◆ mEnabled

bool EffectUIHost::mEnabled { true }
private

Definition at line 146 of file EffectUI.h.

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

◆ mHadPriorState

const bool EffectUIHost::mHadPriorState
private

Definition at line 156 of file EffectUI.h.

Referenced by DoCancel().

◆ mInitialized

bool EffectUIHost::mInitialized { false }
private

Definition at line 132 of file EffectUI.h.

Referenced by CleanupRealtime(), and InitializeInstance().

◆ mIsBatch

bool EffectUIHost::mIsBatch {}
private

Definition at line 135 of file EffectUI.h.

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

◆ mIsGUI

bool EffectUIHost::mIsGUI {}
private

Definition at line 134 of file EffectUI.h.

Referenced by BuildButtonBar(), and Initialize().

◆ mMenuBtn

wxButton* EffectUIHost::mMenuBtn {}
private

Definition at line 138 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 163 of file EffectUI.h.

Referenced by EffectUIHost(), and Initialize().

◆ mPlaying

bool EffectUIHost::mPlaying {}
private

◆ mPlayPos

double EffectUIHost::mPlayPos { 0.0 }
private

Definition at line 153 of file EffectUI.h.

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

◆ mPlayToggleBtn

wxButton* EffectUIHost::mPlayToggleBtn {}
private

Definition at line 141 of file EffectUI.h.

Referenced by BuildButtonBar(), and UpdateControls().

◆ 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 144 of file EffectUI.h.

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

◆ mRealtimeEnabledBM

wxBitmap EffectUIHost::mRealtimeEnabledBM
private

Definition at line 143 of file EffectUI.h.

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

◆ mRegion

SelectedRegion EffectUIHost::mRegion
private

Definition at line 152 of file EffectUI.h.

Referenced by OnPlay(), and OnPlayback().

◆ mSupportsRealtime

const bool EffectUIHost::mSupportsRealtime
private

◆ mUserPresets

RegistryPaths EffectUIHost::mUserPresets
private

Definition at line 131 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: