]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
* Delete transition from context menu
[kdenlive] / src / clipitem.cpp
index d3ce230dc2e009d9be6c4e2424585d1584f82156..d6d5ee7dc9eb552c9121b0f184b62520a42e18c8 100644 (file)
@@ -257,37 +257,38 @@ void ClipItem::paint(QPainter *painter,
 
     }
 
-    // draw start / end fades
-    QBrush fades;
-    if (isSelected()) {
-        fades = QBrush(QColor(200, 50, 50, 150));
-    } else fades = QBrush(QColor(200, 200, 200, 200));
-
-    if (m_startFade != 0) {
-        QPainterPath fadeInPath;
-        fadeInPath.moveTo(br.x() , br.y());
-        fadeInPath.lineTo(br.x() , br.y() + br.height());
-        fadeInPath.lineTo(br.x() + m_startFade * scale, br.y());
-        fadeInPath.closeSubpath();
-        painter->fillPath(fadeInPath, fades);
-        if (isSelected()) {
-            QLineF l(br.x() + m_startFade * scale, br.y(), br.x(), br.y() + br.height());
-            painter->drawLine(l);
-        }
-    }
-    if (m_endFade != 0) {
-        QPainterPath fadeOutPath;
-        fadeOutPath.moveTo(br.x() + br.width(), br.y());
-        fadeOutPath.lineTo(br.x() + br.width(), br.y() + br.height());
-        fadeOutPath.lineTo(br.x() + br.width() - m_endFade * scale, br.y());
-        fadeOutPath.closeSubpath();
-        painter->fillPath(fadeOutPath, fades);
-        if (isSelected()) {
-            QLineF l(br.x() + br.width() - m_endFade * scale, br.y(), br.x() + br.width(), br.y() + br.height());
-            painter->drawLine(l);
-        }
-    }
-
+    /*
+      // draw start / end fades
+      QBrush fades;
+      if (isSelected()) {
+          fades = QBrush(QColor(200, 50, 50, 150));
+      } else fades = QBrush(QColor(200, 200, 200, 200));
+
+      if (m_startFade != 0) {
+          QPainterPath fadeInPath;
+          fadeInPath.moveTo(br.x() , br.y());
+          fadeInPath.lineTo(br.x() , br.y() + br.height());
+          fadeInPath.lineTo(br.x() + m_startFade * scale, br.y());
+          fadeInPath.closeSubpath();
+          painter->fillPath(fadeInPath, fades);
+          if (isSelected()) {
+              QLineF l(br.x() + m_startFade * scale, br.y(), br.x(), br.y() + br.height());
+              painter->drawLine(l);
+          }
+      }
+      if (m_endFade != 0) {
+          QPainterPath fadeOutPath;
+          fadeOutPath.moveTo(br.x() + br.width(), br.y());
+          fadeOutPath.lineTo(br.x() + br.width(), br.y() + br.height());
+          fadeOutPath.lineTo(br.x() + br.width() - m_endFade * scale, br.y());
+          fadeOutPath.closeSubpath();
+          painter->fillPath(fadeOutPath, fades);
+          if (isSelected()) {
+              QLineF l(br.x() + br.width() - m_endFade * scale, br.y(), br.x() + br.width(), br.y() + br.height());
+              painter->drawLine(l);
+          }
+      }
+      */
     QPen pen = painter->pen();
     pen.setColor(Qt::white);
     //pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
@@ -308,21 +309,23 @@ void ClipItem::paint(QPainter *painter,
         painter->setFont(font);
     }
 
-    // For testing puspose only: draw transitions count
-    {
-        painter->setPen(pen);
-        QFont font = painter->font();
-        QFont smallFont = font;
-        smallFont.setPointSize(8);
-        painter->setFont(smallFont);
-        QString txt = " Transitions: " + QString::number(m_transitionsList.count()) + " ";
-        QRectF txtBoundin = painter->boundingRect(br, Qt::AlignRight | Qt::AlignTop, txt);
-        painter->fillRect(txtBoundin, QBrush(QColor(0, 0, 0, 150)));
-        painter->drawText(txtBoundin, Qt::AlignCenter, txt);
-        pen.setColor(Qt::black);
-        painter->setPen(pen);
-        painter->setFont(font);
-    }
+    /*
+      // For testing puspose only: draw transitions count
+      {
+          painter->setPen(pen);
+          QFont font = painter->font();
+          QFont smallFont = font;
+          smallFont.setPointSize(8);
+          painter->setFont(smallFont);
+          QString txt = " Transitions: " + QString::number(m_transitionsList.count()) + " ";
+          QRectF txtBoundin = painter->boundingRect(br, Qt::AlignRight | Qt::AlignTop, txt);
+          painter->fillRect(txtBoundin, QBrush(QColor(0, 0, 0, 150)));
+          painter->drawText(txtBoundin, Qt::AlignCenter, txt);
+          pen.setColor(Qt::black);
+          painter->setPen(pen);
+          painter->setFont(font);
+      }
+    */
 
     // Draw clip name
     QRectF txtBounding = painter->boundingRect(br, Qt::AlignHCenter | Qt::AlignTop, " " + m_clipName + " ");
@@ -388,12 +391,12 @@ void ClipItem::paint(QPainter *painter,
 
 
 OPERATIONTYPE ClipItem::operationMode(QPointF pos, double scale) {
-    if (abs((int)(pos.x() - (rect().x() + scale * m_startFade))) < 6 && abs((int)(pos.y() - rect().y())) < 6) return FADEIN;
-    else if (abs((int)(pos.x() - rect().x())) < 6) return RESIZESTART;
-    else if (abs((int)(pos.x() - (rect().x() + rect().width() - scale * m_endFade))) < 6 && abs((int)(pos.y() - rect().y())) < 6) return FADEOUT;
-    else if (abs((int)(pos.x() - (rect().x() + rect().width()))) < 6) return RESIZEEND;
-    else if (abs((int)(pos.x() - (rect().x() + 10))) < 6 && abs((int)(pos.y() - (rect().y() + rect().height() / 2 - 5))) < 6) return TRANSITIONSTART;
-    else if (abs((int)(pos.x() - (rect().x() + rect().width() - 20))) < 6 && abs((int)(pos.y() - (rect().y() + rect().height() / 2 - 5))) < 6) return TRANSITIONEND;
+    if (qAbs((int)(pos.x() - (rect().x() + scale * m_startFade))) < 6 && qAbs((int)(pos.y() - rect().y())) < 6) return FADEIN;
+    else if (qAbs((int)(pos.x() - rect().x())) < 6) return RESIZESTART;
+    else if (qAbs((int)(pos.x() - (rect().x() + rect().width() - scale * m_endFade))) < 6 && qAbs((int)(pos.y() - rect().y())) < 6) return FADEOUT;
+    else if (qAbs((int)(pos.x() - (rect().x() + rect().width()))) < 6) return RESIZEEND;
+    else if (qAbs((int)(pos.x() - (rect().x() + 10))) < 6 && qAbs((int)(pos.y() - (rect().y() + rect().height() / 2 - 5))) < 6) return TRANSITIONSTART;
+    else if (qAbs((int)(pos.x() - (rect().x() + rect().width() - 20))) < 6 && qAbs((int)(pos.y() - (rect().y() + rect().height() / 2 - 5))) < 6) return TRANSITIONEND;
 
     return MOVE;
 }
@@ -565,8 +568,11 @@ void ClipItem::setEffectAt(int ix, QDomElement effect) {
     update(boundingRect());
 }
 
-QMap <QString, QString> ClipItem::addEffect(QDomElement effect) {
+QMap <QString, QString> ClipItem::addEffect(QDomElement effect, bool animate) {
     QMap <QString, QString> effectParams;
+    /*QDomDocument doc;
+    doc.appendChild(doc.importNode(effect, true));
+    kDebug() << "///////  CLIP ADD EFFECT: "<< doc.toString();*/
     m_effectList.append(effect);
     effectParams["tag"] = effect.attribute("tag");
     effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
@@ -582,7 +588,7 @@ QMap <QString, QString> ClipItem::addEffect(QDomElement effect) {
             effectParams[e.attribute("name")] =  QString::number(effectParams[e.attribute("name")].toDouble() / e.attribute("factor").toDouble());
         }
     }
-    flashClip();
+    if (animate) flashClip();
     update(boundingRect());
     return effectParams;
 }