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 UpdateTrackData (const Track &track)
 
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 mTrackName
 
AudacityProjectmpProject {}
 
Observer::Subscription mProjectWindowDestroyedSubscription
 
Observer::Subscription mParameterChangedSubscription
 

Detailed Description

UI state for realtime effect.

Definition at line 29 of file RealtimeEffectStateUI.h.

Constructor & Destructor Documentation

◆ RealtimeEffectStateUI()

RealtimeEffectStateUI::RealtimeEffectStateUI ( RealtimeEffectState state)
explicit

Definition at line 39 of file RealtimeEffectStateUI.cpp.

41{
42}
RealtimeEffectState & mRealtimeEffectState

◆ ~RealtimeEffectStateUI()

RealtimeEffectStateUI::~RealtimeEffectStateUI ( )
override

Definition at line 44 of file RealtimeEffectStateUI.cpp.

45{
46 Hide();
47}
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 185 of file RealtimeEffectStateUI.cpp.

186{
188}
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 156 of file RealtimeEffectStateUI.cpp.

157{
158 return Get(const_cast<RealtimeEffectState&>(state));
159}
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 150 of file RealtimeEffectStateUI.cpp.

151{
153}
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 124 of file RealtimeEffectStateUI.cpp.

125{
126 if (mEffectUIHost != nullptr)
127 {
128 mpProject = project; // May reassign as null to skip autosave in OnClose
129 // EffectUIHost calls Destroy in OnClose handler
130 mEffectUIHost->Close();
131 mEffectUIHost = {};
132 }
133}
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 49 of file RealtimeEffectStateUI.cpp.

50{
51 return mEffectUIHost != nullptr;
52}

References mEffectUIHost.

Referenced by Toggle().

Here is the caller graph for this function:

◆ OnClose()

void RealtimeEffectStateUI::OnClose ( wxCloseEvent &  evt)
private

Definition at line 190 of file RealtimeEffectStateUI.cpp.

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

References AutoSave(), mEffectUIHost, and mpProject.

Here is the call graph for this function:

◆ Show()

void RealtimeEffectStateUI::Show ( AudacityProject project)

Definition at line 54 of file RealtimeEffectStateUI.cpp.

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

136{
137 if(IsShown())
138 Hide(&project);
139 else
140 Show(project);
141}
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 161 of file RealtimeEffectStateUI.cpp.

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

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

Referenced by Show(), and UpdateTrackData().

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

◆ UpdateTrackData()

void RealtimeEffectStateUI::UpdateTrackData ( const Track track)

Definition at line 143 of file RealtimeEffectStateUI.cpp.

144{
145 mTrackName = track.GetName();
146
147 UpdateTitle();
148}
const wxString & GetName() const
Name is always the same for all channels of a group.
Definition: Track.cpp:64

References Track::GetName(), mTrackName, and UpdateTitle().

Here is the call graph for this function:

Member Data Documentation

◆ mEffectName

TranslatableString RealtimeEffectStateUI::mEffectName
private

Definition at line 59 of file RealtimeEffectStateUI.h.

Referenced by UpdateTitle().

◆ mEffectUIHost

wxWeakRef<EffectUIHost> RealtimeEffectStateUI::mEffectUIHost
private

Definition at line 57 of file RealtimeEffectStateUI.h.

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

◆ mParameterChangedSubscription

Observer::Subscription RealtimeEffectStateUI::mParameterChangedSubscription
private

Definition at line 64 of file RealtimeEffectStateUI.h.

Referenced by Show().

◆ mpProject

AudacityProject* RealtimeEffectStateUI::mpProject {}
private

Definition at line 61 of file RealtimeEffectStateUI.h.

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

◆ mProjectWindowDestroyedSubscription

Observer::Subscription RealtimeEffectStateUI::mProjectWindowDestroyedSubscription
private

Definition at line 63 of file RealtimeEffectStateUI.h.

Referenced by Show().

◆ mRealtimeEffectState

RealtimeEffectState& RealtimeEffectStateUI::mRealtimeEffectState
private

Definition at line 55 of file RealtimeEffectStateUI.h.

Referenced by Show(), and UpdateTitle().

◆ mTrackName

wxString RealtimeEffectStateUI::mTrackName
private

Definition at line 60 of file RealtimeEffectStateUI.h.

Referenced by UpdateTitle(), and UpdateTrackData().


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