Audacity 3.2.0
Classes | 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 SetTrack (const std::shared_ptr< Track > &track)
 Shows effects from the effect stack of the track. More...
 
void ResetTrack ()
 
bool IsTopNavigationDomain (NavigationKind) const override
 
void SetFocus () override
 

Private Member Functions

void OnCharHook (wxKeyEvent &evt)
 

Private Attributes

AButtonmToggleEffects {nullptr}
 
wxStaticText * mTrackTitle {nullptr}
 
RealtimeEffectListWindowmEffectList {nullptr}
 
wxWindow * mHeader {nullptr}
 
AudacityProjectmProject
 
std::weak_ptr< TrackmCurrentTrack
 
Observer::Subscription mTrackListChanged
 
Observer::Subscription mUndoSubscription
 
std::vector< std::shared_ptr< Track > > 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 1323 of file RealtimeEffectPanel.cpp.

1327 : wxPanel(parent, id, pos, size, style, name)
1328 , mProject(project)
1329 , mPrefsListenerHelper(std::make_unique<PrefsListenerHelper>(project))
1330{
1331 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1332
1333 auto header = safenew ThemedWindowWrapper<ListNavigationPanel>(this, wxID_ANY);
1334 header->SetMinClientSize({254, -1});
1335#if wxUSE_ACCESSIBILITY
1336 safenew WindowAccessible(header);
1337#endif
1338 header->SetBackgroundColorIndex(clrMedium);
1339 {
1340 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1341 auto toggleEffects = safenew ThemedAButtonWrapper<AButton>(header);
1342 toggleEffects->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
1343 toggleEffects->SetButtonToggles(true);
1344 toggleEffects->SetTranslatableLabel(XO("Power"));
1345 toggleEffects->SetBackgroundColorIndex(clrMedium);
1346 mToggleEffects = toggleEffects;
1347
1348 toggleEffects->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
1349 if (mEffectList)
1350 {
1352
1354 }
1355 });
1356
1357 hSizer->Add(toggleEffects, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxLEFT, 5);
1358 {
1359 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1360
1361 auto headerText = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString);
1362 headerText->SetFont(wxFont(wxFontInfo().Bold()));
1363 headerText->SetTranslatableLabel(XO("Realtime Effects"));
1364 headerText->SetForegroundColorIndex(clrTrackPanelText);
1365
1366 auto trackTitle = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
1367 trackTitle->SetForegroundColorIndex(clrTrackPanelText);
1368 mTrackTitle = trackTitle;
1369
1370 vSizer->Add(headerText);
1371 vSizer->Add(trackTitle);
1372
1373 hSizer->Add(vSizer.release(), 1, wxEXPAND | wxALL, 10);
1374 }
1375 auto close = safenew ThemedAButtonWrapper<AButton>(header);
1376 close->SetTranslatableLabel(XO("Close"));
1377 close->SetImageIndices(0, bmpCloseNormal, bmpCloseHover, bmpCloseDown, bmpCloseHover, bmpCloseDisabled);
1378 close->SetBackgroundColorIndex(clrMedium);
1379
1380 close->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { Close(); });
1381
1382 hSizer->Add(close, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxRIGHT, 5);
1383
1384 header->SetSizer(hSizer.release());
1385 }
1386 vSizer->Add(header, 0, wxEXPAND);
1387
1388 auto effectList = safenew ThemedWindowWrapper<RealtimeEffectListWindow>(this, wxID_ANY);
1389 effectList->SetBackgroundColorIndex(clrMedium);
1390 vSizer->Add(effectList, 1, wxEXPAND);
1391
1392 mHeader = header;
1393 mEffectList = effectList;
1394
1395 SetSizerAndFit(vSizer.release());
1396
1397 Bind(wxEVT_CHAR_HOOK, &RealtimeEffectPanel::OnCharHook, this);
1399 auto track = evt.mpTrack.lock();
1400 auto waveTrack = dynamic_cast<WaveTrack*>(track.get());
1401
1402 if (waveTrack == nullptr)
1403 return;
1404
1405 switch (evt.mType)
1406 {
1408 if (mCurrentTrack.lock() == track)
1409 mTrackTitle->SetLabel(track->GetName());
1410 UpdateRealtimeEffectUIData(*waveTrack);
1411 break;
1413 if (evt.mExtra == 0)
1414 mPotentiallyRemovedTracks.push_back(track);
1415 break;
1417 // Addition can be fired as a part of "replace" event.
1418 // Calling UpdateRealtimeEffectUIData is mostly no-op,
1419 // it will just create a new State and Access for it.
1420 UpdateRealtimeEffectUIData(*waveTrack);
1421 break;
1422 default:
1423 break;
1424 }
1425 });
1426
1428 [this](UndoRedoMessage message)
1429 {
1430 if (
1431 message.type == UndoRedoMessage::Type::Purge ||
1432 message.type == UndoRedoMessage::Type::BeginPurge ||
1433 message.type == UndoRedoMessage::Type::EndPurge)
1434 return;
1435
1436 auto& trackList = TrackList::Get(mProject);
1437
1438 // Realtime effect UI is only updated on Undo or Redo
1439 auto waveTracks = trackList.Any<WaveTrack>();
1440
1441 if (
1442 message.type == UndoRedoMessage::Type::UndoOrRedo ||
1443 message.type == UndoRedoMessage::Type::Reset)
1444 {
1445 for (auto waveTrack : waveTracks)
1446 UpdateRealtimeEffectUIData(*waveTrack);
1447 }
1448
1449 // But mPotentiallyRemovedTracks processing happens as fast as possible.
1450 // This event is fired right after the track is deleted, so we do not
1451 // hold the strong reference to the track much longer than need.
1452 if (mPotentiallyRemovedTracks.empty())
1453 return;
1454
1455 // Collect RealtimeEffectUIs that are currently shown
1456 // for the potentially removed tracks
1457 std::vector<RealtimeEffectStateUI*> shownUIs;
1458
1459 for (auto track : mPotentiallyRemovedTracks)
1460 {
1461 // By construction, track cannot be null
1462 assert(track != nullptr);
1463
1465 *track,
1466 [&shownUIs](auto& ui)
1467 {
1468 if (ui.IsShown())
1469 shownUIs.push_back(&ui);
1470 });
1471 }
1472
1473 // For every UI shown - check if the corresponding state
1474 // is reachable from the current track list.
1475 for (auto effectUI : shownUIs)
1476 {
1477 bool reachable = false;
1478
1479 for (auto track : waveTracks)
1480 {
1482 *track,
1483 [effectUI, &reachable](auto& ui)
1484 {
1485 if (effectUI == &ui)
1486 reachable = true;
1487 });
1488
1489 if (reachable)
1490 break;
1491 }
1492
1493 if (!reachable)
1494 // Don't need to autosave for an unreachable state
1495 effectUI->Hide();
1496 }
1497
1499 });
1500}
const TranslatableString name
Definition: Distortion.cpp:82
#define XO(s)
Definition: Internat.h:31
#define safenew
Definition: MemoryX.h:10
for(int ii=0, nn=names.size();ii< nn;++ii)
bool IsDown()
Definition: AButton.h:129
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)
std::weak_ptr< Track > mCurrentTrack
Observer::Subscription mUndoSubscription
std::vector< std::shared_ptr< Track > > mPotentiallyRemovedTracks
wxStaticText * mTrackTitle
RealtimeEffectListWindow * mEffectList
void OnCharHook(wxKeyEvent &evt)
std::unique_ptr< PrefsListenerHelper > mPrefsListenerHelper
AudacityProject & mProject
Observer::Subscription mTrackListChanged
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1437
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:67
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
void VisitRealtimeEffectStateUIs(Track &track, Visitor &&visitor)
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:1288
const int mExtra
Definition: Track.h:1327
const std::weak_ptr< Track > mpTrack
Definition: Track.h:1326
const Type mType
Definition: Track.h:1325
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:1313
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:1307
@ TRACK_DATA_CHANGE
Posted when certain fields of a track change.
Definition: Track.h:1294
Type of message published by UndoManager.
Definition: UndoManager.h:61
enum UndoRedoMessage::Type type

References TrackListEvent::ADDITION, TrackList::Any(), TrackListEvent::DELETION, RealtimeEffectListWindow::EnableEffects(), for(), ProjectHistory::Get(), UndoManager::Get(), TrackList::Get(), AButton::IsDown(), mCurrentTrack, mEffectList, TrackListEvent::mExtra, mHeader, ProjectHistory::ModifyState(), mPotentiallyRemovedTracks, mProject, TrackListEvent::mpTrack, mToggleEffects, mTrackListChanged, mTrackTitle, TrackListEvent::mType, mUndoSubscription, OnCharHook(), safenew, 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 1502 of file RealtimeEffectPanel.cpp.

1503{
1504}

Member Function Documentation

◆ IsTopNavigationDomain()

bool RealtimeEffectPanel::IsTopNavigationDomain ( NavigationKind  ) const
inlineoverride

Definition at line 72 of file RealtimeEffectPanel.h.

72{ return true; }

◆ OnCharHook()

void RealtimeEffectPanel::OnCharHook ( wxKeyEvent &  evt)
private

Definition at line 1540 of file RealtimeEffectPanel.cpp.

1541{
1542 if(evt.GetKeyCode() == WXK_ESCAPE && IsShown() && IsDescendant(FindFocus()))
1543 Close();
1544 else
1545 evt.Skip();
1546}

Referenced by RealtimeEffectPanel().

Here is the caller graph for this function:

◆ ResetTrack()

void RealtimeEffectPanel::ResetTrack ( )

Definition at line 1526 of file RealtimeEffectPanel.cpp.

1527{
1528 mTrackTitle->SetLabel(wxEmptyString);
1531 mCurrentTrack.reset();
1532 mHeader->SetName(wxEmptyString);
1533}
void Disable()
Definition: AButton.cpp:625

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

Referenced by SetTrack(), and ProjectWindow::ShowEffectsPanel().

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

◆ SetFocus()

void RealtimeEffectPanel::SetFocus ( )
override

Definition at line 1535 of file RealtimeEffectPanel.cpp.

1536{
1537 mHeader->SetFocus();
1538}

References mHeader.

Referenced by ProjectWindow::ShowEffectsPanel().

Here is the caller graph for this function:

◆ SetTrack()

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

Shows effects from the effect stack of the track.

Parameters
trackPointer to the existing track, or null

Definition at line 1506 of file RealtimeEffectPanel.cpp.

1507{
1508 //Avoid creation-on-demand of a useless, empty list in case the track is of non-wave type.
1509 if(track && dynamic_cast<WaveTrack*>(&*track) != nullptr)
1510 {
1511 mTrackTitle->SetLabel(track->GetName());
1513 track && RealtimeEffectList::Get(*track).IsActive()
1515 : mToggleEffects->PopUp();
1516 mEffectList->SetTrack(mProject, track);
1517
1518 mCurrentTrack = track;
1519 //i18n-hint: argument - track name
1520 mHeader->SetName(wxString::Format(_("Realtime effects for %s"), track->GetName()));
1521 }
1522 else
1523 ResetTrack();
1524}
#define _(s)
Definition: Internat.h:75
void PushDown()
Definition: AButton.cpp:642
void Enable()
Definition: AButton.cpp:616
void PopUp()
Definition: AButton.cpp:650
static RealtimeEffectList & Get(AudacityProject &project)
bool IsActive() const
Non-blocking atomic boolean load.
void SetTrack(AudacityProject &project, const std::shared_ptr< Track > &track)

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

Referenced by ProjectWindow::ShowEffectsPanel().

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

Member Data Documentation

◆ mCurrentTrack

std::weak_ptr<Track> 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().

◆ 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<Track> > RealtimeEffectPanel::mPotentiallyRemovedTracks
private

Definition at line 47 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel().

◆ mPrefsListenerHelper

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

Definition at line 52 of file RealtimeEffectPanel.h.

◆ mProject

AudacityProject& RealtimeEffectPanel::mProject
private

Definition at line 40 of file RealtimeEffectPanel.h.

Referenced by RealtimeEffectPanel(), and SetTrack().

◆ 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: