} else {
// Check transition keyframes
QDomElement old = transition->toXML();
- if (transition->updateKeyframes()) {
+ if (transition->updateKeyframes(oldInfo.cropDuration.frames(m_document->fps()) - 1)) {
QDomElement xml = transition->toXML();
m_document->renderer()->mltUpdateTransition(xml.attribute("tag"), xml.attribute("tag"), xml.attribute("transition_btrack").toInt(), m_document->tracksCount() - xml.attribute("transition_atrack").toInt(), transition->startPos(), transition->endPos(), xml);
new EditTransitionCommand(this, transition->track(), transition->startPos(), old, xml, false, command);
+ ItemInfo info = transition->info();
+ QPoint p;
+ ClipItem *transitionClip = getClipItemAt(info.startPos, info.track);
+ if (transitionClip && transitionClip->baseClip()) {
+ QString size = transitionClip->baseClip()->getProperty("frame_size");
+ double factor = transitionClip->baseClip()->getProperty("aspect_ratio").toDouble();
+ if (factor == 0) factor = 1.0;
+ p.setX((int)(size.section('x', 0, 0).toInt() * factor + 0.5));
+ p.setY(size.section('x', 1, 1).toInt());
+ }
+ emit transitionItemSelected(transition, getPreviousVideoTrack(info.track), p, true);
}
new MoveTransitionCommand(this, oldInfo, info, false, command);
}
}
}
if (event->y() >= m_lineHeight && event->y() < height()) {
- m_drag = true;
- m_seekPosition = xPos / m_scale;
- emit requestSeek(m_seekPosition);
- update();
+ int seekRequest = xPos / m_scale;
+ m_drag = true;
+ if (seekRequest != m_position) {
+ m_seekPosition = seekRequest;
+ emit requestSeek(m_seekPosition);
+ update();
+ }
}
}
p.setPen(palette().dark().color());
p.drawLine(margin, m_lineHeight, width() - margin - 1, m_lineHeight);
p.drawLine(margin, m_lineHeight - 3, margin, m_lineHeight + 3);
- p.drawLine(width() - margin - 1, m_lineHeight - 3, width() - margin - 1, m_lineHeight + 3);
+ p.drawLine(width() - margin, m_lineHeight - 3, width() - margin, m_lineHeight + 3);
// draw pointer
if (m_seekPosition != SEEK_INACTIVE) {
return 3;
}
-bool Transition::updateKeyframes()
+bool Transition::updateKeyframes(int oldEnd)
{
QString keyframes;
QDomElement pa;
QStringList values = keyframes.split(';');
int frame;
int i = 0;
- foreach(const QString &pos, values) {
- if (!pos.contains('=')) {
- i++;
- continue;
- }
- frame = pos.section('=', 0, 0).toInt();
- if (frame > duration) {
- modified = true;
- break;
- }
- i++;
+ if (oldEnd < duration) {
+ // Transition was expanded, check if we had a keyframe at end position
+ foreach(QString pos, values) {
+ if (!pos.contains('=')) {
+ i++;
+ continue;
+ }
+ frame = pos.section('=', 0, 0).toInt();
+ if (frame == oldEnd) {
+ // Move that keyframe to new end
+ values[i] = QString::number(duration) + '=' + pos.section('=', 1);
+ pa.setAttribute("value", values.join(";"));
+ return true;
+ }
+ i++;
+ }
+ return false;
+ }
+ else {
+ // Transition was shortened, check for out of bounds keyframes
+ foreach(const QString &pos, values) {
+ if (!pos.contains('=')) {
+ i++;
+ continue;
+ }
+ frame = pos.section('=', 0, 0).toInt();
+ if (frame > duration) {
+ modified = true;
+ break;
+ }
+ i++;
+ }
}
if (modified) {
if (i > 0) {
void setAutomatic(bool automatic);
bool hasGeometry();
int defaultZValue() const;
- /** @brief When a transition is resized, check if keyframes are out of the transition and fix if necessary. */
- bool updateKeyframes();
+ /** @brief When a transition is resized, check if keyframes are out of the transition and fix if necessary.
+ * @param oldEnd the previous transition end, so that when we expand the transition, if there is a keyframe at end we move it
+ */
+ bool updateKeyframes(int oldEnd);
protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);