| 70 | } |
| 71 | |
| 72 | bool SetEnvelopeCommand::ApplyInner(const CommandContext &context, Track &t) |
| 73 | { |
| 74 | // if no time is specified, then |
| 75 | // - delete deletes any envelope in selected tracks. |
| 76 | // - value is not set for any clip |
| 77 | t.TypeSwitch([&](WaveTrack &waveTrack) { |
| 78 | for (const auto pClip : waveTrack.SortedIntervalArray()) { |
| 79 | bool bFound = |
| 80 | !bHasT || ( |
| 81 | (pClip->GetPlayStartTime() <= mT) && |
| 82 | (pClip->GetPlayEndTime() >= mT) |
| 83 | ); |
| 84 | if (bFound) { |
| 85 | // Inside this IF is where we actually apply the command |
| 86 | auto &env = pClip->GetEnvelope(); |
| 87 | bool didSomething = false; |
| 88 | if (bHasDelete && mbDelete) |
| 89 | env.Clear(), didSomething = true; |
| 90 | if (bHasT && bHasV) |
| 91 | env.InsertOrReplace(mT, env.ClampValue(mV)), |
| 92 | didSomething = true; |
| 93 | |
| 94 | if (didSomething) |
| 95 | // Consolidate, because this ApplyInner() function may be |
| 96 | // visited multiple times in one command invocation |
| 97 | ProjectHistory::Get(context.project).PushState( |
| 98 | XO("Edited Envelope"), XO("Envelope"), |
| 99 | UndoPush::CONSOLIDATE); |
| 100 | } |
| 101 | } |
| 102 | } ); |
| 103 | |
| 104 | |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | namespace { |
| 109 | using namespace MenuRegistry; |
nothing calls this directly
no test coverage detected