#include "customtrackview.h"
TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
- : QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0), m_currentZoom(4) {
+ : QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0) {
view = new Ui::TimeLine_UI();
view->setupUi(this);
connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), view->headers_area->verticalScrollBar(), SLOT(setValue(int)));
connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
- parseDocument(doc->toXml());
+ parseDocument(m_doc->toXml());
connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
connect(m_trackview, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotClipItemSelected(ClipItem*)));
connect(m_trackview, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotTransitionItemSelected(Transition*)));
- slotChangeZoom(m_currentZoom);
+ slotChangeZoom(m_doc->zoom());
}
-int TrackView::currentZoom() const {
- return m_currentZoom;
-}
int TrackView::duration() const {
return m_trackview->duration();
QDomElement e = params.item(i).toElement();
if (!e.isNull() && e.attribute("tag") == paramName) {
if (e.attribute("type") == "double") {
- QString factor = e.attribute("factor");
- if (!factor.isEmpty()) {
+ QString factor = e.attribute("factor", "1");
+ if (factor != "1") {
double val = paramValue.toDouble() * factor.toDouble();
paramValue = QString::number(val);
}
}
}
- // Add guides
+ // Add guides
QDomNodeList guides = doc.elementsByTagName("guide");
- kDebug() << "//////////// OPENING PRJECT FILE, FOUND: " << guides.count() << " GUIDES$$$$$$$$$";
for (int i = 0; i < guides.count(); i++) {
e = guides.item(i).toElement();
- const QString comment = e.attribute("comment");
- const GenTime pos = GenTime(e.attribute("time").toDouble());
- m_trackview->addGuide(pos, comment);
- }
+ const QString comment = e.attribute("comment");
+ const GenTime pos = GenTime(e.attribute("time").toDouble());
+ m_trackview->addGuide(pos, comment);
+ }
m_trackview->setDuration(duration);
kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
}
void TrackView::slotChangeZoom(int factor) {
-
+ m_doc->setZoom(factor);
m_ruler->setPixelPerMark(factor);
m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
- m_currentZoom = factor;
m_trackview->setScale(m_scale);
}
ItemInfo clipinfo;
clipinfo.startPos = GenTime(position, m_doc->fps());
- clipinfo.endPos = clipinfo.startPos + GenTime(out - in, m_doc->fps());
+ clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
+ clipinfo.cropStart = GenTime(in, m_doc->fps());
clipinfo.track = ix;
//kDebug() << "// INSERTINGÂ CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
- ClipItem *item = new ClipItem(clip, clipinfo, GenTime(in, m_doc->fps()), m_scale, m_doc->fps());
+ ClipItem *item = new ClipItem(clip, clipinfo, m_scale, m_doc->fps());
m_scene->addItem(item);
- position += (out - in);
+ clip->addReference();
+ position += (out - in + 1);
// parse clip effects
for (QDomNode n2 = elem.firstChild(); !n2.isNull(); n2 = n2.nextSibling()) {
QDomElement effect = n2.toElement();
if (effect.tagName() == "filter") {
+ kDebug() << " * * * * * * * * * * ** CLIP EFF FND * * * * * * * * * * *";
// add effect to clip
QString effecttag;
QString effectid;
QDomElement effectparam = n3.toElement();
if (effectparam.attribute("name") == "tag") {
effecttag = effectparam.text();
- }
- if (effectparam.attribute("name") == "kdenlive_id") {
+ } else if (effectparam.attribute("name") == "kdenlive_id") {
effectid = effectparam.text();
- }
- if (effectparam.attribute("name") == "kdenlive_ix") {
+ } else if (effectparam.attribute("name") == "kdenlive_ix") {
effectindex = effectparam.text();
}
}
// get effect standard tags
- QDomElement clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
+ QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
+ if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
- if (clipeffect.isNull()) clipeffect = MainWindow::customEffects.getEffectByTag(effecttag, effectid);
+
clipeffect.setAttribute("kdenlive_ix", effectindex);
QDomNodeList clipeffectparams = clipeffect.childNodes();
+ if (MainWindow::videoEffects.hasKeyFrames(clipeffect)) {
+ kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
+ // effect is key-framable, read all effects to retrieve keyframes
+ double factor;
+ QString starttag;
+ QString endtag;
+ QDomNodeList params = clipeffect.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (e.attribute("type") == "keyframe") {
+ starttag = e.attribute("starttag", "start");
+ endtag = e.attribute("endtag", "end");
+ factor = e.attribute("factor", "1").toDouble();
+ break;
+ }
+ }
+ QString keyframes;
+ int effectin = effect.attribute("in").toInt();
+ int effectout = effect.attribute("out").toInt();
+ double startvalue;
+ double endvalue;
+ for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
+ // parse effect parameters
+ QDomElement effectparam = n3.toElement();
+ if (effectparam.attribute("name") == starttag)
+ startvalue = effectparam.text().toDouble() * factor;
+ if (effectparam.attribute("name") == endtag)
+ endvalue = effectparam.text().toDouble() * factor;
+ }
+ // add first keyframe
+ keyframes.append(QString::number(in + effectin) + ":" + QString::number(startvalue) + ";" + QString::number(in + effectout) + ":" + QString::number(endvalue) + ";");
+ QDomNode lastParsedEffect;
+ n2 = n2.nextSibling();
+ bool continueParsing = true;
+ for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
+ // parse all effects
+ QDomElement kfreffect = n2.toElement();
+ int effectout = kfreffect.attribute("out").toInt();
+
+ for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
+ // parse effect parameters
+ QDomElement subeffectparam = n4.toElement();
+ if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
+ //We are not in the same effect, stop parsing
+ lastParsedEffect = n2.previousSibling();
+ continueParsing = false;
+ break;
+ } else if (subeffectparam.attribute("name") == endtag) {
+ endvalue = subeffectparam.text().toDouble() * factor;
+ break;
+ }
+ }
+ if (continueParsing) keyframes.append(QString::number(in + effectout) + ":" + QString::number(endvalue) + ";");
+ }
+
+ params = clipeffect.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
+ }
+ if (!continueParsing) {
+ n2 = lastParsedEffect;
+ }
+ }
+
// adjust effect parameters
for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
// parse effect parameters
}
}
item->addEffect(clipeffect, false);
+ item->effectsCounter();
}
}
return m_editMode;
}
+
+
#include "trackview.moc"