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 (Track *track, bool focus)
 
void HidePanel ()
 
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
 

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< TrackmCurrentTrack
 
Observer::Subscription mTrackListChanged
 
Observer::Subscription mUndoSubscription
 
Observer::Subscription mFocusChangeSubscription
 
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 1368 of file RealtimeEffectPanel.cpp.

1372 : wxPanel(parent, id, pos, size, style, name)
1373 , mProject(project)
1374 , mPrefsListenerHelper(std::make_unique<PrefsListenerHelper>(project))
1375{
1376 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1377
1378 auto header = safenew ThemedWindowWrapper<ListNavigationPanel>(this, wxID_ANY);
1379#if wxUSE_ACCESSIBILITY
1380 safenew WindowAccessible(header);
1381#endif
1382 header->SetBackgroundColorIndex(clrMedium);
1383 {
1384 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1385 auto toggleEffects = safenew ThemedAButtonWrapper<AButton>(header);
1386 toggleEffects->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
1387 toggleEffects->SetButtonToggles(true);
1388 toggleEffects->SetTranslatableLabel(XO("Power"));
1389 toggleEffects->SetBackgroundColorIndex(clrMedium);
1390 mToggleEffects = toggleEffects;
1391
1392 toggleEffects->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
1393 if (mEffectList)
1394 {
1396
1398 }
1399 });
1400
1401 hSizer->Add(toggleEffects, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxLEFT, 5);
1402 {
1403 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1404
1405 auto headerText = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString);
1406 headerText->SetFont(wxFont(wxFontInfo().Bold()));
1407 headerText->SetTranslatableLabel(XO("Realtime Effects"));
1408 headerText->SetForegroundColorIndex(clrTrackPanelText);
1409
1410 auto trackTitle = safenew ThemedWindowWrapper<wxStaticText>(header, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
1411 trackTitle->SetForegroundColorIndex(clrTrackPanelText);
1412 mTrackTitle = trackTitle;
1413
1414 vSizer->Add(headerText);
1415 vSizer->Add(trackTitle);
1416
1417 hSizer->Add(vSizer.release(), 1, wxEXPAND | wxALL, 10);
1418 }
1419 auto close = safenew ThemedAButtonWrapper<AButton>(header);
1420 close->SetTranslatableLabel(XO("Close"));
1421 close->SetImageIndices(0, bmpCloseNormal, bmpCloseHover, bmpCloseDown, bmpCloseHover, bmpCloseDisabled);
1422 close->SetBackgroundColorIndex(clrMedium);
1423
1424 close->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { Close(); });
1425
1426 hSizer->Add(close, 0, wxSTRETCH_NOT | wxALIGN_CENTER | wxRIGHT, 5);
1427
1428 header->SetSizer(hSizer.release());
1429 }
1430 vSizer->Add(header, 0, wxEXPAND);
1431
1432 auto effectList = safenew ThemedWindowWrapper<RealtimeEffectListWindow>(this, wxID_ANY);
1433 effectList->SetBackgroundColorIndex(clrMedium);
1434 vSizer->Add(effectList, 1, wxEXPAND);
1435
1436 mHeader = header;
1437 mEffectList = effectList;
1438
1439 SetSizerAndFit(vSizer.release());
1440
1441 Bind(wxEVT_CHAR_HOOK, &RealtimeEffectPanel::OnCharHook, this);
1443 auto track = evt.mpTrack.lock();
1444 auto waveTrack = dynamic_cast<WaveTrack*>(track.get());
1445
1446 if (waveTrack == nullptr)
1447 return;
1448
1449 switch (evt.mType)
1450 {
1452 if (mCurrentTrack.lock() == track)
1453 mTrackTitle->SetLabel(track->GetName());
1454 UpdateRealtimeEffectUIData(*waveTrack);
1455 break;
1457 if (evt.mExtra == 0)
1458 mPotentiallyRemovedTracks.push_back(track);
1459 break;
1461 // Addition can be fired as a part of "replace" event.
1462 // Calling UpdateRealtimeEffectUIData is mostly no-op,
1463 // it will just create a new State and Access for it.
1464 UpdateRealtimeEffectUIData(*waveTrack);
1465 break;
1466 default:
1467 break;
1468 }
1469 });
1470
1472 [this](UndoRedoMessage message)
1473 {
1474 if (
1475 message.type == UndoRedoMessage::Type::Purge ||
1476 message.type == UndoRedoMessage::Type::BeginPurge ||
1477 message.type == UndoRedoMessage::Type::EndPurge)
1478 return;
1479
1480 auto& trackList = TrackList::Get(mProject);
1481
1482 // Realtime effect UI is only updated on Undo or Redo
1483 auto waveTracks = trackList.Any<WaveTrack>();
1484
1485 if (
1486 message.type == UndoRedoMessage::Type::UndoOrRedo ||
1487 message.type == UndoRedoMessage::Type::Reset)
1488 {
1489 for (auto waveTrack : waveTracks)
1490 UpdateRealtimeEffectUIData(*waveTrack);
1491 }
1492
1493 // But mPotentiallyRemovedTracks processing happens as fast as possible.
1494 // This event is fired right after the track is deleted, so we do not
1495 // hold the strong reference to the track much longer than need.
1496 if (mPotentiallyRemovedTracks.empty())
1497 return;
1498
1499 // Collect RealtimeEffectUIs that are currently shown
1500 // for the potentially removed tracks
1501 std::vector<RealtimeEffectStateUI*> shownUIs;
1502
1503 for (auto track : mPotentiallyRemovedTracks)
1504 {
1505 // By construction, track cannot be null
1506 assert(track != nullptr);
1507
1509 *track,
1510 [&shownUIs](auto& ui)
1511 {
1512 if (ui.IsShown())
1513 shownUIs.push_back(&ui);
1514 });
1515 }
1516
1517 // For every UI shown - check if the corresponding state
1518 // is reachable from the current track list.
1519 for (auto effectUI : shownUIs)
1520 {
1521 bool reachable = false;
1522
1523 for (auto track : waveTracks)
1524 {
1526 *track,
1527 [effectUI, &reachable](auto& ui)
1528 {
1529 if (effectUI == &ui)
1530 reachable = true;
1531 });
1532
1533 if (reachable)
1534 break;
1535 }
1536
1537 if (!reachable)
1538 // Don't need to autosave for an unreachable state
1539 effectUI->Hide();
1540 }
1541
1543 });
1544
1546 .Subscribe([this](const TrackFocusChangeMessage& msg) {
1547 if (IsShown())
1548 {
1549 auto& trackFocus = TrackFocus::Get(mProject);
1550 ShowPanel(trackFocus.Get(), false);
1551 }
1552 });
1553
1554 Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent&) {
1555 HidePanel(); });
1556}
const TranslatableString name
Definition: Distortion.cpp:74
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
for(int ii=0, nn=names.size();ii< nn;++ii)
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)
std::weak_ptr< Track > mCurrentTrack
Observer::Subscription mUndoSubscription
void ShowPanel(Track *track, bool focus)
std::vector< std::shared_ptr< Track > > mPotentiallyRemovedTracks
wxStaticText * mTrackTitle
RealtimeEffectListWindow * mEffectList
void OnCharHook(wxKeyEvent &evt)
std::unique_ptr< PrefsListenerHelper > mPrefsListenerHelper
Observer::Subscription mFocusChangeSubscription
AudacityProject & mProject
Observer::Subscription mTrackListChanged
Track * Get()
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(), 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(), 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 1558 of file RealtimeEffectPanel.cpp.

1559{
1560}

Member Function Documentation

◆ Get() [1/2]

RealtimeEffectPanel & RealtimeEffectPanel::Get ( AudacityProject project)
static

Definition at line 1357 of file RealtimeEffectPanel.cpp.

1358{
1360}
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(), 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 1363 of file RealtimeEffectPanel.cpp.

1364{
1365 return Get(const_cast<AudacityProject &>(project));
1366}
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().

Here is the call graph for this function:

◆ HidePanel()

void RealtimeEffectPanel::HidePanel ( )

Definition at line 1589 of file RealtimeEffectPanel.cpp.

1590{
1591 wxWindowUpdateLocker freeze(this);
1592
1593 auto &projectWindow = ProjectWindow::Get(mProject);
1594 const auto pContainerWindow = projectWindow.GetContainerWindow();
1595 const auto pTrackListWindow = projectWindow.GetTrackListWindow();
1596 if (pContainerWindow->GetWindow2() == nullptr)
1597 //only effects panel is present, restore split positions before removing effects panel
1598 //Workaround: ::Replace and ::Initialize do not work here...
1599 pContainerWindow->SplitVertically(this, pTrackListWindow);
1600
1601 pContainerWindow->Unsplit(this);
1602 pTrackListWindow->SetFocus();
1603 projectWindow.Layout();
1604}
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 1640 of file RealtimeEffectPanel.cpp.

1641{
1642 if(evt.GetKeyCode() == WXK_ESCAPE && IsShown() && IsDescendant(FindFocus()))
1643 Close();
1644 else
1645 evt.Skip();
1646}

Referenced by RealtimeEffectPanel().

Here is the caller graph for this function:

◆ ResetTrack()

void RealtimeEffectPanel::ResetTrack ( )

Definition at line 1626 of file RealtimeEffectPanel.cpp.

1627{
1628 mTrackTitle->SetLabel(wxEmptyString);
1631 mCurrentTrack.reset();
1632 mHeader->SetName(wxEmptyString);
1633}
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 1635 of file RealtimeEffectPanel.cpp.

1636{
1637 mHeader->SetFocus();
1638}

References mHeader.

Referenced by ShowPanel().

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

1607{
1608 //Avoid creation-on-demand of a useless, empty list in case the track is of non-wave type.
1609 if(track && dynamic_cast<WaveTrack*>(&*track) != nullptr)
1610 {
1611 mTrackTitle->SetLabel(track->GetName());
1613 track && RealtimeEffectList::Get(*track).IsActive()
1615 : mToggleEffects->PopUp();
1616 mEffectList->SetTrack(mProject, track);
1617
1618 mCurrentTrack = track;
1619 //i18n-hint: argument - track name
1620 mHeader->SetName(wxString::Format(_("Realtime effects for %s"), track->GetName()));
1621 }
1622 else
1623 ResetTrack();
1624}
#define _(s)
Definition: Internat.h:75
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< 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 ShowPanel().

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

◆ ShowPanel()

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

Definition at line 1562 of file RealtimeEffectPanel.cpp.

1563{
1564 if(track == nullptr)
1565 {
1566 ResetTrack();
1567 return;
1568 }
1569
1570 wxWindowUpdateLocker freeze(this);
1571
1572 SetTrack(track->shared_from_this());
1573
1574 auto &projectWindow = ProjectWindow::Get(mProject);
1575 const auto pContainerWindow = projectWindow.GetContainerWindow();
1576 if (pContainerWindow->GetWindow1() != this)
1577 {
1578 //Restore previous effects window size
1579 pContainerWindow->SplitVertically(
1580 this,
1581 projectWindow.GetTrackListWindow(),
1582 this->GetSize().GetWidth());
1583 }
1584 if(focus)
1585 SetFocus();
1586 projectWindow.Layout();
1587}
void SetTrack(const std::shared_ptr< Track > &track)
Shows effects from the effect stack of the track.

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

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<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().

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