]> git.sesse.net Git - kdenlive/commitdiff
Real fix for set in point problem:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 22 Dec 2008 12:15:44 +0000 (12:15 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 22 Dec 2008 12:15:44 +0000 (12:15 +0000)
http://www.kdenlive.org:80/mantis/view.php?id=501

svn path=/branches/KDE4/; revision=2815

src/customtrackview.cpp
src/renderer.cpp
src/renderer.h

index 8ba7426af0f27f8cac8ca023f859f3dd9778d39b..ea7ae03b853e09a73659bf2700bc40ba3959b0c5 100644 (file)
@@ -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;
+        }
     }
 
 
index 625e33312a78d0fdfff564d55e6db52d8177f5af..acb242e51195ccbe36198de5015d9f3b2cb0ba9d 100644 (file)
@@ -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;
 }
 
 
index 0da0dad2fa7ce6187e92af403177642fe07716a4..eb1f89a3dda12d1b48889826f22032bf8281d5f5 100644 (file)
@@ -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);