Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ripple for speed change #1516

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/commands/timelinecommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,7 @@ UpdateCommand::UpdateCommand(TimelineDock &timeline, int trackIndex, int clipInd
, m_isFirstRedo(true)
, m_undoHelper(*timeline.model())
, m_ripple(Settings.timelineRipple())
, m_rippleAllTracks(Settings.timelineRippleAllTracks())
{
setText(QObject::tr("Change clip properties"));
m_undoHelper.recordBeforeState();
Expand All @@ -1677,6 +1678,7 @@ void UpdateCommand::setXmlAfter(const QString &xml)
{
m_xmlAfter = xml;
m_ripple = Settings.timelineRipple();
m_rippleAllTracks = Settings.timelineRippleAllTracks();
}

void UpdateCommand::setPosition(int trackIndex, int clipIndex, int position)
Expand All @@ -1698,8 +1700,8 @@ void UpdateCommand::redo()
m_undoHelper.recordBeforeState();
Mlt::Producer clip(MLT.profile(), "xml-string", m_xmlAfter.toUtf8().constData());
if (m_ripple) {
m_timeline.model()->removeClip(m_trackIndex, m_clipIndex, false);
m_timeline.model()->insertClip(m_trackIndex, clip, m_position, false, false);
m_timeline.model()->removeClip(m_trackIndex, m_clipIndex, m_rippleAllTracks);
m_timeline.model()->insertClip(m_trackIndex, clip, m_position, m_rippleAllTracks, false);
} else {
m_timeline.model()->liftClip(m_trackIndex, m_clipIndex);
m_timeline.model()->overwrite(m_trackIndex, clip, m_position, false);
Expand Down
1 change: 1 addition & 0 deletions src/commands/timelinecommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ class UpdateCommand : public QUndoCommand
bool m_isFirstRedo;
UndoHelper m_undoHelper;
bool m_ripple;
bool m_rippleAllTracks;
};

class DetachAudioCommand: public QUndoCommand
Expand Down
22 changes: 0 additions & 22 deletions src/docks/timelinedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1995,28 +1995,6 @@ void TimelineDock::onProducerChanged(Mlt::Producer *after)
//TODO: keyframes
}
}

if (speedRatio != 1.0 && Settings.timelineRipple() && Settings.timelineRippleAllTracks()
&& (clipIndex + 1) < playlist.count()) {
auto position = info->start + out - in + 1;
QScopedPointer<Mlt::ClipInfo> nextInfo(playlist.clip_info(clipIndex + 1));
if (playlist.is_blank(clipIndex + 1)) {
position += nextInfo->frame_count;
nextInfo.reset(playlist.clip_info(clipIndex + 2));
}
if (nextInfo && nextInfo->cut) {
MAIN.undoStack()->beginMacro(tr("Change clip properties"));
MAIN.undoStack()->push(
new Timeline::LiftCommand(m_model, trackIndex, clipIndex));
auto moveCommand = new Timeline::MoveClipCommand(*this, 0, position - nextInfo->start, true);
moveCommand->addClip(trackIndex, clipIndex + 1);
MAIN.undoStack()->push(moveCommand);
MAIN.undoStack()->push(
new Timeline::OverwriteCommand(m_model, trackIndex, info->start, MLT.XML(after), false));
MAIN.undoStack()->endMacro();
return;
}
}
}
}
QString xmlAfter = MLT.XML(after);
Expand Down