m_transitionTrack(transitiontrack)
{
setZValue(3);
- setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (qreal)(KdenliveSettings::trackheight() / 3 * 2 - 1));
+ m_info.cropDuration = info.endPos - info.startPos;
+ setRect(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal)(KdenliveSettings::trackheight() / 3 * 2 - 1));
setPos(info.startPos.frames(fps), (qreal)(info.track * KdenliveSettings::trackheight() + KdenliveSettings::trackheight() / 3 * 2));
- m_cropStart = GenTime();
+ m_info.cropStart = GenTime();
m_maxDuration = GenTime(600);
if (m_automaticTransition) setBrush(QColor(200, 200, 50, 100));
if (m_parameters.attribute("force_track") == "1") m_forceTransitionTrack = true;
m_name = m_parameters.elementsByTagName("name").item(0).toElement().text();
m_secondClip = 0;
- setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
//m_referenceClip->addTransition(this);
}
return false; //m_parameters.attribute("reverse").toInt();
}
-QPixmap Transition::transitionPixmap() const
-{
- KIcon icon;
- QString tag = transitionTag();
- if (tag == "luma") {
- if (invertedTransition()) icon = KIcon("kdenlive_trans_up");
- else icon = KIcon("kdenlive_trans_down");
- } else if (tag == "composite") {
- icon = KIcon("kdenlive_trans_wiper");
- } else if (tag == "lumafile") {
- icon = KIcon("kdenlive_trans_luma");
- } else icon = KIcon("kdenlive_trans_pip");
- return icon.pixmap(QSize(15, 15));
-}
-
-
void Transition::setTransitionDirection(bool /*inv*/)
{
//m_parameters.setAttribute("reverse", inv);
const QStyleOptionGraphicsItem *option,
QWidget */*widget*/)
{
- const double scale = option->matrix.m11();
- QRectF exposed = option->exposedRect;
+ const QRectF exposed = option->exposedRect;
painter->setClipRect(exposed);
- QRectF br = rect();
- QRectF mapped = painter->matrix().mapRect(br);
+ const QRectF br = rect();
+ const QRectF mapped = painter->matrix().mapRect(br);
painter->fillRect(exposed, brush());
QPointF p1(br.x(), br.y() + br.height() / 2 - 7);
painter->setMatrixEnabled(false);
//painter->drawPixmap(painter->matrix().map(p1) + QPointF(5, 0), transitionPixmap());
- QString text = transitionName();
- if (m_forceTransitionTrack) text.append("|>");
- QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + text + ' ');
- painter->fillRect(txtBounding, QBrush(QColor(50, 50, 0, 150)));
- txtBounding.translate(QPointF(1, 1));
- painter->setPen(QColor(255, 255, 255, 255));
+ const QString text = m_name + (m_forceTransitionTrack ? "|>" : QString());
+
+ // Draw clip name
+ QColor frameColor(brush().color().darker());
+ if (isSelected() || (parentItem() && parentItem()->isSelected())) {
+ frameColor = QColor(Qt::red);
+ }
+ frameColor.setAlpha(160);
+
+ const QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + text + ' ');
+ //painter->fillRect(txtBounding2, frameColor);
+ painter->setBrush(frameColor);
+ painter->setPen(Qt::NoPen);
+ painter->drawRoundedRect(txtBounding, 3, 3);
+ painter->setBrush(QBrush(Qt::NoBrush));
+
+ painter->setPen(Qt::white);
painter->drawText(txtBounding, Qt::AlignCenter, text);
- /* painter->setPen(QColor(0, 0, 0, 180));
- top += painter->fontInfo().pixelSize();
- QPointF p2(br.x(), top);
- painter->drawText(painter->matrix().map(p2) + QPointF(26, 1), transitionName());
- painter->setPen(QColor(255, 255, 255, 180));
- QPointF p3(br.x(), top);
- painter->drawText(painter->matrix().map(p3) + QPointF(25, 0), transitionName());*/
- painter->setMatrixEnabled(true);
+ // Draw frame
QPen pen = painter->pen();
- if (isSelected()) {
- pen.setColor(Qt::red);
- //pen.setWidth(2);
- } else {
- pen.setColor(Qt::black);
- //pen.setWidth(1);
- }
- // expand clip rect to allow correct painting of clip border
- exposed.setRight(exposed.right() + 1 / scale + 0.5);
- exposed.setBottom(exposed.bottom() + 1);
- painter->setClipRect(exposed);
+ pen.setColor(frameColor);
painter->setPen(pen);
- painter->drawRect(br);
+ painter->setClipping(false);
+ painter->drawRect(painter->matrix().mapRect(rect()));
}
int Transition::type() const
// Only one clip is moving
QRectF sceneShape = rect();
sceneShape.translate(newPos);
- QList<QGraphicsItem*> items = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ QList<QGraphicsItem*> items;
+ if (projectScene()->editMode() == NORMALEDIT)
+ items = scene()->items(sceneShape, Qt::IntersectsItemShape);
items.removeAll(this);
if (!items.isEmpty()) {
if ((int) otherPos.y() != (int) pos().y()) return pos();
//kDebug()<<"//// CURRENT Y: "<<pos().y()<<", COLLIDING Y: "<<otherPos.y();
if (pos().x() < otherPos.x()) {
- int npos = (static_cast < AbstractClipItem* >(items.at(i))->startPos() - m_cropDuration).frames(m_fps);
+ int npos = (static_cast < AbstractClipItem* >(items.at(i))->startPos() - m_info.cropDuration).frames(m_fps);
newPos.setX(npos);
} else {
// get pos just after colliding clip
int npos = static_cast < AbstractClipItem* >(items.at(i))->endPos().frames(m_fps);
newPos.setX(npos);
}
- m_track = newTrack;
+ m_info.track = newTrack;
//kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
- m_startPos = GenTime((int) newPos.x(), m_fps);
+ m_info.startPos = GenTime((int) newPos.x(), m_fps);
return newPos;
}
}
}
- m_track = newTrack;
- m_startPos = GenTime((int) newPos.x(), m_fps);
+ m_info.track = newTrack;
+ m_info.startPos = GenTime((int) newPos.x(), m_fps);
//kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
return newPos;
}
m_parameters.setAttribute("clipb_starttime", m_secondClip->startPos().frames(m_referenceClip->fps()));
m_parameters.setAttribute("clipb_track", transitionEndTrack());
}
- return m_parameters;
+ return m_parameters.cloneNode().toElement();
}
bool Transition::hasGeometry()
return false;
}
+int Transition::defaultZValue() const
+{
+ return 3;
+}
+