1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-25 17:08:07 +02:00

Count stereo tracks as one track, not two.

The TrackIterator actually iterates through channels, so we need to skip the linked tracks when counting.
This commit is contained in:
James Crook 2016-10-07 21:53:10 +01:00
parent fe2dfca3e0
commit d6302bc370

View File

@ -1894,17 +1894,34 @@ void TrackPanel::SelectTrack(Track *pTrack, bool selected, bool updateLastPicked
}
}
// Counts tracks, counting stereo tracks as one track.
size_t TrackPanel::GetTrackCount(){
auto tracks = GetTracks();
return (size_t)tracks->GetCount();
size_t count = 0;
TrackListIterator iter(GetTracks());
for (Track *t = iter.First(); t; t = iter.Next()) {
count += 1;
if( t->GetLinked() ){
t = iter.Next();
if( !t )
break;
}
}
return count;
}
// Counts selected tracks, counting stereo tracks as one track.
size_t TrackPanel::GetSelectedTrackCount(){
size_t count = 0;
TrackListIterator iter(GetTracks());
for (Track *t = iter.First(); t; t = iter.Next()) {
count += t->GetSelected() ? 1:0;
if( t->GetLinked() ){
t = iter.Next();
if( !t )
break;
}
}
return count;
}