#include "kdenlivesettings.h"
#include "kthumb.h"
-ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, GenTime cropStart, double scale, double fps)
+ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double scale, double fps)
: AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_effectsCounter(1), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_thumbsRequested(0), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1) {
QRectF rect((double) info.startPos.frames(fps) * scale, (double)(info.track * KdenliveSettings::trackheight() + 1), (double)(info.endPos - info.startPos).frames(fps) * scale, (double)(KdenliveSettings::trackheight() - 1));
setRect(rect);
m_clipName = clip->name();
m_producer = clip->getId();
m_clipType = clip->clipType();
- m_cropStart = cropStart;
+ m_cropStart = info.cropStart;
m_maxDuration = clip->maxDuration();
setAcceptDrops(true);
audioThumbReady = clip->audioThumbCreated();
setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setAcceptsHoverEvents(true);
- connect(this , SIGNAL(prepareAudioThumb(double, QPainterPath, int, int)) , this, SLOT(slotPrepareAudioThumb(double, QPainterPath, int, int)));
+ connect(this , SIGNAL(prepareAudioThumb(double, QPainterPath, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, QPainterPath, int, int, int)));
setBrush(QColor(141, 166, 215));
if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW) {
if (endThumbTimer) delete endThumbTimer;
}
+ClipItem *ClipItem::clone(double scale) const {
+ ClipItem *duplicate = new ClipItem(m_clip, info(), scale, m_fps);
+ duplicate->setEffectList(m_effectList);
+ return duplicate;
+}
+
+void ClipItem::setEffectList(const EffectsList effectList) {
+ //m_effectList = effectList.clone();
+}
+
int ClipItem::selectedEffectIndex() const {
return m_selectedEffect;
}
void ClipItem::setKeyframes(const int ix, const QString keyframes) {
QDomElement effect = effectAt(ix);
+ if (effect.attribute("disabled") == "1") return;
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;
+ 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(const int ix) {
-
m_selectedEffect = ix;
QDomElement effect = effectAt(m_selectedEffect);
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") {
- 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;
+ if (effect.attribute("disabled") != "1")
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull() && e.attribute("type") == "keyframe") {
+ 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;
}
- update();
- return;
}
- }
if (!m_keyframes.isEmpty()) {
m_keyframes.clear();
update();
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;
- }
+ result = e.attribute("keyframes");
+ break;
+ }
}
return result;
}
void ClipItem::updateKeyframeEffect() {
// regenerate xml parameter from the clip keyframes
QDomElement effect = effectAt(m_selectedEffect);
+ if (effect.attribute("disabled") == "1") return;
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
if (startpixel < 0)
startpixel = 0;
- int endpixel = (int)option->exposedRect.right() - rect().x();
+ int endpixel = (int)option->exposedRect.right();
if (endpixel < 0)
endpixel = 0;
}
// draw audio thumbnails
- if (KdenliveSettings::audiothumbnails() && ((m_clipType == AV && option->exposedRect.bottom() > br.height() / 2) || m_clipType == AUDIO) && audioThumbReady) {
+ if (KdenliveSettings::audiothumbnails() && ((m_clipType == AV && option->exposedRect.bottom() > (br.y() + br.height() / 2)) || m_clipType == AUDIO) && audioThumbReady) {
QPainterPath path = m_clipType == AV ? roundRectPathLower : resultClipPath;
if (m_clipType == AV) painter->fillPath(path, QBrush(QColor(200, 200, 200, 140)));
- int channels = 2;
+ int channels = baseClip()->getProperty("channels").toInt();
if (scale != framePixelWidth)
audioThumbCachePic.clear();
- emit prepareAudioThumb(scale, path, startpixel, endpixel + 200);//200 more for less missing parts before repaint after scrolling
+ emit prepareAudioThumb(scale, path, startpixel, endpixel + 200, channels);//200 more for less missing parts before repaint after scrolling
int cropLeft = (int)((m_cropStart).frames(m_fps) * scale);
for (int startCache = startpixel - startpixel % 100; startCache < endpixel + 300;startCache += 100) {
if (audioThumbCachePic.contains(startCache) && !audioThumbCachePic[startCache].isNull())
return snaps;
}
-void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, QPainterPath path, int startpixel, int endpixel) {
- int channels = 2;
+QList <CommentedTime> ClipItem::commentedSnapMarkers() const {
+ QList < CommentedTime > snaps;
+ QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
+ GenTime pos;
+ double framepos;
- QRectF re = path.boundingRect();
+ for (int i = 0; i < markers.size(); i++) {
+ pos = markers.at(i).time() - cropStart();
+ if (pos > GenTime()) {
+ if (pos > duration()) break;
+ else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment()));
+ }
+ }
+ return snaps;
+}
+
+void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, QPainterPath path, int startpixel, int endpixel, int channels) {
+ QRectF re = path.boundingRect();
+ //kDebug() << "// PREP AUDIO THMB FRMO : " << startpixel << ", to: " << endpixel;
//if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
for (int startCache = startpixel - startpixel % 100;startCache + 100 < endpixel ;startCache += 100) {
}
}
}
- setSelectedEffect(m_selectedEffect);
+ if (m_selectedEffect >= 0) setSelectedEffect(m_selectedEffect);
}
r.setHeight(20);
update(r);
}
+ if (m_selectedEffect == -1) {
+ m_selectedEffect = 0;
+ setSelectedEffect(m_selectedEffect);
+ }
return effectParams;
}