1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-15 15:11:12 +02:00

Bug 1290 - "Split New" clips cannot be dragged back into the track they came from.

Fixed by giving some tolerance in how the dragged clip(s) are placed.
The tolerance is 1px, so it depends on the zoom.  Therefore if zoomed in your positioning is more precise.
This commit is contained in:
James Crook
2017-08-19 22:46:33 +01:00
parent 4d43d2273b
commit e984211cce
3 changed files with 40 additions and 7 deletions

View File

@@ -707,25 +707,39 @@ UIHandle::Result TimeShiftHandle::Drag
// Now check that the move is possible
bool ok = true;
// The test for tolerance will need review with FishEye!
// The tolerance is supposed to be the time for one pixel, i.e. one pixel tolerance
// at current zoom.
double slide = desiredSlideAmount; // remember amount requested.
double tolerance = viewInfo.PositionToTime(event.m_x+1) - viewInfo.PositionToTime(event.m_x+1);
// The desiredSlideAmount may change and the tolerance may get used up.
for ( unsigned ii = 0, nn = mClipMoveState.capturedClipArray.size();
ok && ii < nn; ++ii) {
TrackClip &trackClip = mClipMoveState.capturedClipArray[ii];
WaveClip *const pSrcClip = trackClip.clip;
if (pSrcClip)
ok = trackClip.dstTrack->CanInsertClip(pSrcClip, desiredSlideAmount);
ok = trackClip.dstTrack->CanInsertClip(pSrcClip, desiredSlideAmount, tolerance);
}
if (!ok) {
// Failure, even with using tolerance.
// Failure -- put clips back where they were
for ( unsigned ii = 0, nn = mClipMoveState.capturedClipArray.size();
ii < nn; ++ii) {
TrackClip &trackClip = mClipMoveState.capturedClipArray[ii];
WaveClip *const pSrcClip = trackClip.clip;
if (pSrcClip)
if (pSrcClip){
// Attempt to move to a new track did not work.
// Put the clip back appropriately shifted!
trackClip.holder->Offset(slide);
// Assume track is wave because it has a clip
static_cast<WaveTrack*>(trackClip.track)->
AddClip(std::move(trackClip.holder));
}
}
// Make the offset permanent; start from a "clean slate"
mMouseClickX = event.m_x;
return RefreshAll;
}
else {