1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include "customtrackview.h"
23 #include "customtrackscene.h"
25 #include "docclipbase.h"
26 #include "transition.h"
27 #include "kdenlivesettings.h"
29 #include "profilesdialog.h"
31 #include "rotoscoping/rotowidget.h"
39 #include <QStyleOptionGraphicsItem>
40 #include <QGraphicsScene>
43 static int FRAME_SIZE;
45 ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, int strobe, int frame_width, bool generateThumbs) :
46 AbstractClipItem(info, QRectF(), fps),
52 m_startPix(QPixmap()),
57 m_startThumbRequested(false),
58 m_endThumbRequested(false),
63 m_limitedKeyFrames(false)
66 FRAME_SIZE = frame_width;
67 setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double) itemHeight());
68 setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1 + itemOffset());
70 // set speed independant info
71 if (m_speed <= 0 && m_speed > -1)
73 m_speedIndependantInfo = m_info;
74 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
75 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
77 m_videoPix = KIcon("kdenlive-show-video").pixmap(QSize(16, 16));
78 m_audioPix = KIcon("kdenlive-show-audio").pixmap(QSize(16, 16));
81 m_clipName = m_clip->name();
83 m_clipName = m_clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
85 m_producer = m_clip->getId();
86 m_clipType = m_clip->clipType();
87 //m_cropStart = info.cropStart;
88 m_maxDuration = m_clip->maxDuration();
90 m_audioThumbReady = m_clip->audioThumbCreated();
91 //setAcceptsHoverEvents(true);
92 connect(this , SIGNAL(prepareAudioThumb(double, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, int, int, int)));
94 if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
95 m_baseColor = QColor(141, 166, 215);
96 if (!m_clip->isPlaceHolder()) {
98 m_startThumbTimer.setSingleShot(true);
99 connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
100 m_endThumbTimer.setSingleShot(true);
101 connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
102 connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
103 connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
104 if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
107 } else if (m_clipType == COLOR) {
108 QString colour = m_clip->getProperty("colour");
109 colour = colour.replace(0, 2, "#");
110 m_baseColor = QColor(colour.left(7));
111 } else if (m_clipType == IMAGE || m_clipType == TEXT) {
112 m_baseColor = QColor(141, 166, 215);
113 if (m_clipType == TEXT) {
114 connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
116 //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
117 } else if (m_clipType == AUDIO) {
118 m_baseColor = QColor(141, 215, 166);
119 connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
124 ClipItem::~ClipItem()
127 if (scene()) scene()->removeItem(this);
128 if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
129 //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
130 //disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
135 ClipItem *ClipItem::clone(ItemInfo info) const
137 ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed, m_strobe, FRAME_SIZE);
138 if (m_clipType == IMAGE || m_clipType == TEXT) duplicate->slotSetStartThumb(m_startPix);
139 else if (m_clipType != COLOR) {
140 if (info.cropStart == m_info.cropStart) duplicate->slotSetStartThumb(m_startPix);
141 if (info.cropStart + (info.endPos - info.startPos) == m_info.cropStart + m_info.cropDuration) {
142 duplicate->slotSetEndThumb(m_endPix);
145 //kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
146 duplicate->setEffectList(m_effectList);
147 duplicate->setVideoOnly(m_videoOnly);
148 duplicate->setAudioOnly(m_audioOnly);
149 duplicate->setFades(fadeIn(), fadeOut());
150 //duplicate->setSpeed(m_speed);
154 void ClipItem::setEffectList(const EffectsList effectList)
156 m_effectList.clone(effectList);
157 m_effectNames = m_effectList.effectNames().join(" / ");
158 if (!m_effectList.isEmpty()) {
159 for (int i = 0; i < m_effectList.count(); i++) {
160 QString effectId = m_effectList.item(i).attribute("id");
161 // check if it is a fade effect
162 QDomNodeList params = m_effectList.item(i).elementsByTagName("parameter");
164 for (int j = 0; j < params.count(); j++) {
165 QDomElement e = params.item(j).toElement();
167 if (effectId == "fadein") {
168 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
169 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
170 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
172 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
173 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
174 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
176 } else if (effectId == "fade_from_black") {
177 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
178 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
179 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
181 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
182 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
183 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
185 } else if (effectId == "fadeout") {
186 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
187 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
188 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
190 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
191 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
192 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
194 } else if (effectId == "fade_to_black") {
195 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
196 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
197 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
199 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
200 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
201 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
211 setSelectedEffect(0);
215 const EffectsList ClipItem::effectList() const
220 int ClipItem::selectedEffectIndex() const
222 return m_selectedEffect;
225 void ClipItem::initEffect(QDomElement effect, int diff)
227 // the kdenlive_ix int is used to identify an effect in mlt's playlist, should
229 if (effect.attribute("kdenlive_ix").toInt() == 0)
230 effect.setAttribute("kdenlive_ix", QString::number(effectsCounter()));
232 if (effect.attribute("id") == "freeze" && diff > 0) {
233 EffectsList::setParameter(effect, "frame", QString::number(diff));
236 // Init parameter value & keyframes if required
237 QDomNodeList params = effect.elementsByTagName("parameter");
238 for (int i = 0; i < params.count(); i++) {
239 QDomElement e = params.item(i).toElement();
244 // Check if this effect has a variable parameter
245 if (e.attribute("default").contains('%')) {
246 double evaluatedValue = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("default"));
247 e.setAttribute("default", evaluatedValue);
248 if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
249 e.setAttribute("value", evaluatedValue);
253 if (effect.attribute("id") == "crop") {
254 // default use_profile to 1 for clips with proxies to avoid problems when rendering
255 if (e.attribute("name") == "use_profile" && !(m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-"))
256 e.setAttribute("value", "1");
259 if ((e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("keyframes").isEmpty()) {
260 // Effect has a keyframe type parameter, we need to set the values
261 e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + e.attribute("default"));
264 if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
265 if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
266 int end = (cropDuration() + cropStart()).frames(m_fps) - 1;
268 if (effect.attribute("id") == "fadeout") {
269 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
270 int effectDuration = EffectsList::parameter(effect, "in").toInt();
271 if (effectDuration > cropDuration().frames(m_fps)) {
272 effectDuration = cropDuration().frames(m_fps) / 2;
274 start -= effectDuration;
276 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
277 start -= EffectsList::parameter(fadeout, "out").toInt() - EffectsList::parameter(fadeout, "in").toInt();
279 } else if (effect.attribute("id") == "fade_to_black") {
280 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
281 int effectDuration = EffectsList::parameter(effect, "in").toInt();
282 if (effectDuration > cropDuration().frames(m_fps)) {
283 effectDuration = cropDuration().frames(m_fps) / 2;
285 start -= effectDuration;
287 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
288 start -= EffectsList::parameter(fadeout, "out").toInt() - EffectsList::parameter(fadeout, "in").toInt();
291 EffectsList::setParameter(effect, "in", QString::number(start));
292 EffectsList::setParameter(effect, "out", QString::number(end));
293 } else if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
294 int start = cropStart().frames(m_fps);
296 if (effect.attribute("id") == "fadein") {
297 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
298 int effectDuration = EffectsList::parameter(effect, "out").toInt();
299 if (effectDuration > cropDuration().frames(m_fps)) {
300 effectDuration = cropDuration().frames(m_fps) / 2;
302 end += effectDuration;
304 end += EffectsList::parameter(m_effectList.getEffectByTag(QString(), "fade_from_black"), "out").toInt();
305 } else if (effect.attribute("id") == "fade_from_black") {
306 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
307 int effectDuration = EffectsList::parameter(effect, "out").toInt();
308 if (effectDuration > cropDuration().frames(m_fps)) {
309 effectDuration = cropDuration().frames(m_fps) / 2;
311 end += effectDuration;
313 end += EffectsList::parameter(m_effectList.getEffectByTag(QString(), "fadein"), "out").toInt();
315 EffectsList::setParameter(effect, "in", QString::number(start));
316 EffectsList::setParameter(effect, "out", QString::number(end));
321 bool ClipItem::checkKeyFrames()
323 bool clipEffectsModified = false;
325 // go through all effects this clip has
326 for (int ix = 0; ix < m_effectList.count(); ++ix) {
327 QStringList keyframeParams = keyframes(ix);
328 QStringList newKeyFrameParams;
329 bool effModified = false;
331 // go through all params which have keyframes
332 foreach(const QString &kfr, keyframeParams) {
333 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
334 QStringList newKeyFrames;
335 bool cutKeyFrame = false;
336 bool modified = false;
338 double lastValue = -1;
339 int start = cropStart().frames(m_fps);
340 int end = (cropStart() + cropDuration()).frames(m_fps);
342 // go through all keyframes for one param
343 foreach(const QString &str, keyframes) {
344 int pos = str.section(':', 0, 0).toInt();
345 double val = locale.toDouble(str.section(':', 1, 1));
346 if (pos - start < 0) {
347 // a keyframe is defined before the start of the clip
349 } else if (cutKeyFrame) {
350 // create new keyframe at clip start, calculate interpolated value
352 int diff = pos - lastPos;
353 double ratio = (double)(start - lastPos) / diff;
354 double newValue = lastValue + (val - lastValue) * ratio;
355 newKeyFrames.append(QString::number(start) + ':' + locale.toString(newValue));
362 // create new keyframe at clip end, calculate interpolated value
363 int diff = pos - lastPos;
365 double ratio = (double)(end - lastPos) / diff;
366 double newValue = lastValue + (val - lastValue) * ratio;
367 newKeyFrames.append(QString::number(end) + ':' + locale.toString(newValue));
372 newKeyFrames.append(QString::number(pos) + ':' + locale.toString(val));
379 newKeyFrameParams.append(newKeyFrames.join(";"));
386 setKeyframes(ix, newKeyFrameParams);
387 clipEffectsModified = true;
390 return clipEffectsModified;
393 void ClipItem::setKeyframes(const int ix, const QStringList keyframes)
395 QDomElement effect = getEffectAt(ix);
396 if (effect.attribute("disable") == "1") return;
398 QDomNodeList params = effect.elementsByTagName("parameter");
399 int keyframeParams = 0;
400 for (int i = 0; i < params.count(); i++) {
401 QDomElement e = params.item(i).toElement();
402 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
403 e.setAttribute("keyframes", keyframes.at(keyframeParams));
404 if (ix == m_selectedEffect && keyframeParams == 0) {
407 double max = locale.toDouble(e.attribute("max"));
408 double min = locale.toDouble(e.attribute("min"));
409 m_keyframeFactor = 100.0 / (max - min);
410 m_keyframeOffset = min;
411 m_keyframeDefault = locale.toDouble(e.attribute("default"));
412 m_selectedKeyframe = 0;
414 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
415 foreach(const QString &str, keyframes) {
416 int pos = str.section(':', 0, 0).toInt();
417 double val = locale.toDouble(str.section(':', 1, 1));
418 m_keyframes[pos] = val;
420 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
421 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
430 void ClipItem::setSelectedEffect(const int ix)
432 m_selectedEffect = ix;
434 QDomElement effect = effectAt(m_selectedEffect);
435 if (!effect.isNull() && effect.attribute("disable") != "1") {
436 QDomNodeList params = effect.elementsByTagName("parameter");
437 for (int i = 0; i < params.count(); i++) {
438 QDomElement e = params.item(i).toElement();
439 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
441 m_limitedKeyFrames = e.attribute("type") == "keyframe";
443 double max = locale.toDouble(e.attribute("max"));
444 double min = locale.toDouble(e.attribute("min"));
445 m_keyframeFactor = 100.0 / (max - min);
446 m_keyframeOffset = min;
447 m_keyframeDefault = locale.toDouble(e.attribute("default"));
448 m_selectedKeyframe = 0;
451 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
452 foreach(const QString &str, keyframes) {
453 int pos = str.section(':', 0, 0).toInt();
454 double val = locale.toDouble(str.section(':', 1, 1));
455 m_keyframes[pos] = val;
457 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end())
458 m_editedKeyframe = -1;
465 if (!m_keyframes.isEmpty()) {
471 QStringList ClipItem::keyframes(const int index)
474 QDomElement effect = effectAt(index);
475 QDomNodeList params = effect.elementsByTagName("parameter");
477 for (int i = 0; i < params.count(); i++) {
478 QDomElement e = params.item(i).toElement();
479 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe"))
480 result.append(e.attribute("keyframes"));
485 void ClipItem::updateKeyframeEffect()
487 // regenerate xml parameter from the clip keyframes
488 QDomElement effect = getEffectAt(m_selectedEffect);
489 if (effect.attribute("disable") == "1") return;
490 QDomNodeList params = effect.elementsByTagName("parameter");
491 QDomElement e = params.item(m_visibleParam).toElement();
495 if (m_keyframes.count() > 0) {
496 QMap<int, int>::const_iterator i = m_keyframes.constBegin();
497 while (i != m_keyframes.constEnd()) {
498 keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';');
502 // Effect has a keyframe type parameter, we need to set the values
503 e.setAttribute("keyframes", keyframes);
507 QDomElement ClipItem::selectedEffect()
509 if (m_selectedEffect == -1 || m_effectList.isEmpty()) return QDomElement();
510 return effectAt(m_selectedEffect);
513 void ClipItem::resetThumbs(bool clearExistingThumbs)
515 if (clearExistingThumbs) {
516 m_startPix = QPixmap();
517 m_endPix = QPixmap();
518 m_audioThumbCachePic.clear();
520 //kDebug()<<"........... RESET THMBS: "<<clearExistingThumbs;
525 void ClipItem::refreshClip(bool checkDuration, bool forceResetThumbs)
527 if (checkDuration && (m_maxDuration != m_clip->maxDuration())) {
528 m_maxDuration = m_clip->maxDuration();
529 if (m_clipType != IMAGE && m_clipType != TEXT && m_clipType != COLOR) {
530 if (m_maxDuration != GenTime() && m_info.cropStart + m_info.cropDuration > m_maxDuration) {
531 // Clip duration changed, make sure to stay in correct range
532 if (m_info.cropStart > m_maxDuration) {
533 m_info.cropStart = GenTime();
534 m_info.cropDuration = qMin(m_info.cropDuration, m_maxDuration);
536 m_info.cropDuration = m_maxDuration;
538 updateRectGeometry();
542 if (m_clipType == COLOR) {
543 QString colour = m_clip->getProperty("colour");
544 colour = colour.replace(0, 2, "#");
545 m_baseColor = QColor(colour.left(7));
547 } else resetThumbs(forceResetThumbs);
550 void ClipItem::slotFetchThumbs()
552 if (scene() == NULL || m_clipType == AUDIO || m_clipType == COLOR) return;
553 if (m_clipType == IMAGE) {
554 if (m_startPix.isNull()) {
555 m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
561 if (m_clipType == TEXT) {
562 if (m_startPix.isNull()) slotGetStartThumb();
566 if (m_endPix.isNull() && m_startPix.isNull()) {
567 m_startThumbRequested = true;
568 m_endThumbRequested = true;
569 m_clip->slotExtractImage((int)m_speedIndependantInfo.cropStart.frames(m_fps), (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
571 if (m_endPix.isNull()) {
574 if (m_startPix.isNull()) {
580 void ClipItem::slotGetStartThumb()
582 m_startThumbRequested = true;
583 m_clip->slotExtractImage((int)m_speedIndependantInfo.cropStart.frames(m_fps), -1);
586 void ClipItem::slotGetEndThumb()
588 m_endThumbRequested = true;
589 m_clip->slotExtractImage(-1, (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
593 void ClipItem::slotSetStartThumb(QImage img)
595 if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
596 QPixmap pix = QPixmap::fromImage(img);
598 QRectF r = sceneBoundingRect();
599 r.setRight(pix.width() + 2);
604 void ClipItem::slotSetEndThumb(QImage img)
606 if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
607 QPixmap pix = QPixmap::fromImage(img);
609 QRectF r = sceneBoundingRect();
610 r.setLeft(r.right() - pix.width() - 2);
615 void ClipItem::slotThumbReady(int frame, QImage img)
617 if (scene() == NULL) return;
618 QRectF r = boundingRect();
619 QPixmap pix = QPixmap::fromImage(img);
620 double width = pix.width() / projectScene()->scale().x();
621 if (m_startThumbRequested && frame == m_speedIndependantInfo.cropStart.frames(m_fps)) {
623 m_startThumbRequested = false;
624 update(r.left(), r.top(), width, pix.height());
625 if (m_clipType == IMAGE || m_clipType == TEXT) {
626 update(r.right() - width, r.top(), width, pix.height());
628 } else if (m_endThumbRequested && frame == (m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1) {
630 m_endThumbRequested = false;
631 update(r.right() - width, r.top(), width, pix.height());
635 void ClipItem::slotSetStartThumb(const QPixmap pix)
640 void ClipItem::slotSetEndThumb(const QPixmap pix)
645 QPixmap ClipItem::startThumb() const
650 QPixmap ClipItem::endThumb() const
655 void ClipItem::slotGotAudioData()
657 m_audioThumbReady = true;
658 if (m_clipType == AV && !isAudioOnly()) {
659 QRectF r = boundingRect();
660 r.setTop(r.top() + r.height() / 2 - 1);
665 int ClipItem::type() const
670 DocClipBase *ClipItem::baseClip() const
675 QDomElement ClipItem::xml() const
680 QDomElement ClipItem::itemXml() const
682 QDomElement xml = m_clip->toXML();
683 if (m_speed != 1.0) xml.setAttribute("speed", m_speed);
684 if (m_strobe > 1) xml.setAttribute("strobe", m_strobe);
685 if (m_audioOnly) xml.setAttribute("audio_only", 1);
686 else if (m_videoOnly) xml.setAttribute("video_only", 1);
690 int ClipItem::clipType() const
695 QString ClipItem::clipName() const
700 void ClipItem::setClipName(const QString &name)
705 const QString ClipItem::clipProducer() const
710 void ClipItem::flashClip()
712 if (m_timeLine == 0) {
713 m_timeLine = new QTimeLine(750, this);
714 m_timeLine->setUpdateInterval(80);
715 m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve);
716 m_timeLine->setFrameRange(0, 100);
717 connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animate(qreal)));
719 //m_timeLine->start();
722 void ClipItem::animate(qreal /*value*/)
724 QRectF r = boundingRect();
730 void ClipItem::paint(QPainter *painter,
731 const QStyleOptionGraphicsItem *option,
736 if (parentItem()) paintColor = QColor(255, 248, 149);
737 else paintColor = m_baseColor;
738 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
739 paintColor = paintColor.darker();
740 framePen.setColor(Qt::red);
741 framePen.setWidthF(2.0);
744 framePen.setColor(paintColor.darker());
747 const QRectF exposed = option->exposedRect;
748 painter->setClipRect(exposed);
749 painter->fillRect(exposed, paintColor);
750 painter->setWorldMatrixEnabled(false);;
751 const QRectF mapped = painter->worldTransform().mapRect(rect());
753 if (KdenliveSettings::videothumbnails() && !isAudioOnly()) {
754 QPen pen = painter->pen();
755 pen.setColor(QColor(255, 255, 255, 150));
756 painter->setPen(pen);
757 if ((m_clipType == IMAGE || m_clipType == TEXT) && !m_startPix.isNull()) {
758 const QPointF top = mapped.topRight() - QPointF(m_startPix.width() - 1, 0);
759 painter->drawPixmap(top, m_startPix);
760 QLineF l2(top.x(), mapped.top(), top.x(), mapped.bottom());
761 painter->drawLine(l2);
762 } else if (!m_endPix.isNull()) {
763 const QPointF top = mapped.topRight() - QPointF(m_endPix.width() - 1, 0);
764 painter->drawPixmap(top, m_endPix);
765 QLineF l2(top.x(), mapped.top(), top.x(), mapped.bottom());
766 painter->drawLine(l2);
768 if (!m_startPix.isNull()) {
769 painter->drawPixmap(mapped.topLeft(), m_startPix);
770 QLineF l2(mapped.left() + m_startPix.width(), mapped.top(), mapped.left() + m_startPix.width(), mapped.bottom());
771 painter->drawLine(l2);
774 // if we are in full zoom, paint thumbnail for every frame
775 if (m_clip->thumbProducer() && clipType() != COLOR && clipType() != AUDIO && !m_audioOnly && painter->worldTransform().m11() == FRAME_SIZE) {
776 int offset = (m_info.startPos - m_info.cropStart).frames(m_fps);
777 int left = qMax((int) m_info.cropStart.frames(m_fps) + 1, (int) mapToScene(exposed.left(), 0).x() - offset);
778 int right = qMin((int)(m_info.cropStart + m_info.cropDuration).frames(m_fps) - 1, (int) mapToScene(exposed.right(), 0).x() - offset);
779 QPointF startPos = mapped.topLeft();
780 int startOffset = m_info.cropStart.frames(m_fps);
781 if (clipType() == IMAGE || clipType() == TEXT) {
782 for (int i = left; i <= right; i++) {
783 painter->drawPixmap(startPos + QPointF(FRAME_SIZE *(i - startOffset), 0), m_startPix);
787 #if KDE_IS_VERSION(4,5,0)
788 if (m_clip && m_clip->thumbProducer()) {
789 QString path = m_clip->fileURL().path() + "_";
792 pen.setStyle(Qt::DotLine);
793 painter->setPen(pen);
795 for (int i = left; i <= right; i++) {
796 img = m_clip->thumbProducer()->findCachedThumb(path + QString::number(i));
797 QPointF xpos = startPos + QPointF(FRAME_SIZE *(i - startOffset), 0);
798 if (img.isNull()) missing << i;
799 else painter->drawImage(xpos, img);
800 painter->drawLine(xpos, xpos + QPointF(0, mapped.height()));
802 if (!missing.isEmpty()) {
803 m_clip->thumbProducer()->queryIntraThumbs(missing);
804 connect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache()));
810 painter->setPen(Qt::black);
813 // draw audio thumbnails
814 if (KdenliveSettings::audiothumbnails() && m_speed == 1.0 && !isVideoOnly() && ((m_clipType == AV && (exposed.bottom() > (rect().height() / 2) || isAudioOnly())) || m_clipType == AUDIO) && m_audioThumbReady) {
816 double startpixel = exposed.left();
819 double endpixel = exposed.right();
822 //kDebug()<<"/// REPAINTING AUDIO THMBS ZONE: "<<startpixel<<"x"<<endpixel;
824 /*QPainterPath path = m_clipType == AV ? roundRectPathLower : resultClipPath;*/
826 if (m_clipType == AV && !isAudioOnly()) {
828 mappedRect.setTop(mappedRect.bottom() - mapped.height() / 2);
829 } else mappedRect = mapped;
831 double scale = painter->worldTransform().m11();
833 if (isEnabled() && m_clip) channels = m_clip->getProperty("channels").toInt();
834 if (scale != m_framePixelWidth)
835 m_audioThumbCachePic.clear();
836 double cropLeft = m_info.cropStart.frames(m_fps);
837 const int clipStart = mappedRect.x();
838 const int mappedStartPixel = painter->worldTransform().map(QPointF(startpixel + cropLeft, 0)).x() - clipStart;
839 const int mappedEndPixel = painter->worldTransform().map(QPointF(endpixel + cropLeft, 0)).x() - clipStart;
840 cropLeft = cropLeft * scale;
843 emit prepareAudioThumb(scale, mappedStartPixel, mappedEndPixel, channels);
846 for (int startCache = mappedStartPixel - (mappedStartPixel) % 100; startCache < mappedEndPixel; startCache += 100) {
847 if (m_audioThumbCachePic.contains(startCache) && !m_audioThumbCachePic[startCache].isNull())
848 painter->drawPixmap(clipStart + startCache - cropLeft, mappedRect.y(), m_audioThumbCachePic[startCache]);
852 // only paint details if clip is big enough
853 if (mapped.width() > 20) {
855 // Draw effects names
856 if (!m_effectNames.isEmpty() && mapped.width() > 40) {
857 QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignLeft | Qt::AlignTop, m_effectNames);
859 if (m_timeLine && m_timeLine->state() == QTimeLine::Running) {
860 qreal value = m_timeLine->currentValue();
861 txtBounding.setWidth(txtBounding.width() * value);
862 bgColor.setRgb(50 + 200 *(1.0 - value), 50, 50, 100 + 50 * value);
863 } else bgColor.setRgb(50, 50, 90, 180);
865 QPainterPath rounded;
866 rounded.moveTo(txtBounding.bottomRight());
867 rounded.arcTo(txtBounding.right() - txtBounding.height() - 2, txtBounding.top() - txtBounding.height(), txtBounding.height() * 2, txtBounding.height() * 2, 270, 90);
868 rounded.lineTo(txtBounding.topLeft());
869 rounded.lineTo(txtBounding.bottomLeft());
870 painter->fillPath(rounded, bgColor);
871 painter->setPen(Qt::lightGray);
872 painter->drawText(txtBounding.adjusted(1, 0, 1, 0), Qt::AlignCenter, m_effectNames);
875 const QRectF txtBounding2 = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + m_clipName + ' ');
876 painter->setBrush(framePen.color());
877 painter->setPen(Qt::NoPen);
878 painter->drawRoundedRect(txtBounding2, 3, 3);
879 painter->setBrush(QBrush(Qt::NoBrush));
882 painter->drawPixmap(txtBounding2.topLeft() - QPointF(17, -1), m_videoPix);
883 } else if (m_audioOnly) {
884 painter->drawPixmap(txtBounding2.topLeft() - QPointF(17, -1), m_audioPix);
886 painter->setPen(Qt::white);
887 painter->drawText(txtBounding2, Qt::AlignCenter, m_clipName);
891 if (isEnabled() && m_clip) {
892 QList < CommentedTime > markers = m_clip->commentedSnapMarkers();
893 QList < CommentedTime >::Iterator it = markers.begin();
896 QBrush markerBrush(QColor(120, 120, 0, 140));
897 QPen pen = painter->pen();
898 pen.setColor(QColor(255, 255, 255, 200));
899 pen.setStyle(Qt::DotLine);
901 for (; it != markers.end(); ++it) {
902 pos = GenTime((int)((*it).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
903 if (pos > GenTime()) {
904 if (pos > cropDuration()) break;
905 QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
906 QLineF l2 = painter->worldTransform().map(l);
907 painter->setPen(pen);
908 painter->drawLine(l2);
909 if (KdenliveSettings::showmarkers()) {
910 framepos = rect().x() + pos.frames(m_fps);
911 const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
912 const QRectF r2 = painter->worldTransform().mapRect(r1);
913 const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
914 painter->setBrush(markerBrush);
915 painter->setPen(Qt::NoPen);
916 painter->drawRoundedRect(txtBounding3, 3, 3);
917 painter->setBrush(QBrush(Qt::NoBrush));
918 painter->setPen(Qt::white);
919 painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
921 //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
926 // draw start / end fades
929 fades = QBrush(QColor(200, 50, 50, 150));
930 } else fades = QBrush(QColor(200, 200, 200, 200));
932 if (m_startFade != 0) {
933 QPainterPath fadeInPath;
934 fadeInPath.moveTo(0, 0);
935 fadeInPath.lineTo(0, rect().height());
936 fadeInPath.lineTo(m_startFade, 0);
937 fadeInPath.closeSubpath();
938 QPainterPath f1 = painter->worldTransform().map(fadeInPath);
939 painter->fillPath(f1/*.intersected(resultClipPath)*/, fades);
940 /*if (isSelected()) {
941 QLineF l(m_startFade * scale, 0, 0, itemHeight);
942 painter->drawLine(l);
945 if (m_endFade != 0) {
946 QPainterPath fadeOutPath;
947 fadeOutPath.moveTo(rect().width(), 0);
948 fadeOutPath.lineTo(rect().width(), rect().height());
949 fadeOutPath.lineTo(rect().width() - m_endFade, 0);
950 fadeOutPath.closeSubpath();
951 QPainterPath f1 = painter->worldTransform().map(fadeOutPath);
952 painter->fillPath(f1/*.intersected(resultClipPath)*/, fades);
953 /*if (isSelected()) {
954 QLineF l(itemWidth - m_endFade * scale, 0, itemWidth, itemHeight);
955 painter->drawLine(l);
960 painter->setPen(QPen(Qt::lightGray));
961 // draw effect or transition keyframes
962 drawKeyFrames(painter, m_limitedKeyFrames);
966 // expand clip rect to allow correct painting of clip border
967 painter->setClipping(false);
968 painter->setPen(framePen);
969 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
970 painter->drawRect(mapped.adjusted(0.5, 0.5, -0.5, -0.5));
973 painter->drawRect(mapped.adjusted(0, 0, -0.5, 0));
978 OPERATIONTYPE ClipItem::operationMode(QPointF pos)
980 if (isItemLocked()) return NONE;
981 const double scale = projectScene()->scale().x();
982 double maximumOffset = 6 / scale;
983 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
984 int kf = mouseOverKeyFrames(pos, maximumOffset);
986 m_editedKeyframe = kf;
990 QRectF rect = sceneBoundingRect();
991 int addtransitionOffset = 10;
992 // Don't allow add transition if track height is very small
993 if (rect.height() < 30) addtransitionOffset = 0;
995 if (qAbs((int)(pos.x() - (rect.x() + m_startFade))) < maximumOffset && qAbs((int)(pos.y() - rect.y())) < 6) {
997 } else if (pos.x() - rect.x() < maximumOffset && (rect.bottom() - pos.y() > addtransitionOffset)) {
999 } else if (qAbs((int)(pos.x() - (rect.x() + rect.width() - m_endFade))) < maximumOffset && qAbs((int)(pos.y() - rect.y())) < 6) {
1001 } else if ((rect.right() - pos.x() < maximumOffset) && (rect.bottom() - pos.y() > addtransitionOffset)) {
1003 } else if ((pos.x() - rect.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
1004 return TRANSITIONSTART;
1005 } else if ((rect.right() - pos.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
1006 return TRANSITIONEND;
1012 int ClipItem::itemHeight()
1014 return KdenliveSettings::trackheight() - 2;
1017 void ClipItem::resetFrameWidth(int width)
1023 QList <GenTime> ClipItem::snapMarkers() const
1025 QList < GenTime > snaps;
1026 QList < GenTime > markers = baseClip()->snapMarkers();
1029 for (int i = 0; i < markers.size(); i++) {
1030 pos = GenTime((int)(markers.at(i).frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
1031 if (pos > GenTime()) {
1032 if (pos > cropDuration()) break;
1033 else snaps.append(pos + startPos());
1039 QList <CommentedTime> ClipItem::commentedSnapMarkers() const
1041 QList < CommentedTime > snaps;
1042 QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
1045 for (int i = 0; i < markers.size(); i++) {
1046 pos = GenTime((int)(markers.at(i).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
1047 if (pos > GenTime()) {
1048 if (pos > cropDuration()) break;
1049 else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment()));
1055 void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, int endpixel, int channels)
1057 QRectF re = sceneBoundingRect();
1058 if (m_clipType == AV && !isAudioOnly()) re.setTop(re.y() + re.height() / 2);
1060 //kDebug() << "// PREP AUDIO THMB FRMO : scale:" << pixelForOneFrame<< ", from: " << startpixel << ", to: " << endpixel;
1061 //if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
1063 for (int startCache = startpixel - startpixel % 100; startCache < endpixel; startCache += 100) {
1064 //kDebug() << "creating " << startCache;
1065 //if (framePixelWidth!=pixelForOneFrame ||
1066 if (m_framePixelWidth == pixelForOneFrame && m_audioThumbCachePic.contains(startCache))
1068 if (m_audioThumbCachePic[startCache].isNull() || m_framePixelWidth != pixelForOneFrame) {
1069 m_audioThumbCachePic[startCache] = QPixmap(100, (int)(re.height()));
1070 m_audioThumbCachePic[startCache].fill(QColor(180, 180, 200, 140));
1072 bool fullAreaDraw = pixelForOneFrame < 10;
1073 QMap<int, QPainterPath > positiveChannelPaths;
1074 QMap<int, QPainterPath > negativeChannelPaths;
1075 QPainter pixpainter(&m_audioThumbCachePic[startCache]);
1077 audiopen.setWidth(0);
1078 pixpainter.setPen(audiopen);
1079 //pixpainter.setRenderHint(QPainter::Antialiasing,true);
1080 //pixpainter.drawLine(0,0,100,re.height());
1081 // Bail out, if caller provided invalid data
1082 if (channels <= 0) {
1083 kWarning() << "Unable to draw image with " << channels << "number of channels";
1087 int channelHeight = m_audioThumbCachePic[startCache].height() / channels;
1089 for (int i = 0; i < channels; i++) {
1091 positiveChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
1092 negativeChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
1095 for (int samples = 0; samples <= 100; samples++) {
1096 double frame = (double)(samples + startCache - 0) / pixelForOneFrame;
1097 int sample = (int)((frame - (int)(frame)) * 20); // AUDIO_FRAME_SIZE
1098 if (frame < 0 || sample < 0 || sample > 19)
1100 QMap<int, QByteArray> frame_channel_data = baseClip()->m_audioFrameCache[(int)frame];
1102 for (int channel = 0; channel < channels && frame_channel_data[channel].size() > 0; channel++) {
1104 int y = channelHeight * channel + channelHeight / 2;
1105 int delta = (int)(frame_channel_data[channel][sample] - 127 / 2) * channelHeight / 64;
1107 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + qAbs(delta));
1108 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - qAbs(delta));
1110 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + delta);
1111 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - delta);
1114 for (int channel = 0; channel < channels ; channel++)
1115 if (fullAreaDraw && samples == 100) {
1116 positiveChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
1117 negativeChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
1118 positiveChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
1119 negativeChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
1123 pixpainter.setPen(QPen(QColor(0, 0, 0)));
1124 pixpainter.setBrush(QBrush(QColor(60, 60, 60)));
1126 for (int i = 0; i < channels; i++) {
1128 //pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
1129 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
1131 pixpainter.drawPath(positiveChannelPaths[i]);
1134 //audioThumbWasDrawn=true;
1135 m_framePixelWidth = pixelForOneFrame;
1140 int ClipItem::fadeIn() const
1145 int ClipItem::fadeOut() const
1151 void ClipItem::setFadeIn(int pos)
1153 if (pos == m_startFade) return;
1154 int oldIn = m_startFade;
1155 m_startFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
1156 QRectF rect = boundingRect();
1157 update(rect.x(), rect.y(), qMax(oldIn, m_startFade), rect.height());
1160 void ClipItem::setFadeOut(int pos)
1162 if (pos == m_endFade) return;
1163 int oldOut = m_endFade;
1164 m_endFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
1165 QRectF rect = boundingRect();
1166 update(rect.x() + rect.width() - qMax(oldOut, m_endFade), rect.y(), qMax(oldOut, m_endFade), rect.height());
1170 void ClipItem::setFades(int in, int out)
1178 void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
1180 //if (e->pos().x() < 20) m_hover = true;
1182 if (isItemLocked()) return;
1184 QRectF r = boundingRect();
1185 double width = 35 / projectScene()->scale().x();
1186 double height = r.height() / 2;
1187 //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
1188 update(r.x(), r.y() + height, width, height);
1189 update(r.right() - width, r.y() + height, width, height);
1193 void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
1195 if (isItemLocked()) return;
1197 QRectF r = boundingRect();
1198 double width = 35 / projectScene()->scale().x();
1199 double height = r.height() / 2;
1200 //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
1201 update(r.x(), r.y() + height, width, height);
1202 update(r.right() - width, r.y() + height, width, height);
1206 void ClipItem::resizeStart(int posx, bool /*size*/)
1208 bool sizeLimit = false;
1209 if (clipType() != IMAGE && clipType() != COLOR && clipType() != TEXT) {
1210 const int min = (startPos() - cropStart()).frames(m_fps);
1211 if (posx < min) posx = min;
1215 if (posx == startPos().frames(m_fps)) return;
1216 const int previous = cropStart().frames(m_fps);
1217 AbstractClipItem::resizeStart(posx, sizeLimit);
1219 // set speed independant info
1220 m_speedIndependantInfo = m_info;
1221 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
1222 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
1224 if ((int) cropStart().frames(m_fps) != previous) {
1225 if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
1226 m_startThumbTimer.start(150);
1231 void ClipItem::resizeEnd(int posx)
1233 const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps);
1234 if (posx > max && maxDuration() != GenTime()) posx = max;
1235 if (posx == endPos().frames(m_fps)) return;
1236 //kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
1237 const int previous = cropDuration().frames(m_fps);
1238 AbstractClipItem::resizeEnd(posx);
1240 // set speed independant info
1241 m_speedIndependantInfo = m_info;
1242 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
1243 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
1245 if ((int) cropDuration().frames(m_fps) != previous) {
1246 if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
1247 m_endThumbTimer.start(150);
1253 QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
1255 if (change == QGraphicsItem::ItemSelectedChange) {
1256 if (value.toBool()) setZValue(10);
1259 if (change == ItemPositionChange && scene()) {
1260 // calculate new position.
1261 //if (parentItem()) return pos();
1262 QPointF newPos = value.toPointF();
1263 //kDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++";
1264 int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
1265 xpos = qMax(xpos, 0);
1267 int newTrack = newPos.y() / KdenliveSettings::trackheight();
1268 newTrack = qMin(newTrack, projectScene()->tracksCount() - 1);
1269 newTrack = qMax(newTrack, 0);
1270 newPos.setY((int)(newTrack * KdenliveSettings::trackheight() + 1));
1271 // Only one clip is moving
1272 QRectF sceneShape = rect();
1273 sceneShape.translate(newPos);
1274 QList<QGraphicsItem*> items;
1275 if (projectScene()->editMode() == NORMALEDIT)
1276 items = scene()->items(sceneShape, Qt::IntersectsItemShape);
1277 items.removeAll(this);
1278 bool forwardMove = newPos.x() > pos().x();
1280 if (!items.isEmpty()) {
1281 for (int i = 0; i < items.count(); i++) {
1282 if (!items.at(i)->isEnabled()) continue;
1283 if (items.at(i)->type() == type()) {
1285 QPointF otherPos = items.at(i)->pos();
1286 if ((int) otherPos.y() != (int) pos().y()) {
1290 offset = qMax(offset, (int)(newPos.x() - (static_cast < AbstractClipItem* >(items.at(i))->startPos() - cropDuration()).frames(m_fps)));
1292 offset = qMax(offset, (int)((static_cast < AbstractClipItem* >(items.at(i))->endPos().frames(m_fps)) - newPos.x()));
1297 sceneShape.translate(QPointF(-offset, 0));
1298 newPos.setX(newPos.x() - offset);
1300 sceneShape.translate(QPointF(offset, 0));
1301 newPos.setX(newPos.x() + offset);
1303 QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
1304 subitems.removeAll(this);
1305 for (int j = 0; j < subitems.count(); j++) {
1306 if (!subitems.at(j)->isEnabled()) continue;
1307 if (subitems.at(j)->type() == type()) {
1308 // move was not successful, revert to previous pos
1309 m_info.startPos = GenTime((int) pos().x(), m_fps);
1315 m_info.track = newTrack;
1316 m_info.startPos = GenTime((int) newPos.x(), m_fps);
1322 m_info.track = newTrack;
1323 m_info.startPos = GenTime((int) newPos.x(), m_fps);
1324 //kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
1327 return QGraphicsItem::itemChange(change, value);
1331 /*void ClipItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
1334 int ClipItem::effectsCounter()
1336 return effectsCount() + 1;
1339 int ClipItem::effectsCount()
1341 return m_effectList.count();
1344 int ClipItem::hasEffect(const QString &tag, const QString &id) const
1346 return m_effectList.hasEffect(tag, id);
1349 QStringList ClipItem::effectNames()
1351 return m_effectList.effectNames();
1354 QDomElement ClipItem::effectAt(int ix) const
1356 if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
1357 return m_effectList.at(ix).cloneNode().toElement();
1360 QDomElement ClipItem::getEffectAt(int ix) const
1362 if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
1363 return m_effectList.at(ix);
1366 void ClipItem::setEffectAt(int ix, QDomElement effect)
1368 if (ix < 0 || ix > (m_effectList.count() - 1) || effect.isNull()) {
1369 kDebug() << "Invalid effect index: " << ix;
1372 //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
1373 effect.setAttribute("kdenlive_ix", ix + 1);
1374 m_effectList.replace(ix, effect);
1375 m_effectNames = m_effectList.effectNames().join(" / ");
1376 QString id = effect.attribute("id");
1377 if (id == "fadein" || id == "fadeout" || id == "fade_from_black" || id == "fade_to_black")
1380 QRectF r = boundingRect();
1386 EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animate*/)
1388 bool needRepaint = false;
1391 if (!effect.hasAttribute("kdenlive_ix")) {
1392 ix = effectsCounter();
1393 } else ix = effect.attribute("kdenlive_ix").toInt();
1394 if (!m_effectList.isEmpty() && ix <= m_effectList.count()) {
1396 m_effectList.insert(ix - 1, effect);
1397 for (int i = ix; i < m_effectList.count(); i++) {
1398 int index = m_effectList.item(i).attribute("kdenlive_ix").toInt();
1399 if (index >= ix) m_effectList.item(i).setAttribute("kdenlive_ix", index + 1);
1401 } else m_effectList.append(effect);
1402 EffectsParameterList parameters;
1403 parameters.addParam("tag", effect.attribute("tag"));
1404 parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
1405 if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
1406 if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
1408 QString effectId = effect.attribute("id");
1409 if (effectId.isEmpty()) effectId = effect.attribute("tag");
1410 parameters.addParam("id", effectId);
1412 // special case: the affine effect needs in / out points
1414 QDomNodeList params = effect.elementsByTagName("parameter");
1416 bool needInOutSync = false;
1417 for (int i = 0; i < params.count(); i++) {
1418 QDomElement e = params.item(i).toElement();
1420 if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
1421 // Effects with a geometry parameter need to sync in / out with parent clip
1422 needInOutSync = true;
1424 if (e.attribute("type") == "simplekeyframe") {
1425 QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
1426 double factor = locale.toDouble(e.attribute("factor", "1"));
1427 double offset = e.attribute("offset", "0").toDouble();
1428 if (factor != 1 || offset != 0) {
1429 for (int j = 0; j < values.count(); j++) {
1430 QString pos = values.at(j).section(':', 0, 0);
1431 double val = (locale.toDouble(values.at(j).section(':', 1, 1)) - offset) / factor;
1432 values[j] = pos + "=" + locale.toString(val);
1435 parameters.addParam(e.attribute("name"), values.join(";"));
1436 /*parameters.addParam("max", e.attribute("max"));
1437 parameters.addParam("min", e.attribute("min"));
1438 parameters.addParam("factor", );*/
1439 } else if (e.attribute("type") == "keyframe") {
1440 parameters.addParam("keyframes", e.attribute("keyframes"));
1441 parameters.addParam("max", e.attribute("max"));
1442 parameters.addParam("min", e.attribute("min"));
1443 parameters.addParam("factor", e.attribute("factor", "1"));
1444 parameters.addParam("offset", e.attribute("offset", "0"));
1445 parameters.addParam("starttag", e.attribute("starttag", "start"));
1446 parameters.addParam("endtag", e.attribute("endtag", "end"));
1447 } else if (e.attribute("factor", "1") == "1" && e.attribute("offset", "0") == "0") {
1448 parameters.addParam(e.attribute("name"), e.attribute("value"));
1450 // check if it is a fade effect
1451 if (effectId == "fadein") {
1453 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
1454 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
1455 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
1457 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
1458 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
1459 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
1461 } else if (effectId == "fade_from_black") {
1463 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
1464 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
1465 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
1467 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
1468 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
1469 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
1471 } else if (effectId == "fadeout") {
1473 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
1474 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
1475 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
1477 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
1478 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
1479 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
1481 } else if (effectId == "fade_to_black") {
1483 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
1484 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
1485 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
1487 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
1488 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
1489 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
1494 if (e.attribute("factor").contains('%')) {
1495 fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
1497 fact = locale.toDouble(e.attribute("factor", "1"));
1499 double offset = e.attribute("offset", "0").toDouble();
1500 parameters.addParam(e.attribute("name"), locale.toString((locale.toDouble(e.attribute("value")) - offset) / fact));
1504 if (needInOutSync) {
1505 parameters.addParam("in", QString::number(cropStart().frames(m_fps)));
1506 parameters.addParam("out", QString::number((cropStart() + cropDuration()).frames(m_fps) - 1));
1507 parameters.addParam("_sync_in_out", "1");
1509 m_effectNames = m_effectList.effectNames().join(" / ");
1510 if (fade > 0) m_startFade = fade;
1511 else if (fade < 0) m_endFade = -fade;
1513 if (m_selectedEffect == -1) {
1514 setSelectedEffect(0);
1515 } else if (m_selectedEffect == ix - 1) setSelectedEffect(m_selectedEffect);
1516 if (needRepaint) update(boundingRect());
1520 else { /*if (!needRepaint) */
1521 QRectF r = boundingRect();
1528 void ClipItem::deleteEffect(QString index)
1530 bool needRepaint = false;
1533 for (int i = 0; i < m_effectList.count(); ++i) {
1534 ix = m_effectList.at(i).attribute("kdenlive_ix");
1536 QString effectId = m_effectList.at(i).attribute("id");
1537 if ((effectId == "fadein" && hasEffect(QString(), "fade_from_black") == -1) ||
1538 (effectId == "fade_from_black" && hasEffect(QString(), "fadein") == -1)) {
1541 } else if ((effectId == "fadeout" && hasEffect(QString(), "fade_to_black") == -1) ||
1542 (effectId == "fade_to_black" && hasEffect(QString(), "fadeout") == -1)) {
1545 } else if (EffectsList::hasKeyFrames(m_effectList.at(i))) needRepaint = true;
1546 m_effectList.removeAt(i);
1548 } else if (ix.toInt() > index.toInt()) {
1549 m_effectList.item(i).setAttribute("kdenlive_ix", ix.toInt() - 1);
1552 m_effectNames = m_effectList.effectNames().join(" / ");
1554 if (m_effectList.isEmpty() || m_selectedEffect + 1 == index.toInt()) {
1555 // Current effect was removed
1556 if (index.toInt() > m_effectList.count() - 1) {
1557 setSelectedEffect(m_effectList.count() - 1);
1558 } else setSelectedEffect(index.toInt());
1560 if (needRepaint) update(boundingRect());
1562 QRectF r = boundingRect();
1566 //if (!m_effectList.isEmpty()) flashClip();
1569 double ClipItem::speed() const
1574 int ClipItem::strobe() const
1579 void ClipItem::setSpeed(const double speed, const int strobe)
1582 if (m_speed <= 0 && m_speed > -1)
1585 if (m_speed == 1.0) m_clipName = baseClip()->name();
1586 else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + '%';
1587 m_info.cropStart = GenTime((int)(m_speedIndependantInfo.cropStart.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1588 m_info.cropDuration = GenTime((int)(m_speedIndependantInfo.cropDuration.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1592 GenTime ClipItem::maxDuration() const
1594 return GenTime((int)(m_maxDuration.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1597 GenTime ClipItem::speedIndependantCropStart() const
1599 return m_speedIndependantInfo.cropStart;
1602 GenTime ClipItem::speedIndependantCropDuration() const
1604 return m_speedIndependantInfo.cropDuration;
1608 const ItemInfo ClipItem::speedIndependantInfo() const
1610 return m_speedIndependantInfo;
1614 void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event)
1616 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
1618 doc.setContent(effects, true);
1619 const QDomElement e = doc.documentElement();
1620 if (scene() && !scene()->views().isEmpty()) {
1622 CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1623 if (view) view->slotAddEffect(e, m_info.startPos, track());
1628 void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
1630 if (isItemLocked()) event->setAccepted(false);
1631 else event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
1634 void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
1639 void ClipItem::addTransition(Transition* t)
1641 m_transitionsList.append(t);
1642 //CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1644 QDomElement e = doc.documentElement();
1645 //if (view) view->slotAddTransition(this, t->toXML() , t->startPos(), track());
1648 void ClipItem::setVideoOnly(bool force)
1650 m_videoOnly = force;
1653 void ClipItem::setAudioOnly(bool force)
1655 m_audioOnly = force;
1656 if (m_audioOnly) m_baseColor = QColor(141, 215, 166);
1658 if (m_clipType == COLOR) {
1659 QString colour = m_clip->getProperty("colour");
1660 colour = colour.replace(0, 2, "#");
1661 m_baseColor = QColor(colour.left(7));
1662 } else if (m_clipType == AUDIO) m_baseColor = QColor(141, 215, 166);
1663 else m_baseColor = QColor(141, 166, 215);
1665 m_audioThumbCachePic.clear();
1668 bool ClipItem::isAudioOnly() const
1673 bool ClipItem::isVideoOnly() const
1678 void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
1680 if (effect.attribute("disable") == "1") return;
1682 effect.setAttribute("active_keyframe", pos);
1683 m_editedKeyframe = pos;
1684 QDomNodeList params = effect.elementsByTagName("parameter");
1685 for (int i = 0; i < params.count(); i++) {
1686 QDomElement e = params.item(i).toElement();
1687 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
1688 QString kfr = e.attribute("keyframes");
1689 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
1692 foreach(const QString &str, keyframes) {
1693 int kpos = str.section(':', 0, 0).toInt();
1694 double newval = locale.toDouble(str.section(':', 1, 1));
1697 } else if (!added) {
1698 if (i == m_visibleParam)
1699 newkfr.append(QString::number(pos) + ":" + QString::number(val));
1701 newkfr.append(QString::number(pos) + ":" + locale.toString(newval));
1702 if (kpos > pos) newkfr.append(str);
1704 } else newkfr.append(str);
1707 if (i == m_visibleParam)
1708 newkfr.append(QString::number(pos) + ":" + QString::number(val));
1710 newkfr.append(QString::number(pos) + ":" + e.attribute("default"));
1712 e.setAttribute("keyframes", newkfr.join(";"));
1717 void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double value)
1719 if (effect.attribute("disable") == "1") return;
1721 effect.setAttribute("active_keyframe", newpos);
1722 QDomNodeList params = effect.elementsByTagName("parameter");
1723 int start = cropStart().frames(m_fps);
1724 int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
1725 for (int i = 0; i < params.count(); i++) {
1726 QDomElement e = params.item(i).toElement();
1727 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
1728 QString kfr = e.attribute("keyframes");
1729 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
1731 foreach(const QString &str, keyframes) {
1732 if (str.section(':', 0, 0).toInt() != oldpos) {
1734 } else if (newpos != -1) {
1735 newpos = qMax(newpos, start);
1736 newpos = qMin(newpos, end);
1737 if (i == m_visibleParam)
1738 newkfr.append(QString::number(newpos) + ":" + locale.toString(value));
1740 newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1));
1743 e.setAttribute("keyframes", newkfr.join(";"));
1747 updateKeyframes(effect);
1751 void ClipItem::updateKeyframes(QDomElement effect)
1753 m_keyframes.clear();
1756 QDomNodeList params = effect.elementsByTagName("parameter");
1757 QDomElement e = params.item(m_visibleParam).toElement();
1758 if (e.attribute("intimeline") != "1") {
1759 setSelectedEffect(m_selectedEffect);
1762 m_limitedKeyFrames = e.attribute("type") == "keyframe";
1763 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
1764 foreach(const QString &str, keyframes) {
1765 int pos = str.section(':', 0, 0).toInt();
1766 double val = locale.toDouble(str.section(':', 1, 1));
1767 m_keyframes[pos] = val;
1769 if (!m_keyframes.contains(m_selectedKeyframe)) m_selectedKeyframe = -1;
1772 Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
1775 return m_clip->audioProducer(track);
1776 else if (isVideoOnly())
1777 return m_clip->videoProducer();
1779 return m_clip->getProducer(trackSpecific ? track : -1);
1782 QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo)
1784 QMap<int, QDomElement> effects;
1785 for (int i = 0; i < m_effectList.count(); i++) {
1786 QDomElement effect = m_effectList.at(i);
1788 if (effect.attribute("id").startsWith("fade")) {
1789 QString id = effect.attribute("id");
1790 int in = EffectsList::parameter(effect, "in").toInt();
1791 int out = EffectsList::parameter(effect, "out").toInt();
1792 int clipEnd = (cropStart() + cropDuration()).frames(m_fps) - 1;
1793 if (id == "fade_from_black" || id == "fadein") {
1794 if (in != cropStart().frames(m_fps)) {
1795 effects[i] = effect.cloneNode().toElement();
1796 int diff = in - cropStart().frames(m_fps);
1799 EffectsList::setParameter(effect, "in", QString::number(in));
1800 EffectsList::setParameter(effect, "out", QString::number(out));
1802 if (out > clipEnd) {
1803 if (!effects.contains(i))
1804 effects[i] = effect.cloneNode().toElement();
1805 EffectsList::setParameter(effect, "out", QString::number(clipEnd));
1807 if (effects.contains(i))
1808 setFadeIn(out - in);
1810 if (out != clipEnd) {
1811 effects[i] = effect.cloneNode().toElement();
1812 int diff = out - clipEnd;
1813 in = qMax(in - diff, (int) cropStart().frames(m_fps));
1815 EffectsList::setParameter(effect, "in", QString::number(in));
1816 EffectsList::setParameter(effect, "out", QString::number(out));
1818 if (in < cropStart().frames(m_fps)) {
1819 if (!effects.contains(i))
1820 effects[i] = effect.cloneNode().toElement();
1821 EffectsList::setParameter(effect, "in", QString::number(cropStart().frames(m_fps)));
1823 if (effects.contains(i))
1824 setFadeOut(out - in);
1827 } else if (effect.attribute("id") == "freeze" && cropStart() != oldInfo.cropStart) {
1828 effects[i] = effect.cloneNode().toElement();
1829 int diff = (oldInfo.cropStart - cropStart()).frames(m_fps);
1830 int frame = EffectsList::parameter(effect, "frame").toInt();
1831 EffectsList::setParameter(effect, "frame", QString::number(frame - diff));
1835 QDomNodeList params = effect.elementsByTagName("parameter");
1836 for (int j = 0; j < params.count(); j++) {
1837 QDomElement param = params.item(j).toElement();
1839 QString type = param.attribute("type");
1840 if (type == "geometry" && !param.hasAttribute("fixed")) {
1841 if (!effects.contains(i))
1842 effects[i] = effect.cloneNode().toElement();
1843 updateGeometryKeyframes(effect, j, width, height, oldInfo);
1844 } else if (type == "simplekeyframe" || type == "keyframe") {
1845 if (!effects.contains(i))
1846 effects[i] = effect.cloneNode().toElement();
1847 updateNormalKeyframes(param);
1849 } else if (type == "roto-spline") {
1850 if (!effects.contains(i))
1851 effects[i] = effect.cloneNode().toElement();
1852 QString value = param.attribute("value");
1853 if (adjustRotoDuration(&value, cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1))
1854 param.setAttribute("value", value);
1862 bool ClipItem::updateNormalKeyframes(QDomElement parameter)
1864 int in = cropStart().frames(m_fps);
1865 int out = (cropStart() + cropDuration()).frames(m_fps) - 1;
1868 const QStringList data = parameter.attribute("keyframes").split(';', QString::SkipEmptyParts);
1869 QMap <int, double> keyframes;
1870 foreach (QString keyframe, data)
1871 keyframes[keyframe.section(':', 0, 0).toInt()] = locale.toDouble(keyframe.section(':', 1, 1));
1874 QMap<int, double>::iterator i = keyframes.end();
1876 double lastValue = 0;
1880 * Take care of resize from start
1882 bool startFound = false;
1883 while (i-- != keyframes.begin()) {
1884 if (i.key() < in && !startFound) {
1887 keyframes[in] = i.value();
1889 relPos = (in - i.key()) / (qreal)(lastPos - i.key() + 1);
1890 keyframes[in] = i.value() + (lastValue - i.value()) * relPos;
1894 lastValue = i.value();
1896 i = keyframes.erase(i);
1900 * Take care of resize from end
1902 i = keyframes.begin();
1904 bool endFound = false;
1905 while (i != keyframes.end()) {
1906 if (i.key() > out && !endFound) {
1909 keyframes[out] = i.value();
1911 relPos = (out - lastPos) / (qreal)(i.key() - lastPos + 1);
1912 keyframes[out] = lastValue + (i.value() - lastValue) * relPos;
1916 lastValue = i.value();
1918 i = keyframes.erase(i);
1923 if (startFound || endFound) {
1925 QMap<int, double>::const_iterator k = keyframes.constBegin();
1926 while (k != keyframes.constEnd()) {
1927 newkfr.append(QString::number(k.key()) + ':' + QString::number(qRound(k.value())) + ';');
1930 parameter.setAttribute("keyframes", newkfr);
1937 void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, ItemInfo oldInfo)
1940 QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
1941 int offset = oldInfo.cropStart.frames(m_fps);
1942 QString data = param.attribute("value");
1944 QStringList kfrs = data.split(';');
1946 foreach (QString keyframe, kfrs) {
1947 if (keyframe.contains('=')) {
1948 int pos = keyframe.section('=', 0, 0).toInt();
1950 data.append(QString::number(pos) + "=" + keyframe.section('=', 1) + ";");
1952 else data.append(keyframe + ";");
1955 Mlt::Geometry geometry(data.toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
1956 param.setAttribute("value", geometry.serialise(cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1));
1959 void ClipItem::slotGotThumbsCache()
1961 disconnect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache()));
1965 #include "clipitem.moc"