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 1069 of file RealtimeEffectPanel.cpp.

1073 : wxPanel(parent, id, pos, size, style, name)
1074 , mProject(project)
1075 , mPrefsListenerHelper(std::make_unique<PrefsListenerHelper>(project))
1076{
1077 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1078
1079 auto header = safenew ThemedWindowWrapper<ListNavigationPanel>(this, wxID_ANY);
1080#if wxUSE_ACCESSIBILITY
1081 safenew WindowAccessible(header);
1082#endif
1083 header->SetBackgroundColorIndex(clrMedium);
1084 {
1085 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1086 auto toggleEffects = safenew ThemedAButtonWrapper<AButton>(header);
1087 toggleEffects->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
1088 toggleEffects->SetButtonToggles(true);
1089 toggleEffects->SetTranslatableLabel(XO("Power"));
1090 toggleEffects->SetBackgroundColorIndex(clrMedium);
1091 mToggleEffects = toggleEffects;
1092
1093 toggleEffects->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
1094 if (mEffectList)
1095 {
1097
1100 }
1101 });
1102
1103 hSizer->Add(toggleEffects, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxLEFT, 5);
1104 {
1105 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1106
1107 auto headerText = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString);
1108 headerText->SetFont(wxFont(wxFontInfo().Bold()));
1109 headerText->SetTranslatableLabel(XO("Realtime Effects"));
1110 headerText->SetForegroundColorIndex(clrTrackPanelText);
1111
1112 auto trackTitle = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
1113 trackTitle->SetForegroundColorIndex(clrTrackPanelText);
1114 mTrackTitle = trackTitle;
1115
1116 vSizer->Add(headerText);
1117 vSizer->Add(trackTitle);
1118
1119 hSizer->Add(vSizer.release(), 1, wxEXPAND | wxALL, 10);
1120 }
1121 auto close = safenew ThemedAButtonWrapper<AButton>(header);
1122 close->SetTranslatableLabel(XO("Close"));
1123 close->SetImageIndices(0, bmpCloseNormal, bmpCloseHover, bmpCloseDown, bmpCloseHover, bmpCloseDisabled);
1124 close->SetBackgroundColorIndex(clrMedium);
1125
1126 close->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { Close(); });
1127
1128 hSizer->Add(close, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxRIGHT, 5);
1129
1130 header->SetSizer(hSizer.release());
1131 }
1132 vSizer->Add(header, 0, wxEXPAND);
1133
1134 auto effectList = safenew ThemedWindowWrapper<RealtimeEffectListWindow>(this, wxID_ANY);
1135 effectList->SetBackgroundColorIndex(clrMedium);
1136 vSizer->Add(effectList, 1, wxEXPAND);
1137
1138 mHeader = header;
1139 mEffectList = effectList;
1140
1141 SetSizerAndFit(vSizer.release());
1142
1143 Bind(wxEVT_CHAR_HOOK, &RealtimeEffectPanel::OnCharHook, this);
1146 auto track = evt.mpTrack.lock();
1147 auto waveTrack = std::dynamic_pointer_cast<WaveTrack>(track);
1148
1149 if (waveTrack == nullptr)
1150 return;
1151
1152 switch (evt.mType)
1153 {
1155 if (mCurrentTrack.lock() == waveTrack)
1156 mTrackTitle->SetLabel(track->GetName());
1157 UpdateRealtimeEffectUIData(*waveTrack);
1158 break;
1160 if (evt.mExtra == 0)
1161 mPotentiallyRemovedTracks.push_back(waveTrack);
1162 break;
1164 // Addition can be fired as a part of "replace" event.
1165 // Calling UpdateRealtimeEffectUIData is mostly no-op,
1166 // it will just create a new State and Access for it.
1167 UpdateRealtimeEffectUIData(*waveTrack);
1168 break;
1169 default:
1170 break;
1171 }
1172 });
1173
1175 [this](UndoRedoMessage message)
1176 {
1177 if (
1178 message.type == UndoRedoMessage::Type::Purge ||
1179 message.type == UndoRedoMessage::Type::BeginPurge ||
1180 message.type == UndoRedoMessage::Type::EndPurge)
1181 return;
1182
1183 auto& trackList = TrackList::Get(mProject);
1184
1185 // Realtime effect UI is only updated on Undo or Redo
1186 auto waveTracks = trackList.Any<WaveTrack>();
1187
1188 if (
1189 message.type == UndoRedoMessage::Type::UndoOrRedo ||
1190 message.type == UndoRedoMessage::Type::Reset)
1191 {
1192 for (auto waveTrack : waveTracks)
1193 UpdateRealtimeEffectUIData(*waveTrack);
1194 }
1195
1196 // But mPotentiallyRemovedTracks processing happens as fast as possible.
1197 // This event is fired right after the track is deleted, so we do not
1198 // hold the strong reference to the track much longer than need.
1199 if (mPotentiallyRemovedTracks.empty())
1200 return;
1201
1202 // Collect RealtimeEffectUIs that are currently shown
1203 // for the potentially removed tracks
1204 std::vector<RealtimeEffectStateUI*> shownUIs;
1205
1206 for (auto track : mPotentiallyRemovedTracks)
1207 {
1208 // By construction, track cannot be null
1209 assert(track != nullptr);
1210
1212 *track,
1213 [&shownUIs](auto& ui)
1214 {
1215 if (ui.IsShown())
1216 shownUIs.push_back(&ui);
1217 });
1218 }
1219
1220 // For every UI shown - check if the corresponding state
1221 // is reachable from the current track list.
1222 for (auto effectUI : shownUIs)
1223 {
1224 bool reachable = false;
1225
1226 for (auto track : waveTracks)
1227 {
1229 *track,
1230 [effectUI, &reachable](auto& ui)
1231 {
1232 if (effectUI == &ui)
1233 reachable = true;
1234 });
1235
1236 if (reachable)
1237 break;
1238 }
1239
1240 if (!reachable)
1241 // Don't need to autosave for an unreachable state
1242 effectUI->Hide();
1243 }
1244
1246 });
1247
1249 .Subscribe([this](const TrackFocusChangeMessage& msg) {
1250 if (IsShown())
1251 {
1252 auto& trackFocus = TrackFocus::Get(mProject);
1253 ShowPanel(dynamic_cast<SampleTrack *>(trackFocus.Get()), false);
1254 }
1255 });
1256
1257 Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent&) {
1258 HidePanel(); });
1259}
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
static PendingTracks & Get(AudacityProject &project)
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()
Definition: TrackFocus.cpp:156
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
void MarkUnsaved()
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
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:803
const int mExtra
Definition: Track.h:839
const std::weak_ptr< Track > mpTrack
Definition: Track.h:838
const Type mType
Definition: Track.h:837
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:825
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:819
@ TRACK_DATA_CHANGE
Posted when certain fields of a track change.
Definition: Track.h:809
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(), PendingTracks::Get(), TrackList::Get(), HidePanel(), AButton::IsDown(), UndoManager::MarkUnsaved(), 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 1261 of file RealtimeEffectPanel.cpp.

1262{
1263}

Member Function Documentation

◆ Get() [1/2]

RealtimeEffectPanel & RealtimeEffectPanel::Get ( AudacityProject project)
static

Definition at line 1058 of file RealtimeEffectPanel.cpp.

1059{
1061}
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:318
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 1064 of file RealtimeEffectPanel.cpp.

1065{
1066 return Get(const_cast<AudacityProject &>(project));
1067}
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 1292 of file RealtimeEffectPanel.cpp.

1293{
1294 wxWindowUpdateLocker freeze(this);
1295
1296 auto &projectWindow = ProjectWindow::Get(mProject);
1297 const auto pContainerWindow = projectWindow.GetContainerWindow();
1298 const auto pTrackListWindow = projectWindow.GetTrackListWindow();
1299 if (pContainerWindow->GetWindow2() == nullptr)
1300 //only effects panel is present, restore split positions before removing effects panel
1301 //Workaround: ::Replace and ::Initialize do not work here...
1302 pContainerWindow->SplitVertically(this, pTrackListWindow);
1303
1304 pContainerWindow->Unsplit(this);
1305 pTrackListWindow->SetFocus();
1306 projectWindow.Layout();
1307}
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 1343 of file RealtimeEffectPanel.cpp.

1344{
1345 if(evt.GetKeyCode() == WXK_ESCAPE && IsShown() && IsDescendant(FindFocus()))
1346 Close();
1347 else
1348 evt.Skip();
1349}
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:375

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 1329 of file RealtimeEffectPanel.cpp.

1330{
1331 mTrackTitle->SetLabel(wxEmptyString);
1334 mCurrentTrack.reset();
1335 mHeader->SetName(wxEmptyString);
1336}
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 1338 of file RealtimeEffectPanel.cpp.

1339{
1340 mHeader->SetFocus();
1341}

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 1309 of file RealtimeEffectPanel.cpp.

1310{
1311 //Avoid creation-on-demand of a useless, empty list in case the track is of non-wave type.
1312 if(track && dynamic_cast<WaveTrack*>(&*track) != nullptr)
1313 {
1314 mTrackTitle->SetLabel(track->GetName());
1316 track && RealtimeEffectList::Get(*track).IsActive()
1318 : mToggleEffects->PopUp();
1319 mEffectList->SetTrack(mProject, track);
1320
1321 mCurrentTrack = track;
1322 //i18n-hint: argument - track name
1323 mHeader->SetName(wxString::Format(_("Realtime effects for %s"), track->GetName()));
1324 }
1325 else
1326 ResetTrack();
1327}
#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 1265 of file RealtimeEffectPanel.cpp.

1266{
1267 if(track == nullptr)
1268 {
1269 ResetTrack();
1270 return;
1271 }
1272
1273 wxWindowUpdateLocker freeze(this);
1274
1276
1277 auto &projectWindow = ProjectWindow::Get(mProject);
1278 const auto pContainerWindow = projectWindow.GetContainerWindow();
1279 if (pContainerWindow->GetWindow1() != this)
1280 {
1281 //Restore previous effects window size
1282 pContainerWindow->SplitVertically(
1283 this,
1284 projectWindow.GetTrackListWindow(),
1285 this->GetSize().GetWidth());
1286 }
1287 if(focus)
1288 SetFocus();
1289 projectWindow.Layout();
1290}
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:146

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: