From a21559154dbf2a6f58a82deb69c2502ef43abf10 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 22 Dec 2008 12:15:44 +0000 Subject: [PATCH] Real fix for set in point problem: http://www.kdenlive.org:80/mantis/view.php?id=501 svn path=/branches/KDE4/; revision=2815 --- src/customtrackview.cpp | 29 ++++++++++++++++------------- src/renderer.cpp | 7 ++++--- src/renderer.h | 2 +- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 8ba7426a..ea7ae03b 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1495,7 +1495,7 @@ void CustomTrackView::slotRemoveSpace() { emit displayMessage(i18n("You must be in an empty space to remove space (time=%1, track:%2)", m_document->timecode().getTimecodeFromFrames(mapToScene(m_menuPosition).x()), track), ErrorMessage); return; } - int length = m_document->renderer()->mltGetSpaceLength(pos, m_document->tracksCount() - track); + int length = m_document->renderer()->mltGetSpaceLength(pos, m_document->tracksCount() - track, true); //kDebug() << "// GOT LENGT; " << length; if (length <= 0) { emit displayMessage(i18n("You must be in an empty space to remove space (time=%1, track:%2)", m_document->timecode().getTimecodeFromFrames(mapToScene(m_menuPosition).x()), track), ErrorMessage); @@ -2315,6 +2315,8 @@ void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end) { kDebug() << "----------------  ERROR, CANNOT find clip to resize at... "; // << startPos; return; } + bool snap = KdenliveSettings::snaptopoints(); + KdenliveSettings::setSnaptopoints(false); if (resizeClipStart) { ItemInfo clipinfo = item->info(); clipinfo.track = m_document->tracksCount() - clipinfo.track; @@ -2333,6 +2335,7 @@ void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end) { } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage); } m_document->renderer()->doRefresh(); + KdenliveSettings::setSnaptopoints(snap); } void CustomTrackView::updateClipFade(ClipItem * item, bool updateFadeOut) { @@ -2935,15 +2938,15 @@ void CustomTrackView::setInPoint() { ItemInfo endInfo = clip->info(); endInfo.startPos = GenTime(m_cursorPos, m_document->fps()); if (endInfo.startPos >= startInfo.endPos) { - // Check for invalid resize + // Check for invalid resize emit displayMessage(i18n("Invalid action"), ErrorMessage); return; } else if (endInfo.startPos < startInfo.startPos) { - int length = m_document->renderer()->mltGetSpaceLength(endInfo.startPos, m_document->tracksCount() - startInfo.track); - if (length < (startInfo.startPos - endInfo.startPos).frames(m_document->fps())) { - emit displayMessage(i18n("Invalid action"), ErrorMessage); - return; - } + int length = m_document->renderer()->mltGetSpaceLength(endInfo.startPos, m_document->tracksCount() - startInfo.track, false); + if (length < (startInfo.startPos - endInfo.startPos).frames(m_document->fps())) { + emit displayMessage(i18n("Invalid action"), ErrorMessage); + return; + } } ResizeClipCommand *command = new ResizeClipCommand(this, startInfo, endInfo, true); m_commandStack->push(command); @@ -2959,15 +2962,15 @@ void CustomTrackView::setOutPoint() { ItemInfo endInfo = clip->info(); endInfo.endPos = GenTime(m_cursorPos, m_document->fps()); if (endInfo.endPos <= startInfo.startPos) { - // Check for invalid resize + // Check for invalid resize emit displayMessage(i18n("Invalid action"), ErrorMessage); return; } else if (endInfo.endPos > startInfo.endPos) { - int length = m_document->renderer()->mltGetSpaceLength(endInfo.endPos, m_document->tracksCount() - startInfo.track); - if (length < (endInfo.endPos - startInfo.endPos).frames(m_document->fps())) { - emit displayMessage(i18n("Invalid action"), ErrorMessage); - return; - } + int length = m_document->renderer()->mltGetSpaceLength(endInfo.endPos, m_document->tracksCount() - startInfo.track, false); + if (length < (endInfo.endPos - startInfo.endPos).frames(m_document->fps())) { + emit displayMessage(i18n("Invalid action"), ErrorMessage); + return; + } } diff --git a/src/renderer.cpp b/src/renderer.cpp index 625e3331..acb242e5 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -598,7 +598,7 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId) { // Retrieve audio / video codec name - // If there is a + // If there is a char property[200]; if (producer->get_int("video_index") > -1) { /*if (context->duration == AV_NOPTS_VALUE) { @@ -1427,7 +1427,7 @@ bool Render::mltRemoveClip(int track, GenTime position) { return true; } -int Render::mltGetSpaceLength(const GenTime pos, int track) { +int Render::mltGetSpaceLength(const GenTime pos, int track, bool fromBlankStart) { if (!m_mltProducer) { kDebug() << "PLAYLIST NOT INITIALISED //////"; return -1; @@ -1446,7 +1446,8 @@ int Render::mltGetSpaceLength(const GenTime pos, int track) { Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); int clipIndex = trackPlaylist.get_clip_index_at(insertPos); if (!trackPlaylist.is_blank(clipIndex)) return -1; - return trackPlaylist.clip_length(clipIndex); + if (fromBlankStart) return trackPlaylist.clip_length(clipIndex); + return trackPlaylist.clip_length(clipIndex) + trackPlaylist.clip_start(clipIndex) - insertPos; } diff --git a/src/renderer.h b/src/renderer.h index 0da0dad2..eb1f89a3 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -151,7 +151,7 @@ Q_OBJECT public: void mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod); void mltCutClip(int track, GenTime position); void mltInsertSpace(const GenTime pos, int track, const GenTime duration); - int mltGetSpaceLength(const GenTime pos, int track); + int mltGetSpaceLength(const GenTime pos, int track, bool fromBlankStart); bool mltResizeClipEnd(ItemInfo info, GenTime clipDuration); bool mltResizeClipStart(ItemInfo info, GenTime diff); bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart, Mlt::Producer *prod); -- 2.39.2