1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 16:49:41 +02:00

Bug 2363 - Double-click-selecting a clip partly selects clip before too

This commit is contained in:
James Crook 2020-03-21 22:54:15 +00:00
parent 37c8a6ef23
commit a072e21b77
3 changed files with 13 additions and 2 deletions

View File

@ -474,6 +474,16 @@ bool WaveClip::AfterClip(double t) const
return ts > GetEndSample() + mAppendBufferLen;
}
// A sample at time t could be in the clip, but
// a clip start at time t still be from a clip
// not overlapping this one, with this test.
bool WaveClip::IsClipStartAfterClip(double t) const
{
auto ts = (sampleCount)floor(t * mRate + 0.5);
return ts >= GetEndSample() + mAppendBufferLen;
}
///Delete the wave cache - force redraw. Thread-safe
void WaveClip::ClearWaveCache()
{

View File

@ -231,6 +231,7 @@ public:
bool WithinClip(double t) const;
bool BeforeClip(double t) const;
bool AfterClip(double t) const;
bool IsClipStartAfterClip(double t) const;
bool GetSamples(samplePtr buffer, sampleFormat format,
sampleCount start, size_t len, bool mayThrow = true) const;

View File

@ -108,13 +108,13 @@ namespace
void AddClipsToCaptured
( ClipMoveState &state, Track *t, double t0, double t1 )
{
bool exclude = true;
bool exclude = true; // to exclude a whole track.
auto &clips = state.capturedClipArray;
t->TypeSwitch(
[&](WaveTrack *wt) {
exclude = false;
for(const auto &clip: wt->GetClips())
if ( ! clip->AfterClip(t0) && ! clip->BeforeClip(t1) &&
if ( ! clip->IsClipStartAfterClip(t0) && ! clip->BeforeClip(t1) &&
// Avoid getting clips that were already captured
! std::any_of( clips.begin(), clips.end(),
[&](const TrackClip &c) { return c.clip == clip.get(); } ) )