]> git.sesse.net Git - kdenlive/commitdiff
Fix drawing of "keyframe" effects (effect is not apply before first keyframe nor...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 29 Jun 2011 21:16:48 +0000 (21:16 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 29 Jun 2011 21:16:48 +0000 (21:16 +0000)
svn path=/trunk/kdenlive/; revision=5747

src/abstractclipitem.cpp
src/abstractclipitem.h
src/clipitem.cpp
src/clipitem.h

index f0e8061b950f015ec36bc16f5ae5ebbd790deb02..d294df380e0a5233e2da6f7d1560ee7fc119efdb 100644 (file)
@@ -246,7 +246,7 @@ GenTime AbstractClipItem::maxDuration() const
     return m_maxDuration;
 }
 
-void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/)
+void AbstractClipItem::drawKeyFrames(QPainter *painter, bool limitedKeyFrames)
 {
     if (m_keyframes.count() < 1)
         return;
@@ -262,6 +262,12 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/)
     if (active) {
         x1 = br.x();
         x2 = br.right();
+        if (limitedKeyFrames) {
+            QMap<int, int>::const_iterator end = m_keyframes.constEnd();
+            end--;
+            x2 = x1 + maxw * (end.key() - start);
+            x1 += maxw * (m_keyframes.constBegin().key() - start);
+        }
         y1 = br.bottom() - (m_keyframeDefault - m_keyframeOffset) * maxh;
         QLineF l(x1, y1, x2, y1);
         QLineF l2 = painter->matrix().map(l);
@@ -280,8 +286,10 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/)
     x1 = br.x() + maxw * (i.key() - start);
     y1 = br.bottom() - (i.value() - m_keyframeOffset) * maxh;
 
+
+
     // make sure line begins with clip beginning
-    if (i.key() != start) {
+    if (!limitedKeyFrames && i.key() != start) {
         QLineF l(br.x(), y1, x1, y1);
         l2 = painter->matrix().map(l);
         painter->drawLine(l2);
@@ -314,7 +322,7 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/)
     }
 
     // make sure line ends at clip end
-    if (x1 != br.right()) {
+    if (!limitedKeyFrames && x1 != br.right()) {
         QLineF l(x1, y1, br.right(), y1);
         painter->drawLine(painter->matrix().map(l));
     }
index bf554e0b56dacc6e7e52b81bb50919d88e66bbb2..ff59dec8c1ef146d5e2742d8a631d97ff58f7c97 100644 (file)
@@ -115,8 +115,13 @@ protected:
     /** The (keyframe) parameter that is visible and editable in timeline (on the clip) */
     int m_visibleParam;
     double m_fps;
-    //QRect visibleRect();
-    void drawKeyFrames(QPainter *painter, QRectF exposedRect);
+    /** @brief Draw the keyframes of a clip
+      * @param painter The painter device for the clip
+      * @param limitedKeyFrames The keyframes can be of type "keyframe" or "simplekeyframe". In the
+      *        "simplekeyframe" type, the effect always starts on clip start and ends on clip end. With the
+      *        "keyframe" type, the effect starts on the first keyframe and ends on the last keyframe
+      */
+    void drawKeyFrames(QPainter *painter, bool limitedKeyFrames);
     int mouseOverKeyFrames(QPointF pos, double maxOffset);
     virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
 
index 4bf64cb155bd449d2aba629ac8a765bc050f52e6..0e85b25c80097edc46fca5672e962695464ae75a 100644 (file)
@@ -57,7 +57,8 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
         //m_hover(false),
         m_speed(speed),
         m_strobe(strobe),
-        m_framePixelWidth(0)
+        m_framePixelWidth(0),
+        m_limitedKeyFrames(false)
 {
     setZValue(2);
     setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double) itemHeight());
@@ -433,6 +434,7 @@ void ClipItem::setSelectedEffect(const int ix)
             QDomElement e = params.item(i).toElement();
             if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
                 m_keyframes.clear();
+                m_limitedKeyFrames = e.attribute("type") == "keyframe";
                 m_visibleParam = i;
                 double max = e.attribute("max").toDouble();
                 double min = e.attribute("min").toDouble();
@@ -940,7 +942,7 @@ void ClipItem::paint(QPainter *painter,
 
     painter->setPen(QPen(Qt::lightGray));
     // draw effect or transition keyframes
-    if (mapped.width() > 20) drawKeyFrames(painter, exposed);
+    if (mapped.width() > 20) drawKeyFrames(painter, m_limitedKeyFrames);
 
     //painter->setMatrixEnabled(true);
 
@@ -1716,6 +1718,7 @@ void ClipItem::updateKeyframes(QDomElement effect)
         setSelectedEffect(m_selectedEffect);
         return;
     }
+    m_limitedKeyFrames = e.attribute("type") == "keyframe";
     const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
     foreach(const QString &str, keyframes) {
         int pos = str.section(':', 0, 0).toInt();
index 7e49dfdbae47159ae50036be77cbc35f26ff0a1f..4ff7c4e0832f2167e7d17d4c514bd80be41731cb 100644 (file)
@@ -226,6 +226,9 @@ private:
 
     QPixmap m_videoPix;
     QPixmap m_audioPix;
+    /** @brief Keyframes type can be "keyframe" or "simplekeyframe" which have to be painted differently.
+     * True if keyframe type is "keyframe" */
+    bool m_limitedKeyFrames;
 
 private slots:
     void slotGetStartThumb();