]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
cleanup
[kdenlive] / src / clipitem.cpp
index 91e3f583a0afc27f9f5b4d957d8d2b2c97e1f8ea..339f709c04bb7e17cfcfe66bc80d4beb1d14384a 100644 (file)
@@ -504,11 +504,10 @@ void ClipItem::refreshClip(bool checkDuration)
                 if (m_info.cropStart > m_maxDuration) {
                     m_info.cropStart = GenTime();
                     m_info.cropDuration = qMin(m_info.cropDuration, m_maxDuration);
-                    updateRectGeometry();
                 } else {
                     m_info.cropDuration = m_maxDuration;
-                    updateRectGeometry();
                 }
+                updateRectGeometry();
             }
         }
     }
@@ -646,12 +645,7 @@ DocClipBase *ClipItem::baseClip() const
 
 QDomElement ClipItem::xml() const
 {
-    QDomElement xml = m_clip->toXML();
-    if (m_speed != 1.0) xml.setAttribute("speed", m_speed);
-    if (m_strobe > 1) xml.setAttribute("strobe", m_strobe);
-    if (m_audioOnly) xml.setAttribute("audio_only", 1);
-    else if (m_videoOnly) xml.setAttribute("video_only", 1);
-    return xml;
+    itemXml();
 }
 
 QDomElement ClipItem::itemXml() const
@@ -741,8 +735,10 @@ void ClipItem::paint(QPainter *painter,
             painter->drawLine(l2);
         }
         if (painter->matrix().m11() == FRAME_SIZE) {
-            int offset = (m_info.startPos + m_info.cropStart).frames(m_fps);
-            doGetIntraThumbs(painter, mapped.topLeft(), m_info.cropStart.frames(m_fps), (int) mapToScene(exposed.left(), 0).x() - offset, (int) mapToScene(exposed.right(), 0).x() - offset);
+            int offset = (m_info.startPos - m_info.cropStart).frames(m_fps);
+            int left = qMax((int) m_info.startPos.frames(m_fps) + 1, (int) mapToScene(exposed.left(), 0).x());
+            int right = qMin((int)(m_info.startPos + m_info.cropDuration).frames(m_fps) - 1, (int) mapToScene(exposed.right(), 0).x());
+            doGetIntraThumbs(painter, mapped.topLeft(), m_info.cropStart.frames(m_fps), left - offset, right - offset);
         }
         painter->setPen(Qt::black);
     }
@@ -975,7 +971,6 @@ QList <GenTime> ClipItem::snapMarkers() const
     GenTime pos;
 
     for (int i = 0; i < markers.size(); i++) {
-
         pos = GenTime((int)(markers.at(i).frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
         if (pos > GenTime()) {
             if (pos > cropDuration()) break;
@@ -1221,10 +1216,12 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
                     pos = str.section(':', 0, 0).toInt();
                     val = str.section(':', 1, 1).toDouble();
                     if (pos == previous) {
+                        // first or last keyframe
                         kfr[current] = val;
                         modified = true;
                     } else {
                         if ((fromStart && pos >= current) || (!fromStart && pos <= current)) {
+                            // only keyframes in range
                             kfr[pos] = val;
                             modified = true;
                         }
@@ -1624,8 +1621,8 @@ int ClipItem::strobe() const
 void ClipItem::setSpeed(const double speed, const int strobe)
 {
     m_speed = speed;
-    if (m_speed <= 0 && m_speed > -1) 
-       m_speed = 1.0;
+    if (m_speed <= 0 && m_speed > -1)
+        m_speed = 1.0;
     m_strobe = strobe;
     if (m_speed == 1.0) m_clipName = baseClip()->name();
     else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + '%';