Fix Auto Resize when Dragging Sample Files onto Sample Clips (#7952)

Changes things so that only sample clips with auto-resize enabled will automatically resize to the sample length when dragging-dropping a sample from the sidebar onto a sample clip. Non-auto-resize clips will keep their original length, but still update so that their start time offset is 0.
This commit is contained in:
regulus79
2025-06-13 21:30:11 -04:00
committed by GitHub
parent a505f570e9
commit 45ab56dd71

View File

@@ -179,26 +179,21 @@ void SampleClip::setSampleBuffer(std::shared_ptr<const SampleBuffer> sb)
void SampleClip::setSampleFile(const QString& sf)
{
int length = 0;
// Remove any prior offset in the clip
setStartTimeOffset(0);
if (!sf.isEmpty())
{
//Otherwise set it to the sample's length
m_sample = Sample(gui::SampleLoader::createBufferFromFile(sf));
length = sampleLength();
updateLength();
}
if (length == 0)
else
{
//If there is no sample, make the clip a bar long
// If there is no sample, make the clip a bar long
float nom = Engine::getSong()->getTimeSigModel().getNumerator();
float den = Engine::getSong()->getTimeSigModel().getDenominator();
length = DefaultTicksPerBar * (nom / den);
changeLength(DefaultTicksPerBar * (nom / den));
}
changeLength(length);
setStartTimeOffset(0);
emit sampleChanged();
emit playbackPositionChanged();
}