1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Use TypeSwitch and track_cast

This commit is contained in:
Paul Licameli
2017-04-11 18:16:03 -04:00
parent fd10ed26cd
commit 51842fc78b
13 changed files with 806 additions and 872 deletions

View File

@@ -54,32 +54,29 @@ void SetEnvelopeCommand::PopulateOrExchange(ShuttleGui & S)
bool SetEnvelopeCommand::ApplyInner( const CommandContext & context, Track * t )
{
static_cast<void>(context);
if( (t->GetKind() != Track::Wave))
return true;
// if no time is specified, then
// if no time is specified, then
// - delete deletes any envelope in selected tracks.
// - value is not set for any clip
WaveTrack *waveTrack = static_cast<WaveTrack*>(t);
WaveClipPointers ptrs( waveTrack->SortedClipArray());
for(auto it = ptrs.begin(); (it != ptrs.end()); it++ ){
WaveClip * pClip = *it;
bool bFound =
!bHasT || (
( pClip->GetStartTime() <= mT) &&
( pClip->GetEndTime() >= mT )
);
if( bFound )
{
// Inside this IF is where we actually apply the command
Envelope* pEnv = pClip->GetEnvelope();
if( bHasDelete && mbDelete )
pEnv->mEnv.clear();
if( bHasT && bHasV )
pEnv->InsertOrReplace( mT, mV );
t->TypeSwitch([&](WaveTrack *waveTrack) {
WaveClipPointers ptrs( waveTrack->SortedClipArray());
for(auto it = ptrs.begin(); (it != ptrs.end()); it++ ){
WaveClip * pClip = *it;
bool bFound =
!bHasT || (
( pClip->GetStartTime() <= mT) &&
( pClip->GetEndTime() >= mT )
);
if( bFound )
{
// Inside this IF is where we actually apply the command
Envelope* pEnv = pClip->GetEnvelope();
if( bHasDelete && mbDelete )
pEnv->mEnv.clear();
if( bHasT && bHasV )
pEnv->InsertOrReplace( mT, mV );
}
}
}
} );
return true;
}