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

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

1260{
1261}

Member Function Documentation

◆ Get() [1/2]

RealtimeEffectPanel & RealtimeEffectPanel::Get ( AudacityProject project)
static

Definition at line 1056 of file RealtimeEffectPanel.cpp.

1057{
1059}
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 1062 of file RealtimeEffectPanel.cpp.

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

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

1342{
1343 if(evt.GetKeyCode() == WXK_ESCAPE && IsShown() && IsDescendant(FindFocus()))
1344 Close();
1345 else
1346 evt.Skip();
1347}
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 1327 of file RealtimeEffectPanel.cpp.

1328{
1329 mTrackTitle->SetLabel(wxEmptyString);
1332 mCurrentTrack.reset();
1333 mHeader->SetName(wxEmptyString);
1334}
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 1336 of file RealtimeEffectPanel.cpp.

1337{
1338 mHeader->SetFocus();
1339}

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

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

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