editguidecommand.cpp
statusbarmessagelabel.cpp
regiongrabber.cpp
+ editkeyframecommand.cpp
)
kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc )
}
}
+void ClipItem::setKeyframes(const int ix, const QString keyframes) {
+ QDomElement effect = effectAt(ix);
+ 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") == "keyframe") {
+ e.setAttribute("keyframes", keyframes);
+ if (ix == m_selectedEffect) {
+ m_keyframes.clear();
+ double max = e.attribute("max").toDouble();
+ double min = e.attribute("min").toDouble();
+ m_keyframeFactor = 100.0 / (max - min);
+ m_keyframeDefault = e.attribute("default").toDouble();
+ // parse keyframes
+ QStringList keyframes = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+ foreach(QString str, keyframes) {
+ int pos = str.section(":", 0, 0).toInt();
+ double val = str.section(":", 1, 1).toDouble();
+ m_keyframes[pos] = val;
+ }
+ update();
+ return;
+ }
+ break;
+ }
+ }
+
+}
+
-void ClipItem::setSelectedEffect(int ix) {
+void ClipItem::setSelectedEffect(const int ix) {
m_selectedEffect = ix;
QDomElement effect = effectAt(m_selectedEffect);
}
}
+QString ClipItem::keyframes(const int index) {
+ QString result;
+ QDomElement effect = effectAt(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") == "keyframe") {
+ result = e.attribute("keyframes");
+ break;
+ }
+ }
+ return result;
+}
+
void ClipItem::updateKeyframeEffect() {
// regenerate xml parameter from the clip keyframes
QDomElement effect = effectAt(m_selectedEffect);
QList <GenTime> snapMarkers() const;
uint fadeIn() const;
uint fadeOut() const;
- void setSelectedEffect(int ix);
+ void setSelectedEffect(const int ix);
void updateKeyframeEffect();
QDomElement selectedEffect();
int selectedEffectIndex() const;
void initEffect(QDomElement effect);
+ QString keyframes(const int index);
+ void setKeyframes(const int ix, const QString keyframes);
protected:
//virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
#include "moveeffectcommand.h"
#include "addtransitioncommand.h"
#include "edittransitioncommand.h"
+#include "editkeyframecommand.h"
#include "addmarkercommand.h"
#include "razorclipcommand.h"
#include "kdenlivesettings.h"
int pos = m_document->timecode().getFrameCount(view.kfr_position->text(), m_document->fps());
m_dragItem->updateKeyFramePos(GenTime(pos, m_document->fps()) + m_dragItem->cropStart(), (double) view.kfr_value->value() * m_dragItem->keyFrameFactor());
ClipItem *item = (ClipItem *)m_dragItem;
- item->updateKeyframeEffect();
+ QString previous = item->keyframes(item->selectedEffectIndex());
+ item->updateKeyframeEffect();
+ QString next = item->keyframes(item->selectedEffectIndex());
+ EditKeyFrameCommand *command = new EditKeyFrameCommand(this, item->track(), item->startPos(), item->selectedEffectIndex(), previous, next, false);
+ m_commandStack->push(command);
updateEffect(m_tracksList.count() - item->track(), item->startPos(), item->selectedEffect());
}
GenTime keyFramePos = GenTime((int)(mapToScene(event->pos()).x() / m_scale), m_document->fps()) - m_dragItem->startPos() + m_dragItem->cropStart();
m_dragItem->addKeyFrame(keyFramePos, mapToScene(event->pos()).toPoint().y());
ClipItem * item = (ClipItem *) m_dragItem;
+ QString previous = item->keyframes(item->selectedEffectIndex());
item->updateKeyframeEffect();
+ QString next = item->keyframes(item->selectedEffectIndex());
+ EditKeyFrameCommand *command = new EditKeyFrameCommand(this, m_dragItem->track(), m_dragItem->startPos(), item->selectedEffectIndex(), previous, next, false);
+ m_commandStack->push(command);
updateEffect(m_tracksList.count() - item->track(), item->startPos(), item->selectedEffect());
}
}
}
+
+void CustomTrackView::editKeyFrame(const GenTime pos, const int track, const int index, const QString keyframes) {
+ ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
+ if (clip) {
+ clip->setKeyframes(index, keyframes);
+ updateEffect(m_tracksList.count() - clip->track(), clip->startPos(), clip->effectAt(index));
+ }
+ else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);
+}
+
+
void CustomTrackView::displayContextMenu(QPoint pos, AbstractClipItem *clip) {
if (clip == NULL) m_timelineContextMenu->popup(pos);
else if (clip->type() == AVWIDGET) m_timelineContextClipMenu->popup(pos);
} else if (m_operationMode == KEYFRAME) {
// update the MLT effect
ClipItem * item = (ClipItem *) m_dragItem;
+ QString previous = item->keyframes(item->selectedEffectIndex());
item->updateKeyframeEffect();
+ QString next = item->keyframes(item->selectedEffectIndex());
+ EditKeyFrameCommand *command = new EditKeyFrameCommand(this, item->track(), item->startPos(), item->selectedEffectIndex(), previous, next, false);
+ m_commandStack->push(command);
updateEffect(m_tracksList.count() - item->track(), item->startPos(), item->selectedEffect());
}
void slotSeekToNextSnap();
double getSnapPointForPos(double pos);
QDomElement xmlInfo();
+ void editKeyFrame(const GenTime pos, const int track, const int index, const QString keyframes);
public slots:
void setCursorPos(int pos, bool seek = true);
private:
CustomTrackView *m_view;
- int m_track;
+ const int m_track;
QDomElement m_effect;
QDomElement m_oldeffect;
- GenTime m_pos;
+ const GenTime m_pos;
bool m_doIt;
};
--- /dev/null
+/***************************************************************************
+ editkeyframecommand.cpp - description
+ -------------------
+ begin : 2008
+ copyright : (C) 2008 by Jean-Baptiste Mardelle
+ email : jb@kdenlive.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include <KLocale>
+
+#include "editkeyframecommand.h"
+#include "customtrackview.h"
+
+EditKeyFrameCommand::EditKeyFrameCommand(CustomTrackView *view, const int track, GenTime pos, const int effectIndex, const QString& oldkeyframes, const QString& newkeyframes, bool doIt) : m_view(view), m_track(track), m_pos(pos), m_index(effectIndex), m_oldkfr(oldkeyframes), m_newkfr(newkeyframes), m_doIt(doIt) {
+ int prev = m_oldkfr.split(";", QString::SkipEmptyParts).count();
+ int next = m_newkfr.split(";", QString::SkipEmptyParts).count();
+ if (prev == next) setText(i18n("Edit keyframe"));
+ else if (prev > next) setText(i18n("Delete keyframe"));
+ else setText(i18n("Add keyframe"));
+ //kDebug() << "/// CREATE GUIDE COMMAND, TIMES: " << m_oldPos.frames(25) << "x" << m_pos.frames(25);
+}
+
+
+// virtual
+void EditKeyFrameCommand::undo() {
+ m_view->editKeyFrame(m_pos, m_track, m_index, m_oldkfr);
+}
+// virtual
+void EditKeyFrameCommand::redo() {
+ if (m_doIt) {
+ m_view->editKeyFrame(m_pos, m_track, m_index, m_newkfr);
+ }
+ m_doIt = true;
+}
+
+#include "editkeyframecommand.moc"
--- /dev/null
+/***************************************************************************
+ editkeyframecommand.h - description
+ -------------------
+ begin : 2008
+ copyright : (C) 2008 by Jean-Baptiste Mardelle
+ email : jb@kdenlive.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KEYFRAMECOMMAND_H
+#define KEYFRAMECOMMAND_H
+
+#include <QUndoCommand>
+#include <QGraphicsView>
+#include <QPointF>
+#include <QDomElement>
+#include <KDebug>
+
+#include "gentime.h"
+#include "definitions.h"
+class CustomTrackView;
+
+
+class EditKeyFrameCommand : public QUndoCommand {
+public:
+ EditKeyFrameCommand(CustomTrackView *view, const int track, GenTime pos, const int effectIndex, const QString& oldkeyframes, const QString& newkeyframes, bool doIt);
+ virtual void undo();
+ virtual void redo();
+
+private:
+ CustomTrackView *m_view;
+ const QString m_oldkfr;
+ const QString m_newkfr;
+ const int m_track;
+ const int m_index;
+ const GenTime m_pos;
+ bool m_doIt;
+};
+
+#endif
+
private:
CustomTrackView *m_view;
- int m_track;
+ const int m_track;
QDomElement m_effect;
QDomElement m_oldeffect;
- GenTime m_pos;
+ const GenTime m_pos;
bool m_doIt;
};
private:
CustomTrackView *m_view;
- ItemInfo m_startPos;
- ItemInfo m_endPos;
+ const ItemInfo m_startPos;
+ const ItemInfo m_endPos;
bool m_doIt;
};