#include "kdenlivesettings.h"
ClipItem::ClipItem(DocClipBase *clip, int track, int startpos, const QRectF & rect, int duration)
- : QGraphicsRectItem(rect), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_startFade(0), m_endFade(0)
+ : QGraphicsRectItem(rect), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_startFade(0), m_endFade(0), m_effectsCounter(0)
{
//setToolTip(name);
kDebug()<<"******* CREATING NEW TML CLIP, DUR: "<<duration;
{
QRectF br = rect();
painter->setRenderHints(QPainter::Antialiasing);
- QPainterPath roundRectPath;
+ QPainterPath roundRectPathUpper,roundRectPathLower;
double roundingY = 20;
double roundingX = 20;
double offset = 1;
painter->setClipRect(option->exposedRect);
if (roundingX > br.width() / 2) roundingX = br.width() / 2;
//kDebug()<<"-----PAINTING, SCAL: "<<scale<<", height: "<<br.height();
- roundRectPath.moveTo(br.x() + br .width() - offset, br.y() + roundingY);
- roundRectPath.arcTo(br.x() + br .width() - roundingX - offset, br.y(), roundingX, roundingY, 0.0, 90.0);
- roundRectPath.lineTo(br.x() + roundingX, br.y());
- roundRectPath.arcTo(br.x() + offset, br.y(), roundingX, roundingY, 90.0, 90.0);
- roundRectPath.lineTo(br.x() + offset, br.y() + br.height() - roundingY);
- roundRectPath.arcTo(br.x() + offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 180.0, 90.0);
- roundRectPath.lineTo(br.x() + br .width() - roundingX, br.y() + br.height() - offset);
- roundRectPath.arcTo(br.x() + br .width() - roundingX - offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 270.0, 90.0);
- roundRectPath.closeSubpath();
- painter->setClipPath(roundRectPath, Qt::IntersectClip);
+ roundRectPathUpper.moveTo(br.x() + br .width() - offset, br.y() + br.height()/2 - offset);
+ roundRectPathUpper.arcTo(br.x() + br .width() - roundingX - offset, br.y(), roundingX, roundingY, 0.0, 90.0);
+ roundRectPathUpper.lineTo(br.x() + roundingX, br.y());
+ roundRectPathUpper.arcTo(br.x() + offset, br.y(), roundingX, roundingY, 90.0, 90.0);
+ roundRectPathUpper.lineTo(br.x() + offset, br.y() + br.height()/2 - offset);
+ roundRectPathUpper.closeSubpath();
+
+ roundRectPathLower.moveTo(br.x() + offset, br.y() + br.height()/2 - offset);
+ roundRectPathLower.arcTo(br.x() + offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 180.0, 90.0);
+ roundRectPathLower.lineTo(br.x() + br .width() - roundingX, br.y() + br.height() - offset);
+ roundRectPathLower.arcTo(br.x() + br .width() - roundingX - offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 270.0, 90.0);
+ roundRectPathLower.lineTo(br.x() + br .width() - offset, br.y()+ br.height()/2 - offset);
+ roundRectPathLower.closeSubpath();
+
+ painter->setClipPath(roundRectPathUpper.united(roundRectPathLower), Qt::IntersectClip);
//painter->fillPath(roundRectPath, brush()); //, QBrush(QColor(Qt::red)));
painter->fillRect(br, brush());
//painter->fillRect(QRectF(br.x() + br.width() - m_endPix.width(), br.y(), m_endPix.width(), br.height()), QBrush(QColor(Qt::black)));
QLineF l2(br.x() + m_startPix.width(), br.y(), br.x() + m_startPix.width(), br.y() + br.height());
painter->drawLine(l2);
}
-
+ if (m_clipType == AV || m_clipType==AUDIO ){
+ QPainterPath path= m_clipType==AV ? roundRectPathLower : roundRectPathUpper.united(roundRectPathLower);
+ painter->fillPath(path,QBrush(QColor(200,200,200,127)));
+ //for test
+ int channels=2;
+ kDebug() << "audio frames=" << baseClip()->audioFrameChache.size() ;
+ for (int channel=0;channel<channels;channel++){
+ QRectF re=path.boundingRect();
+ int y=re.y()+re.height()*channel/channels+ (re.height()/channels)/2;
+ painter->drawLine(re.x() , y, re.x() + re.width(), y );
+ }
+ }
// draw start / end fades
double scale = br.width() / m_cropDuration;
QBrush fades;
}
}
- painter->setClipRect(option->exposedRect);
QPen pen = painter->pen();
- pen.setColor(Qt::red);
- pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
-
+ pen.setColor(Qt::white);
+ //pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
// Draw clip name
+ QString effects = effectNames().join(" / ");
+ if (!effects.isEmpty()) {
+ painter->setPen(pen);
+ QFont font = painter->font();
+ QFont smallFont = font;
+ smallFont.setPointSize(8);
+ painter->setFont(smallFont);
+ QRectF txtBounding = painter->boundingRect(br, Qt::AlignLeft | Qt::AlignTop, " " + effects + " ");
+ painter->fillRect(txtBounding, QBrush(QColor(0,0,0,150)));
+ painter->drawText(txtBounding, Qt::AlignCenter, effects);
+ pen.setColor(Qt::black);
+ painter->setPen(pen);
+ painter->setFont(font);
+ }
+
QRectF txtBounding = painter->boundingRect(br, Qt::AlignCenter, " " + m_clipName + " ");
painter->fillRect(txtBounding, QBrush(QColor(255,255,255,150)));
painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
+ pen.setColor(Qt::red);
+ pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
if (isSelected()) painter->setPen(pen);
- painter->drawPath(roundRectPath);
+ painter->setClipRect(option->exposedRect);
+ painter->drawPath(roundRectPathUpper.united(roundRectPathLower));
//painter->fillRect(QRect(br.x(), br.y(), roundingX, roundingY), QBrush(QColor(Qt::green)));
/*QRectF recta(rect().x(), rect().y(), scale,rect().height());
m_track = track;
}
+int ClipItem::effectsCounter()
+{
+ return m_effectsCounter++;
+}
+
+int ClipItem::effectsCount()
+{
+ return m_effectList.size();
+}
+
+QStringList ClipItem::effectNames()
+{
+ return m_effectList.effectNames();
+}
+
+QDomElement ClipItem::effectAt(int ix)
+{
+ return m_effectList.at(ix);
+}
+
+void ClipItem::setEffectAt(int ix, QDomElement effect)
+{
+ kDebug()<<"CHange EFFECT AT: "<<ix<<", CURR: "<<m_effectList.at(ix).attribute("tag")<<", NEW: "<<effect.attribute("tag");
+ m_effectList.insert(ix, effect);
+ m_effectList.removeAt(ix + 1);
+ update(boundingRect());
+}
+
+QMap <QString, QString> ClipItem::addEffect(QDomElement effect)
+{
+ QMap <QString, QString> effectParams;
+ m_effectList.append(effect);
+ effectParams["tag"] = effect.attribute("tag");
+ effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull())
+ effectParams[e.attribute("name")] = e.attribute("value");
+ }
+ update(boundingRect());
+ return effectParams;
+}
+
+QMap <QString, QString> ClipItem::getEffectArgs(QDomElement effect)
+{
+ QMap <QString, QString> effectParams;
+ effectParams["tag"] = effect.attribute("tag");
+ effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull())
+ effectParams[e.attribute("name")] = e.attribute("value");
+ }
+ return effectParams;
+}
+
+void ClipItem::deleteEffect(QString index)
+{
+ for (int i = 0; i < m_effectList.size(); ++i) {
+ if (m_effectList.at(i).attribute("kdenlive_ix") == index) {
+ m_effectList.removeAt(i);
+ break;
+ }
+ }
+ update(boundingRect());
+}
+
// virtual
/*