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 35 of file RealtimeEffectStateUI.cpp.

37{
38}
RealtimeEffectState & mRealtimeEffectState

◆ ~RealtimeEffectStateUI()

RealtimeEffectStateUI::~RealtimeEffectStateUI ( )
override

Definition at line 40 of file RealtimeEffectStateUI.cpp.

41{
42 Hide();
43}
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 177 of file RealtimeEffectStateUI.cpp.

178{
180}
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.

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

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 148 of file RealtimeEffectStateUI.cpp.

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

143{
145}
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309
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 116 of file RealtimeEffectStateUI.cpp.

117{
118 if (mEffectUIHost != nullptr)
119 {
120 mpProject = project; // May reassign as null to skip autosave in OnClose
121 // EffectUIHost calls Destroy in OnClose handler
122 mEffectUIHost->Close();
123 mEffectUIHost = {};
124 }
125}
wxWeakRef< EffectUIHost > mEffectUIHost
AudacityProject * mpProject

References mEffectUIHost, and mpProject.

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

Here is the caller graph for this function:

◆ IsShown()

bool RealtimeEffectStateUI::IsShown ( ) const
noexcept

Definition at line 45 of file RealtimeEffectStateUI.cpp.

46{
47 return mEffectUIHost != nullptr;
48}

References mEffectUIHost.

Referenced by Toggle().

Here is the caller graph for this function:

◆ OnClose()

void RealtimeEffectStateUI::OnClose ( wxCloseEvent &  evt)
private

Definition at line 182 of file RealtimeEffectStateUI.cpp.

183{
184 auto next = GetNextHandler();
185 mEffectUIHost->RemoveEventHandler(this);
186 auto pProject = mpProject;
187 mpProject = nullptr;
188 if (pProject)
189 AutoSave(*pProject);
190
191 // Pass the event through to the dialog
192 if (next)
193 next->ProcessEvent(evt);
194}
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 50 of file RealtimeEffectStateUI.cpp.

51{
52 if (mEffectUIHost != nullptr && mEffectUIHost->IsShown())
53 {
54 // Bring the host to front
55 mEffectUIHost->Raise();
56 return;
57 }
58
59 const auto ID = mRealtimeEffectState.GetID();
60 const auto effectPlugin = EffectManager::Get().GetEffect(ID);
61
62 if (effectPlugin == nullptr)
63 return;
64
65 EffectUIClientInterface* client = effectPlugin->GetEffectUIClientInterface();
66
67 // Effect has no client interface
68 if (client == nullptr)
69 return;
70
71 auto& projectWindow = ProjectWindow::Get(project);
72
73 std::shared_ptr<EffectInstance> pInstance;
74
75 auto access = mRealtimeEffectState.GetAccess();
76
77 // EffectUIHost invokes shared_from_this on access
79 &projectWindow, project, *effectPlugin, *client, pInstance, *access,
80 mRealtimeEffectState.shared_from_this()));
81
82 if (!dlg->Initialize())
83 return;
84
85 // Dialog is owned by its parent now!
86 mEffectUIHost = dlg.release();
87
89
90 client->ShowClientInterface(
91 projectWindow, *mEffectUIHost, mEffectUIHost->GetValidator(), false);
92
93 // The dialog was modal? That shouldn't have happened
94 if (mEffectUIHost == nullptr || !mEffectUIHost->IsShown())
95 {
96 assert(false);
97 mEffectUIHost = {};
98 }
99
100 if (mEffectUIHost) {
101 mEffectUIHost->PushEventHandler(this);
102 mpProject = &project;
103 }
104
105 mProjectWindowDestroyedSubscription = projectWindow.Subscribe(
106 [this, &project](ProjectWindowDestroyedMessage) {
107 // This achieves autosave on close of project before other important
108 // project state is destroyed
109 Hide(&project);
110 });
111
112 mParameterChangedSubscription = mEffectUIHost->GetValidator()->Subscribe(
113 [this](auto) { ProjectHistory::Get(*mpProject).ModifyState(false); });
114}
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:162
EffectPlugin * GetEffect(const PluginID &ID)
static EffectManager & Get()
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
virtual int ShowClientInterface(wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal=false)=0
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
std::shared_ptr< EffectSettingsAccess > GetAccess()
const PluginID & GetID() const noexcept
Observer::Subscription mParameterChangedSubscription
Observer::Subscription mProjectWindowDestroyedSubscription
Message sent when the project window is closed.
Definition: ProjectWindow.h:32

References EffectManager::Get(), ProjectHistory::Get(), ProjectWindow::Get(), RealtimeEffectState::GetAccess(), EffectManager::GetEffect(), RealtimeEffectState::GetID(), Hide(), mEffectUIHost, ProjectHistory::ModifyState(), mParameterChangedSubscription, mpProject, mProjectWindowDestroyedSubscription, mRealtimeEffectState, safenew, EffectUIClientInterface::ShowClientInterface(), 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 127 of file RealtimeEffectStateUI.cpp.

128{
129 if(IsShown())
130 Hide(&project);
131 else
132 Show(project);
133}
bool IsShown() const noexcept
void Show(AudacityProject &project)

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

Here is the call graph for this function:

◆ UpdateTitle()

void RealtimeEffectStateUI::UpdateTitle ( )
private

Definition at line 153 of file RealtimeEffectStateUI.cpp.

154{
155 if (mEffectUIHost == nullptr)
156 return;
157
158 if (mEffectName.empty())
159 {
160 const auto ID = mRealtimeEffectState.GetID();
161 const auto effectPlugin = EffectManager::Get().GetEffect(ID);
162
163 if (effectPlugin != nullptr)
164 mEffectName = effectPlugin->GetDefinition().GetName();
165 }
166
167 const auto title =
168 mTrackName.empty() ?
170 /* i18n-hint: First %s is an effect name, second is a track name */
171 XO("%s - %s").Format(mEffectName, mTrackName);
172
173 mEffectUIHost->SetTitle(title);
174 mEffectUIHost->SetName(title);
175}
#define XO(s)
Definition: Internat.h:31
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 135 of file RealtimeEffectStateUI.cpp.

136{
137 mTrackName = track.GetName();
138
139 UpdateTitle();
140}
wxString GetName() const
Definition: Track.h:466

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: