Audacity  3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
TrackList Class Referencefinal

A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list of tracks, event notifications. More...

#include <Track.h>

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

Public Types

using iterator = TrackIter< Track >
 
using const_iterator = TrackIter< const Track >
 
using value_type = Track *
 
using Updater = std::function< void(Track &dest, const Track &src) >
 
- Public Types inherited from Observer::Publisher< TrackListEvent >
using message_type = TrackListEvent
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const TrackListEvent &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

 TrackList (AudacityProject *pOwner)
 
void Swap (TrackList &that)
 
virtual ~TrackList ()
 
AudacityProjectGetOwner ()
 
const AudacityProjectGetOwner () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
template<typename TrackType = Track>
auto Find (Track *pTrack) -> TrackIter< TrackType >
 Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track. More...
 
template<typename TrackType = const Track>
auto Find (const Track *pTrack) const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIter< TrackType > >
 Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track. More...
 
TrackIter< TrackFindLeader (Track *pTrack)
 
TrackIter< const TrackFindLeader (const Track *pTrack) const
 
template<typename TrackType = Track>
auto Any () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Any () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
template<typename TrackType = Track>
auto Selected () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Selected () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
template<typename TrackType = Track>
auto Leaders () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Leaders () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
template<typename TrackType = Track>
auto SelectedLeaders () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto SelectedLeaders () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
void Permute (const std::vector< TrackNodePointer > &permutation)
 For use in sorting: assume each iterator points into this list, no duplications. More...
 
TrackFindById (TrackId id)
 
template<typename TrackKind >
TrackKind * AddToHead (const std::shared_ptr< TrackKind > &t)
 Add a Track, giving it a fresh id. More...
 
template<typename TrackKind >
TrackKind * Add (const std::shared_ptr< TrackKind > &t)
 
void UnlinkChannels (Track &track)
 Removes linkage if track belongs to a group. More...
 
bool MakeMultiChannelTrack (Track &first, int nChannels, bool aligned)
 Converts channels to a multichannel track. More...
 
ListOfTracks::value_type Replace (Track *t, const ListOfTracks::value_type &with)
 
TrackNodePointer Remove (Track *t)
 Remove the Track and return an iterator to what followed it. More...
 
void Clear (bool sendEvent=true)
 Make the list empty. More...
 
bool CanMoveUp (Track *t) const
 
bool CanMoveDown (Track *t) const
 
bool MoveUp (Track *t)
 
bool MoveDown (Track *t)
 
bool Move (Track *t, bool up)
 
bool Contains (const Track *t) const
 Mainly a test function. Uses a linear search, so could be slow. More...
 
template<typename Subclass >
std::shared_ptr< Subclass > Lock (const std::weak_ptr< Subclass > &wTrack)
 
bool empty () const
 
size_t size () const
 
double GetStartTime () const
 
double GetEndTime () const
 
double GetMinOffset () const
 
std::shared_ptr< TrackRegisterPendingChangedTrack (Updater updater, Track *src)
 
void RegisterPendingNewTrack (const std::shared_ptr< Track > &pTrack)
 
void UpdatePendingTracks ()
 
void ClearPendingTracks (ListOfTracks *pAdded=nullptr)
 
bool ApplyPendingTracks ()
 
bool HasPendingTracks () const
 
- Public Member Functions inherited from Observer::Publisher< TrackListEvent >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static TrackListGet (AudacityProject &project)
 
static const TrackListGet (const AudacityProject &project)
 
static std::shared_ptr< TrackListCreate (AudacityProject *pOwner)
 
template<typename TrackType >
static auto SingletonRange (TrackType *pTrack) -> TrackIterRange< TrackType >
 
template<typename TrackType >
static auto Channels (TrackType *pTrack) -> TrackIterRange< TrackType >
 

Private Member Functions

 TrackList (const TrackList &that)=delete
 
TrackListoperator= (const TrackList &)=delete
 
 TrackList (TrackList &&that)=delete
 
TrackListoperator= (TrackList &&)=delete
 
void clear ()=delete
 
TrackDoAddToHead (const std::shared_ptr< Track > &t)
 
TrackDoAdd (const std::shared_ptr< Track > &t)
 
template<typename TrackType = Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto Tracks (const Pred &pred={}) -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto Tracks (const Pred &pred={}) const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
TrackGetPrev (Track *t, bool linked=false) const
 
TrackGetNext (Track *t, bool linked=false) const
 Return a track in the list that comes after Track t. More...
 
template<typename TrackType >
TrackIter< TrackType > MakeTrackIterator (TrackNodePointer iter) const
 
template<typename TrackType >
TrackIter< TrackType > EndIterator () const
 
TrackIterRange< TrackEmptyRange () const
 
bool isNull (TrackNodePointer p) const
 
TrackNodePointer getEnd () const
 
TrackNodePointer getBegin () const
 
TrackNodePointer getNext (TrackNodePointer p) const
 Move an iterator to the next node, if any; else stay at end. More...
 
TrackNodePointer getPrev (TrackNodePointer p) const
 Move an iterator to the previous node, if any; else wrap to end. More...
 
void RecalcPositions (TrackNodePointer node)
 
void QueueEvent (TrackListEvent event)
 
void SelectionEvent (const std::shared_ptr< Track > &pTrack)
 
void PermutationEvent (TrackNodePointer node)
 
void DataEvent (const std::shared_ptr< Track > &pTrack, int code)
 
void EnsureVisibleEvent (const std::shared_ptr< Track > &pTrack, bool modifyState)
 
void DeletionEvent (TrackNodePointer node={})
 
void AdditionEvent (TrackNodePointer node)
 
void ResizingEvent (TrackNodePointer node)
 
void SwapNodes (TrackNodePointer s1, TrackNodePointer s2)
 

Static Private Member Functions

template<typename TrackType , typename InTrackType >
static TrackIterRange< TrackType > Channels_ (TrackIter< InTrackType > iter1)
 

Private Attributes

AudacityProjectmOwner
 
ListOfTracks mPendingUpdates
 Shadow tracks holding append-recording in progress; need to put them into a list so that GetLink() works. More...
 
std::vector< UpdatermUpdaters
 This is in correspondence with mPendingUpdates. More...
 

Static Private Attributes

static long sCounter = -1
 

Friends

class Track
 

Additional Inherited Members

- Static Public Attributes inherited from Observer::Publisher< TrackListEvent >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< TrackListEvent >
CallbackReturn Publish (const TrackListEvent &message)
 Send a message to connected callbacks. More...
 

Detailed Description

A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list of tracks, event notifications.

Definition at line 1283 of file Track.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 1330 of file Track.h.

◆ iterator

Definition at line 1329 of file Track.h.

◆ Updater

using TrackList::Updater = std::function< void(Track &dest, const Track &src) >

Definition at line 1664 of file Track.h.

◆ value_type

Definition at line 1331 of file Track.h.

Constructor & Destructor Documentation

◆ TrackList() [1/3]

TrackList::TrackList ( const TrackList that)
privatedelete

◆ TrackList() [2/3]

TrackList::TrackList ( TrackList &&  that)
privatedelete

◆ TrackList() [3/3]

TrackList::TrackList ( AudacityProject pOwner)
explicit

Definition at line 387 of file Track.cpp.

388  : mOwner{ pOwner }
389 {
390 }

◆ ~TrackList()

TrackList::~TrackList ( )
virtual

Definition at line 429 of file Track.cpp.

430 {
431  Clear(false);
432 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

template<typename TrackKind >
TrackKind* TrackList::Add ( const std::shared_ptr< TrackKind > &  t)
inline

Definition at line 1502 of file Track.h.

1503  { return static_cast< TrackKind* >( DoAdd( t ) ); }

Referenced by Effect::AddedAnalysisTrack::AddedAnalysisTrack(), ApplyPendingTracks(), Effect::DoEffect(), anonymous_namespace{EditMenus.cpp}::FinishCopy(), AUPImportFileHandle::HandleLabelTrack(), AUPImportFileHandle::HandleNoteTrack(), AUPImportFileHandle::HandleTimeTrack(), AUPImportFileHandle::HandleWaveTrack(), Effect::Preview(), Effect::ReplaceProcessedTracks(), and LabelDialog::TransferDataFromWindow().

Here is the caller graph for this function:

◆ AdditionEvent()

void TrackList::AdditionEvent ( TrackNodePointer  node)
private

Definition at line 498 of file Track.cpp.

499 {
500  QueueEvent({ TrackListEvent::ADDITION, *node.first });
501 }

References TrackListEvent::ADDITION, and QueueEvent().

Referenced by ApplyPendingTracks(), DoAdd(), and DoAddToHead().

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

◆ AddToHead()

template<typename TrackKind >
TrackKind* TrackList::AddToHead ( const std::shared_ptr< TrackKind > &  t)
inline

Add a Track, giving it a fresh id.

Definition at line 1498 of file Track.h.

1499  { return static_cast< TrackKind* >( DoAddToHead( t ) ); }

◆ Any() [1/2]

template<typename TrackType = Track>
auto TrackList::Any ( ) -> TrackIterRange< TrackType >
inline

Definition at line 1379 of file Track.h.

1381  {
1382  return Tracks< TrackType >();
1383  }

Referenced by anonymous_namespace{Track.cpp}::Accumulate(), ImportCommand::Apply(), LabelDefaultClickHandle::Click(), Effect::CopyInputTracks(), ExportMultipleDialog::CountTracksAndLabels(), ExportPlugin::CreateMixer(), CutCopyAvailableFlag(), LabelTrackView::DoKeyDown(), TrackPanel::DrawTracks(), anonymous_namespace{LabelMenus.cpp}::EditByLabel(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), ControlToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), GetInfoCommand::ExploreTrackPanel(), ExportMultipleDialog::ExportMultipleByTrack(), LabelDialog::FindAllLabels(), anonymous_namespace{Snap.cpp}::FindCandidates(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), ProjectAudioManager::GetAllPlaybackTracks(), GetAllSeqBlocks(), GetNumExportChannels(), TrackView::GetTotalHeight(), MixerBoard::HasSolo(), ClipMoveState::Init(), LabelTracksExistFlag(), anonymous_namespace{FileMenus.cpp}::NoteTracksExistFlag(), AudacityPrintout::OnPrintPage(), ProjectAudioManager::OnRecord(), LabelDialog::OnSelectCell(), ScreenshotBigDialog::OnShortTracks(), TransportActions::Handler::OnTimerRecord(), TranscriptionToolBar::PlayAtSpeed(), ProjectHistory::PopState(), Effect::Preview(), EffectFindClipping::Process(), SelectionState::SelectNone(), SelectionState::SelectRangeOfTracks(), TracksExistFlag(), LabelDialog::TransferDataFromWindow(), LyricsPanel::UpdateLyrics(), TrackPanel::UpdateVRulerSize(), VisitBlocks(), WaveTracksExistFlag(), ZoomInAvailableFlag(), ZoomOutAvailableFlag(), and SelectionStateChanger::~SelectionStateChanger().

Here is the caller graph for this function:

◆ Any() [2/2]

template<typename TrackType = const Track>
auto TrackList::Any ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1386 of file Track.h.

1390  {
1391  return Tracks< TrackType >();
1392  }

◆ ApplyPendingTracks()

bool TrackList::ApplyPendingTracks ( )
Exception safety guarantee:
Strong

Definition at line 989 of file Track.cpp.

990 {
991  bool result = false;
992 
993  ListOfTracks additions;
994  ListOfTracks updates;
995  {
996  // Always clear, even if one of the update functions throws
997  auto cleanup = finally( [&] { ClearPendingTracks( &additions ); } );
999  updates.swap( mPendingUpdates );
1000  }
1001 
1002  // Remaining steps must be No-fail-guarantee so that this function
1003  // gives Strong-guarantee
1004 
1005  std::vector< std::shared_ptr<Track> > reinstated;
1006 
1007  for (auto &pendingTrack : updates) {
1008  if (pendingTrack) {
1009  pendingTrack->AttachedTrackObjects::ForEach([&](auto &attachment){
1010  attachment.Reparent( pendingTrack );
1011  });
1012  auto src = FindById( pendingTrack->GetId() );
1013  if (src)
1014  this->Replace(src, pendingTrack), result = true;
1015  else
1016  // Perhaps a track marked for pending changes got deleted by
1017  // some other action. Recreate it so we don't lose the
1018  // accumulated changes.
1019  reinstated.push_back(pendingTrack);
1020  }
1021  }
1022 
1023  // If there are tracks to reinstate, append them to the list.
1024  for (auto &pendingTrack : reinstated)
1025  if (pendingTrack)
1026  this->Add( pendingTrack ), result = true;
1027 
1028  // Put the pending added tracks back into the list, preserving their
1029  // positions.
1030  bool inserted = false;
1031  ListOfTracks::iterator first;
1032  for (auto &pendingTrack : additions) {
1033  if (pendingTrack) {
1034  auto iter = ListOfTracks::begin();
1035  std::advance( iter, pendingTrack->GetIndex() );
1036  iter = ListOfTracks::insert( iter, pendingTrack );
1037  pendingTrack->SetOwner( shared_from_this(), {iter, this} );
1038  pendingTrack->SetId( TrackId{ ++sCounter } );
1039  if (!inserted) {
1040  first = iter;
1041  inserted = true;
1042  }
1043  }
1044  }
1045  if (inserted) {
1046  TrackNodePointer node{first, this};
1047  RecalcPositions(node);
1048  AdditionEvent(node);
1049  result = true;
1050  }
1051 
1052  return result;
1053 }

References Add(), AdditionEvent(), ClearPendingTracks(), FindById(), mPendingUpdates, RecalcPositions(), Replace(), sCounter, and UpdatePendingTracks().

Referenced by ProjectAudioManager::OnCommitRecording().

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

◆ begin() [1/2]

iterator TrackList::begin ( )
inline

Definition at line 1332 of file Track.h.

1332 { return Any().begin(); }

Referenced by TimeShiftHandle::DoSlideVertical(), empty(), HasPendingTracks(), and EffectTruncSilence::ProcessAll().

Here is the caller graph for this function:

◆ begin() [2/2]

const_iterator TrackList::begin ( ) const
inline

Definition at line 1334 of file Track.h.

1334 { return Any().begin(); }

◆ CanMoveDown()

bool TrackList::CanMoveDown ( Track t) const

Definition at line 755 of file Track.cpp.

756 {
757  return GetNext(t, true) != NULL;
758 }

References GetNext().

Here is the call graph for this function:

◆ CanMoveUp()

bool TrackList::CanMoveUp ( Track t) const

Definition at line 750 of file Track.cpp.

751 {
752  return GetPrev(t, true) != NULL;
753 }

References GetPrev().

Here is the call graph for this function:

◆ cbegin()

const_iterator TrackList::cbegin ( ) const
inline

Definition at line 1336 of file Track.h.

1336 { return begin(); }

◆ cend()

const_iterator TrackList::cend ( ) const
inline

Definition at line 1337 of file Track.h.

1337 { return end(); }

◆ Channels()

template<typename TrackType >
static auto TrackList::Channels ( TrackType *  pTrack) -> TrackIterRange< TrackType >
inlinestatic

Definition at line 1483 of file Track.h.

1485  {
1486  return Channels_<TrackType>( pTrack->GetOwner()->FindLeader(pTrack) );
1487  }

Referenced by AppendItem(), SelectTracksCommand::Apply(), SetTrackBase::Apply(), WaveTrackView::CaptureKey(), anonymous_namespace{ClipMenus.cpp}::ChannelsHaveDifferentClipBoundaries(), anonymous_namespace{TrackPanel.cpp}::ResizingChannelGroup::Children(), anonymous_namespace{TrackPanel.cpp}::Subgroup::Children(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Children(), ProjectAudioManager::ChooseExistingRecordingTracks(), TrackPanelResizeHandle::Click(), CutlineHandle::Click(), EnvelopeHandle::Click(), WaveformPrefs::Commit(), MinimizeButtonHandle::CommitChanges(), TrackShifter::CommonMayMigrateTo(), WaveTrackView::CopySelectedText(), WaveTrackView::CutSelectedText(), anonymous_namespace{TrackMenus.cpp}::DoAlign(), anonymous_namespace{ClipMenus.cpp}::DoClipMove(), WaveformVRulerControls::DoHandleWheelRotation(), SpectrumVRulerControls::DoHandleWheelRotation(), ClipMoveState::DoHorizontalOffset(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), TrackUtilities::DoRemoveTrack(), anonymous_namespace{TrackMenus.cpp}::DoSortTracks(), TrackUtilities::DoTrackMute(), TrackUtilities::DoTrackSolo(), SpectrumVZoomHandle::DoZoom(), WaveformVZoomHandle::DoZoom(), TrackPanelResizeHandle::Drag(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Draw(), TrackPanelResizerCell::Draw(), SpectrumView::Draw(), WaveformView::Draw(), ExportMultipleDialog::ExportMultipleByTrack(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), anonymous_namespace{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), anonymous_namespace{WaveClipTrimHandle.cpp}::FindClipsInChannels(), TrackView::GetChannelGroupHeight(), ContrastDialog::GetDB(), CommonTrackView::GetMinimizedHeight(), MixerTrackCluster::GetRight(), VampEffect::Init(), ClipMoveState::Init(), TrackPanelAx::IsFocused(), LOFImportFileHandle::lofOpenFiles(), MixAndRender(), TrackPanel::OnEnsureVisible(), FormatMenuTable::OnFormatChange(), WaveTrackMenuTable::OnMultiView(), EditActions::Handler::OnPaste(), WaveTrackMenuTable::OnSetDisplay(), TrackMenuTable::OnSetName(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), EditActions::Handler::OnSplit(), WaveTrackMenuTable::OnSwapChannels(), WaveColorMenuTable::OnWaveColorChange(), WaveformVRulerMenuTable::OnWaveformScaleType(), WaveTrackView::PasteText(), SpectrumPrefs::Preview(), EffectLoudness::Process(), EffectNormalize::Process(), NyquistEffect::Process(), EffectSBSMS::Process(), EffectStereoToMono::Process(), VampEffect::Process(), EffectTruncSilence::ProcessIndependently(), NyquistEffect::ProcessOne(), Effect::ProcessPass(), TrackPanel::RefreshTrack(), SpectrumPrefs::Rollback(), WaveTrackView::SelectAllText(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectedClipOfFocusedTrack(), SelectionState::SelectTrack(), SelectionState::SelectTrackLength(), GetInfoCommand::SendTracks(), TrackView::SetMinimized(), RateMenuTable::SetRate(), anonymous_namespace{TrackMenus.cpp}::SetTrackGain(), anonymous_namespace{TrackMenus.cpp}::SetTrackPan(), GainSliderHandle::SetValue(), PanSliderHandle::SetValue(), ScreenshotBigDialog::SizeTracks(), WaveTrackMenuTable::SplitStereo(), AudioIO::StartStream(), anonymous_namespace{WaveTrackControls.cpp}::Status1DrawFunction(), SwapNodes(), UnlinkChannels(), and TrackPanel::UpdateTrackVRuler().

◆ Channels_()

template<typename TrackType , typename InTrackType >
static TrackIterRange< TrackType > TrackList::Channels_ ( TrackIter< InTrackType >  iter1)
inlinestaticprivate

Definition at line 1461 of file Track.h.

1462  {
1463  // Assume iterator filters leader tracks
1464  if (*iter1) {
1465  return {
1466  iter1.Filter( &Track::Any )
1467  .template Filter<TrackType>(),
1468  (++iter1).Filter( &Track::Any )
1469  .template Filter<TrackType>()
1470  };
1471  }
1472  else
1473  // empty range
1474  return {
1475  iter1.template Filter<TrackType>(),
1476  iter1.template Filter<TrackType>()
1477  };
1478  }

References Track::Any(), and TrackIter< TrackType >::Filter().

Here is the call graph for this function:

◆ clear()

void TrackList::clear ( )
privatedelete

◆ Clear()

void TrackList::Clear ( bool  sendEvent = true)

Make the list empty.

Definition at line 672 of file Track.cpp.

673 {
674  // Null out the back-pointers to this in tracks, in case there
675  // are outstanding shared_ptrs to those tracks, making them outlive
676  // the temporary ListOfTracks below.
677  for ( auto pTrack: *this )
678  pTrack->SetOwner( {}, {} );
679  for ( auto pTrack: mPendingUpdates )
680  pTrack->SetOwner( {}, {} );
681 
682  ListOfTracks tempList;
683  tempList.swap( *this );
684 
685  ListOfTracks updating;
686  updating.swap( mPendingUpdates );
687 
688  mUpdaters.clear();
689 
690  if (sendEvent)
691  DeletionEvent();
692 }

References DeletionEvent(), mPendingUpdates, and mUpdaters.

Referenced by ~TrackList().

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

◆ ClearPendingTracks()

void TrackList::ClearPendingTracks ( ListOfTracks pAdded = nullptr)
Exception safety guarantee:
No-fail

Definition at line 948 of file Track.cpp.

949 {
950  for (const auto &pTrack: mPendingUpdates)
951  pTrack->SetOwner( {}, {} );
952  mPendingUpdates.clear();
953  mUpdaters.clear();
954 
955  if (pAdded)
956  pAdded->clear();
957 
958  // To find the first node that remains after the first deleted one
959  TrackNodePointer node;
960  bool foundNode = false;
961 
962  for (auto it = ListOfTracks::begin(), stop = ListOfTracks::end();
963  it != stop;) {
964  if (it->get()->GetId() == TrackId{}) {
965  do {
966  if (pAdded)
967  pAdded->push_back( *it );
968  (*it)->SetOwner( {}, {} );
969  it = erase( it );
970  }
971  while (it != stop && it->get()->GetId() == TrackId{});
972 
973  if (!foundNode && it != stop) {
974  node = (*it)->GetNode();
975  foundNode = true;
976  }
977  }
978  else
979  ++it;
980  }
981 
982  if (!empty()) {
984  DeletionEvent( node );
985  }
986 }

References DeletionEvent(), empty(), getBegin(), mPendingUpdates, mUpdaters, and RecalcPositions().

Referenced by ApplyPendingTracks(), ProjectAudioManager::CancelRecording(), and AudacityApp::OnExceptionInMainLoop().

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

◆ Contains()

bool TrackList::Contains ( const Track t) const

Mainly a test function. Uses a linear search, so could be slow.

Definition at line 849 of file Track.cpp.

850 {
851  return make_iterator_range( *this ).contains( t );
852 }

References make_iterator_range().

Here is the call graph for this function:

◆ Create()

std::shared_ptr< TrackList > TrackList::Create ( AudacityProject pOwner)
static

Definition at line 393 of file Track.cpp.

394 {
395  return std::make_shared<TrackList>( pOwner );
396 }

Referenced by Clipboard::Clipboard(), Effect::CopyInputTracks(), ProjectFileManager::DoSave(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), UndoManager::ModifyState(), EditActions::Handler::OnCopy(), EditActions::Handler::OnCut(), EditActions::Handler::OnSplitCut(), Effect::Preview(), EffectTwoPassSimpleMono::Process(), UndoManager::PushState(), ProjectFileManager::ReadProjectFile(), and ProjectFileIO::SaveProject().

Here is the caller graph for this function:

◆ DataEvent()

void TrackList::DataEvent ( const std::shared_ptr< Track > &  pTrack,
int  code 
)
private

Definition at line 470 of file Track.cpp.

471 {
472  QueueEvent({
473  TrackListEvent::TRACK_DATA_CHANGE, pTrack, code });
474 }

References QueueEvent(), and TrackListEvent::TRACK_DATA_CHANGE.

Here is the call graph for this function:

◆ DeletionEvent()

void TrackList::DeletionEvent ( TrackNodePointer  node = {})
private

Definition at line 488 of file Track.cpp.

489 {
490  QueueEvent({
492  node.second && node.first != node.second->end()
493  ? *node.first
494  : nullptr
495  });
496 }

References TrackListEvent::DELETION, and QueueEvent().

Referenced by Clear(), ClearPendingTracks(), and Remove().

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

◆ DoAdd()

Track * TrackList::DoAdd ( const std::shared_ptr< Track > &  t)
private

Definition at line 564 of file Track.cpp.

565 {
566  push_back(t);
567 
568  auto n = getPrev( getEnd() );
569 
570  t->SetOwner(shared_from_this(), n);
571  t->SetId( TrackId{ ++sCounter } );
572  RecalcPositions(n);
573  AdditionEvent(n);
574  return back().get();
575 }

References AdditionEvent(), getEnd(), getPrev(), RecalcPositions(), sCounter, Track::SetId(), and Track::SetOwner().

Here is the call graph for this function:

◆ DoAddToHead()

Track * TrackList::DoAddToHead ( const std::shared_ptr< Track > &  t)
private

Definition at line 552 of file Track.cpp.

553 {
554  Track *pTrack = t.get();
555  push_front(ListOfTracks::value_type(t));
556  auto n = getBegin();
557  pTrack->SetOwner(shared_from_this(), n);
558  pTrack->SetId( TrackId{ ++sCounter } );
559  RecalcPositions(n);
560  AdditionEvent(n);
561  return front().get();
562 }

References AdditionEvent(), getBegin(), RecalcPositions(), sCounter, Track::SetId(), and Track::SetOwner().

Here is the call graph for this function:

◆ empty()

bool TrackList::empty ( ) const

Definition at line 854 of file Track.cpp.

855 {
856  return begin() == end();
857 }

References begin(), and end().

Referenced by anonymous_namespace{Track.cpp}::Accumulate(), ClearPendingTracks(), ProjectFileManager::Import(), ApplyMacroDialog::OnApplyToFiles(), and size().

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

◆ EmptyRange()

auto TrackList::EmptyRange ( ) const
private

Definition at line 508 of file Track.cpp.

510 {
511  auto it = const_cast<TrackList*>(this)->getEnd();
512  return {
513  { it, it, it, &Track::Any },
514  { it, it, it, &Track::Any }
515  };
516 }

References Track::Any(), and getEnd().

Here is the call graph for this function:

◆ end() [1/2]

iterator TrackList::end ( )
inline

Definition at line 1333 of file Track.h.

1333 { return Any().end(); }

Referenced by TimeShiftHandle::DoSlideVertical(), empty(), HasPendingTracks(), MakeMultiChannelTrack(), and RecalcPositions().

Here is the caller graph for this function:

◆ end() [2/2]

const_iterator TrackList::end ( ) const
inline

Definition at line 1335 of file Track.h.

1335 { return Any().end(); }

◆ EndIterator()

template<typename TrackType >
TrackIter< TrackType > TrackList::EndIterator ( ) const
inlineprivate

Definition at line 1605 of file Track.h.

1606  {
1607  auto e = const_cast<TrackList*>(this)->getEnd();
1608  return { e, e, e };
1609  }

◆ EnsureVisibleEvent()

void TrackList::EnsureVisibleEvent ( const std::shared_ptr< Track > &  pTrack,
bool  modifyState 
)
private

Definition at line 476 of file Track.cpp.

478 {
480  pTrack, static_cast<int>(modifyState) });
481 }

References QueueEvent(), and TrackListEvent::TRACK_REQUEST_VISIBLE.

Here is the call graph for this function:

◆ Find() [1/2]

template<typename TrackType = const Track>
auto TrackList::Find ( const Track pTrack) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIter< TrackType > >
inline

Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.

const overload will only produce iterators over const TrackType

Definition at line 1353 of file Track.h.

1357  {
1358  if (!pTrack || pTrack->GetOwner().get() != this)
1359  return EndIterator<TrackType>();
1360  else
1361  return MakeTrackIterator<TrackType>( pTrack->GetNode() );
1362  }

◆ Find() [2/2]

template<typename TrackType = Track>
auto TrackList::Find ( Track pTrack) -> TrackIter< TrackType >
inline

Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.

Definition at line 1341 of file Track.h.

1343  {
1344  if (!pTrack || pTrack->GetOwner().get() != this)
1345  return EndIterator<TrackType>();
1346  else
1347  return MakeTrackIterator<TrackType>( pTrack->GetNode() );
1348  }

Referenced by TimeShiftHandle::DoSlideVertical(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate(), and RecalcPositions().

Here is the caller graph for this function:

◆ FindById()

Track * TrackList::FindById ( TrackId  id)

Definition at line 541 of file Track.cpp.

542 {
543  // Linear search. Tracks in a project are usually very few.
544  // Search only the non-pending tracks.
545  auto it = std::find_if( ListOfTracks::begin(), ListOfTracks::end(),
546  [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
547  if (it == ListOfTracks::end())
548  return {};
549  return it->get();
550 }

Referenced by ApplyPendingTracks(), TrackPanelAx::IsFocused(), and UpdatePendingTracks().

Here is the caller graph for this function:

◆ FindLeader() [1/2]

TrackIter< const Track > TrackList::FindLeader ( const Track pTrack) const
inline

Definition at line 1371 of file Track.h.

1372  {
1373  return const_cast<TrackList*>(this)->
1374  FindLeader( const_cast<Track*>(pTrack) ).Filter< const Track >();
1375  }

◆ FindLeader() [2/2]

auto TrackList::FindLeader ( Track pTrack)

Definition at line 518 of file Track.cpp.

520 {
521  auto iter = Find(pTrack);
522  while( *iter && ! ( *iter )->IsLeader() )
523  --iter;
524  return iter.Filter( &Track::IsLeader );
525 }

References ActiveProjects::Find(), and Track::IsLeader().

Referenced by TrackPanel::FindTrackRect(), TrackPanel::RefreshTrack(), TrackFocus::Set(), and SwapNodes().

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

◆ Get() [1/2]

TrackList & TrackList::Get ( AudacityProject project)
static

Definition at line 377 of file Track.cpp.

378 {
379  return project.AttachedObjects::Get< TrackList >( key );
380 }

References key.

Referenced by SelectUtilities::ActivatePlayRegion(), ProjectFileManager::AddImportedTracks(), SelectHandle::AdjustSelection(), AdornedRulerPanel::AdornedRulerPanel(), AnyTracksSelectedPred(), AppendItem(), ImportCommand::Apply(), ScreenshotCommand::Apply(), SelectTimeCommand::Apply(), SelectTracksCommand::Apply(), SetLabelCommand::Apply(), SetTrackBase::Apply(), BrushHandleHitTest(), TrackSelectHandle::CalculateRearrangingThresholds(), TrackPanelResizeHandle::Cancel(), ProjectAudioManager::CancelRecording(), Exporter::CheckMix(), ProjectAudioManager::ChooseExistingRecordingTracks(), ButtonHandle::Click(), TrackPanelResizeHandle::Click(), LabelDefaultClickHandle::Click(), LabelGlyphHandle::Click(), BrushHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), BackgroundHandle::Click(), CutCopyAvailableFlag(), DefaultPlayOptions(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), anonymous_namespace{TrackMenus.cpp}::DoAlign(), anonymous_namespace{SelectMenus.cpp}::DoBoundaryMove(), anonymous_namespace{ClipMenus.cpp}::DoClipLeftOrRight(), LOFImportFileHandle::doDurationAndScrollOffset(), LabelTrackView::DoEditLabels(), EffectUI::DoEffect(), anonymous_namespace{FileMenus.cpp}::DoExport(), DoImportMIDI(), LabelTrackView::DoKeyDown(), SelectUtilities::DoListSelection(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), TrackUtilities::DoMoveTrack(), anonymous_namespace{SelectMenus.cpp}::DoNextPeakFrequency(), anonymous_namespace{NavigationMenus.cpp}::DoNextTrack(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{EditMenus.cpp}::DoPasteText(), anonymous_namespace{NavigationMenus.cpp}::DoPrevTrack(), ProjectAudioManager::DoRecord(), TrackUtilities::DoRemoveTrack(), TrackUtilities::DoRemoveTracks(), ProjectFileManager::DoSave(), SelectUtilities::DoSelectSomething(), anonymous_namespace{SelectUtilities.cpp}::DoSelectTimeAndAudioTracks(), SelectUtilities::DoSelectTimeAndTracks(), anonymous_namespace{TrackMenus.cpp}::DoSortTracks(), TrackUtilities::DoTrackMute(), TrackUtilities::DoTrackSolo(), ProjectWindow::DoZoomFit(), anonymous_namespace{ViewMenus.cpp}::DoZoomFitV(), ButtonHandle::Drag(), TrackPanelResizeHandle::Drag(), LabelTextHandle::Drag(), NoteTrackVZoomHandle::Drag(), SpectrumVZoomHandle::Drag(), WaveformVZoomHandle::Drag(), TimeTrackVZoomHandle::Drag(), BrushHandle::Drag(), SelectHandle::Drag(), TimeShiftHandle::Drag(), TrackSelectHandle::Drag(), EditableTracksSelectedPred(), ControlToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), UndoManager::EstimateRemovedBlocks(), Exporter::ExamineTracks(), TimerRecordDialog::ExecutePostRecordActions(), GetInfoCommand::ExploreTrackPanel(), ExportCL::Export(), ExportFFmpeg::Export(), ExportFLAC::Export(), ExportMP3::Export(), ExportOGG::Export(), ExportPCM::Export(), anonymous_namespace{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), ProjectWindow::FixScrollbars(), SpectrumView::ForAll(), ProjectFileIO::GenerateDoc(), Get(), GetAllSeqBlocks(), FrequencyPlotDialog::GetAudio(), ContrastDialog::GetDB(), GetPropertiesOfSelected(), CompareAudioCommand::GetSelection(), SliderHandle::GetSlider(), ScreenshotCommand::GetTrackRect(), TrackPanelAx::GetTracks(), ProjectWindow::GetZoomOfToFit(), LabelGlyphHandle::HandleGlyphDragRelease(), AUPImportFileHandle::HandleImport(), AUPImportFileHandle::HandleLabelTrack(), AUPImportFileHandle::HandleNoteTrack(), AUPImportFileHandle::HandleTimeTrack(), AUPImportFileHandle::HandleWaveTrack(), SelectHandle::HitTest(), ProjectFileManager::Import(), AUPImportFileHandle::Import(), anonymous_namespace{ProjectFileManager.cpp}::ImportProject(), EffectEqualization::Init(), NyquistEffect::Init(), ProjectHistory::InitialState(), anonymous_namespace{LabelMenus.cpp}::LabelsSelectedFlag(), LabelTracksExistFlag(), LOFImportFileHandle::lofOpenFiles(), MixerBoard::MixerBoard(), ProjectHistory::ModifyState(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), TrackActions::Handler::MuteTracks(), anonymous_namespace{SelectMenus.cpp}::NearestZeroCrossing(), LabelTrack::New(), NoteTrack::New(), TimeTrack::New(), WaveTrack::New(), anonymous_namespace{FileMenus.cpp}::NoteTracksExistFlag(), ApplyMacroDialog::OnApplyToFiles(), ProjectManager::OnCloseWindow(), ViewActions::Handler::OnCollapseAllTracks(), ProjectAudioManager::OnCommitRecording(), EditActions::Handler::OnCopy(), LabelEditActions::Handler::OnCopyLabels(), SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), EditActions::Handler::OnCut(), LabelEditActions::Handler::OnCutLabels(), EditActions::Handler::OnDelete(), LabelEditActions::Handler::OnDeleteLabels(), EditActions::Handler::OnDisjoin(), LabelEditActions::Handler::OnDisjoinLabels(), EditActions::Handler::OnDuplicate(), AudacityApp::OnExceptionInMainLoop(), ViewActions::Handler::OnExpandAllTracks(), FileActions::Handler::OnExportLabels(), FileActions::Handler::OnExportMIDI(), NavigationActions::Handler::OnFirstTrack(), ContrastDialog::OnGetBackground(), ContrastDialog::OnGetForeground(), FileActions::Handler::OnImportLabels(), EditActions::Handler::OnJoin(), LabelEditActions::Handler::OnJoinLabels(), NavigationActions::Handler::OnLastTrack(), WaveTrackMenuTable::OnMergeStereo(), LabelEditActions::Handler::OnNewLabelTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::Handler::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewWaveTrack(), EditActions::Handler::OnPaste(), LabelEditActions::Handler::OnPasteNewLabel(), FileActions::Handler::OnPrint(), ProjectAudioManager::OnRecord(), EditActions::Handler::OnRedo(), TrackActions::Handler::OnResample(), SelectActions::Handler::OnSelectAll(), SelectActions::Handler::OnSelectCursorEnd(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectSyncLockSel(), SelectActions::Handler::OnSelectTrackStartToEnd(), ScreenshotBigDialog::OnShortTracks(), EditActions::Handler::OnSilence(), LabelEditActions::Handler::OnSilenceLabels(), EditActions::Handler::OnSplit(), EditActions::Handler::OnSplitCut(), LabelEditActions::Handler::OnSplitCutLabels(), EditActions::Handler::OnSplitDelete(), LabelEditActions::Handler::OnSplitDeleteLabels(), LabelEditActions::Handler::OnSplitLabels(), EditActions::Handler::OnSplitNew(), WaveTrackMenuTable::OnSwapChannels(), TransportActions::Handler::OnTimerRecord(), TrackActions::Handler::OnTrackMoveBottom(), TrackActions::Handler::OnTrackMoveDown(), TrackActions::Handler::OnTrackMoveTop(), TrackActions::Handler::OnTrackMoveUp(), EditActions::Handler::OnTrim(), EditActions::Handler::OnUndo(), anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate(), ProjectFileManager::OpenProjectFile(), TimeTrack::PasteInto(), anonymous_namespace{MixerBoard.cpp}::PlayableTracksExistFlag(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayPlayRegion(), ProjectHistory::PopState(), TrackSelectHandle::Preview(), NyquistEffect::Process(), SpectralDataManager::ProcessTracks(), TrackPanel::ProcessUIHandleResult(), ProjectHistory::PushState(), ProjectFileManager::ReadProjectFile(), ProjectHistory::RedoAvailable(), ProjectWindow::RedrawProject(), ButtonHandle::Release(), LabelTextHandle::Release(), NoteTrackButtonHandle::Release(), NoteTrackVZoomHandle::Release(), SpectrumVZoomHandle::Release(), WaveformVZoomHandle::Release(), TimeTrackVZoomHandle::Release(), AffordanceHandle::Release(), LabelDefaultClickHandle::RestoreState(), ProjectManager::SafeToOpenProjectInto(), ProjectFileIO::SaveCopy(), LabelDefaultClickHandle::SaveState(), ProjectWindow::ScrollingLowerBoundTime(), anonymous_namespace{SelectMenus.cpp}::SeekWhenAudioInactive(), NoteTrackAffordanceHandle::SelectAt(), SelectUtilities::SelectNone(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendTracks(), TrackFocus::Set(), ScreenshotBigDialog::SizeTracks(), ProjectWindow::SkipEnd(), WaveTrackMenuTable::SplitStereo(), ProjectSelectionManager::SSBL_GetRate(), StereoRequiredFlag(), TracksExistFlag(), ProjectHistory::UndoAvailable(), LyricsPanel::UpdateLyrics(), ProjectSettings::UpdatePrefs(), WaveTracksExistFlag(), WaveTracksSelectedFlag(), ProjectFileIO::WriteXML(), ProjectWindow::ZoomAfterImport(), ZoomInAvailableFlag(), and ZoomOutAvailableFlag().

◆ Get() [2/2]

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

Definition at line 382 of file Track.cpp.

383 {
384  return Get( const_cast< AudacityProject & >( project ) );
385 }

References Get().

Here is the call graph for this function:

◆ getBegin()

TrackNodePointer TrackList::getBegin ( ) const
inlineprivate

Definition at line 1619 of file Track.h.

1620  { return { const_cast<TrackList*>(this)->ListOfTracks::begin(),
1621  const_cast<TrackList*>(this)}; }

Referenced by ClearPendingTracks(), DoAddToHead(), and Permute().

Here is the caller graph for this function:

◆ getEnd()

TrackNodePointer TrackList::getEnd ( ) const
inlineprivate

Definition at line 1616 of file Track.h.

1617  { return { const_cast<TrackList*>(this)->ListOfTracks::end(),
1618  const_cast<TrackList*>(this)}; }

Referenced by DoAdd(), EmptyRange(), Remove(), and size().

Here is the caller graph for this function:

◆ GetEndTime()

double TrackList::GetEndTime ( ) const

Definition at line 897 of file Track.cpp.

898 {
899  return Accumulate(*this, &Track::GetEndTime, -DBL_MAX, std::max);
900 }

References anonymous_namespace{Track.cpp}::Accumulate(), and Track::GetEndTime().

Referenced by SelectTimeCommand::Apply(), DefaultPlayOptions(), LOFImportFileHandle::doDurationAndScrollOffset(), ExportMultipleDialog::ExportMultipleByLabel(), AudacityPrintout::OnPrintPage(), and AdornedRulerPanel::StartQPPlay().

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

◆ GetMinOffset()

double TrackList::GetMinOffset ( ) const

Definition at line 887 of file Track.cpp.

888 {
889  return Accumulate(*this, &Track::GetOffset, DBL_MAX, std::min);
890 }

References anonymous_namespace{Track.cpp}::Accumulate(), Track::GetOffset(), and min().

Here is the call graph for this function:

◆ GetNext()

Track * TrackList::GetNext ( Track t,
bool  linked = false 
) const
private

Return a track in the list that comes after Track t.

Definition at line 695 of file Track.cpp.

696 {
697  if (t) {
698  auto node = t->GetNode();
699  if ( !isNull( node ) ) {
700  if ( linked && t->HasLinkedTrack() )
701  node = getNext( node );
702 
703  if ( !isNull( node ) )
704  node = getNext( node );
705 
706  if ( !isNull( node ) )
707  return node.first->get();
708  }
709  }
710 
711  return nullptr;
712 }

References getNext(), Track::GetNode(), Track::HasLinkedTrack(), and isNull().

Referenced by CanMoveDown(), and MoveDown().

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

◆ getNext()

TrackNodePointer TrackList::getNext ( TrackNodePointer  p) const
inlineprivate

Move an iterator to the next node, if any; else stay at end.

Definition at line 1624 of file Track.h.

1625  {
1626  if ( isNull(p) )
1627  return p;
1628  auto q = p;
1629  ++q.first;
1630  return q;
1631  }

Referenced by GetNext(), and Remove().

Here is the caller graph for this function:

◆ GetOwner() [1/2]

AudacityProject* TrackList::GetOwner ( )
inline

Definition at line 1323 of file Track.h.

1323 { return mOwner; }

Referenced by Effect::FindProject(), and Effect::Preview().

Here is the caller graph for this function:

◆ GetOwner() [2/2]

const AudacityProject* TrackList::GetOwner ( ) const
inline

Definition at line 1324 of file Track.h.

1324 { return mOwner; }

◆ GetPrev()

Track * TrackList::GetPrev ( Track t,
bool  linked = false 
) const
private

Definition at line 714 of file Track.cpp.

715 {
716  if (t) {
717  TrackNodePointer prev;
718  auto node = t->GetNode();
719  if ( !isNull( node ) ) {
720  // linked is true and input track second in team?
721  if (linked) {
722  prev = getPrev( node );
723  if( !isNull( prev ) &&
724  !t->HasLinkedTrack() && t->GetLinkedTrack() )
725  // Make it the first
726  node = prev;
727  }
728 
729  prev = getPrev( node );
730  if ( !isNull( prev ) ) {
731  // Back up once
732  node = prev;
733 
734  // Back up twice sometimes when linked is true
735  if (linked) {
736  prev = getPrev( node );
737  if( !isNull( prev ) &&
738  !(*node.first)->HasLinkedTrack() && (*node.first)->GetLinkedTrack() )
739  node = prev;
740  }
741 
742  return node.first->get();
743  }
744  }
745  }
746 
747  return nullptr;
748 }

References Track::GetLinkedTrack(), Track::GetNode(), getPrev(), Track::HasLinkedTrack(), and isNull().

Referenced by CanMoveUp(), and MoveUp().

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

◆ getPrev()

TrackNodePointer TrackList::getPrev ( TrackNodePointer  p) const
inlineprivate

Move an iterator to the previous node, if any; else wrap to end.

Definition at line 1634 of file Track.h.

1635  {
1636  if (p == getBegin())
1637  return getEnd();
1638  else {
1639  auto q = p;
1640  --q.first;
1641  return q;
1642  }
1643  }

Referenced by DoAdd(), GetPrev(), RecalcPositions(), and size().

Here is the caller graph for this function:

◆ GetStartTime()

double TrackList::GetStartTime ( ) const

Definition at line 892 of file Track.cpp.

893 {
894  return Accumulate(*this, &Track::GetStartTime, DBL_MAX, std::min);
895 }

References anonymous_namespace{Track.cpp}::Accumulate(), Track::GetStartTime(), and min().

Referenced by AdornedRulerPanel::StartQPPlay().

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

◆ HasPendingTracks()

bool TrackList::HasPendingTracks ( ) const

Definition at line 1181 of file Track.cpp.

1182 {
1183  if ( !mPendingUpdates.empty() )
1184  return true;
1185  if (end() != std::find_if(begin(), end(), [](const Track *t){
1186  return t->GetId() == TrackId{};
1187  }))
1188  return true;
1189  return false;
1190 }

References begin(), end(), Track::GetId(), and mPendingUpdates.

Here is the call graph for this function:

◆ isNull()

bool TrackList::isNull ( TrackNodePointer  p) const
inlineprivate

Definition at line 1613 of file Track.h.

1614  { return (p.second == this && p.first == ListOfTracks::end())
1615  || (p.second == &mPendingUpdates && p.first == mPendingUpdates.end()); }

Referenced by GetNext(), GetPrev(), RecalcPositions(), Remove(), and SwapNodes().

Here is the caller graph for this function:

◆ Leaders() [1/2]

template<typename TrackType = Track>
auto TrackList::Leaders ( ) -> TrackIterRange< TrackType >
inline

Definition at line 1413 of file Track.h.

1415  {
1416  return Tracks< TrackType >( &Track::IsLeader );
1417  }

References Track::IsLeader().

Referenced by ExportMultipleDialog::CountTracksAndLabels(), ExportMultipleDialog::ExportMultipleByTrack(), ScreenshotCommand::GetTrackRect(), TrackSelectHandle::Preview(), NyquistEffect::Process(), and MixerBoard::UpdateTrackClusters().

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

◆ Leaders() [2/2]

template<typename TrackType = const Track>
auto TrackList::Leaders ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1420 of file Track.h.

1424  {
1425  return Tracks< TrackType >( &Track::IsLeader );
1426  }

References Track::IsLeader().

Here is the call graph for this function:

◆ Lock()

template<typename Subclass >
std::shared_ptr<Subclass> TrackList::Lock ( const std::weak_ptr< Subclass > &  wTrack)
inline

◆ MakeMultiChannelTrack()

bool TrackList::MakeMultiChannelTrack ( Track first,
int  nChannels,
bool  aligned 
)

Converts channels to a multichannel track.

Parameters
firstand the following must be in this list. Tracks should not be a part of another group (not linked)
nChannelsnumber of channels, for now only 2 channels supported
alignedif true, the link type will be set to Track::LinkType::Aligned, or Track::LinkType::Group otherwise
Returns
true on success, false if some prerequisites do not met

Definition at line 615 of file Track.cpp.

616 {
617  if (nChannels != 2)
618  return false;
619 
620  auto list = track.mList.lock();
621  if (list.get() == this)
622  {
623  if (*list->FindLeader(&track) != &track)
624  return false;
625 
626  auto first = list->Find(&track);
627  auto canLink = [&]() -> bool {
628  int count = nChannels;
629  for (auto it = first, end = TrackList::end(); it != end && count; ++it)
630  {
631  if ((*it)->HasLinkedTrack())
632  return false;
633  --count;
634  }
635  return count == 0;
636  }();
637 
638  if (!canLink)
639  return false;
640 
641  (*first)->SetLinkType(aligned ? Track::LinkType::Aligned : Track::LinkType::Group);
642  (*first)->SetChannel(Track::LeftChannel);
643  auto second = std::next(first);
644  (*second)->SetChannel(Track::RightChannel);
645  }
646  else
648  return true;
649 }

References Track::Aligned, end(), Track::Group, Track::LeftChannel, Track::mList, Track::RightChannel, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by ProjectAudioManager::DoRecord(), and Effect::Preview().

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

◆ MakeTrackIterator()

template<typename TrackType >
TrackIter< TrackType > TrackList::MakeTrackIterator ( TrackNodePointer  iter) const
inlineprivate

Definition at line 1596 of file Track.h.

1597  {
1598  auto b = const_cast<TrackList*>(this)->getBegin();
1599  auto e = const_cast<TrackList*>(this)->getEnd();
1600  return { b, iter, e };
1601  }

◆ Move()

bool TrackList::Move ( Track t,
bool  up 
)
inline

Definition at line 1533 of file Track.h.

1533 { return up ? MoveUp(t) : MoveDown(t); }

◆ MoveDown()

bool TrackList::MoveDown ( Track t)

Definition at line 836 of file Track.cpp.

837 {
838  if (t) {
839  Track *n = GetNext(t, true);
840  if (n) {
841  SwapNodes(t->GetNode(), n->GetNode());
842  return true;
843  }
844  }
845 
846  return false;
847 }

References GetNext(), Track::GetNode(), and SwapNodes().

Here is the call graph for this function:

◆ MoveUp()

bool TrackList::MoveUp ( Track t)

Definition at line 823 of file Track.cpp.

824 {
825  if (t) {
826  Track *p = GetPrev(t, true);
827  if (p) {
828  SwapNodes(p->GetNode(), t->GetNode());
829  return true;
830  }
831  }
832 
833  return false;
834 }

References Track::GetNode(), GetPrev(), and SwapNodes().

Here is the call graph for this function:

◆ operator=() [1/2]

TrackList& TrackList::operator= ( const TrackList )
privatedelete

◆ operator=() [2/2]

TrackList& TrackList::operator= ( TrackList &&  )
privatedelete

◆ PermutationEvent()

void TrackList::PermutationEvent ( TrackNodePointer  node)
private

Definition at line 483 of file Track.cpp.

484 {
485  QueueEvent({ TrackListEvent::PERMUTED, *node.first });
486 }

References TrackListEvent::PERMUTED, and QueueEvent().

Referenced by Permute(), and SwapNodes().

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

◆ Permute()

void TrackList::Permute ( const std::vector< TrackNodePointer > &  permutation)

For use in sorting: assume each iterator points into this list, no duplications.

Definition at line 527 of file Track.cpp.

528 {
529  for (const auto iter : permutation) {
530  ListOfTracks::value_type track = *iter.first;
531  erase(iter.first);
532  Track *pTrack = track.get();
533  pTrack->SetOwner(shared_from_this(),
534  { insert(ListOfTracks::end(), track), this });
535  }
536  auto n = getBegin();
537  RecalcPositions(n);
538  PermutationEvent(n);
539 }

References getBegin(), PermutationEvent(), RecalcPositions(), and Track::SetOwner().

Here is the call graph for this function:

◆ QueueEvent()

void TrackList::QueueEvent ( TrackListEvent  event)
private

Definition at line 457 of file Track.cpp.

458 {
459  BasicUI::CallAfter( [wThis = weak_from_this(), event = std::move(event)]{
460  if (auto pThis = wThis.lock())
461  pThis->Publish(event);
462  } );
463 }

References BasicUI::CallAfter().

Referenced by AdditionEvent(), DataEvent(), DeletionEvent(), EnsureVisibleEvent(), PermutationEvent(), ResizingEvent(), and SelectionEvent().

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

◆ RecalcPositions()

void TrackList::RecalcPositions ( TrackNodePointer  node)
private

Definition at line 434 of file Track.cpp.

435 {
436  if ( isNull( node ) )
437  return;
438 
439  Track *t;
440  int i = 0;
441 
442  auto prev = getPrev( node );
443  if ( !isNull( prev ) ) {
444  t = prev.first->get();
445  i = t->GetIndex() + 1;
446  }
447 
448  const auto theEnd = end();
449  for (auto n = Find( node.first->get() ); n != theEnd; ++n) {
450  t = *n;
451  t->SetIndex(i++);
452  }
453 
455 }

References end(), Find(), Track::GetIndex(), getPrev(), isNull(), Track::SetIndex(), and UpdatePendingTracks().

Referenced by ApplyPendingTracks(), ClearPendingTracks(), DoAdd(), DoAddToHead(), Permute(), Remove(), and SwapNodes().

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

◆ RegisterPendingChangedTrack()

std::shared_ptr< Track > TrackList::RegisterPendingChangedTrack ( Updater  updater,
Track src 
)

Definition at line 903 of file Track.cpp.

904 {
905  std::shared_ptr<Track> pTrack;
906  if (src) {
907  pTrack = src->Clone(); // not duplicate
908  // Share the satellites with the original, though they do not point back
909  // to the pending track
910  ((AttachedTrackObjects&)*pTrack) = *src; // shallow copy
911  }
912 
913  if (pTrack) {
914  mUpdaters.push_back( updater );
915  mPendingUpdates.push_back( pTrack );
916  auto n = mPendingUpdates.end();
917  --n;
918  pTrack->SetOwner(shared_from_this(), {n, &mPendingUpdates});
919  }
920 
921  return pTrack;
922 }

References Track::Clone(), mPendingUpdates, mUpdaters, and Track::SetOwner().

Referenced by ProjectAudioManager::DoRecord().

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

◆ RegisterPendingNewTrack()

void TrackList::RegisterPendingNewTrack ( const std::shared_ptr< Track > &  pTrack)

Definition at line 924 of file Track.cpp.

925 {
926  Add<Track>( pTrack );
927  pTrack->SetId( TrackId{} );
928 }

References Track::SetId().

Referenced by ProjectAudioManager::DoRecord().

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

◆ Remove()

TrackNodePointer TrackList::Remove ( Track t)

Remove the Track and return an iterator to what followed it.

Definition at line 651 of file Track.cpp.

652 {
653  auto result = getEnd();
654  if (t) {
655  auto node = t->GetNode();
656  t->SetOwner({}, {});
657 
658  if ( !isNull( node ) ) {
659  ListOfTracks::value_type holder = *node.first;
660 
661  result = getNext( node );
662  erase(node.first);
663  if ( !isNull( result ) )
664  RecalcPositions(result);
665 
666  DeletionEvent(result);
667  }
668  }
669  return result;
670 }

References DeletionEvent(), getEnd(), getNext(), Track::GetNode(), isNull(), RecalcPositions(), and Track::SetOwner().

Referenced by Effect::DoEffect(), and Effect::ReplaceProcessedTracks().

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

◆ Replace()

auto TrackList::Replace ( Track t,
const ListOfTracks::value_type &  with 
)

Replace first track with second track, give back a holder Give the replacement the same id as the replaced

Definition at line 577 of file Track.cpp.

579 {
580  ListOfTracks::value_type holder;
581  if (t && with) {
582  auto node = t->GetNode();
583  t->SetOwner({}, {});
584 
585  holder = *node.first;
586 
587  Track *pTrack = with.get();
588  *node.first = with;
589  pTrack->SetOwner(shared_from_this(), node);
590  pTrack->SetId( t->GetId() );
591  RecalcPositions(node);
592 
593  DeletionEvent(node);
594  AdditionEvent(node);
595  }
596  return holder;
597 }

References Track::SetId(), and Track::SetOwner().

Referenced by ApplyPendingTracks(), Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(), and Effect::ReplaceProcessedTracks().

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

◆ ResizingEvent()

void TrackList::ResizingEvent ( TrackNodePointer  node)
private

Definition at line 503 of file Track.cpp.

504 {
505  QueueEvent({ TrackListEvent::RESIZING, *node.first });
506 }

References QueueEvent(), and TrackListEvent::RESIZING.

Here is the call graph for this function:

◆ Selected() [1/2]

template<typename TrackType = Track>
auto TrackList::Selected ( ) -> TrackIterRange< TrackType >
inline

◆ Selected() [2/2]

template<typename TrackType = const Track>
auto TrackList::Selected ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1403 of file Track.h.

1407  {
1408  return Tracks< TrackType >( &Track::IsSelected );
1409  }

References Track::IsSelected().

Here is the call graph for this function:

◆ SelectedLeaders() [1/2]

template<typename TrackType = Track>
auto TrackList::SelectedLeaders ( ) -> TrackIterRange< TrackType >
inline

Definition at line 1430 of file Track.h.

1432  {
1433  return Tracks< TrackType >( &Track::IsSelectedLeader );
1434  }

References Track::IsSelectedLeader().

Referenced by Effect::CountWaveTracks(), ContrastDialog::GetDB(), and TrackPanel::GetSelectedTrackCount().

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

◆ SelectedLeaders() [2/2]

template<typename TrackType = const Track>
auto TrackList::SelectedLeaders ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1437 of file Track.h.

1441  {
1442  return Tracks< TrackType >( &Track::IsSelectedLeader );
1443  }

References Track::IsSelectedLeader().

Here is the call graph for this function:

◆ SelectionEvent()

void TrackList::SelectionEvent ( const std::shared_ptr< Track > &  pTrack)
private

Definition at line 465 of file Track.cpp.

466 {
468 }

References QueueEvent(), and TrackListEvent::SELECTION_CHANGE.

Here is the call graph for this function:

◆ SingletonRange()

template<typename TrackType >
static auto TrackList::SingletonRange ( TrackType *  pTrack) -> TrackIterRange< TrackType >
inlinestatic

Definition at line 1447 of file Track.h.

1449  {
1450  return pTrack->GetOwner()->template Any<TrackType>()
1451  .StartingWith( pTrack ).EndingAfter( pTrack );
1452  }

References TrackIterRange< TrackType >::EndingAfter(), and TrackIterRange< TrackType >::StartingWith().

Referenced by anonymous_namespace{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), EffectLoudness::Process(), and EffectNormalize::Process().

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

◆ size()

size_t TrackList::size ( ) const

Definition at line 859 of file Track.cpp.

860 {
861  int cnt = 0;
862 
863  if (!empty())
864  cnt = getPrev( getEnd() ).first->get()->GetIndex() + 1;
865 
866  return cnt;
867 }

References empty(), getEnd(), and getPrev().

Referenced by ScreenshotCommand::Apply(), and ProjectSettings::UpdatePrefs().

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

◆ Swap()

void TrackList::Swap ( TrackList that)

Definition at line 409 of file Track.cpp.

410 {
411  auto SwapLOTs = [](
412  ListOfTracks &a, const std::weak_ptr< TrackList > &aSelf,
413  ListOfTracks &b, const std::weak_ptr< TrackList > &bSelf )
414  {
415  a.swap(b);
416  for (auto it = a.begin(), last = a.end(); it != last; ++it)
417  (*it)->SetOwner(aSelf, {it, &a});
418  for (auto it = b.begin(), last = b.end(); it != last; ++it)
419  (*it)->SetOwner(bSelf, {it, &b});
420  };
421 
422  const auto self = shared_from_this();
423  const auto otherSelf = that.shared_from_this();
424  SwapLOTs( *this, self, that, otherSelf );
425  SwapLOTs( this->mPendingUpdates, self, that.mPendingUpdates, otherSelf );
426  mUpdaters.swap(that.mUpdaters);
427 }

◆ SwapNodes()

void TrackList::SwapNodes ( TrackNodePointer  s1,
TrackNodePointer  s2 
)
private

Definition at line 764 of file Track.cpp.

765 {
766  // if a null pointer is passed in, we want to know about it
767  wxASSERT(!isNull(s1));
768  wxASSERT(!isNull(s2));
769 
770  // Deal with first track in each team
771  s1 = ( * FindLeader( s1.first->get() ) )->GetNode();
772  s2 = ( * FindLeader( s2.first->get() ) )->GetNode();
773 
774  // Safety check...
775  if (s1 == s2)
776  return;
777 
778  // Be sure s1 is the earlier iterator
779  if ((*s1.first)->GetIndex() >= (*s2.first)->GetIndex())
780  std::swap(s1, s2);
781 
782  // For saving the removed tracks
783  using Saved = std::vector< ListOfTracks::value_type >;
784  Saved saved1, saved2;
785 
786  auto doSave = [&] ( Saved &saved, TrackNodePointer &s ) {
787  size_t nn = Channels( s.first->get() ).size();
788  saved.resize( nn );
789  // Save them in backwards order
790  while( nn-- )
791  saved[nn] = *s.first, s.first = erase(s.first);
792  };
793 
794  doSave( saved1, s1 );
795  // The two ranges are assumed to be disjoint but might abut
796  const bool same = (s1 == s2);
797  doSave( saved2, s2 );
798  if (same)
799  // Careful, we invalidated s1 in the second doSave!
800  s1 = s2;
801 
802  // Reinsert them
803  auto doInsert = [&] ( Saved &saved, TrackNodePointer &s ) {
804  Track *pTrack;
805  for (auto & pointer : saved)
806  pTrack = pointer.get(),
807  // Insert before s, and reassign s to point at the new node before
808  // old s; which is why we saved pointers in backwards order
809  pTrack->SetOwner(shared_from_this(),
810  s = { insert(s.first, pointer), this } );
811  };
812  // This does not invalidate s2 even when it equals s1:
813  doInsert( saved2, s1 );
814  // Even if s2 was same as s1, this correctly inserts the saved1 range
815  // after the saved2 range, when done after:
816  doInsert( saved1, s2 );
817 
818  // Now correct the Index in the tracks, and other things
819  RecalcPositions(s1);
820  PermutationEvent(s1);
821 }

References Channels(), FindLeader(), isNull(), PermutationEvent(), RecalcPositions(), Track::SetOwner(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by MoveDown(), and MoveUp().

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

◆ Tracks() [1/2]

template<typename TrackType = Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto TrackList::Tracks ( const Pred &  pred = {}) -> TrackIterRange< TrackType >
inlineprivate

Definition at line 1568 of file Track.h.

1568  {} )
1570  {
1571  auto b = getBegin(), e = getEnd();
1572  return { { b, b, e, pred }, { b, e, e, pred } };
1573  }

◆ Tracks() [2/2]

template<typename TrackType = const Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto TrackList::Tracks ( const Pred &  pred = {}) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inlineprivate

Definition at line 1581 of file Track.h.

1581  {} ) const
1582  -> std::enable_if_t< std::is_const_v<TrackType>,
1584  >
1585  {
1586  auto b = const_cast<TrackList*>(this)->getBegin();
1587  auto e = const_cast<TrackList*>(this)->getEnd();
1588  return { { b, b, e, pred }, { b, e, e, pred } };
1589  }

◆ UnlinkChannels()

void TrackList::UnlinkChannels ( Track track)

Removes linkage if track belongs to a group.

Definition at line 599 of file Track.cpp.

600 {
601  auto list = track.mList.lock();
602  if (list.get() == this)
603  {
604  auto channels = TrackList::Channels(&track);
605  for (auto c : channels)
606  {
607  c->SetLinkType(Track::LinkType::None);
608  c->SetChannel(Track::ChannelType::MonoChannel);
609  }
610  }
611  else
613 }

References Channels(), Track::mList, Track::None, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by WaveTrackMenuTable::SplitStereo().

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

◆ UpdatePendingTracks()

void TrackList::UpdatePendingTracks ( )

Definition at line 930 of file Track.cpp.

931 {
932  auto pUpdater = mUpdaters.begin();
933  for (const auto &pendingTrack : mPendingUpdates) {
934  // Copy just a part of the track state, according to the update
935  // function
936  const auto &updater = *pUpdater;
937  auto src = FindById( pendingTrack->GetId() );
938  if (pendingTrack && src) {
939  if (updater)
940  updater( *pendingTrack, *src );
941  pendingTrack->DoSetLinkType(src->GetLinkType());
942  }
943  ++pUpdater;
944  }
945 }

References FindById(), mPendingUpdates, mUpdaters, and anonymous_namespace{LogWindow.cpp}::pUpdater.

Referenced by ApplyPendingTracks(), ProjectAudioManager::DoRecord(), TrackPanel::ProcessUIHandleResult(), and RecalcPositions().

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

Friends And Related Function Documentation

◆ Track

friend class Track
friend

Definition at line 1489 of file Track.h.

Member Data Documentation

◆ mOwner

AudacityProject* TrackList::mOwner
private

Definition at line 1709 of file Track.h.

◆ mPendingUpdates

ListOfTracks TrackList::mPendingUpdates
private

Shadow tracks holding append-recording in progress; need to put them into a list so that GetLink() works.

Beware, they are in a disjoint iteration sequence from ordinary tracks

Definition at line 1713 of file Track.h.

Referenced by ApplyPendingTracks(), Clear(), ClearPendingTracks(), HasPendingTracks(), RegisterPendingChangedTrack(), and UpdatePendingTracks().

◆ mUpdaters

std::vector< Updater > TrackList::mUpdaters
private

This is in correspondence with mPendingUpdates.

Definition at line 1715 of file Track.h.

Referenced by Clear(), ClearPendingTracks(), RegisterPendingChangedTrack(), and UpdatePendingTracks().

◆ sCounter

long TrackList::sCounter = -1
staticprivate

Definition at line 1661 of file Track.h.

Referenced by ApplyPendingTracks(), DoAdd(), and DoAddToHead().


The documentation for this class was generated from the following files:
TrackList::isNull
bool isNull(TrackNodePointer p) const
Definition: Track.h:1613
Track::LinkType::Aligned
@ Aligned
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: Track.cpp:373
Track::SetId
void SetId(TrackId id)
Definition: Track.h:268
make_iterator_range
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:423
TrackList::FindById
Track * FindById(TrackId id)
Definition: Track.cpp:541
TrackList::PermutationEvent
void PermutationEvent(TrackNodePointer node)
Definition: Track.cpp:483
TrackListEvent::TRACK_DATA_CHANGE
@ TRACK_DATA_CHANGE
Posted when certain fields of a track change.
Definition: Track.h:1246
ClientData::Site::Find
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:333
TrackList::getEnd
TrackNodePointer getEnd() const
Definition: Track.h:1616
Track::SetOwner
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Update mNode when Track is added to TrackList, or removed from it.
Definition: Track.cpp:132
TrackList::GetNext
Track * GetNext(Track *t, bool linked=false) const
Return a track in the list that comes after Track t.
Definition: Track.cpp:695
Track::GetEndTime
virtual double GetEndTime() const =0
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1483
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1288
Track::GetOwner
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:378
TrackList::Add
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1502
TrackList::Find
auto Find(Track *pTrack) -> TrackIter< TrackType >
Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.
Definition: Track.h:1341
TrackList::RecalcPositions
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:434
Track::Any
bool Any() const
Definition: Track.cpp:292
BasicUI::CallAfter
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:38
TrackListEvent::ADDITION
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:1259
anonymous_namespace{Track.cpp}::Accumulate
double Accumulate(const TrackList &list, double(Track::*memfn)() const, double ident, const double &(*combine)(const double &, const double &))
Definition: Track.cpp:872
TrackList::end
iterator end()
Definition: Track.h:1333
Track::GetStartTime
virtual double GetStartTime() const =0
TrackList::mUpdaters
std::vector< Updater > mUpdaters
This is in correspondence with mPendingUpdates.
Definition: Track.h:1715
TrackList::mPendingUpdates
ListOfTracks mPendingUpdates
Shadow tracks holding append-recording in progress; need to put them into a list so that GetLink() wo...
Definition: Track.h:1713
TrackList::FindLeader
TrackIter< Track > FindLeader(Track *pTrack)
Definition: Track.cpp:518
Track::mList
std::weak_ptr< TrackList > mList
Definition: Track.h:243
Track::GetId
TrackId GetId() const
Definition: Track.h:266
anonymous_namespace{LogWindow.cpp}::pUpdater
std::optional< LogWindowUpdater > pUpdater
Definition: LogWindow.cpp:53
TrackListEvent::TRACK_REQUEST_VISIBLE
@ TRACK_REQUEST_VISIBLE
Posted when a track needs to be scrolled into view.
Definition: Track.h:1249
TrackList::AdditionEvent
void AdditionEvent(TrackNodePointer node)
Definition: Track.cpp:498
TrackList::mOwner
AudacityProject * mOwner
Definition: Track.h:1709
TrackList::begin
iterator begin()
Definition: Track.h:1332
TrackList::ClearPendingTracks
void ClearPendingTracks(ListOfTracks *pAdded=nullptr)
Definition: Track.cpp:948
ListOfTracks
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:41
Track::LinkType::Group
@ Group
Track::GetOffset
virtual double GetOffset() const =0
TrackNodePointer
std::pair< ListOfTracks::iterator, ListOfTracks * > TrackNodePointer
Pairs a std::list iterator and a pointer to a list, for comparison purposes.
Definition: Track.h:47
Track::Clone
virtual Holder Clone() const =0
ClientData::Site
Utility to register hooks into a host class that attach client data.
Definition: ClientData.h:220
Track::RightChannel
@ RightChannel
Definition: Track.h:262
TrackList::DoAddToHead
Track * DoAddToHead(const std::shared_ptr< Track > &t)
Definition: Track.cpp:552
Track::IsSelected
bool IsSelected() const
Definition: Track.cpp:295
TrackListEvent::DELETION
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:1263
THROW_INCONSISTENCY_EXCEPTION
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
Definition: InconsistencyException.h:79
Track::HasLinkedTrack
bool HasLinkedTrack() const noexcept
Returns true for leaders of multichannel groups.
Definition: Track.cpp:205
TrackIter::Filter
TrackIter Filter(const Predicate2 &pred2) const
Return an iterator that replaces the predicate.
Definition: Track.h:984
Track::LinkType::None
@ None
anonymous_namespace{NoteTrack.cpp}::swap
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:753
Track::IsSelectedLeader
bool IsSelectedLeader() const
Definition: Track.cpp:303
TrackIterRange
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:1119
TrackList::MoveUp
bool MoveUp(Track *t)
Definition: Track.cpp:823
TrackList::DeletionEvent
void DeletionEvent(TrackNodePointer node={})
Definition: Track.cpp:488
TrackList::getBegin
TrackNodePointer getBegin() const
Definition: Track.h:1619
TrackList::QueueEvent
void QueueEvent(TrackListEvent event)
Definition: Track.cpp:457
TrackList::UpdatePendingTracks
void UpdatePendingTracks()
Definition: Track.cpp:930
TrackList::Clear
void Clear(bool sendEvent=true)
Make the list empty.
Definition: Track.cpp:672
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
TrackId
An in-session identifier of track objects across undo states. It does not persist between sessions.
Definition: Track.h:150
Track::GetIndex
int GetIndex() const
Definition: Track.cpp:140
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:377
TrackList::GetPrev
Track * GetPrev(Track *t, bool linked=false) const
Definition: Track.cpp:714
TrackList::sCounter
static long sCounter
Definition: Track.h:1661
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
Track::IsLeader
bool IsLeader() const
Definition: Track.cpp:298
TrackList::SwapNodes
void SwapNodes(TrackNodePointer s1, TrackNodePointer s2)
Definition: Track.cpp:764
TrackListEvent::RESIZING
@ RESIZING
Posted when some track changed its height.
Definition: Track.h:1256
TrackList::DoAdd
Track * DoAdd(const std::shared_ptr< Track > &t)
Definition: Track.cpp:564
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
TrackList::Replace
ListOfTracks::value_type Replace(Track *t, const ListOfTracks::value_type &with)
Definition: Track.cpp:577
TrackList::getNext
TrackNodePointer getNext(TrackNodePointer p) const
Move an iterator to the next node, if any; else stay at end.
Definition: Track.h:1624
TrackListEvent::SELECTION_CHANGE
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.
Definition: Track.h:1243
TrackList::getPrev
TrackNodePointer getPrev(TrackNodePointer p) const
Move an iterator to the previous node, if any; else wrap to end.
Definition: Track.h:1634
Track::GetLinkedTrack
Track * GetLinkedTrack() const
Definition: Track.cpp:179
TrackList::MoveDown
bool MoveDown(Track *t)
Definition: Track.cpp:836
TrackListEvent::PERMUTED
@ PERMUTED
Posted when tracks are reordered but otherwise unchanged.
Definition: Track.h:1253
Track::SetIndex
void SetIndex(int index)
Definition: Track.cpp:145
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1379
Track::LeftChannel
@ LeftChannel
Definition: Track.h:261
TrackList::empty
bool empty() const
Definition: Track.cpp:854
Track::GetNode
TrackNodePointer GetNode() const
Retrieve mNode with debug checks.
Definition: Track.cpp:125