Skip to content

Commit

Permalink
Selected clip length updates
Browse files Browse the repository at this point in the history
Do not update the clip length when dragging a node in
`AutomationClip::setDragValue`.

This is achieved by removing the call to `updateLength` from
`AutomationClip::removeNode` and explicitly calling the update in all
other places that call `removeNode` except in `setDragValue`.

This commit therefore also improves the separation of concerns.
Removing a node now only update the data structures. Updating the clip
length is a completely different thing and rather a "policy" and
therefore both calls should be done independently.
  • Loading branch information
michaelgregorius committed Aug 27, 2024
1 parent a321e90 commit 44837db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/AutomationClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class LMMS_EXPORT AutomationClip : public Clip
const bool ignoreSurroundingPoints = true
);

void removeNode(const TimePos & time, bool lengthUpdate = true);
void removeNode(const TimePos & time);
void removeNodes(const int tick0, const int tick1);

void resetNodes(const int tick0, const int tick1);
Expand Down
17 changes: 10 additions & 7 deletions src/core/AutomationClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ TimePos AutomationClip::putValues(



void AutomationClip::removeNode(const TimePos & time, bool lengthUpdate)
void AutomationClip::removeNode(const TimePos & time)
{
QMutexLocker m(&m_clipMutex);

Expand All @@ -353,11 +353,6 @@ void AutomationClip::removeNode(const TimePos & time, bool lengthUpdate)
}
generateTangents(it, 3);

if (lengthUpdate)
{
updateLength();
}

emit dataChanged();
}

Expand All @@ -374,6 +369,7 @@ void AutomationClip::removeNodes(const int tick0, const int tick1)
if (tick0 == tick1)
{
removeNode(TimePos(tick0));
updateLength();
return;
}

Expand All @@ -394,6 +390,12 @@ void AutomationClip::removeNodes(const int tick0, const int tick1)
{
removeNode(node);
}

if (!nodesToRemove.empty())
{
// Only update the length if we have actually removed nodes
updateLength();
}
}


Expand Down Expand Up @@ -463,6 +465,7 @@ void AutomationClip::recordValue(TimePos time, float value)
else if( valueAt( time ) != value )
{
removeNode(time);
updateLength();
}
}

Expand Down Expand Up @@ -523,7 +526,7 @@ TimePos AutomationClip::setDragValue(
}
}

this->removeNode(newTime, false);
this->removeNode(newTime);
m_oldTimeMap = m_timeMap;
m_dragging = true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 )
x += xstep;
m_clip->removeNode(TimePos(x));
m_clip->putValue( TimePos( x ), y );
m_clip->updateLength();
}
}

Expand Down Expand Up @@ -406,6 +407,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )
if (node != m_clip->getTimeMap().end())
{
m_clip->removeNode(POS(node));
m_clip->updateLength();
Engine::getSong()->setModified();
}
};
Expand Down

0 comments on commit 44837db

Please sign in to comment.