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

UI state for realtime effect. More...

#include <RealtimeEffectStateUI.h>

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

Public Member Functions

 RealtimeEffectStateUI (RealtimeEffectState &state)
 
 ~RealtimeEffectStateUI () override
 
bool IsShown () const noexcept
 
void Show (AudacityProject &project)
 
void Hide (AudacityProject *project=nullptr)
 
void Toggle (AudacityProject &project)
 
void SetTargetName (const wxString &name)
 
void AutoSave (AudacityProject &project)
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static RealtimeEffectStateUIGet (RealtimeEffectState &state)
 
static const RealtimeEffectStateUIGet (const RealtimeEffectState &state)
 

Private Member Functions

void UpdateTitle ()
 
void OnClose (wxCloseEvent &evt)
 

Private Attributes

RealtimeEffectStatemRealtimeEffectState
 
wxWeakRef< EffectUIHostmEffectUIHost
 
TranslatableString mEffectName
 
wxString mTargetName
 
AudacityProjectmpProject {}
 
Observer::Subscription mProjectWindowDestroyedSubscription
 
Observer::Subscription mParameterChangedSubscription
 

Detailed Description

UI state for realtime effect.

Definition at line 28 of file RealtimeEffectStateUI.h.

Constructor & Destructor Documentation

◆ RealtimeEffectStateUI()

RealtimeEffectStateUI::RealtimeEffectStateUI ( RealtimeEffectState state)
explicit

Definition at line 38 of file RealtimeEffectStateUI.cpp.

40{
41}
RealtimeEffectState & mRealtimeEffectState

◆ ~RealtimeEffectStateUI()

RealtimeEffectStateUI::~RealtimeEffectStateUI ( )
override

Definition at line 43 of file RealtimeEffectStateUI.cpp.

44{
45 Hide();
46}
void Hide(AudacityProject *project=nullptr)

References Hide().

Here is the call graph for this function:

Member Function Documentation

◆ AutoSave()

void RealtimeEffectStateUI::AutoSave ( AudacityProject project)

Definition at line 183 of file RealtimeEffectStateUI.cpp.

184{
186}
const auto project
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.

References GlobalHook< AutoSave, void(AudacityProject &) >::Call(), and project.

Referenced by OnClose().

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

◆ Get() [1/2]

const RealtimeEffectStateUI & RealtimeEffectStateUI::Get ( const RealtimeEffectState state)
static

Definition at line 154 of file RealtimeEffectStateUI.cpp.

155{
156 return Get(const_cast<RealtimeEffectState&>(state));
157}
static RealtimeEffectStateUI & Get(RealtimeEffectState &state)

References Get().

Here is the call graph for this function:

◆ Get() [2/2]

RealtimeEffectStateUI & RealtimeEffectStateUI::Get ( RealtimeEffectState state)
static

Definition at line 148 of file RealtimeEffectStateUI.cpp.

149{
151}
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:318
UI state for realtime effect.
const RealtimeEffectState::RegisteredFactory realtimeEffectStateUIFactory

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), and anonymous_namespace{RealtimeEffectStateUI.cpp}::realtimeEffectStateUIFactory.

Referenced by Get(), RealtimeEffectListWindow::OnEffectListItemChange(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::RemoveFromList(), and anonymous_namespace{RealtimeEffectPanel.cpp}::VisitRealtimeEffectStateUIs().

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

◆ Hide()

void RealtimeEffectStateUI::Hide ( AudacityProject project = nullptr)

Definition at line 123 of file RealtimeEffectStateUI.cpp.

124{
125 if (mEffectUIHost != nullptr)
126 {
127 mpProject = project; // May reassign as null to skip autosave in OnClose
128 // EffectUIHost calls Destroy in OnClose handler
129 mEffectUIHost->Close();
130 mEffectUIHost = {};
131 }
132}
wxWeakRef< EffectUIHost > mEffectUIHost
AudacityProject * mpProject

References mEffectUIHost, mpProject, and project.

Referenced by Show(), Toggle(), and ~RealtimeEffectStateUI().

Here is the caller graph for this function:

◆ IsShown()

bool RealtimeEffectStateUI::IsShown ( ) const
noexcept

Definition at line 48 of file RealtimeEffectStateUI.cpp.

49{
50 return mEffectUIHost != nullptr;
51}

References mEffectUIHost.

Referenced by Toggle().

Here is the caller graph for this function:

◆ OnClose()

void RealtimeEffectStateUI::OnClose ( wxCloseEvent &  evt)
private

Definition at line 188 of file RealtimeEffectStateUI.cpp.

189{
190 auto next = GetNextHandler();
191 mEffectUIHost->RemoveEventHandler(this);
192 auto pProject = mpProject;
193 mpProject = nullptr;
194 if (pProject)
195 AutoSave(*pProject);
196
197 // Pass the event through to the dialog
198 if (next)
199 next->ProcessEvent(evt);
200}
void AutoSave(AudacityProject &project)

References AutoSave(), mEffectUIHost, and mpProject.

Here is the call graph for this function:

◆ SetTargetName()

void RealtimeEffectStateUI::SetTargetName ( const wxString &  name)

Sets the display name of the target, that will help distinguish effect UI among others.

Definition at line 142 of file RealtimeEffectStateUI.cpp.

143{
144 mTargetName = targetName;
145 UpdateTitle();
146}

References mTargetName, and UpdateTitle().

Here is the call graph for this function:

◆ Show()

void RealtimeEffectStateUI::Show ( AudacityProject project)

Definition at line 53 of file RealtimeEffectStateUI.cpp.

54{
55 if (mEffectUIHost != nullptr && mEffectUIHost->IsShown())
56 {
57 // Bring the host to front
58 mEffectUIHost->Raise();
59 return;
60 }
61
62 const auto ID = mRealtimeEffectState.GetID();
63 const auto effectPlugin =
64 dynamic_cast<EffectBase*>(EffectManager::Get().GetEffect(ID));
65
66 if (effectPlugin == nullptr)
67 return;
68
69 const auto client = dynamic_cast<EffectUIServices *>(effectPlugin);
70
71 // Effect has no client interface
72 if (client == nullptr)
73 return;
74
75 auto& projectWindow = ProjectWindow::Get(project);
76
77 std::shared_ptr<EffectInstance> pInstance;
78
79 auto access = mRealtimeEffectState.GetAccess();
80
81 // EffectUIHost invokes shared_from_this on access
83 &projectWindow, project, *effectPlugin, *client, pInstance, *access,
84 mRealtimeEffectState.shared_from_this()));
85
86 if (!dlg->Initialize())
87 return;
88
89 // Dialog is owned by its parent now!
90 mEffectUIHost = dlg.release();
91
93
94 client->ShowClientInterface(*effectPlugin,
95 projectWindow, *mEffectUIHost, mEffectUIHost->GetEditor(), false);
96
97 // The dialog was modal? That shouldn't have happened
98 if (mEffectUIHost == nullptr || !mEffectUIHost->IsShown())
99 {
100 assert(false);
101 mEffectUIHost = {};
102 }
103
104 if (mEffectUIHost) {
105 mEffectUIHost->PushEventHandler(this);
107 }
108
109 mProjectWindowDestroyedSubscription = projectWindow.Subscribe(
111 // This achieves autosave on close of project before other important
112 // project state is destroyed
113 Hide(&project);
114 });
115
116 mParameterChangedSubscription = mEffectUIHost->GetEditor()->Subscribe(
117 [this](auto) { if (mpProject) { // This can be null if closing an effect without making changes.
118 UndoManager::Get(*mpProject).MarkUnsaved();
119 }
120 });
121}
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:164
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
EffectPlugin * GetEffect(const PluginID &ID)
static EffectManager & Get()
static ProjectWindow & Get(AudacityProject &project)
std::shared_ptr< EffectSettingsAccess > GetAccess()
const PluginID & GetID() const noexcept
Observer::Subscription mParameterChangedSubscription
Observer::Subscription mProjectWindowDestroyedSubscription
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
void MarkUnsaved()
Message sent when the project window is closed.
Definition: ProjectWindow.h:29

References EffectManager::Get(), UndoManager::Get(), ProjectWindow::Get(), RealtimeEffectState::GetAccess(), EffectManager::GetEffect(), RealtimeEffectState::GetID(), Hide(), UndoManager::MarkUnsaved(), mEffectUIHost, mParameterChangedSubscription, mpProject, mProjectWindowDestroyedSubscription, mRealtimeEffectState, project, safenew, and UpdateTitle().

Referenced by Toggle().

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

◆ Toggle()

void RealtimeEffectStateUI::Toggle ( AudacityProject project)

Definition at line 134 of file RealtimeEffectStateUI.cpp.

135{
136 if(IsShown())
137 Hide(&project);
138 else
139 Show(project);
140}
bool IsShown() const noexcept
void Show(AudacityProject &project)

References Hide(), IsShown(), project, and Show().

Here is the call graph for this function:

◆ UpdateTitle()

void RealtimeEffectStateUI::UpdateTitle ( )
private

Definition at line 159 of file RealtimeEffectStateUI.cpp.

160{
161 if (mEffectUIHost == nullptr)
162 return;
163
164 if (mEffectName.empty())
165 {
166 const auto ID = mRealtimeEffectState.GetID();
167 const auto effectPlugin = EffectManager::Get().GetEffect(ID);
168
169 if (effectPlugin != nullptr)
170 mEffectName = effectPlugin->GetDefinition().GetName();
171 }
172
173 const auto title =
174 mTargetName.empty() ?
176 /* i18n-hint: First %s is an effect name, second is a track name */
177 XO("%s - %s").Format(mEffectName, mTargetName);
178
179 mEffectUIHost->SetTitle(title);
180 mEffectUIHost->SetName(title);
181}
XO("Cut/Copy/Paste")
static const auto title
TranslatableString mEffectName

References TranslatableString::empty(), EffectManager::Get(), EffectManager::GetEffect(), RealtimeEffectState::GetID(), mEffectName, mEffectUIHost, mRealtimeEffectState, mTargetName, title, and XO().

Referenced by SetTargetName(), and Show().

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

Member Data Documentation

◆ mEffectName

TranslatableString RealtimeEffectStateUI::mEffectName
private

Definition at line 60 of file RealtimeEffectStateUI.h.

Referenced by UpdateTitle().

◆ mEffectUIHost

wxWeakRef<EffectUIHost> RealtimeEffectStateUI::mEffectUIHost
private

Definition at line 58 of file RealtimeEffectStateUI.h.

Referenced by Hide(), IsShown(), OnClose(), Show(), and UpdateTitle().

◆ mParameterChangedSubscription

Observer::Subscription RealtimeEffectStateUI::mParameterChangedSubscription
private

Definition at line 65 of file RealtimeEffectStateUI.h.

Referenced by Show().

◆ mpProject

AudacityProject* RealtimeEffectStateUI::mpProject {}
private

Definition at line 62 of file RealtimeEffectStateUI.h.

Referenced by Hide(), OnClose(), and Show().

◆ mProjectWindowDestroyedSubscription

Observer::Subscription RealtimeEffectStateUI::mProjectWindowDestroyedSubscription
private

Definition at line 64 of file RealtimeEffectStateUI.h.

Referenced by Show().

◆ mRealtimeEffectState

RealtimeEffectState& RealtimeEffectStateUI::mRealtimeEffectState
private

Definition at line 56 of file RealtimeEffectStateUI.h.

Referenced by Show(), and UpdateTitle().

◆ mTargetName

wxString RealtimeEffectStateUI::mTargetName
private

Definition at line 61 of file RealtimeEffectStateUI.h.

Referenced by SetTargetName(), and UpdateTitle().


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