| 272 | } |
| 273 | |
| 274 | void ClipMoveState::Init( |
| 275 | AudacityProject &project, |
| 276 | Track &capturedTrack, |
| 277 | TrackShifter::HitTestResult hitTestResult, |
| 278 | std::unique_ptr<TrackShifter> pHit, |
| 279 | double clickTime, |
| 280 | const ViewInfo &viewInfo, |
| 281 | TrackList &trackList, bool syncLocked ) |
| 282 | { |
| 283 | shifters.clear(); |
| 284 | |
| 285 | initialized = true; |
| 286 | |
| 287 | auto &state = *this; |
| 288 | state.mCapturedTrack = capturedTrack.SharedPointer(); |
| 289 | |
| 290 | switch (hitTestResult) { |
| 291 | case TrackShifter::HitTestResult::Miss: |
| 292 | wxASSERT(false); |
| 293 | pHit.reset(); |
| 294 | break; |
| 295 | case TrackShifter::HitTestResult::Track: |
| 296 | pHit.reset(); |
| 297 | break; |
| 298 | case TrackShifter::HitTestResult::Intervals: |
| 299 | break; |
| 300 | case TrackShifter::HitTestResult::Selection: |
| 301 | state.movingSelection = true; |
| 302 | break; |
| 303 | default: |
| 304 | break; |
| 305 | } |
| 306 | |
| 307 | if (!pHit) |
| 308 | return; |
| 309 | |
| 310 | state.shifters[&capturedTrack] = std::move( pHit ); |
| 311 | |
| 312 | // Collect TrackShifters for the rest of the tracks |
| 313 | for (auto track : trackList) { |
| 314 | auto &pShifter = state.shifters[track]; |
| 315 | if (!pShifter) |
| 316 | pShifter = MakeTrackShifter::Call(*track, project); |
| 317 | } |
| 318 | |
| 319 | if ( state.movingSelection ) { |
| 320 | // All selected tracks may move some intervals |
| 321 | const TrackShifter::TimeInterval interval{ |
| 322 | viewInfo.selectedRegion.t0(), |
| 323 | viewInfo.selectedRegion.t1() |
| 324 | }; |
| 325 | for ( const auto &pair : state.shifters ) { |
| 326 | auto &shifter = *pair.second; |
| 327 | auto &track = shifter.GetTrack(); |
| 328 | if (&track == &capturedTrack) |
| 329 | // Don't change the choice of intervals made by HitTest |
| 330 | continue; |
| 331 | if ( track.IsSelected() ) |