]> git.sesse.net Git - kdenlive/commitdiff
Fix double click in a timeline clip to add keyframe
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 22 Feb 2013 14:14:17 +0000 (15:14 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 22 Feb 2013 14:14:17 +0000 (15:14 +0100)
src/abstractclipitem.cpp
src/abstractclipitem.h
src/customtrackview.cpp
src/monitor.cpp
src/monitor.h
src/trackview.cpp

index 865edd1294911c7452faff3cd88fc15dc822488a..0abf87aa6a116cfd4e2a851f1324904be74ccee6 100644 (file)
@@ -449,6 +449,21 @@ int AbstractClipItem::keyFrameNumber() const
     return m_keyframes.count();
 }
 
+int AbstractClipItem::checkForSingleKeyframe()
+{
+    // Check if we have only one keyframe
+    if (!m_keyframes.isEmpty() && m_keyframes.count() == 1) {
+       int min = (int) cropStart().frames(m_fps);
+       int max = (int)(cropStart() + cropDuration()).frames(m_fps) - 1;
+       if (m_keyframes.contains(min)) {
+           // Add keyframe at end of clip to allow inserting a new keframe in between
+           m_keyframes[max] = m_keyframes.value(min);
+           return m_keyframes.value(min);
+       }
+    }
+    return -1;
+}
+
 int AbstractClipItem::addKeyFrame(const GenTime &pos, const double value)
 {
     QRectF br = sceneBoundingRect();
index 0737952c1bcbb995e9f80ee95b65864a2e82a77a..db71b10ee982e0139e9d31711daf613430e39875 100644 (file)
@@ -49,6 +49,7 @@ public:
     * @param pos new Position
     * @param value new Value */
     void updateKeyFramePos(const GenTime &pos, const double value);
+    int checkForSingleKeyframe();
     int addKeyFrame(const GenTime &pos, const double value);
     bool hasKeyFrames() const;
     int editedKeyFramePos() const;
index 0d219f3bcaa009b5f30c395f29423f32c5eecd30..41fcf28563770cf3606e5fdbc63beda6a1d5141f 100644 (file)
@@ -1433,10 +1433,14 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event)
         } else*/  {
             // add keyframe
             GenTime keyFramePos = GenTime((int)(mapToScene(event->pos()).x()), m_document->fps()) - m_dragItem->startPos() + m_dragItem->cropStart();
+           int single = m_dragItem->checkForSingleKeyframe();
             int val = m_dragItem->addKeyFrame(keyFramePos, mapToScene(event->pos()).toPoint().y());
             ClipItem * item = static_cast <ClipItem *>(m_dragItem);
+           QDomElement oldEffect = item->selectedEffect().cloneNode().toElement();
+           if (single > -1) {
+               item->insertKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), (item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1, single);
+           }
             //QString previous = item->keyframes(item->selectedEffectIndex());
-            QDomElement oldEffect = item->selectedEffect().cloneNode().toElement();
             item->insertKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), keyFramePos.frames(m_document->fps()), val);
             //item->updateKeyframeEffect();
             //QString next = item->keyframes(item->selectedEffectIndex());
@@ -3014,6 +3018,7 @@ Qt::DropActions CustomTrackView::supportedDropActions() const
 
 void CustomTrackView::setDuration(int duration)
 {
+    if (m_projectDuration == duration) return;
     int diff = qAbs(duration - sceneRect().width());
     if (diff * matrix().m11() > -50) {
         if (matrix().m11() < 0.4) setSceneRect(0, 0, (duration + 100 / matrix().m11()), sceneRect().height());
index 27b28de30c65f9616cd985f7669ec09060ea5a69..309e79cb20e1fe2b91d470e0f278cf58a99cf837 100644 (file)
@@ -49,7 +49,6 @@
 Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile, QWidget *parent) :
     AbstractMonitor(id, manager, parent)
     , render(NULL)
-    , m_name(Kdenlive::noMonitor)
     , m_currentClip(NULL)
     , m_overlay(NULL)
     , m_scale(1)
index 0658ca5d629efa64ee18d991299186ebf17a8d0c..c7821273f87f231cf22a1f95cf91395ca933bfff 100644 (file)
@@ -122,7 +122,6 @@ protected:
     //virtual void paintEvent(QPaintEvent * event);
 
 private:
-    Kdenlive::MONITORID m_name;
     DocClipBase *m_currentClip;
     SmallRuler *m_ruler;
     Overlay *m_overlay;
index e46a750b58f4e8b216f094429818b210de2aa381..5ffa2af605fd7faf0fe1cc19a19d91a73f68027f 100644 (file)
@@ -201,7 +201,7 @@ void TrackView::parseDocument(QDomDocument doc)
     QDomElement tractor = mlt.firstChildElement("tractor");
     QDomNodeList tracks = tractor.elementsByTagName("track");
     QDomNodeList playlists = doc.elementsByTagName("playlist");
-    int duration = 300;
+    int duration = 1;
     m_projectTracks = tracks.count();
     int trackduration = 0;
     QDomElement e;