X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fclipitem.cpp;h=1db6e65d950655ccb979c170700958baab2e9024;hb=f8eb4753c4d354f8156c8421d7b01c0af0a052fc;hp=2eece5225e1504be17576560b28d0b635fe52443;hpb=b90210ff66b5523cf38e313d56b06cefd947718a;p=kdenlive diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 2eece522..1db6e65d 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -63,7 +63,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, GenTime cropStart, double s 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) { @@ -97,6 +97,16 @@ ClipItem::~ClipItem() { if (endThumbTimer) delete endThumbTimer; } +ClipItem *ClipItem::clone(double scale) const { + ClipItem *duplicate = new ClipItem(m_clip, info(), cropStart(), 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; } @@ -124,6 +134,7 @@ void ClipItem::initEffect(QDomElement effect) { 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(); @@ -148,7 +159,6 @@ void ClipItem::setKeyframes(const int ix, const QString keyframes) { break; } } - } @@ -156,25 +166,26 @@ 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(); @@ -199,6 +210,7 @@ QString ClipItem::keyframes(const int index) { 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++) { @@ -341,7 +353,7 @@ void ClipItem::paint(QPainter *painter, if (startpixel < 0) startpixel = 0; - int endpixel = (int)option->exposedRect.right() - rect().x(); + int endpixel = (int)option->exposedRect.right(); if (endpixel < 0) endpixel = 0; @@ -373,15 +385,15 @@ void ClipItem::paint(QPainter *painter, } // 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()) @@ -591,11 +603,26 @@ QList ClipItem::snapMarkers() const { return snaps; } -void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, QPainterPath path, int startpixel, int endpixel) { - int channels = 2; +QList 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) { @@ -776,7 +803,7 @@ void ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b } } } - setSelectedEffect(m_selectedEffect); + if (m_selectedEffect >= 0) setSelectedEffect(m_selectedEffect); } @@ -873,8 +900,8 @@ QMap ClipItem::addEffect(QDomElement effect, bool animate) { update(r); } if (m_selectedEffect == -1) { - m_selectedEffect = 0; - setSelectedEffect(m_selectedEffect); + m_selectedEffect = 0; + setSelectedEffect(m_selectedEffect); } return effectParams; }