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

A list of TrackListNode items. More...

#include <Track.h>

Inheritance diagram for TrackList:

Public Types

using iterator = TrackListIterator
 
using const_iterator = TrackListConstIterator
 
using value_type = Track *
 
using Updater = std::function< void(Track &dest, const Track &src) >
 

Public Member Functions

void Swap (TrackList &that)
 
virtual ~TrackList ()
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
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 >
TrackAdd (std::unique_ptr< TrackKind > &&t)
 Add a Track, giving it a fresh id. More...
 
template<typename TrackKind >
TrackAddToHead (std::unique_ptr< TrackKind > &&t)
 Add a Track, giving it a fresh id. More...
 
template<typename TrackKind >
TrackAdd (std::shared_ptr< TrackKind > &&t)
 Add a Track, giving it a fresh id. More...
 
ListOfTracks::value_type Replace (Track *t, ListOfTracks::value_type &&with)
 
TrackNodePointer Remove (Track *t)
 
void Clear (bool sendEvent=true)
 Make the list empty. More...
 
void Select (Track *t, bool selected=true)
 
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...
 
int GetGroupHeight (Track *t) const
 
bool CanMoveUp (Track *t) const
 
bool CanMoveDown (Track *t) const
 
bool MoveUp (Track *t)
 
bool MoveDown (Track *t)
 
bool Move (Track *t, bool up)
 
TimeTrackGetTimeTrack ()
 
const TimeTrackGetTimeTrack () const
 
unsigned GetNumExportChannels (bool selectionOnly) const
 Find out how many channels this track list mixes to. More...
 
WaveTrackArray GetWaveTrackArray (bool selectionOnly, bool includeMuted=true)
 
WaveTrackConstArray GetWaveTrackConstArray (bool selectionOnly, bool includeMuted=true) const
 
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
 
int GetHeight () 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 ()
 
std::shared_ptr< TrackFindPendingChangedTrack (TrackId id) const
 
bool HasPendingTracks () const
 

Static Public Member Functions

static std::shared_ptr< TrackListCreate ()
 

Private Member Functions

 TrackList ()
 
 TrackList (const TrackList &that)=delete
 
TrackListoperator= (const TrackList &)=delete
 
 TrackList (TrackList &&that)
 
TrackListoperator= (TrackList &&)
 
void clear ()=delete
 
bool isNull (TrackNodePointer p) const
 
TrackNodePointer getEnd () const
 
TrackNodePointer getBegin () const
 
TrackNodePointer getNext (TrackNodePointer p) const
 
TrackNodePointer getPrev (TrackNodePointer p) const
 
void RecalcPositions (TrackNodePointer node)
 
void PermutationEvent ()
 
void DeletionEvent ()
 
void ResizingEvent (TrackNodePointer node)
 
void SwapNodes (TrackNodePointer s1, TrackNodePointer s2)
 

Private Attributes

std::weak_ptr< TrackListmSelf
 
ListOfTracks mPendingUpdates
 
std::vector< UpdatermUpdaters
 

Static Private Attributes

static long sCounter = -1
 

Friends

class Track
 
class TrackListIterator
 
class SyncLockedTracksIterator
 

Detailed Description

A list of TrackListNode items.

Definition at line 619 of file Track.h.

Member Typedef Documentation

Definition at line 649 of file Track.h.

Definition at line 648 of file Track.h.

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

Definition at line 808 of file Track.h.

Definition at line 650 of file Track.h.

Constructor & Destructor Documentation

TrackList::TrackList ( )
private

Definition at line 786 of file Track.cpp.

787 : wxEvtHandler()
788 {
789 }
TrackList::TrackList ( const TrackList that)
privatedelete
TrackList::TrackList ( TrackList &&  that)
inlineprivate

Definition at line 632 of file Track.h.

References Swap().

632 : TrackList() { Swap(that); }
TrackList()
Definition: Track.cpp:786
void Swap(TrackList &that)
Definition: Track.cpp:808
TrackList::~TrackList ( )
virtual

Definition at line 826 of file Track.cpp.

References Clear().

827 {
828  Clear(false);
829 }
void Clear(bool sendEvent=true)
Make the list empty.
Definition: Track.cpp:1006

Member Function Documentation

template<typename TrackKind >
Track * TrackList::Add ( std::unique_ptr< TrackKind > &&  t)

Add a Track, giving it a fresh id.

Definition at line 906 of file Track.cpp.

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

Referenced by Effect::AddedAnalysisTrack::AddedAnalysisTrack(), ApplyPendingTracks(), AudacityProject::FinishCopy(), AudacityProject::OnAudioIOStopRecording(), Effect::Preview(), Effect::ReplaceProcessedTracks(), and LabelDialog::TransferDataFromWindow().

907 {
908  Track *pTrack;
909  push_back(ListOfTracks::value_type(pTrack = t.release()));
910 
911  auto n = getPrev( getEnd() );
912 
913  pTrack->SetOwner(mSelf, n);
914  pTrack->SetId( TrackId{ ++sCounter } );
915  RecalcPositions(n);
916  ResizingEvent(n);
917  return back().get();
918 }
void SetId(TrackId id)
Definition: Track.h:131
static long sCounter
Definition: Track.h:805
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
void ResizingEvent(TrackNodePointer node)
Definition: Track.cpp:872
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
TrackNodePointer getEnd() const
Definition: Track.h:764
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Definition: Track.cpp:121
Definition: Track.h:81
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
template<typename TrackKind >
Track * TrackList::Add ( std::shared_ptr< TrackKind > &&  t)

Add a Track, giving it a fresh id.

Definition at line 946 of file Track.cpp.

References getEnd(), getPrev(), mSelf, RecalcPositions(), ResizingEvent(), and sCounter.

947 {
948  push_back(t);
949 
950  auto n = getPrev( getEnd() );
951 
952  t->SetOwner(mSelf, n);
953  t->SetId( TrackId{ ++sCounter } );
954  RecalcPositions(n);
955  ResizingEvent(n);
956  return back().get();
957 }
static long sCounter
Definition: Track.h:805
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
void ResizingEvent(TrackNodePointer node)
Definition: Track.cpp:872
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
TrackNodePointer getEnd() const
Definition: Track.h:764
Definition: Track.h:81
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
template<typename TrackKind >
template Track * TrackList::AddToHead< TimeTrack > ( std::unique_ptr< TrackKind > &&  t)

Add a Track, giving it a fresh id.

Definition at line 930 of file Track.cpp.

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

931 {
932  Track *pTrack;
933  push_front(ListOfTracks::value_type(pTrack = t.release()));
934  auto n = getBegin();
935  pTrack->SetOwner(mSelf, n);
936  pTrack->SetId( TrackId{ ++sCounter } );
937  RecalcPositions(n);
938  ResizingEvent(n);
939  return front().get();
940 }
void SetId(TrackId id)
Definition: Track.h:131
static long sCounter
Definition: Track.h:805
void ResizingEvent(TrackNodePointer node)
Definition: Track.cpp:872
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
TrackNodePointer getBegin() const
Definition: Track.h:767
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Definition: Track.cpp:121
Definition: Track.h:81
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
bool TrackList::ApplyPendingTracks ( )

Definition at line 1496 of file Track.cpp.

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

1497 {
1498  bool result = false;
1499 
1500  ListOfTracks additions;
1501  ListOfTracks updates;
1502  {
1503  // Always clear, even if one of the update functions throws
1504  auto cleanup = finally( [&] { ClearPendingTracks( &additions ); } );
1506  updates.swap( mPendingUpdates );
1507  }
1508 
1509  // Remaining steps must be NOFAIL-GUARANTEE so that this function
1510  // gives STRONG-GUARANTEE
1511 
1512  std::vector< std::shared_ptr<Track> > reinstated;
1513 
1514  for (auto &pendingTrack : updates) {
1515  if (pendingTrack) {
1516  auto src = FindById( pendingTrack->GetId() );
1517  if (src)
1518  this->Replace(src, std::move(pendingTrack)), result = true;
1519  else
1520  // Perhaps a track marked for pending changes got deleted by
1521  // some other action. Recreate it so we don't lose the
1522  // accumulated changes.
1523  reinstated.push_back(pendingTrack);
1524  }
1525  }
1526 
1527  // If there are tracks to reinstate, append them to the list.
1528  for (auto &pendingTrack : reinstated)
1529  if (pendingTrack)
1530  this->Add(std::move(pendingTrack)), result = true;
1531 
1532  // Put the pending added tracks back into the list, preserving their
1533  // positions.
1534  bool inserted = false;
1535  ListOfTracks::iterator first;
1536  for (auto &pendingTrack : additions) {
1537  if (pendingTrack) {
1538  auto iter = ListOfTracks::begin();
1539  std::advance( iter, pendingTrack->GetIndex() );
1540  iter = ListOfTracks::insert( iter, pendingTrack );
1541  pendingTrack->SetOwner( mSelf, {iter, this} );
1542  pendingTrack->SetId( TrackId{ ++sCounter } );
1543  if (!inserted) {
1544  first = iter;
1545  inserted = true;
1546  }
1547  }
1548  }
1549  if (inserted) {
1550  RecalcPositions({first, this});
1551  result = true;
1552  }
1553 
1554  return result;
1555 }
Track * Add(std::unique_ptr< TrackKind > &&t)
Add a Track, giving it a fresh id.
Definition: Track.cpp:906
void ClearPendingTracks(ListOfTracks *pAdded=nullptr)
Definition: Track.cpp:1469
static long sCounter
Definition: Track.h:805
ListOfTracks mPendingUpdates
Definition: Track.h:858
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
Track * FindById(TrackId id)
Definition: Track.cpp:894
ListOfTracks::value_type Replace(Track *t, ListOfTracks::value_type &&with)
Definition: Track.cpp:963
Definition: Track.h:81
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:62
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
void UpdatePendingTracks()
Definition: Track.cpp:1449
iterator TrackList::begin ( )
inline

Definition at line 651 of file Track.h.

Referenced by cbegin(), empty(), AudacityProject::FindClipBoundaries(), AudacityProject::FindClips(), GetTimeTrack(), GetWaveTrackArray(), GetWaveTrackConstArray(), and HasPendingTracks().

651  { return iterator{
652  this, { ListOfTracks::begin(), this } }; }
TrackListIterator iterator
Definition: Track.h:648
const_iterator TrackList::begin ( ) const
inline

Definition at line 654 of file Track.h.

654 { return const_iterator{ this }; }
TrackListConstIterator const_iterator
Definition: Track.h:649
bool TrackList::CanMoveDown ( Track t) const

Definition at line 1121 of file Track.cpp.

References GetNext().

Referenced by TrackSelectHandle::CalculateRearrangingThresholds(), and TrackMenuTable::InitMenu().

1122 {
1123  return GetNext(t, true) != NULL;
1124 }
Track * GetNext(Track *t, bool linked=false) const
Return a track in the list that comes after Track t.
Definition: Track.cpp:1048
bool TrackList::CanMoveUp ( Track t) const

Definition at line 1116 of file Track.cpp.

References GetPrev().

Referenced by TrackSelectHandle::CalculateRearrangingThresholds(), and TrackMenuTable::InitMenu().

1117 {
1118  return GetPrev(t, true) != NULL;
1119 }
Track * GetPrev(Track *t, bool linked=false) const
Definition: Track.cpp:1067
const_iterator TrackList::cbegin ( ) const
inline

Definition at line 656 of file Track.h.

References begin().

656 { return begin(); }
iterator begin()
Definition: Track.h:651
const_iterator TrackList::cend ( ) const
inline

Definition at line 657 of file Track.h.

References end().

657 { return end(); }
iterator end()
Definition: Track.h:653
void TrackList::clear ( )
privatedelete

Referenced by TimeShiftHandle::Click().

void TrackList::Clear ( bool  sendEvent = true)

Make the list empty.

Definition at line 1006 of file Track.cpp.

References DeletionEvent(), mPendingUpdates, and mUpdaters.

Referenced by operator=(), and ~TrackList().

1007 {
1008  // Null out the back-pointers in tracks, in case there are outstanding
1009  // shared_ptrs to those tracks.
1010  for ( auto pTrack: *this )
1011  pTrack->SetOwner( {}, {} );
1012  for ( auto pTrack: mPendingUpdates )
1013  pTrack->SetOwner( {}, {} );
1014 
1015  ListOfTracks tempList;
1016  tempList.swap( *this );
1017 
1018  ListOfTracks updating;
1019  updating.swap( mPendingUpdates );
1020 
1021  mUpdaters.clear();
1022 
1023  if (sendEvent)
1024  DeletionEvent();
1025 }
void DeletionEvent()
Definition: Track.cpp:865
ListOfTracks mPendingUpdates
Definition: Track.h:858
std::vector< Updater > mUpdaters
Definition: Track.h:860
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:62
void TrackList::ClearPendingTracks ( ListOfTracks pAdded = nullptr)

Definition at line 1469 of file Track.cpp.

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

Referenced by ApplyPendingTracks().

1471 {
1472  for (const auto &pTrack: mPendingUpdates)
1473  pTrack->SetOwner( {}, {} );
1474  mPendingUpdates.clear();
1475  mUpdaters.clear();
1476 
1477  if (pAdded)
1478  pAdded->clear();
1479 
1480  for (auto it = ListOfTracks::begin(), stop = ListOfTracks::end();
1481  it != stop;) {
1482  if (it->get()->GetId() == TrackId{}) {
1483  if (pAdded)
1484  pAdded->push_back( *it );
1485  (*it)->SetOwner( {}, {} );
1486  it = erase( it );
1487  }
1488  else
1489  ++it;
1490  }
1491 
1492  if (!empty())
1494 }
ListOfTracks mPendingUpdates
Definition: Track.h:858
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
TrackNodePointer getBegin() const
Definition: Track.h:767
Definition: Track.h:81
std::vector< Updater > mUpdaters
Definition: Track.h:860
bool empty() const
Definition: Track.cpp:1229
bool TrackList::Contains ( const Track t) const

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

Definition at line 1224 of file Track.cpp.

References make_iterator_range().

1225 {
1226  return make_iterator_range( *this ).contains( t );
1227 }
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:677
std::shared_ptr< TrackList > TrackList::Create ( )
static
void TrackList::DeletionEvent ( )
private

Definition at line 865 of file Track.cpp.

Referenced by Clear(), and Remove().

866 {
867  auto e = std::make_unique<wxCommandEvent>(EVT_TRACKLIST_DELETION);
868  // wxWidgets will own the event object
869  QueueEvent(e.release());
870 }
bool TrackList::empty ( ) const

Definition at line 1229 of file Track.cpp.

References begin(), and end().

Referenced by ClearPendingTracks(), GetHeight(), CommonTrackPanelCell::HandleWheelRotation(), and size().

1230 {
1231  return begin() == end();
1232 }
iterator begin()
Definition: Track.h:651
iterator end()
Definition: Track.h:653
iterator TrackList::end ( )
inline
const_iterator TrackList::end ( ) const
inline

Definition at line 655 of file Track.h.

655 { return {}; }
Track * TrackList::FindById ( TrackId  id)

Definition at line 894 of file Track.cpp.

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

895 {
896  // Linear search. Tracks in a project are usually very few.
897  // Search only the non-pending tracks.
898  auto it = std::find_if( ListOfTracks::begin(), ListOfTracks::end(),
899  [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
900  if (it == ListOfTracks::end())
901  return {};
902  return it->get();
903 }
std::shared_ptr< Track > TrackList::FindPendingChangedTrack ( TrackId  id) const

Definition at line 1557 of file Track.cpp.

References mPendingUpdates.

Referenced by TrackPanel::DrawEverythingElse(), and TrackArtist::DrawTracks().

1558 {
1559  // Linear search. Tracks in a project are usually very few.
1560  auto it = std::find_if( mPendingUpdates.begin(), mPendingUpdates.end(),
1561  [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
1562  if (it == mPendingUpdates.end())
1563  return {};
1564  return *it;
1565 }
ListOfTracks mPendingUpdates
Definition: Track.h:858
TrackNodePointer TrackList::getBegin ( ) const
inlineprivate

Definition at line 767 of file Track.h.

Referenced by AddToHead(), ClearPendingTracks(), TrackListIterator::First(), getPrev(), and Permute().

768  { return { const_cast<TrackList*>(this)->ListOfTracks::begin(),
769  const_cast<TrackList*>(this)}; }
A list of TrackListNode items.
Definition: Track.h:619
TrackNodePointer TrackList::getEnd ( ) const
inlineprivate

Definition at line 764 of file Track.h.

Referenced by Add(), GetHeight(), getPrev(), TrackListIterator::Last(), SyncLockedTracksIterator::Next(), SyncLockedTracksIterator::Prev(), Remove(), and size().

765  { return { const_cast<TrackList*>(this)->ListOfTracks::end(),
766  const_cast<TrackList*>(this)}; }
A list of TrackListNode items.
Definition: Track.h:619
double TrackList::GetEndTime ( ) const
int TrackList::GetGroupHeight ( Track t) const

For mono track height of track For stereo track combined height of both channels.

Definition at line 1105 of file Track.cpp.

References Track::GetHeight(), and Track::GetLink().

Referenced by TrackSelectHandle::CalculateRearrangingThresholds().

1106 {
1107  int height = t->GetHeight();
1108 
1109  t = t->GetLink();
1110  if (t) {
1111  height += t->GetHeight();
1112  }
1113  return height;
1114 }
Track * GetLink() const
Definition: Track.cpp:269
int GetHeight() const
Definition: Track.cpp:180
int TrackList::GetHeight ( ) const

Definition at line 1372 of file Track.cpp.

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

Referenced by AudacityPrintout::OnPrintPage().

1373 {
1374  int height = 0;
1375 
1376  if (!empty()) {
1377  auto track = getPrev( getEnd() ).first->get();
1378  height = track->GetY() + track->GetHeight();
1379  }
1380 
1381  return height;
1382 }
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
TrackNodePointer getEnd() const
Definition: Track.h:764
bool empty() const
Definition: Track.cpp:1229
double TrackList::GetMinOffset ( ) const

Definition at line 1408 of file Track.cpp.

References Track::GetOffset().

1409 {
1410  return Accumulate(*this, &Track::GetOffset, doubleMin);
1411 }
virtual double GetOffset() const =0
Track * TrackList::GetNext ( Track t,
bool  linked = false 
) const

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

Return a track in the list that comes after Track t

Parameters
ta track in the list
linkedif true, skips over linked tracks, if false returns the next track even if it is a linked track

Definition at line 1048 of file Track.cpp.

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

Referenced by TrackSelectHandle::CalculateRearrangingThresholds(), TrackPanelResizeHandle::Cancel(), CanMoveDown(), TrackPanelResizeHandle::Drag(), WaveTrackMenuTable::InitMenu(), SyncLockedTracksIterator::Last(), and MoveDown().

1049 {
1050  if (t) {
1051  auto node = t->GetNode();
1052  if ( !isNull( node ) ) {
1053  if ( linked && t->GetLinked() )
1054  node = getNext( node );
1055 
1056  if ( !isNull( node ) )
1057  node = getNext( node );
1058 
1059  if ( !isNull( node ) )
1060  return node.first->get();
1061  }
1062  }
1063 
1064  return nullptr;
1065 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer GetNode() const
Definition: Track.cpp:114
bool GetLinked() const
Definition: Track.h:279
TrackNodePointer getNext(TrackNodePointer p) const
Definition: Track.h:772
TrackNodePointer TrackList::getNext ( TrackNodePointer  p) const
inlineprivate

Definition at line 772 of file Track.h.

References isNull().

Referenced by GetNext(), TrackListIterator::Next(), Remove(), and Select().

773  {
774  if ( isNull(p) )
775  return p;
776  auto q = p;
777  ++q.first;
778  return q;
779  }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
unsigned TrackList::GetNumExportChannels ( bool  selectionOnly) const

Find out how many channels this track list mixes to.

This is used in exports of the tracks to work out whether to export in Mono, Stereo etc.

Parameters
selectionOnlyWhether to consider the entire track list or only the selected members of it

Definition at line 1260 of file Track.cpp.

References TrackListConstIterator::First(), Track::GetChannel(), Track::GetKind(), WaveTrack::GetPan(), Track::GetSelected(), Track::LeftChannel, Track::MonoChannel, TrackListConstIterator::Next(), Track::RightChannel, and Track::Wave.

Referenced by ExportMultiple::ExportMultipleByLabel().

1261 {
1262  /* counters for tracks panned different places */
1263  int numLeft = 0;
1264  int numRight = 0;
1265  //int numMono = 0;
1266  /* track iteration kit */
1267  const Track *tr;
1269 
1270  for (tr = iter.First(this); tr != NULL; tr = iter.Next()) {
1271 
1272  // Want only unmuted wave tracks.
1273  auto wt = static_cast<const WaveTrack *>(tr);
1274  if ((tr->GetKind() != Track::Wave) ||
1275  wt->GetMute())
1276  continue;
1277 
1278  // do we only want selected ones?
1279  if (selectionOnly && !(tr->GetSelected())) {
1280  //want selected but this one is not
1281  continue;
1282  }
1283 
1284  // Found a left channel
1285  if (tr->GetChannel() == Track::LeftChannel) {
1286  numLeft++;
1287  }
1288 
1289  // Found a right channel
1290  else if (tr->GetChannel() == Track::RightChannel) {
1291  numRight++;
1292  }
1293 
1294  // Found a mono channel, but it may be panned
1295  else if (tr->GetChannel() == Track::MonoChannel) {
1296  float pan = ((WaveTrack*)tr)->GetPan();
1297 
1298  // Figure out what kind of channel it should be
1299  if (pan == -1.0) { // panned hard left
1300  numLeft++;
1301  }
1302  else if (pan == 1.0) { // panned hard right
1303  numRight++;
1304  }
1305  else if (pan == 0) { // panned dead center
1306  // numMono++;
1307  }
1308  else { // panned somewhere else
1309  numLeft++;
1310  numRight++;
1311  }
1312  }
1313  }
1314 
1315  // if there is stereo content, report 2, else report 1
1316  if (numRight > 0 || numLeft > 0) {
1317  return 2;
1318  }
1319 
1320  return 1;
1321 }
bool GetSelected() const
Definition: Track.h:276
const Track * First(const TrackList *val=NULL)
Definition: Track.h:465
float GetPan() const
Definition: WaveTrack.cpp:425
virtual int GetChannel() const
Definition: Track.h:286
virtual int GetKind() const
Definition: Track.h:330
const Track * Next(bool skiplinked=false)
Definition: Track.h:469
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
Track * TrackList::GetPrev ( Track t,
bool  linked = false 
) const

Definition at line 1067 of file Track.cpp.

References Track::GetLink(), Track::GetLinked(), Track::GetNode(), getPrev(), and isNull().

Referenced by TrackSelectHandle::CalculateRearrangingThresholds(), TrackPanelResizeHandle::Cancel(), CanMoveUp(), TrackPanelResizeHandle::Drag(), MoveUp(), and SyncLockedTracksIterator::StartWith().

1068 {
1069  if (t) {
1070  TrackNodePointer prev;
1071  auto node = t->GetNode();
1072  if ( !isNull( node ) ) {
1073  // linked is true and input track second in team?
1074  if (linked) {
1075  prev = getPrev( node );
1076  if( !isNull( prev ) &&
1077  !t->GetLinked() && t->GetLink() )
1078  // Make it the first
1079  node = prev;
1080  }
1081 
1082  prev = getPrev( node );
1083  if ( !isNull( prev ) ) {
1084  // Back up once
1085  node = prev;
1086 
1087  // Back up twice sometimes when linked is true
1088  if (linked) {
1089  prev = getPrev( node );
1090  if( !isNull( prev ) &&
1091  !(*node.first)->GetLinked() && (*node.first)->GetLink() )
1092  node = prev;
1093  }
1094 
1095  return node.first->get();
1096  }
1097  }
1098  }
1099 
1100  return nullptr;
1101 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer GetNode() const
Definition: Track.cpp:114
std::pair< ListOfTracks::iterator, ListOfTracks * > TrackNodePointer
Definition: Track.h:65
bool GetLinked() const
Definition: Track.h:279
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
Track * GetLink() const
Definition: Track.cpp:269
TrackNodePointer TrackList::getPrev ( TrackNodePointer  p) const
inlineprivate

Definition at line 782 of file Track.h.

References getBegin(), and getEnd().

Referenced by Add(), GetHeight(), GetPrev(), TrackListIterator::Last(), TrackListIterator::Prev(), RecalcPositions(), Select(), and size().

783  {
784  if (p == getBegin())
785  return getEnd();
786  else {
787  auto q = p;
788  --q.first;
789  return q;
790  }
791  }
TrackNodePointer getEnd() const
Definition: Track.h:764
TrackNodePointer getBegin() const
Definition: Track.h:767
double TrackList::GetStartTime ( ) const

Definition at line 1413 of file Track.cpp.

References Track::GetStartTime().

Referenced by TimeShiftHandle::DoSlideHorizontal(), AdornedRulerPanel::HandleQPRelease(), ControlToolBar::PlayPlayRegion(), and AdornedRulerPanel::StartQPPlay().

1414 {
1415  return Accumulate(*this, &Track::GetStartTime, doubleMin);
1416 }
virtual double GetStartTime() const =0
TimeTrack * TrackList::GetTimeTrack ( )

Definition at line 1244 of file Track.cpp.

References begin(), end(), Track::GetKind(), and Track::Time.

Referenced by ExportCL::Export(), ExportPCM::Export(), ExportMP3::Export(), AudacityProject::GetDefaultPlayOptions(), GetTimeTrack(), AudacityProject::HandlePasteNothingSelected(), and MixAndRender().

1245 {
1246  auto iter = std::find_if(begin(), end(),
1247  [] ( Track *t ) { return t->GetKind() == Track::Time; }
1248  );
1249  if (iter == end())
1250  return nullptr;
1251  else
1252  return static_cast<TimeTrack*>(*iter);
1253 }
iterator begin()
Definition: Track.h:651
virtual int GetKind() const
Definition: Track.h:330
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:29
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
iterator end()
Definition: Track.h:653
const TimeTrack * TrackList::GetTimeTrack ( ) const

Definition at line 1255 of file Track.cpp.

References GetTimeTrack().

1256 {
1257  return const_cast<TrackList*>(this)->GetTimeTrack();
1258 }
A list of TrackListNode items.
Definition: Track.h:619
TimeTrack * GetTimeTrack()
Definition: Track.cpp:1244
WaveTrackArray TrackList::GetWaveTrackArray ( bool  selectionOnly,
bool  includeMuted = true 
)

Definition at line 1344 of file Track.cpp.

References begin(), and end().

Referenced by RecordingRecoveryHandler::FindTrack(), RecordingRecoveryHandler::HandleXMLEndTag(), and RecordingRecoveryHandler::HandleXMLTag().

1345 {
1346  return GetWaveTracks<WaveTrackArray>(begin(), end(), selectionOnly, includeMuted);
1347 }
iterator begin()
Definition: Track.h:651
iterator end()
Definition: Track.h:653
WaveTrackConstArray TrackList::GetWaveTrackConstArray ( bool  selectionOnly,
bool  includeMuted = true 
) const

Definition at line 1349 of file Track.cpp.

References begin(), and end().

Referenced by ExportCL::Export(), ExportPCM::Export(), ExportMP3::Export(), and GetAllPlaybackTracks().

1350 {
1351  auto list = const_cast<TrackList*>(this);
1352  return GetWaveTracks<WaveTrackConstArray>(
1353  list->begin(), list->end(), selectionOnly, includeMuted);
1354 }
A list of TrackListNode items.
Definition: Track.h:619
bool TrackList::HasPendingTracks ( ) const

Definition at line 1567 of file Track.cpp.

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

Referenced by AudacityProject::RedoAvailable(), and AudacityProject::UndoAvailable().

1568 {
1569  if ( !mPendingUpdates.empty() )
1570  return true;
1571  if (end() != std::find_if(begin(), end(), [](const Track *t){
1572  return t->GetId() == TrackId{};
1573  }))
1574  return true;
1575  return false;
1576 }
TrackId GetId() const
Definition: Track.h:129
iterator begin()
Definition: Track.h:651
ListOfTracks mPendingUpdates
Definition: Track.h:858
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
iterator end()
Definition: Track.h:653
Definition: Track.h:81
bool TrackList::isNull ( TrackNodePointer  p) const
inlineprivate
template<typename Subclass >
std::shared_ptr<Subclass> TrackList::Lock ( const std::weak_ptr< Subclass > &  wTrack)
inline
bool TrackList::Move ( Track t,
bool  up 
)
inline

Definition at line 708 of file Track.h.

References MoveDown(), and MoveUp().

708 { return up ? MoveUp(t) : MoveDown(t); }
bool MoveUp(Track *t)
Definition: Track.cpp:1198
bool MoveDown(Track *t)
Definition: Track.cpp:1211
bool TrackList::MoveDown ( Track t)

Definition at line 1211 of file Track.cpp.

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

Referenced by Move().

1212 {
1213  if (t) {
1214  Track *n = GetNext(t, true);
1215  if (n) {
1216  SwapNodes(t->GetNode(), n->GetNode());
1217  return true;
1218  }
1219  }
1220 
1221  return false;
1222 }
TrackNodePointer GetNode() const
Definition: Track.cpp:114
void SwapNodes(TrackNodePointer s1, TrackNodePointer s2)
Definition: Track.cpp:1131
Track * GetNext(Track *t, bool linked=false) const
Return a track in the list that comes after Track t.
Definition: Track.cpp:1048
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
bool TrackList::MoveUp ( Track t)

Definition at line 1198 of file Track.cpp.

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

Referenced by Move(), and WaveTrackMenuTable::OnSwapChannels().

1199 {
1200  if (t) {
1201  Track *p = GetPrev(t, true);
1202  if (p) {
1203  SwapNodes(p->GetNode(), t->GetNode());
1204  return true;
1205  }
1206  }
1207 
1208  return false;
1209 }
TrackNodePointer GetNode() const
Definition: Track.cpp:114
void SwapNodes(TrackNodePointer s1, TrackNodePointer s2)
Definition: Track.cpp:1131
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
Track * GetPrev(Track *t, bool linked=false) const
Definition: Track.cpp:1067
TrackList& TrackList::operator= ( const TrackList )
privatedelete
TrackList & TrackList::operator= ( TrackList &&  that)
private

Definition at line 799 of file Track.cpp.

References Clear(), and Swap().

800 {
801  if (this != &that) {
802  this->Clear();
803  Swap(that);
804  }
805  return *this;
806 }
void Swap(TrackList &that)
Definition: Track.cpp:808
void Clear(bool sendEvent=true)
Make the list empty.
Definition: Track.cpp:1006
void TrackList::PermutationEvent ( )
private

Definition at line 858 of file Track.cpp.

Referenced by Permute(), and SwapNodes().

859 {
860  auto e = std::make_unique<wxCommandEvent>(EVT_TRACKLIST_PERMUTED);
861  // wxWidgets will own the event object
862  QueueEvent(e.release());
863 }
void TrackList::Permute ( const std::vector< TrackNodePointer > &  permutation)

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

Definition at line 880 of file Track.cpp.

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

881 {
882  for (const auto iter : permutation) {
883  ListOfTracks::value_type track = std::move(*iter.first);
884  erase(iter.first);
885  Track *pTrack = track.get();
886  pTrack->SetOwner(mSelf,
887  { insert(ListOfTracks::end(), std::move(track)), this });
888  }
889  auto n = getBegin();
890  RecalcPositions(n);
892 }
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
TrackNodePointer getBegin() const
Definition: Track.h:767
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Definition: Track.cpp:121
void PermutationEvent()
Definition: Track.cpp:858
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
void TrackList::RecalcPositions ( TrackNodePointer  node)
private

Definition at line 831 of file Track.cpp.

References Track::DoSetY(), end(), Track::GetHeight(), Track::GetIndex(), getPrev(), Track::GetY(), isNull(), Track::SetIndex(), and UpdatePendingTracks().

Referenced by Add(), AddToHead(), ApplyPendingTracks(), ClearPendingTracks(), Permute(), Remove(), and SwapNodes().

832 {
833  if ( isNull( node ) )
834  return;
835 
836  Track *t;
837  int i = 0;
838  int y = 0;
839 
840  auto prev = getPrev( node );
841  if ( !isNull( prev ) ) {
842  t = prev.first->get();
843  i = t->GetIndex() + 1;
844  y = t->GetY() + t->GetHeight();
845  }
846 
847  const auto theEnd = end();
848  for (auto n = TrackListIterator{ this, node }; n != theEnd; ++n) {
849  t = *n;
850  t->SetIndex(i++);
851  t->DoSetY(y);
852  y += t->GetHeight();
853  }
854 
856 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
void SetIndex(int index)
Definition: Track.cpp:149
int GetIndex() const
Definition: Track.cpp:144
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
void DoSetY(int y)
Definition: Track.cpp:175
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
iterator end()
Definition: Track.h:653
An iterator for a TrackList.
Definition: Track.h:402
int GetY() const
Definition: Track.cpp:154
int GetHeight() const
Definition: Track.cpp:180
void UpdatePendingTracks()
Definition: Track.cpp:1449
std::shared_ptr< Track > TrackList::RegisterPendingChangedTrack ( Updater  updater,
Track src 
)

Definition at line 1424 of file Track.cpp.

References Track::Duplicate(), mPendingUpdates, mSelf, and mUpdaters.

1425 {
1426  std::shared_ptr<Track> pTrack;
1427  if (src)
1428  // convert from unique_ptr to shared_ptr
1429  pTrack.reset( src->Duplicate().release() );
1430 
1431  if (pTrack) {
1432  mUpdaters.push_back( updater );
1433  mPendingUpdates.push_back( pTrack );
1434  auto n = mPendingUpdates.end();
1435  --n;
1436  pTrack->SetOwner(mSelf, {n, &mPendingUpdates});
1437  }
1438 
1439  return pTrack;
1440 }
ListOfTracks mPendingUpdates
Definition: Track.h:858
std::vector< Updater > mUpdaters
Definition: Track.h:860
virtual Holder Duplicate() const =0
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
void TrackList::RegisterPendingNewTrack ( const std::shared_ptr< Track > &  pTrack)

Definition at line 1442 of file Track.cpp.

1443 {
1444  auto copy = pTrack;
1445  Add<Track>( std::move( copy ) );
1446  pTrack->SetId( TrackId{} );
1447 }
Definition: Track.h:81
TrackNodePointer TrackList::Remove ( Track t)

Remove this Track or all children of this TrackList. Return an iterator to what followed the removed track.

Definition at line 985 of file Track.cpp.

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

Referenced by TrackListIterator::RemoveCurrent(), and Effect::ReplaceProcessedTracks().

986 {
987  auto result = getEnd();
988  if (t) {
989  auto node = t->GetNode();
990  t->SetOwner({}, {});
991 
992  if ( !isNull( node ) ) {
993  ListOfTracks::value_type holder = std::move( *node.first );
994 
995  result = getNext( node );
996  erase(node.first);
997  if ( !isNull( result ) )
998  RecalcPositions(result);
999 
1000  DeletionEvent();
1001  }
1002  }
1003  return result;
1004 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer GetNode() const
Definition: Track.cpp:114
void DeletionEvent()
Definition: Track.cpp:865
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
TrackNodePointer getEnd() const
Definition: Track.h:764
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Definition: Track.cpp:121
TrackNodePointer getNext(TrackNodePointer p) const
Definition: Track.h:772
auto TrackList::Replace ( Track t,
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 963 of file Track.cpp.

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

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

965 {
966  ListOfTracks::value_type holder;
967  if (t && with) {
968  auto node = t->GetNode();
969  t->SetOwner({}, {});
970 
971  holder = std::move(*node.first);
972 
973  Track *pTrack = with.get();
974  *node.first = std::move(with);
975  pTrack->SetOwner(mSelf, node);
976  pTrack->SetId( t->GetId() );
977  RecalcPositions(node);
978 
979  DeletionEvent();
980  ResizingEvent(node);
981  }
982  return holder;
983 }
void SetId(TrackId id)
Definition: Track.h:131
TrackNodePointer GetNode() const
Definition: Track.cpp:114
TrackId GetId() const
Definition: Track.h:129
void DeletionEvent()
Definition: Track.cpp:865
void ResizingEvent(TrackNodePointer node)
Definition: Track.cpp:872
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Definition: Track.cpp:121
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
void TrackList::ResizingEvent ( TrackNodePointer  node)
private

Definition at line 872 of file Track.cpp.

Referenced by Add(), and AddToHead().

873 {
874  auto e = std::make_unique<TrackListEvent>(EVT_TRACKLIST_RESIZING);
875  e->mpTrack = *node.first;
876  // wxWidgets will own the event object
877  QueueEvent(e.release());
878 }
void TrackList::Select ( Track t,
bool  selected = true 
)

Select a track, and if it is linked to another track, select it, too.

Definition at line 1027 of file Track.cpp.

References Track::GetLinked(), getNext(), Track::GetNode(), getPrev(), isNull(), and Track::SetSelected().

Referenced by SelectionState::SelectTrack().

1028 {
1029  if (t) {
1030  const auto node = t->GetNode();
1031  if ( !isNull( node ) ) {
1032  t->SetSelected( selected );
1033  if ( t->GetLinked() ) {
1034  auto next = getNext( node );
1035  if ( !isNull( next ) )
1036  (*next.first)->SetSelected( selected );
1037  }
1038  else {
1039  auto prev = getPrev( node );
1040  if ( !isNull( prev ) && (*prev.first)->GetLinked() )
1041  (*prev.first)->SetSelected( selected );
1042  }
1043  }
1044  }
1045 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer GetNode() const
Definition: Track.cpp:114
bool GetLinked() const
Definition: Track.h:279
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
virtual void SetSelected(bool s)
Definition: Track.cpp:99
TrackNodePointer getNext(TrackNodePointer p) const
Definition: Track.h:772
size_t TrackList::size ( ) const

Definition at line 1234 of file Track.cpp.

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

Referenced by ScreenshotCommand::Apply().

1235 {
1236  int cnt = 0;
1237 
1238  if (!empty())
1239  cnt = getPrev( getEnd() ).first->get()->GetIndex() + 1;
1240 
1241  return cnt;
1242 }
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
TrackNodePointer getEnd() const
Definition: Track.h:764
bool empty() const
Definition: Track.cpp:1229
void TrackList::Swap ( TrackList that)

Definition at line 808 of file Track.cpp.

Referenced by operator=(), and TrackList().

809 {
810  auto SwapLOTs = [](
811  ListOfTracks &a, const std::weak_ptr< TrackList > &aSelf,
812  ListOfTracks &b, const std::weak_ptr< TrackList > &bSelf )
813  {
814  a.swap(b);
815  for (auto it = a.begin(), last = a.end(); it != last; ++it)
816  (*it)->SetOwner(aSelf, {it, &a});
817  for (auto it = b.begin(), last = b.end(); it != last; ++it)
818  (*it)->SetOwner(bSelf, {it, &b});
819  };
820 
821  SwapLOTs( *this, mSelf, that, that.mSelf );
822  SwapLOTs( this->mPendingUpdates, mSelf, that.mPendingUpdates, that.mSelf );
823  mUpdaters.swap(that.mUpdaters);
824 }
ListOfTracks mPendingUpdates
Definition: Track.h:858
std::vector< Updater > mUpdaters
Definition: Track.h:860
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:62
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
void TrackList::SwapNodes ( TrackNodePointer  s1,
TrackNodePointer  s2 
)
private

Definition at line 1131 of file Track.cpp.

References Track::GetNode(), isNull(), mSelf, PermutationEvent(), RecalcPositions(), and Track::SetOwner().

Referenced by MoveDown(), and MoveUp().

1132 {
1133  // if a null pointer is passed in, we want to know about it
1134  wxASSERT(!isNull(s1));
1135  wxASSERT(!isNull(s2));
1136 
1137  // Deal with first track in each team
1138  Track *link;
1139  link = (*s1.first)->GetLink();
1140  bool linked1 = link != nullptr;
1141  if (linked1 && !(*s1.first)->GetLinked()) {
1142  s1 = link->GetNode();
1143  }
1144 
1145  link = (*s2.first)->GetLink();
1146  bool linked2 = link != nullptr;
1147  if (linked2 && !(*s2.first)->GetLinked()) {
1148  s2 = link->GetNode();
1149  }
1150 
1151  // Safety check...
1152  if (s1 == s2)
1153  return;
1154 
1155  // Be sure s1 is the earlier iterator
1156  if ((*s1.first)->GetIndex() >= (*s2.first)->GetIndex()) {
1157  std::swap(s1, s2);
1158  std::swap(linked1, linked2);
1159  }
1160 
1161  // Remove tracks
1162  ListOfTracks::value_type save11 = std::move(*s1.first), save12{};
1163  s1.first = erase(s1.first);
1164  if (linked1) {
1165  wxASSERT(s1 != s2);
1166  save12 = std::move(*s1.first), s1.first = erase(s1.first);
1167  }
1168  const bool same = (s1 == s2);
1169 
1170  ListOfTracks::value_type save21 = std::move(*s2.first), save22{};
1171  s2.first = erase(s2.first);
1172  if (linked2)
1173  save22 = std::move(*s2.first), s2.first = erase(s2.first);
1174 
1175  if (same)
1176  // We invalidated s1!
1177  s1 = s2;
1178 
1179  // Reinsert them
1180  Track *pTrack;
1181  if (save22)
1182  pTrack = save22.get(),
1183  pTrack->SetOwner(mSelf, s1 = { insert(s1.first, std::move(save22)), this });
1184  pTrack = save21.get(),
1185  pTrack->SetOwner(mSelf, s1 = { insert(s1.first, std::move(save21)), this });
1186 
1187  if (save12)
1188  pTrack = save12.get(),
1189  pTrack->SetOwner(mSelf, s2 = { insert(s2.first, std::move(save12)), this });
1190  pTrack = save11.get(),
1191  pTrack->SetOwner(mSelf, s2 = { insert(s2.first, std::move(save11)), this });
1192 
1193  // Now correct the Index in the tracks, and other things
1194  RecalcPositions(s1);
1195  PermutationEvent();
1196 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer GetNode() const
Definition: Track.cpp:114
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:831
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Definition: Track.cpp:121
void PermutationEvent()
Definition: Track.cpp:858
std::weak_ptr< TrackList > mSelf
Definition: Track.h:800
void TrackList::UpdatePendingTracks ( )

Definition at line 1449 of file Track.cpp.

References FindById(), mPendingUpdates, and mUpdaters.

Referenced by ApplyPendingTracks(), and RecalcPositions().

1450 {
1451  auto pUpdater = mUpdaters.begin();
1452  for (const auto &pendingTrack : mPendingUpdates) {
1453  // Copy just a part of the track state, according to the update
1454  // function
1455  const auto &updater = *pUpdater;
1456  auto src = FindById( pendingTrack->GetId() );
1457  if (pendingTrack && src) {
1458  if (updater)
1459  updater( *pendingTrack, *src );
1460  pendingTrack->DoSetY(src->GetY());
1461  pendingTrack->DoSetHeight(src->GetHeight());
1462  pendingTrack->DoSetMinimized(src->GetMinimized());
1463  pendingTrack->DoSetLinked(src->GetLinked());
1464  }
1465  ++pUpdater;
1466  }
1467 }
ListOfTracks mPendingUpdates
Definition: Track.h:858
Track * FindById(TrackId id)
Definition: Track.cpp:894
std::vector< Updater > mUpdaters
Definition: Track.h:860

Friends And Related Function Documentation

friend class SyncLockedTracksIterator
friend

Definition at line 661 of file Track.h.

friend class Track
friend

Definition at line 659 of file Track.h.

friend class TrackListIterator
friend

Definition at line 660 of file Track.h.

Member Data Documentation

ListOfTracks TrackList::mPendingUpdates
private
std::weak_ptr<TrackList> TrackList::mSelf
private
std::vector< Updater > TrackList::mUpdaters
private
long TrackList::sCounter = -1
staticprivate

Definition at line 805 of file Track.h.

Referenced by Add(), AddToHead(), and ApplyPendingTracks().


The documentation for this class was generated from the following files: