diff --git a/include/Clip.h b/include/Clip.h index 706b982c8..6198ff135 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -94,21 +94,12 @@ public: return m_length; } - /*! \brief Specify whether or not a TCO automatically resizes. - * - * If a TCO does automatically resize, it cannot be manually - * resized by clicking and dragging its edge. - * - */ - inline void setResizable( const bool r ) - { - m_resizable = r; - } - inline const bool getResizable() const - { - return m_resizable; - } + bool hasTrackContainer() const; + + bool isInPattern() const; + + bool manuallyResizable() const; /*! \brief Set whether a clip has been resized yet by the user or the knife tool. * @@ -183,7 +174,6 @@ private: BoolModel m_mutedModel; BoolModel m_soloModel; - bool m_resizable = true; bool m_autoResize = true; bool m_selectViewOnCreate; diff --git a/src/core/AutomationClip.cpp b/src/core/AutomationClip.cpp index 56ba8e9cf..db2e063c8 100644 --- a/src/core/AutomationClip.cpp +++ b/src/core/AutomationClip.cpp @@ -60,21 +60,6 @@ AutomationClip::AutomationClip( AutomationTrack * _auto_track ) : m_lastRecordedValue( 0 ) { changeLength( TimePos( 1, 0 ) ); - if( getTrack() ) - { - switch( getTrack()->trackContainer()->type() ) - { - case TrackContainer::Type::Pattern: - setResizable(false); - break; - - case TrackContainer::Type::Song: - // move down - default: - setResizable(true); - break; - } - } } @@ -105,19 +90,6 @@ AutomationClip::AutomationClip( const AutomationClip & _clip_to_copy ) : // Sets the node's clip to this one m_timeMap[POS(it)].setClip(this); } - if (!getTrack()){ return; } - switch( getTrack()->trackContainer()->type() ) - { - case TrackContainer::Type::Pattern: - setResizable(false); - break; - - case TrackContainer::Type::Song: - // move down - default: - setResizable(true); - break; - } } bool AutomationClip::addObject( AutomatableModel * _obj, bool _search_dup ) diff --git a/src/core/Clip.cpp b/src/core/Clip.cpp index ea7d1f933..3e769f4ea 100644 --- a/src/core/Clip.cpp +++ b/src/core/Clip.cpp @@ -31,6 +31,8 @@ #include "Engine.h" #include "GuiApplication.h" #include "Song.h" +#include "Track.h" +#include "TrackContainer.h" namespace lmms @@ -75,7 +77,6 @@ Clip::Clip(const Clip& other): m_length(other.m_length), m_startTimeOffset(other.m_startTimeOffset), m_mutedModel(other.m_mutedModel.value(), this, tr( "Mute" )), - m_resizable(other.m_resizable), m_autoResize(other.m_autoResize), m_selectViewOnCreate{other.m_selectViewOnCreate}, m_color(other.m_color) @@ -173,6 +174,21 @@ void Clip::copyStateTo( Clip *src, Clip *dst ) } } +bool Clip::hasTrackContainer() const +{ + return getTrack() != nullptr && getTrack()->trackContainer() != nullptr; +} + +bool Clip::isInPattern() const +{ + return hasTrackContainer() + && getTrack()->trackContainer()->type() == TrackContainer::Type::Pattern; +} + +bool Clip::manuallyResizable() const +{ + return !isInPattern(); +} diff --git a/src/core/PatternClip.cpp b/src/core/PatternClip.cpp index abc8a65fd..3e03db604 100644 --- a/src/core/PatternClip.cpp +++ b/src/core/PatternClip.cpp @@ -45,7 +45,6 @@ PatternClip::PatternClip(Track* track) : changeLength( TimePos( t, 0 ) ); restoreJournallingState(); } - setResizable(true); } void PatternClip::saveSettings(QDomDocument& doc, QDomElement& element) diff --git a/src/core/SampleClip.cpp b/src/core/SampleClip.cpp index 007265c0c..3a131ba6e 100644 --- a/src/core/SampleClip.cpp +++ b/src/core/SampleClip.cpp @@ -67,18 +67,6 @@ SampleClip::SampleClip(Track* _track, Sample sample, bool isPlaying) //care about Clip position connect( this, SIGNAL(positionChanged()), this, SLOT(updateTrackClips())); - switch( getTrack()->trackContainer()->type() ) - { - case TrackContainer::Type::Pattern: - setResizable(false); - break; - - case TrackContainer::Type::Song: - // move down - default: - setResizable(true); - break; - } updateTrackClips(); } @@ -117,18 +105,6 @@ SampleClip::SampleClip(const SampleClip& orig) : //care about Clip position connect( this, SIGNAL(positionChanged()), this, SLOT(updateTrackClips())); - switch( getTrack()->trackContainer()->type() ) - { - case TrackContainer::Type::Pattern: - setResizable(false); - break; - - case TrackContainer::Type::Song: - // move down - default: - setResizable(true); - break; - } updateTrackClips(); } @@ -251,8 +227,7 @@ void SampleClip::setIsPlaying(bool isPlaying) void SampleClip::updateLength() { // If the clip has already been manually resized, don't automatically resize it. - // Unless we are in a pattern, where you can't resize stuff manually - if (getAutoResize() || !getResizable()) + if (getAutoResize()) { changeLength(sampleLength()); setStartTimeOffset(0); diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index c92d6edf0..a2c4ee6c1 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -298,7 +298,7 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra continue; } TimePos relTime = time - p->startPosition() - p->startTimeOffset(); - if (p->getResizable()) { + if (!p->isInPattern()) { relTime = std::min(static_cast(relTime), p->length() - p->startTimeOffset()); } float value = p->valueAt(relTime); diff --git a/src/gui/clips/ClipView.cpp b/src/gui/clips/ClipView.cpp index 89d5a5e79..c7bf046d9 100644 --- a/src/gui/clips/ClipView.cpp +++ b/src/gui/clips/ClipView.cpp @@ -502,7 +502,7 @@ void ClipView::dropEvent( QDropEvent * de ) void ClipView::updateCursor(QMouseEvent * me) { // If we are at the edges, use the resize cursor - if (!me->buttons() && m_clip->getResizable() && !isSelected() + if (!me->buttons() && m_clip->manuallyResizable() && !isSelected() && ((me->x() > width() - RESIZE_GRIP_WIDTH) || (me->x() < RESIZE_GRIP_WIDTH))) { setCursor(Qt::SizeHorCursor); @@ -669,7 +669,7 @@ void ClipView::mousePressEvent( QMouseEvent * me ) setInitialPos( me->pos() ); setInitialOffsets(); - if (!m_clip->getResizable() && !knifeMode) + if (!m_clip->manuallyResizable() && !knifeMode) { // Always move clips that can't be manually resized m_action = Action::Move; setCursor( Qt::SizeAllCursor ); diff --git a/src/tracks/MidiClip.cpp b/src/tracks/MidiClip.cpp index 707cbaf3d..f5b3b9eea 100644 --- a/src/tracks/MidiClip.cpp +++ b/src/tracks/MidiClip.cpp @@ -48,11 +48,6 @@ MidiClip::MidiClip( InstrumentTrack * _instrument_track ) : if (_instrument_track->trackContainer() == Engine::patternStore()) { resizeToFirstTrack(); - setResizable(false); - } - else - { - setResizable(true); } init(); } @@ -72,18 +67,6 @@ MidiClip::MidiClip( const MidiClip& other ) : } init(); - switch( getTrack()->trackContainer()->type() ) - { - case TrackContainer::Type::Pattern: - setResizable(false); - break; - - case TrackContainer::Type::Song: - // move down - default: - setResizable(true); - break; - } } @@ -149,9 +132,8 @@ void MidiClip::updateLength() return; } - // If the clip has already been manually resized, don't automatically resize it. - // Unless we are in a pattern, where you can't resize stuff manually - if (getAutoResize() || !getResizable()) + // If the clip hasn't already been manually resized, automatically resize it. + if (getAutoResize()) { tick_t max_length = TimePos::ticksPerBar();