| 266 | } |
| 267 | |
| 268 | void SeekWhenAudioInactive |
| 269 | (AudacityProject &project, double seekStep, TimeUnit timeUnit, |
| 270 | SelectionOperation operation) |
| 271 | { |
| 272 | auto &viewInfo = ViewInfo::Get(project); |
| 273 | auto &tracks = TrackList::Get(project); |
| 274 | const auto &settings = ProjectSnap::Get(project); |
| 275 | auto &viewport = Viewport::Get(project); |
| 276 | |
| 277 | if (operation == CURSOR_MOVE) |
| 278 | { |
| 279 | MoveWhenAudioInactive( project, seekStep, timeUnit); |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | auto snapMode = settings.GetSnapMode(); |
| 284 | const double t0 = viewInfo.selectedRegion.t0(); |
| 285 | const double t1 = viewInfo.selectedRegion.t1(); |
| 286 | const double end = std::max( |
| 287 | tracks.GetEndTime(), viewInfo.GetScreenEndTime()); |
| 288 | |
| 289 | // Is it t0 or t1 moving? |
| 290 | bool bMoveT0 = (operation == SELECTION_CONTRACT && seekStep > 0) || |
| 291 | (operation == SELECTION_EXTEND && seekStep < 0); |
| 292 | // newT is where we want to move to |
| 293 | double newT = OffsetTime( project, |
| 294 | bMoveT0 ? t0 : t1, seekStep, timeUnit, snapMode); |
| 295 | // constrain to be in the track/screen limits. |
| 296 | newT = std::max( 0.0, newT ); |
| 297 | newT = std::min( newT, end); |
| 298 | // optionally constrain to be a contraction, i.e. so t0/t1 do not cross over |
| 299 | if( operation == SELECTION_CONTRACT ) |
| 300 | newT = bMoveT0 ? std::min( t1, newT ) : std::max( t0, newT ); |
| 301 | |
| 302 | // Actually move |
| 303 | if( bMoveT0 ) |
| 304 | viewInfo.selectedRegion.setT0( newT ); |
| 305 | else |
| 306 | viewInfo.selectedRegion.setT1( newT ); |
| 307 | |
| 308 | // Ensure it is visible |
| 309 | viewport.ScrollIntoView(newT); |
| 310 | } |
| 311 | |
| 312 | // Handle small cursor and play head movements |
| 313 | void SeekLeftOrRight |
no test coverage detected