Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
RealtimeEffectPanel Class Reference

UI Panel that displays realtime effects from the effect stack of an individual track, provides controls for accessing effect settings, stack manipulation (reorder, add, remove) More...

#include <RealtimeEffectPanel.h>

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

Classes

struct  PrefsListenerHelper
 

Public Member Functions

 RealtimeEffectPanel (AudacityProject &project, wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr)
 
 ~RealtimeEffectPanel () override
 
void ShowPanel (SampleTrack *track, bool focus)
 
void HidePanel ()
 
void SetTrack (const std::shared_ptr< SampleTrack > &track)
 Shows effects from the effect stack of the track. More...
 
void ResetTrack ()
 
bool IsTopNavigationDomain (NavigationKind) const override
 
void SetFocus () override
 

Static Public Member Functions

static RealtimeEffectPanelGet (AudacityProject &project)
 
static const RealtimeEffectPanelGet (const AudacityProject &project)
 

Private Member Functions

void OnCharHook (wxKeyEvent &evt)
 

Private Attributes

AButtonmToggleEffects {nullptr}
 
wxStaticText * mTrackTitle {nullptr}
 
RealtimeEffectListWindowmEffectList {nullptr}
 
wxWindow * mHeader {nullptr}
 
AudacityProjectmProject
 
std::weak_ptr< SampleTrackmCurrentTrack
 
Observer::Subscription mTrackListChanged
 
Observer::Subscription mUndoSubscription
 
Observer::Subscription mFocusChangeSubscription
 
std::vector< std::shared_ptr< SampleTrack > > mPotentiallyRemovedTracks
 
std::unique_ptr< PrefsListenerHelpermPrefsListenerHelper
 

Detailed Description

UI Panel that displays realtime effects from the effect stack of an individual track, provides controls for accessing effect settings, stack manipulation (reorder, add, remove)

Definition at line 34 of file RealtimeEffectPanel.h.

Constructor & Destructor Documentation

◆ RealtimeEffectPanel()

RealtimeEffectPanel::RealtimeEffectPanel ( AudacityProject project,
wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString &  name = wxPanelNameStr 
)

Definition at line 1080 of file RealtimeEffectPanel.cpp.

1084 : wxPanel(parent, id, pos, size, style, name)
1085 , mProject(project)
1086 , mPrefsListenerHelper(std::make_unique<PrefsListenerHelper>(project))
1087{
1088 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1089
1090 auto header = safenew ThemedWindowWrapper<ListNavigationPanel>(this, wxID_ANY);
1091#if wxUSE_ACCESSIBILITY
1092 safenew WindowAccessible(header);
1093#endif
1094 header->SetBackgroundColorIndex(clrMedium);
1095 {
1096 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1097 auto toggleEffects = safenew ThemedAButtonWrapper<AButton>(header);
1098 toggleEffects->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
1099 toggleEffects->SetButtonToggles(true);
1100 toggleEffects->SetTranslatableLabel(XO("Power"));
1101 toggleEffects->SetBackgroundColorIndex(clrMedium);
1102 mToggleEffects = toggleEffects;
1103
1104 toggleEffects->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
1105 if (mEffectList)
1106 {
1108
1110 }
1111 });
1112
1113 hSizer->Add(toggleEffects, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxLEFT, 5);
1114 {
1115 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1116
1117 auto headerText = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString);
1118 headerText->SetFont(wxFont(wxFontInfo().Bold()));
1119 headerText->SetTranslatableLabel(XO("Realtime Effects"));
1120 headerText->SetForegroundColorIndex(clrTrackPanelText);
1121
1122 auto trackTitle = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
1123 trackTitle->SetForegroundColorIndex(clrTrackPanelText);
1124 mTrackTitle = trackTitle;
1125
1126 vSizer->Add(headerText);
1127 vSizer->Add(trackTitle);
1128
1129 hSizer->Add(vSizer.release(), 1, wxEXPAND | wxALL, 10);
1130 }
1131 auto close = safenew ThemedAButtonWrapper<AButton>(header);
1132 close->SetTranslatableLabel(XO("Close"));
1133 close->SetImageIndices(0, bmpCloseNormal, bmpCloseHover, bmpCloseDown, bmpCloseHover, bmpCloseDisabled);
1134 close->SetBackgroundColorIndex(clrMedium);
1135
1136 close->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { Close(); });
1137
1138 hSizer->Add(close, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxRIGHT, 5);
1139
1140 header->SetSizer(hSizer.release());
1141 }
1142 vSizer->Add(header, 0, wxEXPAND);
1143
1144 auto effectList = safenew ThemedWindowWrapper<RealtimeEffectListWindow>(this, wxID_ANY);
1145 effectList->SetBackgroundColorIndex(clrMedium);
1146 vSizer->Add(effectList, 1, wxEXPAND);
1147
1148 mHeader = header;
1149 mEffectList = effectList;
1150
1151 SetSizerAndFit(vSizer.release());
1152
1153 Bind(wxEVT_CHAR_HOOK, &RealtimeEffectPanel::OnCharHook, this);
1155 auto track = evt.mpTrack.lock();
1156 auto waveTrack = std::dynamic_pointer_cast<WaveTrack>(track);
1157
1158 if (waveTrack == nullptr)
1159 return;
1160
1161 switch (evt.mType)
1162 {
1164 if (mCurrentTrack.lock() == waveTrack)
1165 mTrackTitle->SetLabel(track->GetName());
1166 UpdateRealtimeEffectUIData(*waveTrack);
1167 break;
1169 if (evt.mExtra == 0)
1170 mPotentiallyRemovedTracks.push_back(waveTrack);
1171 break;
1173 // Addition can be fired as a part of "replace" event.
1174 // Calling UpdateRealtimeEffectUIData is mostly no-op,
1175 // it will just create a new State and Access for it.
1176 UpdateRealtimeEffectUIData(*waveTrack);
1177 break;
1178 default:
1179 break;
1180 }
1181 });
1182
1184 [this](UndoRedoMessage message)
1185 {
1186 if (
1187 message.type == UndoRedoMessage::Type::Purge ||
1188 message.type == UndoRedoMessage::Type::BeginPurge ||
1189 message.type == UndoRedoMessage::Type::EndPurge)
1190 return;
1191
1192 auto& trackList = TrackList::Get(mProject);
1193
1194 // Realtime effect UI is only updated on Undo or Redo
1195 auto waveTracks = trackList.Any<WaveTrack>();
1196
1197 if (
1198 message.type == UndoRedoMessage::Type::UndoOrRedo ||
1199 message.type == UndoRedoMessage::Type::Reset)
1200 {
1201 for (auto waveTrack : waveTracks)
1202 UpdateRealtimeEffectUIData(*waveTrack);
1203 }
1204
1205 // But mPotentiallyRemovedTracks processing happens as fast as possible.
1206 // This event is fired right after the track is deleted, so we do not
1207 // hold the strong reference to the track much longer than need.
1208 if (mPotentiallyRemovedTracks.empty())
1209 return;
1210
1211 // Collect RealtimeEffectUIs that are currently shown
1212 // for the potentially removed tracks
1213 std::vector<RealtimeEffectStateUI*> shownUIs;
1214
1215 for (auto track : mPotentiallyRemovedTracks)
1216 {
1217 // By construction, track cannot be null
1218 assert(track != nullptr);
1219
1221 *track,
1222 [&shownUIs](auto& ui)
1223 {
1224 if (ui.IsShown())
1225 shownUIs.push_back(&ui);
1226 });
1227 }
1228
1229 // For every UI shown - check if the corresponding state
1230 // is reachable from the current track list.
1231 for (auto effectUI : shownUIs)
1232 {
1233 bool reachable = false;
1234
1235 for (auto track : waveTracks)
1236 {
1238 *track,
1239 [effectUI, &reachable](auto& ui)
1240 {
1241 if (effectUI == &ui)
1242 reachable = true;
1243 });
1244
1245 if (reachable)
1246 break;
1247 }
1248
1249 if (!reachable)
1250 // Don't need to autosave for an unreachable state
1251 effectUI->Hide();
1252 }
1253
1255 });
1256
1258 .Subscribe([this](const TrackFocusChangeMessage& msg) {
1259 if (IsShown())
1260 {
1261 auto& trackFocus = TrackFocus::Get(mProject);
1262 ShowPanel(dynamic_cast<SampleTrack *>(trackFocus.Get()), false);
1263 }
1264 });
1265
1266 Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent&) {
1267 HidePanel(); });
1268}
const TranslatableString name
Definition: Distortion.cpp:76
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
for(int ii=0, nn=names.size();ii< nn;++ii)
const auto project
bool IsDown()
Definition: AButton.h:208
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
Observer::Subscription mUndoSubscription
wxStaticText * mTrackTitle
void ShowPanel(SampleTrack *track, bool focus)
RealtimeEffectListWindow * mEffectList
void OnCharHook(wxKeyEvent &evt)
std::weak_ptr< SampleTrack > mCurrentTrack
std::unique_ptr< PrefsListenerHelper > mPrefsListenerHelper
std::vector< std::shared_ptr< SampleTrack > > mPotentiallyRemovedTracks
Observer::Subscription mFocusChangeSubscription
AudacityProject & mProject
Observer::Subscription mTrackListChanged
Track * Get()
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1091
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:354
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
A Track that contains audio waveform data.
Definition: WaveTrack.h:220
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
void VisitRealtimeEffectStateUIs(SampleTrack &track, Visitor &&visitor)
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:937
const int mExtra
Definition: Track.h:976
const std::weak_ptr< Track > mpTrack
Definition: Track.h:975
const Type mType
Definition: Track.h:974
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:962
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:956
@ TRACK_DATA_CHANGE
Posted when certain fields of a track change.
Definition: Track.h:943
Type of message published by UndoManager.
Definition: UndoManager.h:55
enum UndoRedoMessage::Type type

References TrackListEvent::ADDITION, TrackList::Any(), TrackListEvent::DELETION, RealtimeEffectListWindow::EnableEffects(), for(), TrackFocus::Get(), ProjectHistory::Get(), UndoManager::Get(), TrackList::Get(), HidePanel(), AButton::IsDown(), mCurrentTrack, mEffectList, TrackListEvent::mExtra, mFocusChangeSubscription, mHeader, ProjectHistory::ModifyState(), mPotentiallyRemovedTracks, mProject, TrackListEvent::mpTrack, mToggleEffects, mTrackListChanged, mTrackTitle, TrackListEvent::mType, mUndoSubscription, OnCharHook(), project, safenew, ShowPanel(), Observer::Publisher< Message, NotifyAll >::Subscribe(), TrackListEvent::TRACK_DATA_CHANGE, UndoRedoMessage::type, anonymous_namespace{RealtimeEffectPanel.cpp}::UpdateRealtimeEffectUIData(), anonymous_namespace{RealtimeEffectPanel.cpp}::VisitRealtimeEffectStateUIs(), and XO().

Here is the call graph for this function:

◆ ~RealtimeEffectPanel()

RealtimeEffectPanel::~RealtimeEffectPanel ( )
override

Definition at line 1270 of file RealtimeEffectPanel.cpp.

1271{
1272}

Member Function Documentation

◆ Get() [1/2]

RealtimeEffectPanel & RealtimeEffectPanel::Get ( AudacityProject project)
static

Definition at line 1069 of file RealtimeEffectPanel.cpp.

1070{
1072}
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
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 Panel that displays realtime effects from the effect stack of an individual track,...

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), GetAttachedWindows(), project, and anonymous_namespace{RealtimeEffectPanel.cpp}::sKey.

Referenced by EffectsButtonHandle::CommitChanges(), anonymous_namespace{PluginMenus.cpp}::DoManageRealtimeEffectsSidePanel(), Get(), and anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame().

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

◆ Get() [2/2]

const RealtimeEffectPanel & RealtimeEffectPanel::Get ( const AudacityProject project)
static

Definition at line 1075 of file RealtimeEffectPanel.cpp.

1076{
1077 return Get(const_cast<AudacityProject &>(project));
1078}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static RealtimeEffectPanel & Get(AudacityProject &project)

References Get(), and project.

Here is the call graph for this function:

◆ HidePanel()

void RealtimeEffectPanel::HidePanel ( )

Definition at line 1301 of file RealtimeEffectPanel.cpp.

1302{
1303 wxWindowUpdateLocker freeze(this);
1304
1305 auto &projectWindow = ProjectWindow::Get(mProject);
1306 const auto pContainerWindow = projectWindow.GetContainerWindow();
1307 const auto pTrackListWindow = projectWindow.GetTrackListWindow();
1308 if (pContainerWindow->GetWindow2() == nullptr)
1309 //only effects panel is present, restore split positions before removing effects panel
1310 //Workaround: ::Replace and ::Initialize do not work here...
1311 pContainerWindow->SplitVertically(this, pTrackListWindow);
1312
1313 pContainerWindow->Unsplit(this);
1314 pTrackListWindow->SetFocus();
1315 projectWindow.Layout();
1316}
static ProjectWindow & Get(AudacityProject &project)

References ProjectWindow::Get(), and mProject.

Referenced by RealtimeEffectPanel().

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

◆ IsTopNavigationDomain()

bool RealtimeEffectPanel::IsTopNavigationDomain ( NavigationKind  ) const
inlineoverride

Definition at line 79 of file RealtimeEffectPanel.h.

79{ return true; }

◆ OnCharHook()

void RealtimeEffectPanel::OnCharHook ( wxKeyEvent &  evt)
private

Definition at line 1352 of file RealtimeEffectPanel.cpp.

1353{
1354 if(evt.GetKeyCode() == WXK_ESCAPE && IsShown() && IsDescendant(FindFocus()))
1355 Close();
1356 else
1357 evt.Skip();
1358}
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:343

References BasicUI::FindFocus().

Referenced by RealtimeEffectPanel().

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

◆ ResetTrack()

void RealtimeEffectPanel::ResetTrack ( )

Definition at line 1338 of file RealtimeEffectPanel.cpp.

1339{
1340 mTrackTitle->SetLabel(wxEmptyString);
1343 mCurrentTrack.reset();
1344 mHeader->SetName(wxEmptyString);
1345}
void Disable()
Definition: AButton.cpp:560

References AButton::Disable(), mCurrentTrack, mEffectList, mHeader, mToggleEffects, mTrackTitle, and RealtimeEffectListWindow::ResetTrack().

Referenced by SetTrack(), and ShowPanel().

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

◆ SetFocus()

void RealtimeEffectPanel::SetFocus ( )
override

Definition at line 1347 of file RealtimeEffectPanel.cpp.

1348{
1349 mHeader->SetFocus();
1350}

References mHeader.

Referenced by ShowPanel().

Here is the caller graph for this function:

◆ SetTrack()

void RealtimeEffectPanel::SetTrack ( const std::shared_ptr< SampleTrack > &  track)

Shows effects from the effect stack of the track.

Parameters
trackPointer to the existing track, or null

Definition at line 1318 of file RealtimeEffectPanel.cpp.

1319{
1320 //Avoid creation-on-demand of a useless, empty list in case the track is of non-wave type.
1321 if(track && dynamic_cast<WaveTrack*>(&*track) != nullptr)
1322 {
1323 mTrackTitle->SetLabel(track->GetName());
1325 track && RealtimeEffectList::Get(*track).IsActive()
1327 : mToggleEffects->PopUp();
1328 mEffectList->SetTrack(mProject, track);
1329
1330 mCurrentTrack = track;
1331 //i18n-hint: argument - track name
1332 mHeader->SetName(wxString::Format(_("Realtime effects for %s"), track->GetName()));
1333 }
1334 else
1335 ResetTrack();
1336}
#define _(s)
Definition: Internat.h:73
void PushDown()
Definition: AButton.cpp:577
void Enable()
Definition: AButton.cpp:551
void PopUp()
Definition: AButton.cpp:585
static RealtimeEffectList & Get(AudacityProject &project)
bool IsActive() const
Non-blocking atomic boolean load.
void SetTrack(AudacityProject &project, const std::shared_ptr< SampleTrack > &track)

References _, AButton::Enable(), RealtimeEffectList::Get(), RealtimeEffectList::IsActive(), mCurrentTrack, mEffectList, mHeader, mProject, mToggleEffects, mTrackTitle, AButton::PopUp(), AButton::PushDown(), ResetTrack(), and RealtimeEffectListWindow::SetTrack().

Referenced by ShowPanel().

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

◆ ShowPanel()

void RealtimeEffectPanel::ShowPanel ( SampleTrack track,
bool  focus 
)

Definition at line 1274 of file RealtimeEffectPanel.cpp.

1275{
1276 if(track == nullptr)
1277 {
1278 ResetTrack();
1279 return;
1280 }
1281
1282 wxWindowUpdateLocker freeze(this);
1283
1285
1286 auto &projectWindow = ProjectWindow::Get(mProject);
1287 const auto pContainerWindow = projectWindow.GetContainerWindow();
1288 if (pContainerWindow->GetWindow1() != this)
1289 {
1290 //Restore previous effects window size
1291 pContainerWindow->SplitVertically(
1292 this,
1293 projectWindow.GetTrackListWindow(),
1294 this->GetSize().GetWidth());
1295 }
1296 if(focus)
1297 SetFocus();
1298 projectWindow.Layout();
1299}
void SetTrack(const std::shared_ptr< SampleTrack > &track)
Shows effects from the effect stack of the track.
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:161

References ProjectWindow::Get(), mProject, ResetTrack(), SetFocus(), SetTrack(), and Track::SharedPointer().

Referenced by EffectsButtonHandle::CommitChanges(), and RealtimeEffectPanel().

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

Member Data Documentation

◆ mCurrentTrack

std::weak_ptr<SampleTrack> RealtimeEffectPanel::mCurrentTrack
private

Definition at line 42 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel(), ResetTrack(), and SetTrack().

◆ mEffectList

RealtimeEffectListWindow* RealtimeEffectPanel::mEffectList {nullptr}
private

Definition at line 38 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel(), ResetTrack(), and SetTrack().

◆ mFocusChangeSubscription

Observer::Subscription RealtimeEffectPanel::mFocusChangeSubscription
private

Definition at line 46 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel().

◆ mHeader

wxWindow* RealtimeEffectPanel::mHeader {nullptr}
private

Definition at line 39 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel(), ResetTrack(), SetFocus(), and SetTrack().

◆ mPotentiallyRemovedTracks

std::vector<std::shared_ptr<SampleTrack> > RealtimeEffectPanel::mPotentiallyRemovedTracks
private

Definition at line 48 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel().

◆ mPrefsListenerHelper

std::unique_ptr<PrefsListenerHelper> RealtimeEffectPanel::mPrefsListenerHelper
private

Definition at line 53 of file RealtimeEffectPanel.h.

◆ mProject

AudacityProject& RealtimeEffectPanel::mProject
private

Definition at line 40 of file RealtimeEffectPanel.h.

Referenced by HidePanel(), RealtimeEffectPanel(), SetTrack(), and ShowPanel().

◆ mToggleEffects

AButton* RealtimeEffectPanel::mToggleEffects {nullptr}
private

Definition at line 36 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel(), ResetTrack(), and SetTrack().

◆ mTrackListChanged

Observer::Subscription RealtimeEffectPanel::mTrackListChanged
private

Definition at line 44 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel().

◆ mTrackTitle

wxStaticText* RealtimeEffectPanel::mTrackTitle {nullptr}
private

Definition at line 37 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel(), ResetTrack(), and SetTrack().

◆ mUndoSubscription

Observer::Subscription RealtimeEffectPanel::mUndoSubscription
private

Definition at line 45 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel().


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