]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Fix scopes: http://kdenlive.org/mantis/view.php?id=3052
[kdenlive] / src / clipitem.cpp
index 9c7a9a178d8d11bd33d4e2af7cdc75b0289aa3de..01e195c81ef2169121f9a15118f94a9bc47da16e 100644 (file)
@@ -119,6 +119,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
         m_baseColor = QColor(141, 215, 166);
         connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
     }
+    m_paintColor = m_baseColor;
 }
 
 
@@ -349,12 +350,16 @@ const QString ClipItem::adjustKeyframes(QString keyframes, int offset)
     return result.join(";");
 }
 
-bool ClipItem::checkKeyFrames()
+bool ClipItem::checkKeyFrames(int width, int height, int previousDuration, int cutPos)
 {
     bool clipEffectsModified = false;
     QLocale locale;
     // go through all effects this clip has
     for (int ix = 0; ix < m_effectList.count(); ++ix) {
+       // Check geometry params
+       resizeGeometries(ix, width, height, previousDuration, cutPos == -1 ? 0 : cutPos, cropDuration().frames(m_fps) - 1);
+
+       // Check keyframe params
         QStringList keyframeParams = keyframes(ix);
         QStringList newKeyFrameParams;
         bool effModified = false;
@@ -499,6 +504,22 @@ void ClipItem::setSelectedEffect(const int ix)
     }
 }
 
+void ClipItem::resizeGeometries(const int index, int width, int height, int previousDuration, int start, int duration)
+{
+    QString geom;
+    QDomElement effect = m_effectList.at(index);
+    QDomNodeList params = effect.elementsByTagName("parameter");
+
+    for (int i = 0; i < params.count(); i++) {
+        QDomElement e = params.item(i).toElement();
+        if (!e.isNull() && e.attribute("type") == "geometry") {
+            geom = e.attribute("value");
+           Mlt::Geometry geometry(geom.toUtf8().data(), previousDuration, width, height);
+           e.setAttribute("value", geometry.serialise(start, start + duration));
+       }
+    }
+}
+
 QStringList ClipItem::keyframes(const int index)
 {
     QStringList result;
@@ -769,23 +790,21 @@ void ClipItem::paint(QPainter *painter,
                      QWidget *)
 {
     QPalette palette = scene()->palette();
-    QColor paintColor;
+    QColor paintColor = m_paintColor;
     QColor textColor;
     QColor textBgColor;
     QPen framePen;
-    if (parentItem()) paintColor = QColor(255, 248, 149);
-    else paintColor = m_baseColor;
     if (isSelected() || (parentItem() && parentItem()->isSelected())) {
        textColor = palette.highlightedText().color();
        textBgColor = palette.highlight().color();
-        paintColor = paintColor.darker();
         framePen.setColor(textBgColor);
+       paintColor.setRed(qMin(paintColor.red() * 2, 255));
     }
     else {
        textColor = palette.text().color();
        textBgColor = palette.window().color();
        textBgColor.setAlpha(200);
-        framePen.setColor(paintColor.darker());
+        framePen.setColor(m_paintColor.darker());
     }
     const QRectF exposed = option->exposedRect;
     const QTransform transformation = painter->worldTransform();
@@ -800,7 +819,7 @@ void ClipItem::paint(QPainter *painter,
     painter->setClipPath(p.intersected(q));
     painter->setPen(Qt::NoPen);
     painter->fillRect(mappedExposed, paintColor);
-    painter->setPen(paintColor.darker());
+    painter->setPen(m_paintColor.darker());
     // draw thumbnails
     if (KdenliveSettings::videothumbnails() && !isAudioOnly()) {
        QRectF thumbRect;
@@ -1366,8 +1385,10 @@ void ClipItem::resizeEnd(int posx, bool emitChange)
 QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
 {
     if (change == QGraphicsItem::ItemSelectedChange) {
-        if (value.toBool()) setZValue(10);
-        else setZValue(2);
+        if (value.toBool())
+           setZValue(10);
+        else
+           setZValue(2);
     }
     if (change == ItemPositionChange && scene()) {
         // calculate new position.
@@ -1444,6 +1465,11 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
         //kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
         return newPos;
     }
+    if (change == ItemParentChange) {
+       QGraphicsItem* parent = value.value<QGraphicsItem*>();
+       if (parent) m_paintColor = m_baseColor.lighter(135);
+       else m_paintColor = m_baseColor;
+    }
     return QGraphicsItem::itemChange(change, value);
 }
 
@@ -1845,6 +1871,10 @@ void ClipItem::setAudioOnly(bool force)
         } else if (m_clipType == AUDIO) m_baseColor = QColor(141, 215, 166);
         else m_baseColor = QColor(141, 166, 215);
     }
+    if (parentItem())
+       m_paintColor = m_baseColor.lighter(135);
+    else
+       m_paintColor = m_baseColor;
     m_audioThumbCachePic.clear();
 }