]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
start implementing markers
[kdenlive] / src / clipitem.cpp
index d6d5ee7dc9eb552c9121b0f184b62520a42e18c8..097139c7d4abc0b65d305a4c319aef5ea698f956 100644 (file)
@@ -210,7 +210,6 @@ void ClipItem::paint(QPainter *painter,
     //painter->setRenderHints(QPainter::Antialiasing);
 
     QPainterPath roundRectPathUpper = upperRectPart(br), roundRectPathLower = lowerRectPart(br);
-
     painter->setClipRect(option->exposedRect);
 
     // build path around clip
@@ -254,8 +253,40 @@ void ClipItem::paint(QPainter *painter,
             if (audioThumbCachePic.contains(startCache) && !audioThumbCachePic[startCache].isNull())
                 painter->drawPixmap((int)(roundRectPathUpper.united(roundRectPathLower).boundingRect().x() + startCache - cropLeft), (int)(path.boundingRect().y()), audioThumbCachePic[startCache]);
         }
+    }
 
+    // draw markers
+    QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
+    QList < CommentedTime >::Iterator it = markers.begin();
+    GenTime pos;
+    double framepos;
+    const int markerwidth = 4;
+    QBrush markerBrush;
+    markerBrush = QBrush(QColor(120, 120, 0, 100));
+    QPen pen = painter->pen();
+    pen.setColor(QColor(255, 255, 255, 200));
+    pen.setStyle(Qt::DotLine);
+    painter->setPen(pen);
+    for (; it != markers.end(); ++it) {
+        pos = (*it).time() - cropStart();
+        if (pos > GenTime()) {
+            if (pos > duration()) break;
+            framepos = scale * pos.frames(m_fps);
+            QLineF l(br.x() + framepos, br.y() + 5, br.x() + framepos, br.y() + br.height() - 5);
+            painter->drawLine(l);
+            if (KdenliveSettings::showmarkers()) {
+                const QRectF txtBounding = painter->boundingRect(br.x() + framepos + 1, br.y() + 5, br.width() - framepos - 2, br.height() - 10, Qt::AlignLeft | Qt::AlignTop, " " + (*it).comment() + " ");
+                QPainterPath path;
+                path.addRoundedRect(txtBounding, 3, 3);
+                painter->fillPath(path, markerBrush);
+                painter->drawText(txtBounding, Qt::AlignCenter, (*it).comment());
+            }
+            //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
+        }
     }
+    pen.setColor(Qt::black);
+    pen.setStyle(Qt::SolidLine);
+
 
     /*
       // draw start / end fades
@@ -289,8 +320,7 @@ void ClipItem::paint(QPainter *painter,
           }
       }
       */
-    QPen pen = painter->pen();
-    pen.setColor(Qt::white);
+
     //pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
 
     // Draw effects names
@@ -502,7 +532,6 @@ void ClipItem::setFadeOut(int pos, double scale) {
 
 }
 
-
 // virtual
 void ClipItem::mousePressEvent(QGraphicsSceneMouseEvent * event) {
     /*m_resizeMode = operationMode(event->pos());