#include "transition.h"
#include "kdenlivesettings.h"
#include "kthumb.h"
+#include "profilesdialog.h"
#include <KDebug>
#include <KIcon>
ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, bool generateThumbs) :
AbstractClipItem(info, QRectF(), fps),
m_clip(clip),
- m_resizeMode(NONE),
m_startFade(0),
m_endFade(0),
m_audioOnly(false),
{
m_effectList = effectList;
m_effectNames = m_effectList.effectNames().join(" / ");
+ if (!m_effectList.isEmpty()) setSelectedEffect(0);
}
const EffectsList ClipItem::effectList()
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
kDebug() << "// init eff: " << e.attribute("name");
+
+ // Check if this effect has a variable parameter
+ if (e.attribute("default").startsWith('%')) {
+ double evaluatedValue = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("default"));
+ e.setAttribute("default", evaluatedValue);
+ if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
+ e.setAttribute("value", evaluatedValue);
+ }
+ }
+
if (!e.isNull() && e.attribute("type") == "keyframe") {
QString def = e.attribute("default");
// Effect has a keyframe type parameter, we need to set the values
if (e.attribute("keyframes").isEmpty()) {
- e.setAttribute("keyframes", QString::number(m_cropStart.frames(m_fps)) + ':' + def + ';' + QString::number((m_cropStart + m_cropDuration).frames(m_fps)) + ':' + def);
+ e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + def + ';' + QString::number((cropStart() + cropDuration()).frames(m_fps)) + ':' + def);
//kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
break;
}
}
if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
- int end = (duration() + cropStart()).frames(m_fps);
+ int end = (cropDuration() + cropStart()).frames(m_fps);
int start = end;
if (effect.attribute("id") == "fadeout") {
if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
pen.setStyle(Qt::DotLine);
painter->setPen(pen);
for (; it != markers.end(); ++it) {
- pos = (*it).time() - cropStart();
+ pos = (*it).time() / m_speed - cropStart();
if (pos > GenTime()) {
- if (pos > duration()) break;
+ if (pos > cropDuration()) break;
QLineF l(br.x() + pos.frames(m_fps), br.y(), br.x() + pos.frames(m_fps), br.bottom());
QLineF l2 = painter->matrix().map(l);
//framepos = scale * pos.frames(m_fps);
else setToolTip(i18n("Audio fade duration: %1s", GenTime(m_endFade, m_fps).seconds()));
return FADEOUT;
} else if ((rect.right() - pos.x() < maximumOffset) && (rect.bottom() - pos.y() > addtransitionOffset)) {
- setToolTip(i18n("Clip duration: %1s", duration().seconds()));
+ setToolTip(i18n("Clip duration: %1s", cropDuration().seconds()));
return RESIZEEND;
} else if ((pos.x() - rect.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
setToolTip(i18n("Add transition"));
GenTime pos;
for (int i = 0; i < markers.size(); i++) {
- pos = markers.at(i) - cropStart();
+ pos = markers.at(i) / m_speed - cropStart();
if (pos > GenTime()) {
- if (pos > duration()) break;
+ if (pos > cropDuration()) break;
else snaps.append(pos + startPos());
}
}
GenTime pos;
for (int i = 0; i < markers.size(); i++) {
- pos = markers.at(i).time() - cropStart();
+ pos = markers.at(i).time() / m_speed - cropStart();
if (pos > GenTime()) {
- if (pos > duration()) break;
+ if (pos > cropDuration()) break;
else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment()));
}
}
}
-// virtual
-void ClipItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
-{
- /*m_resizeMode = operationMode(event->pos());
- if (m_resizeMode == MOVE) {
- m_maxTrack = scene()->sceneRect().height();
- m_grabPoint = (int) (event->pos().x() - rect().x());
- }*/
- QGraphicsRectItem::mousePressEvent(event);
-}
-
-// virtual
-void ClipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
-{
- m_resizeMode = NONE;
- QGraphicsRectItem::mouseReleaseEvent(event);
-}
-
/*
//virtual
void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
if (posx > max && maxDuration() != GenTime()) posx = max;
if (posx == endPos().frames(m_fps)) return;
//kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
- const int previous = (cropStart() + duration()).frames(m_fps);
+ const int previous = (cropStart() + cropDuration()).frames(m_fps);
AbstractClipItem::resizeEnd(posx, m_speed);
- if ((int)(cropStart() + duration()).frames(m_fps) != previous) {
- if (updateKeyFrames) checkEffectsKeyframesPos(previous, (cropStart() + duration()).frames(m_fps), false);
+ if ((int)(cropStart() + cropDuration()).frames(m_fps) != previous) {
+ if (updateKeyFrames) checkEffectsKeyframesPos(previous, (cropStart() + cropDuration()).frames(m_fps), false);
if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
/*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
m_endThumbTimer->start(150);
kDebug() << "Invalid effect index: " << ix;
return;
}
- kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
+ //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
effect.setAttribute("kdenlive_ix", ix + 1);
m_effectList.insert(ix, effect);
m_effectList.removeAt(ix + 1);
parameters.addParam("endtag", e.attribute("endtag", "end"));
}
- double f = e.attribute("factor", "1").toDouble();
-
- if (f == 1) {
+ if (e.attribute("factor", "1") == "1") {
parameters.addParam(e.attribute("name"), e.attribute("value"));
// check if it is a fade effect
}
}
} else {
- parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / f));
+ double fact;
+ if (e.attribute("factor").startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
+ } else fact = e.attribute("factor", "1").toDouble();
+ parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
}
}
}
parameters.addParam("start", neu);
} else {
if (e.attribute("factor", "1") != "1") {
- parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / e.attribute("factor").toDouble()));
+ double fact;
+ if (e.attribute("factor").startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
+ } else fact = e.attribute("factor", "1").toDouble();
+ parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
} else {
parameters.addParam(e.attribute("name"), e.attribute("value"));
}