]> git.sesse.net Git - kdenlive/commitdiff
* Fix pasting of keyframe effects:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 7 Dec 2009 12:36:37 +0000 (12:36 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 7 Dec 2009 12:36:37 +0000 (12:36 +0000)
http://kdenlive.org/mantis/view.php?id=1325
* When one clip is selected, make it display over its transitions so that keyframes for fades, etc can be adjusted

svn path=/trunk/kdenlive/; revision=4172

src/abstractgroupitem.cpp
src/clipitem.cpp
src/customtrackview.cpp
src/customtrackview.h
src/transition.cpp

index f99fd3ee73ac7c8328511989b827bc5732fe3b3e..d4e9210481b241386a17f504de906f9d4fa61c32 100644 (file)
@@ -147,6 +147,10 @@ void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *optio
 //virtual
 QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value)
 {
+    if (change == QGraphicsItem::ItemSelectedChange) {
+        if (value.toBool()) setZValue(10);
+        else setZValue(1);
+    }
     if (change == ItemPositionChange && scene() && parentItem() == 0) {
         // calculate new position.
         const int trackHeight = KdenliveSettings::trackheight();
index f14d1639afafee738add52abfb46c266104bb03a..94b5a543c648a2685b60ce6250ee865481c2e4ea 100644 (file)
@@ -1158,6 +1158,10 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
 //virtual
 QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
 {
+    if (change == QGraphicsItem::ItemSelectedChange) {
+        if (value.toBool()) setZValue(10);
+        else setZValue(2);
+    }
     if (change == ItemPositionChange && scene()) {
         // calculate new position.
         //if (parentItem()) return pos();
@@ -1434,7 +1438,7 @@ EffectsParameterList ClipItem::getEffectArgs(const QDomElement effect)
                 double val = values.at(j).section(":", 1, 1).toDouble() / factor;
                 values[j] = pos + "=" + QString::number(val);
             }
-            //kDebug() << "/ / / /SENDING KEYFR:"<<values;
+            // kDebug() << "/ / / /SENDING KEYFR:" << values;
             parameters.addParam(e.attribute("name"), values.join(";"));
             /*parameters.addParam(e.attribute("name"), e.attribute("keyframes").replace(":", "="));
             parameters.addParam("max", e.attribute("max"));
index f6da0f714da933e5917974263d4e19572b394712..f079711f056157d3cd5a71d530eb4a4dd6393cdf 100644 (file)
@@ -987,8 +987,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
         return;
     } else if (m_operationMode == MOVE) {
         setCursor(Qt::ClosedHandCursor);
-        if (m_dragItem) m_dragItem->setZValue(10);
-        if (m_selectionGroup) m_selectionGroup->setZValue(10);
     } else if (m_operationMode == TRANSITIONSTART && event->modifiers() != Qt::ControlModifier) {
         ItemInfo info;
         info.startPos = m_dragItem->startPos();
@@ -1363,7 +1361,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
         updateSnapPoints(NULL, offsetList);
         m_selectionGroup->setPos(framePos);
         scene()->addItem(m_selectionGroup);
-        m_selectionGroup->setZValue(10);
+        //m_selectionGroup->setZValue(10);
         return true;
     } else if (data->hasFormat("kdenlive/producerslist")) {
         m_clipDrag = true;
@@ -1409,7 +1407,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             start += info.cropDuration;
             offsetList.append(start);
             ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, false);
-            item->setZValue(10);
+            //item->setZValue(10);
             item->setFlag(QGraphicsItem::ItemIsMovable, false);
             m_selectionGroup->addToGroup(item);
             m_waitingThumbs.append(item);
@@ -1418,7 +1416,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
         updateSnapPoints(NULL, offsetList);
         m_selectionGroup->setPos(framePos);
         scene()->addItem(m_selectionGroup);
-        m_selectionGroup->setZValue(10);
+        //m_selectionGroup->setZValue(10);
         m_thumbsTimer.start();
         return true;
 
@@ -2062,7 +2060,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
 
             //TODO: take care of edit mode for undo
             item->baseClip()->addReference();
-            item->setZValue(item->defaultZValue());
+            //item->setZValue(item->defaultZValue());
             m_document->updateClip(item->baseClip()->getId());
             ItemInfo info = item->info();
 
@@ -2829,8 +2827,6 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
 
     if (m_operationMode == MOVE) {
         setCursor(Qt::OpenHandCursor);
-        if (m_dragItem) m_dragItem->setZValue(m_dragItem->defaultZValue());
-        if (m_selectionGroup) m_selectionGroup->setZValue(1);
         if (m_dragItem->parentItem() == 0) {
             // we are moving one clip, easy
             if (m_dragItem->type() == AVWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) {
@@ -4744,6 +4740,7 @@ void CustomTrackView::pasteClipEffects()
             for (int j = 0; j < clip->effectsCount(); j++) {
                 QDomElement eff = clip->effectAt(j);
                 if (eff.attribute("unique", "0") == "0" || item->hasEffect(eff.attribute("tag"), eff.attribute("id")) == -1) {
+                    adjustKeyfames(clip->cropStart(), item->cropStart(), eff);
                     new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), eff, true, paste);
                 }
             }
@@ -4759,6 +4756,29 @@ void CustomTrackView::pasteClipEffects()
 }
 
 
+void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, QDomElement xml)
+{
+    // parse parameters to check if we need to adjust to the new crop start
+    int diff = (newstart - oldstart).frames(m_document->fps());
+    QDomNodeList params = xml.elementsByTagName("parameter");
+    for (int i = 0; i < params.count(); i++) {
+        QDomElement e = params.item(i).toElement();
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
+            QString def = e.attribute("default");
+            // Effect has a keyframe type parameter, we need to adjust the values
+            QStringList keys = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+            QStringList newKeyFrames;
+            foreach(const QString &str, keys) {
+                int pos = str.section(':', 0, 0).toInt();
+                double val = str.section(':', 1, 1).toDouble();
+                newKeyFrames.append(QString::number(pos + diff) + ':' + QString::number(val));
+            }
+            //kDebug()<<"ORIGIN: "<<keys<<", FIXED: "<<newKeyFrames;
+            e.setAttribute("keyframes", newKeyFrames.join(";"));
+        }
+    }
+}
+
 ClipItem *CustomTrackView::getClipUnderCursor() const
 {
     QRectF rect((double) m_cursorPos, 0.0, 1.0, (double)(m_tracksHeight * m_document->tracksCount()));
index 88275ca6ec6cda7a5cb19943cda92e319491b189..115c989978cffefd7c678e75fd68bb66c68b56bc 100644 (file)
@@ -270,6 +270,8 @@ private:
     /** Adjust clips under another one when working in overwrite mode */
     void adjustTimelineClips(EDITMODE mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command);
     void adjustTimelineTransitions(EDITMODE mode, Transition *item, QUndoCommand *command);
+    /** Adjust keyframes when pasted to another clip */
+    void adjustKeyfames(GenTime oldstart, GenTime newstart, QDomElement xml);
 
 private slots:
     void slotRefreshGuides();
index 315d501cbc1deafa0ffdf38f23491829211df002..10b03740654832b42f6e922008552fe18fc08410 100644 (file)
@@ -211,6 +211,10 @@ int Transition::type() const
 //virtual
 QVariant Transition::itemChange(GraphicsItemChange change, const QVariant &value)
 {
+    if (change == QGraphicsItem::ItemSelectedChange) {
+        if (value.toBool()) setZValue(10);
+        else setZValue(3);
+    }
     if (change == ItemPositionChange && scene()) {
         // calculate new position.
         QPointF newPos = value.toPointF();