]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
several updates for slideshow clips
[kdenlive] / src / customtrackview.cpp
index 73ba40418d6e2d2c9b05c490d78366f7a91f56bd..c02ed596281d26c1a8ddb671408fd3220bfb7e9d 100644 (file)
@@ -587,7 +587,7 @@ void CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut) {
         newPos.track = info.track;
         ClipItem *dup = new ClipItem(item->baseClip(), newPos, m_scale, m_document->fps());
         dup->setCropStart(dup->cropStart() + (cutTime - info.startPos));
-        item->resizeEnd(cutPos - 1, m_scale);
+        item->resizeEnd(cutPos, m_scale);
         scene()->addItem(dup);
         m_document->renderer()->mltCutClip(m_tracksList.count() - info.track, cutTime);
     } else {
@@ -651,7 +651,7 @@ void CustomTrackView::dragMoveEvent(QDragMoveEvent * event) {
     event->setDropAction(Qt::IgnoreAction);
     kDebug() << "+++++++++++++   DRAG MOVE, : " << mapToScene(event->pos()).x() << ", SCAL: " << m_scale;
     if (m_dropItem) {
-        int track = (int)(event->pos().y() / m_tracksHeight);  //) * (m_scale * 50) + m_scale;
+        int track = (int)(mapToScene(event->pos()).y() / m_tracksHeight);  //) * (m_scale * 50) + m_scale;
         m_dropItem->moveTo((int)(mapToScene(event->pos()).x() / m_scale), m_scale, (int)((track - m_dropItem->track()) * m_tracksHeight), track);
         event->setDropAction(Qt::MoveAction);
         if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
@@ -772,6 +772,14 @@ int CustomTrackView::cursorPos() {
     return (int)(m_cursorPos * m_scale);
 }
 
+void CustomTrackView::moveCursorPos(int delta) {
+    emit cursorMoved((int)(m_cursorPos * m_scale), (int)((m_cursorPos + delta) * m_scale));
+    m_cursorPos += delta;
+    m_cursorLine->setPos(m_cursorPos * m_scale, 0);
+    m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    //if (m_autoScroll && m_scale < 50) checkScrolling();
+}
+
 void CustomTrackView::checkScrolling() {
     QRect rectInView = viewport()->rect();
     int delta = rectInView.width() / 3;
@@ -895,6 +903,20 @@ void CustomTrackView::addClip(QDomElement xml, int clipId, ItemInfo info) {
     m_document->renderer()->doRefresh();
 }
 
+void CustomTrackView::slotUpdateClip(int clipId) {
+    QList<QGraphicsItem *> list = scene()->items();
+    ClipItem *clip = NULL;
+    for (int i = 0; i < list.size(); ++i) {
+        if (list.at(i)->type() == AVWIDGET) {
+            clip = static_cast <ClipItem *>(list.at(i));
+            if (clip->clipProducer() == clipId) {
+                clip->refreshClip();
+                m_document->renderer()->mltUpdateClip(m_tracksList.count() - clip->track(), clip->startPos(), clip->xml());
+            }
+        }
+    }
+}
+
 ClipItem *CustomTrackView::getClipItemAt(int pos, int track) {
     QList<QGraphicsItem *> list = scene()->items(QPointF(pos * m_scale, track * m_tracksHeight + m_tracksHeight / 2));
     ClipItem *clip = NULL;
@@ -1028,6 +1050,33 @@ void CustomTrackView::updateSnapPoints(AbstractClipItem *selected) {
     //    kDebug() << "SNAP POINT: " << m_snapPoints.at(i).frames(25);
 }
 
+void CustomTrackView::slotSeekToPreviousSnap() {
+    updateSnapPoints(NULL);
+    GenTime pos = GenTime(m_cursorPos, m_document->fps());
+    GenTime res = GenTime();
+    for (int i = 0; i < m_snapPoints.size(); ++i) {
+        if (m_snapPoints.at(i) >= pos) {
+            if (i == 0) i = 1;
+            res = m_snapPoints.at(i - 1);
+            break;
+        }
+    }
+    setCursorPos((int) res.frames(m_document->fps()));
+}
+
+void CustomTrackView::slotSeekToNextSnap() {
+    updateSnapPoints(NULL);
+    GenTime pos = GenTime(m_cursorPos, m_document->fps());
+    GenTime res = GenTime(m_projectDuration, m_document->fps());
+    for (int i = 0; i < m_snapPoints.size(); ++i) {
+        if (m_snapPoints.at(i) > pos) {
+            res = m_snapPoints.at(i);
+            break;
+        }
+    }
+    setCursorPos((int) res.frames(m_document->fps()));
+}
+
 void CustomTrackView::setTool(PROJECTTOOL tool) {
     m_tool = tool;
 }