MCPcopy Create free account
hub / github.com/audacity/audacity / Click

Method Click

src/tracks/ui/TimeShiftHandle.cpp:457–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457UIHandle::Result TimeShiftHandle::Click(
458 const TrackPanelMouseEvent &evt, AudacityProject *pProject)
459{
460 using namespace RefreshCode;
461 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
462 if ( unsafe )
463 return Cancelled;
464
465 const wxMouseEvent &event = evt.event;
466 const wxRect &rect = evt.rect;
467 auto &viewInfo = ViewInfo::Get( *pProject );
468
469 const auto pView =
470 std::dynamic_pointer_cast<CommonTrackPanelCell>(evt.pCell);
471 const auto pTrack = pView ? pView->FindTrack() : nullptr;
472 if (!pTrack)
473 return RefreshCode::Cancelled;
474
475 mClipMoveState.clear();
476 mDidSlideVertically = false;
477
478 const bool multiToolModeActive =
479 (ToolCodes::multiTool == ProjectSettings::Get( *pProject ).GetTool());
480
481 const double clickTime =
482 viewInfo.PositionToTime(event.m_x, rect.x);
483
484 auto pShifter = MakeTrackShifter::Call(*pTrack, *pProject);
485
486 auto hitTestResult = TrackShifter::HitTestResult::Track;
487 if (!event.ShiftDown()) {
488 TrackShifter::HitTestParams params{
489 rect, event.m_x, event.m_y
490 };
491 hitTestResult = pShifter->HitTest( clickTime, viewInfo, &params );
492 switch( hitTestResult ) {
493 case TrackShifter::HitTestResult::Miss:
494 return Cancelled;
495 default:
496 break;
497 }
498 }
499 else {
500 // just do shifting of one whole track
501 }
502
503 auto &trackList = TrackList::Get(*pProject);
504 mClipMoveState.Init(*pProject, *pTrack,
505 hitTestResult, move(pShifter), clickTime,
506 viewInfo, trackList,
507 SyncLockState::Get( *pProject ).IsSyncLocked() );
508
509 mSlideUpDownOnly = event.CmdDown() && !multiToolModeActive;
510 mRect = rect;
511 mClipMoveState.mMouseClickX = event.m_x;
512 mSnapManager =
513 std::make_shared<SnapManager>(*trackList.GetOwner(),
514 FindCandidates( trackList, mClipMoveState.shifters ),

Callers

nothing calls this directly

Calls 14

GetFunction · 0.85
CallClass · 0.85
moveFunction · 0.85
PositionToTimeMethod · 0.80
IsSyncLockedMethod · 0.80
CapturedIntervalMethod · 0.80
FindCandidatesFunction · 0.70
IsAudioActiveMethod · 0.45
FindTrackMethod · 0.45
clearMethod · 0.45
HitTestMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected