diff --git a/src/core/AutomationClip.cpp b/src/core/AutomationClip.cpp index 32739482b74..539fdd3a5a9 100644 --- a/src/core/AutomationClip.cpp +++ b/src/core/AutomationClip.cpp @@ -197,6 +197,12 @@ void AutomationClip::updateLength() // checks if it has been resized from either direction. if (getAutoResize()) { + if ( m_autoTrack != nullptr && m_autoTrack->trackContainer() == Engine::patternStore() ) + { + // If inside a pattern, the clip is always the lenght of it. + changeLength(TimePos::ticksPerBar() * Engine::patternStore()->lengthOfPattern(m_autoTrack->getClipNum(this))); + return; + } // Using 1 bar as the min length for an un-resized clip. // This does not prevent the user from resizing the clip to be less than a bar later on. changeLength(std::max(TimePos::ticksPerBar(), static_cast(timeMapLength()))); diff --git a/src/core/PatternStore.cpp b/src/core/PatternStore.cpp index 57ec78c9321..8d337da5581 100644 --- a/src/core/PatternStore.cpp +++ b/src/core/PatternStore.cpp @@ -89,7 +89,7 @@ bar_t PatternStore::lengthOfPattern(int pattern) const for (Track * t : tl) { // Don't create Clips here if they don't exist - if (pattern < t->numOfClips()) + if (pattern < t->numOfClips() && t->type() == Track::Type::Instrument) { maxLength = std::max(maxLength, t->getClip(pattern)->length()); } diff --git a/src/core/SampleClip.cpp b/src/core/SampleClip.cpp index e279f76236e..4285b2479eb 100644 --- a/src/core/SampleClip.cpp +++ b/src/core/SampleClip.cpp @@ -27,6 +27,7 @@ #include #include +#include "PatternStore.h" #include "PathUtil.h" #include "SampleClipView.h" #include "SampleTrack.h" @@ -227,6 +228,11 @@ void SampleClip::updateLength() // If the clip has already been manually resized, don't automatically resize it. if (getAutoResize()) { + if (getTrack()->trackContainer() == Engine::patternStore()) + { + changeLength(TimePos::ticksPerBar() * Engine::patternStore()->lengthOfPattern(getTrack()->getClipNum(this))); + return; + } changeLength(sampleLength()); setStartTimeOffset(0); } diff --git a/src/gui/clips/AutomationClipView.cpp b/src/gui/clips/AutomationClipView.cpp index 07d5a2c5f8b..2258297c35a 100644 --- a/src/gui/clips/AutomationClipView.cpp +++ b/src/gui/clips/AutomationClipView.cpp @@ -265,7 +265,7 @@ void AutomationClipView::paintEvent( QPaintEvent * ) // pixels per bar const float ppb = fixedClips() ? ( parentWidget()->width() - 2 * BORDER_WIDTH ) - / (float) m_clip->timeMapLength().getBar() : + / (float) m_clip->length().getBar() : pixelsPerBar(); const auto min = m_clip->firstObject()->minValue(); diff --git a/src/gui/editors/PatternEditor.cpp b/src/gui/editors/PatternEditor.cpp index 6c3b66e29b5..70c83fd756a 100644 --- a/src/gui/editors/PatternEditor.cpp +++ b/src/gui/editors/PatternEditor.cpp @@ -216,11 +216,13 @@ void PatternEditor::updateMaxSteps() m_maxClipLength = 0; for (const auto& track : tl) { - if (track->type() == Track::Type::Instrument) + auto clip = track->getClip(m_ps->currentPattern()); + if (track->type() == Track::Type::Automation || track->type() == Track::Type::Sample) { - auto mClip = static_cast(track->getClip(m_ps->currentPattern())); - m_maxClipLength = std::max(m_maxClipLength, static_cast(mClip->length())); + // The length of automation and sample clips is updated to match the pattern length. + clip->updateLength(); } + m_maxClipLength = std::max(m_maxClipLength, static_cast(clip->length())); } updatePixelsPerBar(); } @@ -377,4 +379,4 @@ void PatternEditorWindow::stop() } -} // namespace lmms::gui \ No newline at end of file +} // namespace lmms::gui diff --git a/src/tracks/MidiClip.cpp b/src/tracks/MidiClip.cpp index f8556ec090b..813900dcf85 100644 --- a/src/tracks/MidiClip.cpp +++ b/src/tracks/MidiClip.cpp @@ -128,7 +128,7 @@ void MidiClip::updateLength() // If the clip hasn't already been manually resized, automatically resize it. if (getAutoResize()) { - if (m_clipType == Type::BeatClip) + if (m_instrumentTrack->trackContainer()->type() == TrackContainer::Type::Pattern) { changeLength(beatClipLength()); updatePatternTrack();