#include <KDebug>
#include <KLocale>
#include <KUrl>
+#include <KCursor>
#include "customtrackview.h"
#include "clipitem.h"
#include "addeffectcommand.h"
#include "editeffectcommand.h"
#include "kdenlivesettings.h"
+#include "transition.h"
+
+//TODO:
+// disable animation if user asked it in KDE's global settings
+// http://lists.kde.org/?l=kde-commits&m=120398724717624&w=2
+// needs something like below (taken from dolphin)
+// #include <kglobalsettings.h>
+// const bool animate = KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects;
+// const int duration = animate ? 1500 : 1;
CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent)
: QGraphicsView(projectscene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0), m_document(doc), m_autoScroll(KdenliveSettings::autoscroll()) {
QColor border = QColor(255, 255, 255, 100);
m_tipPen.setColor(border);
m_tipPen.setWidth(3);
-
setContentsMargins(0, 0, 0, 0);
if (projectscene) {
m_cursorLine = projectscene->addLine(0, 0, 0, 50);
// a button was pressed, delete visual tips
if (m_operationMode == MOVE) {
double snappedPos = getSnapPointForPos(mapToScene(event->pos()).x() - m_clickPoint);
- double moveX = snappedPos; //mapToScene(event->pos()).x();
- //kDebug()<<"/////// MOVE CLIP, EVENT Y: "<<event->scenePos().y()<<", SCENE HEIGHT: "<<scene()->sceneRect().height();
- int moveTrack = (int) mapToScene(event->pos()).y() / 50;
+ kDebug() << "/////// MOVE CLIP, EVENT Y: ";//<<event->scenePos().y()<<", SCENE HEIGHT: "<<scene()->sceneRect().height();
+ int moveTrack = (int) mapToScene(event->pos() - QPoint(0, (m_dragItem->type() == TRANSITIONWIDGET ? 25 : 0))).y() / 50;
int currentTrack = m_dragItem->track();
if (moveTrack > m_tracksCount - 1) moveTrack = m_tracksCount - 1;
int offset = moveTrack - currentTrack;
if (offset != 0) offset = 50 * offset;
- m_dragItem->moveTo(moveX / m_scale, m_scale, offset, moveTrack);
+ m_dragItem->moveTo(snappedPos / m_scale, m_scale, offset, moveTrack);
} else if (m_operationMode == RESIZESTART) {
- int pos = mapToScene(event->pos()).x();
- m_dragItem->resizeStart(pos / m_scale, m_scale);
+ double snappedPos = getSnapPointForPos(mapToScene(event->pos()).x());
+ m_dragItem->resizeStart(snappedPos / m_scale, m_scale);
} else if (m_operationMode == RESIZEEND) {
- int pos = mapToScene(event->pos()).x();
- m_dragItem->resizeEnd(pos / m_scale, m_scale);
+ double snappedPos = getSnapPointForPos(mapToScene(event->pos()).x());
+ m_dragItem->resizeEnd(snappedPos / m_scale, m_scale);
} else if (m_operationMode == FADEIN) {
int pos = mapToScene(event->pos()).x() / m_scale;
- m_dragItem->setFadeIn(pos - m_dragItem->startPos(), m_scale);
+ m_dragItem->setFadeIn(pos - m_dragItem->startPos().frames(m_document->fps()), m_scale);
} else if (m_operationMode == FADEOUT) {
int pos = mapToScene(event->pos()).x() / m_scale;
- m_dragItem->setFadeOut(m_dragItem->endPos() - pos, m_scale);
+ m_dragItem->setFadeOut(m_dragItem->endPos().frames(m_document->fps()) - pos, m_scale);
}
if (m_animation) delete m_animation;
QList<QGraphicsItem *> itemList = items(event->pos());
int i = 0;
- QGraphicsItem *item = NULL;
+ QGraphicsRectItem *item = NULL;
for (int i = 0; i < itemList.count(); i++) {
- if (itemList.at(i)->type() == 70000) {
- item = itemList.at(i);
+ if (itemList.at(i)->type() == AVWIDGET || itemList.at(i)->type() == TRANSITIONWIDGET) {
+ item = (QGraphicsRectItem*) itemList.at(i);
break;
}
}
if (item && event->buttons() == Qt::NoButton) {
- ClipItem *clip = (ClipItem*) item;
+ AbstractClipItem *clip = (AbstractClipItem*) item;
+ OPERATIONTYPE opMode = opMode = clip->operationMode(mapToScene(event->pos()), m_scale);
double size = 8;
- OPERATIONTYPE opMode = clip->operationMode(mapToScene(event->pos()), m_scale);
+
if (opMode == m_moveOpMode) {
QGraphicsView::mouseMoveEvent(event);
return;
if (opMode == MOVE) {
setCursor(Qt::OpenHandCursor);
} else if (opMode == RESIZESTART) {
+ setCursor(KCursor("left_side", Qt::SizeHorCursor));
kDebug() << "******** RESIZE CLIP START; WIDTH: " << size;
if (m_visualTip == NULL) {
QPolygon polygon;
scene()->addItem(m_visualTip);
m_animationTimer->start();
}
- setCursor(Qt::SizeHorCursor);
} else if (opMode == RESIZEEND) {
+ setCursor(KCursor("right_side", Qt::SizeHorCursor));
if (m_visualTip == NULL) {
QPolygon polygon;
polygon << QPoint(clip->rect().x() + clip->rect().width(), clip->rect().y() + clip->rect().height() / 2 - size * 2);
scene()->addItem(m_visualTip);
m_animationTimer->start();
}
- setCursor(Qt::SizeHorCursor);
} else if (opMode == FADEIN) {
if (m_visualTip == NULL) {
m_visualTip = new QGraphicsEllipseItem(clip->rect().x() + clip->fadeIn() * m_scale - size, clip->rect().y() - 8, size * 2, 16);
}
} else {
m_moveOpMode = NONE;
- if (event->buttons() != Qt::NoButton) {
- setCursorPos((int) mapToScene(event->pos().x(), 0).x());
+ if (event->buttons() != Qt::NoButton && event->modifiers() == Qt::NoModifier) {
+ setCursorPos((int) mapToScene(event->pos().x(), 0).x() / m_scale);
}
if (m_visualTip) {
if (m_animation) delete m_animation;
// virtual
void CustomTrackView::mousePressEvent(QMouseEvent * event) {
+ activateMonitor();
int pos = event->x();
if (event->modifiers() == Qt::ControlModifier) {
setDragMode(QGraphicsView::ScrollHandDrag);
QList<QGraphicsItem *> collisionList = items(event->pos());
for (int i = 0; i < collisionList.size(); ++i) {
QGraphicsItem *item = collisionList.at(i);
- if (item->type() == 70000) {
+ if (item->type() == AVWIDGET || item->type() == TRANSITIONWIDGET) {
// select item
if (!item->isSelected()) {
QList<QGraphicsItem *> itemList = items();
item->setSelected(true);
update();
}
- m_dragItem = (ClipItem *) item;
- emit clipItemSelected(m_dragItem);
- m_clickPoint = mapToScene(event->pos()).x() - m_dragItem->startPos() * m_scale;
+
+ m_dragItem = (AbstractClipItem *) item;
+ if (item->type() == AVWIDGET) {
+ emit clipItemSelected((ClipItem*) m_dragItem);
+ }
+ m_clickPoint = mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps()) * m_scale;
m_operationMode = m_dragItem->operationMode(item->mapFromScene(mapToScene(event->pos())), m_scale);
+ if (m_operationMode == MOVE) setCursor(Qt::ClosedHandCursor);
if (m_operationMode == MOVE || m_operationMode == RESIZESTART)
- m_startPos = QPointF(m_dragItem->startPos(), m_dragItem->track());
+ m_startPos = QPointF(m_dragItem->startPos().frames(m_document->fps()), m_dragItem->track());
else if (m_operationMode == RESIZEEND)
- m_startPos = QPointF(m_dragItem->endPos(), m_dragItem->track());
+ m_startPos = QPointF(m_dragItem->endPos().frames(m_document->fps()), m_dragItem->track());
+ else if (m_operationMode == TRANSITIONSTART) {
+ Transition *tr = new Transition(
+ QRect(m_dragItem->startPos().frames(m_document->fps()) *m_scale , m_dragItem->rect().height() / 2,
+ GenTime(2.5).frames(m_document->fps()) *m_scale , m_dragItem->rect().height()
+ ),
+ (ClipItem*)m_dragItem, LUMA_TRANSITION, m_dragItem->startPos(), m_dragItem->startPos() + GenTime(2.5), m_document->fps());
+ tr->setTrack(m_dragItem->track());
+ scene()->addItem(tr);
+ //m_dragItem->addTransition(tra);
+ }
+
kDebug() << "//////// ITEM CLICKED: " << m_startPos;
collision = true;
break;
for (int i = 0; i < itemList.count(); i++)
itemList.at(i)->setSelected(false);
emit clipItemSelected(NULL);
- setCursorPos((int) mapToScene(event->x(), 0).x());
+ setCursorPos((int) mapToScene(event->x(), 0).x() / m_scale);
}
}
updateSnapPoints(m_dragItem);
//QGraphicsView::mousePressEvent(event);
}
+void CustomTrackView::activateMonitor() {
+ emit activateDocumentMonitor();
+}
+
void CustomTrackView::dragEnterEvent(QDragEnterEvent * event) {
if (event->mimeData()->hasFormat("kdenlive/producerslist")) {
kDebug() << "/////////////// DRAG ENTERED, TEXT: " << event->mimeData()->data("kdenlive/producerslist");
void CustomTrackView::slotRefreshEffects(ClipItem *clip) {
int track = m_tracksCount - clip->track();
- GenTime pos = GenTime(clip->startPos(), m_document->fps());
+ GenTime pos = clip->startPos();
m_document->renderer()->mltRemoveEffect(track, pos, "-1", false);
for (int i = 0; i < clip->effectsCount(); i++) {
m_document->renderer()->mltAddEffect(track, pos, clip->getEffectArgs(clip->effectAt(i)), false);
}
kDebug() << "// REQUESTING EFFECT ON CLIP: " << pos.frames(25) << ", TRK: " << track;
for (int i = 0; i < itemList.count(); i++) {
- if (itemList.at(i)->type() == 70000 && (itemList.at(i)->isSelected() || track != -1)) {
+ if (itemList.at(i)->type() == AVWIDGET && (itemList.at(i)->isSelected() || track != -1)) {
ClipItem *item = (ClipItem *)itemList.at(i);
// the kdenlive_ix int is used to identify an effect in mlt's playlist, should
// not be changed
if (effect.attribute("kdenlive_ix").toInt() == 0)
effect.setAttribute("kdenlive_ix", QString::number(item->effectsCounter()));
- AddEffectCommand *command = new AddEffectCommand(this, m_tracksCount - item->track(), GenTime(item->startPos(), m_document->fps()), effect, true);
+ AddEffectCommand *command = new AddEffectCommand(this, m_tracksCount - item->track(), item->startPos(), effect, true);
m_commandStack->push(command);
}
}
+ m_document->setModified(true);
}
void CustomTrackView::slotDeleteEffect(ClipItem *clip, QDomElement effect) {
- AddEffectCommand *command = new AddEffectCommand(this, m_tracksCount - clip->track(), GenTime(clip->startPos(), m_document->fps()), effect, false);
+ AddEffectCommand *command = new AddEffectCommand(this, m_tracksCount - clip->track(), clip->startPos(), effect, false);
m_commandStack->push(command);
+ m_document->setModified(true);
}
void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement effect) {
if (effectParams["disabled"] == "1") {
QString index = effectParams["kdenlive_ix"];
m_document->renderer()->mltRemoveEffect(track, pos, index);
- } else m_document->renderer()->mltEditEffect(m_tracksCount - clip->track(), GenTime(clip->startPos(), m_document->fps()), effectParams);
+ } else m_document->renderer()->mltEditEffect(m_tracksCount - clip->track(), clip->startPos(), effectParams);
}
+ m_document->setModified(true);
}
void CustomTrackView::slotChangeEffectState(ClipItem *clip, QDomElement effect, bool disable) {
QDomElement oldEffect = effect.cloneNode().toElement();
effect.setAttribute("disabled", disable);
- EditEffectCommand *command = new EditEffectCommand(this, m_tracksCount - clip->track(), GenTime(clip->startPos(), m_document->fps()), oldEffect, effect, true);
+ EditEffectCommand *command = new EditEffectCommand(this, m_tracksCount - clip->track(), clip->startPos(), oldEffect, effect, true);
m_commandStack->push(command);
+ m_document->setModified(true);
}
void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect) {
- EditEffectCommand *command = new EditEffectCommand(this, m_tracksCount - clip->track(), GenTime(clip->startPos(), m_document->fps()), oldeffect, effect, true);
+ EditEffectCommand *command = new EditEffectCommand(this, m_tracksCount - clip->track(), clip->startPos(), oldeffect, effect, true);
m_commandStack->push(command);
}
void CustomTrackView::addItem(DocClipBase *clip, QPoint pos) {
int in = 0;
- int out = clip->duration().frames(m_document->fps());
+ GenTime out = clip->duration();
//kdDebug()<<"- - - -CREATING CLIP, duration = "<<out<<", URL: "<<clip->fileURL();
int trackTop = ((int) mapToScene(pos).y() / 50) * 50 + 1;
- m_dropItem = new ClipItem(clip, ((int) mapToScene(pos).y() / 50), in, QRectF(mapToScene(pos).x() * m_scale, trackTop, out * m_scale, 49), out);
+ m_dropItem = new ClipItem(clip, ((int) mapToScene(pos).y() / 50), GenTime(), QRectF(mapToScene(pos).x() * m_scale, trackTop, out.frames(m_document->fps()) * m_scale, 49), out, m_document->fps());
scene()->addItem(m_dropItem);
}
m_dropItem->baseClip()->addReference();
m_document->updateClip(m_dropItem->baseClip()->getId());
// kDebug()<<"IIIIIIIIIIIIIIIIIIIIIIII TRAX CNT: "<<m_tracksCount<<", DROP: "<<m_dropItem->track();
- m_document->renderer()->mltInsertClip(m_tracksCount - m_dropItem->track(), GenTime(m_dropItem->startPos(), m_document->fps()), m_dropItem->xml());
+ m_document->renderer()->mltInsertClip(m_tracksCount - m_dropItem->track(), m_dropItem->startPos(), m_dropItem->xml());
+ m_document->setModified(true);
} else QGraphicsView::dropEvent(event);
m_dropItem = NULL;
}
scene()->setSceneRect(0, 0, (m_projectDuration + 500) * m_scale, scene()->sceneRect().height()); //50 * m_tracksCount);
}
+int CustomTrackView::duration() const {
+ return m_projectDuration;
+}
void CustomTrackView::addTrack() {
m_tracksCount++;
void CustomTrackView::deleteClip(int clipId) {
QList<QGraphicsItem *> itemList = items();
for (int i = 0; i < itemList.count(); i++) {
- if (itemList.at(i)->type() == 70000) {
+ if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *item = (ClipItem *)itemList.at(i);
if (item->clipProducer() == clipId) {
AddTimelineClipCommand *command = new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->track(), item->startPos(), item->rect(), item->duration(), true, true);
}
void CustomTrackView::setCursorPos(int pos, bool seek) {
- emit cursorMoved(m_cursorPos, pos);
+ emit cursorMoved(m_cursorPos * m_scale, pos * m_scale);
m_cursorPos = pos;
- m_cursorLine->setPos(pos, 0);
- int frame = pos / m_scale;
- if (seek) m_document->renderer()->seek(GenTime(frame, m_document->fps()));
+ m_cursorLine->setPos(pos * m_scale, 0);
+ if (seek) m_document->renderer()->seek(GenTime(pos, m_document->fps()));
else if (m_autoScroll && m_scale < 50) checkScrolling();
}
+void CustomTrackView::updateCursorPos() {
+ m_cursorLine->setPos(m_cursorPos * m_scale, 0);
+}
+
int CustomTrackView::cursorPos() {
- return m_cursorPos;
+ return m_cursorPos * m_scale;
}
void CustomTrackView::checkScrolling() {
int delta = rectInView.width() / 3;
int max = rectInView.right() + horizontalScrollBar()->value() - delta;
//kDebug() << "CURSOR POS: "<<m_cursorPos<< "Scale: "<<m_scale;
- if (m_cursorPos >= max) horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 1 + m_scale);
+ if (m_cursorPos * m_scale >= max) horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 1 + m_scale);
}
void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
QGraphicsView::mouseReleaseEvent(event);
setDragMode(QGraphicsView::NoDrag);
if (m_dragItem == NULL) return;
- //kDebug()<<"/// MOVING CLIP: "<<m_startPos<<", END: "<<QPoint(m_dragItem->rect().x(),m_dragItem->rect().y());
- if (m_operationMode == MOVE && m_startPos.x() != m_dragItem->startPos()) {
+ if (m_operationMode == MOVE) setCursor(Qt::OpenHandCursor);
+ if (m_operationMode == MOVE && m_startPos.x() != m_dragItem->startPos().frames(m_document->fps())) {
// move clip
- MoveClipCommand *command = new MoveClipCommand(this, m_startPos, QPointF(m_dragItem->startPos(), m_dragItem->track()), false);
+ MoveClipCommand *command = new MoveClipCommand(this, m_startPos, QPointF(m_dragItem->startPos().frames(m_document->fps()), m_dragItem->track()), false);
m_commandStack->push(command);
- m_document->renderer()->mltMoveClip(m_tracksCount - m_startPos.y(), m_tracksCount - m_dragItem->track(), m_startPos.x(), m_dragItem->startPos());
+ m_document->renderer()->mltMoveClip(m_tracksCount - m_startPos.y(), m_tracksCount - m_dragItem->track(), m_startPos.x(), m_dragItem->startPos().frames(m_document->fps()));
} else if (m_operationMode == RESIZESTART) {
// resize start
- ResizeClipCommand *command = new ResizeClipCommand(this, m_startPos, QPointF(m_dragItem->startPos(), m_dragItem->track()), true, false);
+ ResizeClipCommand *command = new ResizeClipCommand(this, m_startPos, QPointF(m_dragItem->startPos().frames(m_document->fps()), m_dragItem->track()), true, false);
- m_document->renderer()->mltResizeClipStart(m_tracksCount - m_dragItem->track(), GenTime(m_dragItem->endPos(), m_document->fps()), GenTime(m_dragItem->startPos(), m_document->fps()), GenTime(m_startPos.x(), m_document->fps()), GenTime(m_dragItem->cropStart(), m_document->fps()), GenTime(m_dragItem->cropStart(), m_document->fps()) + GenTime(m_dragItem->endPos(), m_document->fps()) - GenTime(m_dragItem->startPos(), m_document->fps()));
+ m_document->renderer()->mltResizeClipStart(m_tracksCount - m_dragItem->track(), m_dragItem->endPos(), m_dragItem->startPos(), GenTime(m_startPos.x(), m_document->fps()), m_dragItem->cropStart(), m_dragItem->cropStart() + m_dragItem->endPos() - m_dragItem->startPos());
m_commandStack->push(command);
m_document->renderer()->doRefresh();
} else if (m_operationMode == RESIZEEND) {
// resize end
- ResizeClipCommand *command = new ResizeClipCommand(this, m_startPos, QPointF(m_dragItem->endPos(), m_dragItem->track()), false, false);
+ ResizeClipCommand *command = new ResizeClipCommand(this, m_startPos, QPointF(m_dragItem->endPos().frames(m_document->fps()), m_dragItem->track()), false, false);
- m_document->renderer()->mltResizeClipEnd(m_tracksCount - m_dragItem->track(), GenTime(m_dragItem->startPos(), m_document->fps()), GenTime(m_dragItem->cropStart(), m_document->fps()), GenTime(m_dragItem->cropStart(), m_document->fps()) + GenTime(m_dragItem->endPos(), m_document->fps()) - GenTime(m_dragItem->startPos(), m_document->fps()));
+ m_document->renderer()->mltResizeClipEnd(m_tracksCount - m_dragItem->track(), m_dragItem->startPos(), m_dragItem->cropStart(), m_dragItem->cropStart() + m_dragItem->endPos() - m_dragItem->startPos());
m_commandStack->push(command);
m_document->renderer()->doRefresh();
}
+ m_document->setModified(true);
m_operationMode = NONE;
m_dragItem = NULL;
}
-void CustomTrackView::deleteClip(int track, int startpos, const QRectF &rect) {
+void CustomTrackView::deleteClip(int track, GenTime startpos, const QRectF &rect) {
ClipItem *item = getClipItemAt(startpos, track);
if (!item) {
kDebug() << "---------------- ERROR, CANNOT find clip to move at: " << rect.x();
item->baseClip()->removeReference();
m_document->updateClip(item->baseClip()->getId());
delete item;
- m_document->renderer()->mltRemoveClip(m_tracksCount - track, GenTime(startpos, m_document->fps()));
+ m_document->renderer()->mltRemoveClip(m_tracksCount - track, startpos);
m_document->renderer()->doRefresh();
}
-void CustomTrackView::addClip(QDomElement xml, int clipId, int track, int startpos, const QRectF &rect, int duration) {
- QRect r(startpos * m_scale, 50 * track, duration * m_scale, 49);
+void CustomTrackView::addClip(QDomElement xml, int clipId, int track, GenTime startpos, const QRectF &rect, GenTime duration) {
+ QRect r(startpos.frames(m_document->fps()) * m_scale, 50 * track, duration.frames(m_document->fps()) * m_scale, 49);
DocClipBase *baseclip = m_document->clipManager()->getClipById(clipId);
- ClipItem *item = new ClipItem(baseclip, track, startpos, r, duration);
+ ClipItem *item = new ClipItem(baseclip, track, startpos, r, duration, m_document->fps());
scene()->addItem(item);
baseclip->addReference();
m_document->updateClip(baseclip->getId());
- m_document->renderer()->mltInsertClip(m_tracksCount - track, GenTime(startpos, m_document->fps()), xml);
+ m_document->renderer()->mltInsertClip(m_tracksCount - track, startpos, xml);
m_document->renderer()->doRefresh();
}
return (ClipItem *) scene()->itemAt(pos * m_scale, track * 50 + 25);
}
+ClipItem *CustomTrackView::getClipItemAt(GenTime pos, int track) {
+ return (ClipItem *) scene()->itemAt(pos.frames(m_document->fps()) * m_scale, track * 50 + 25);
+}
+
void CustomTrackView::moveClip(const QPointF &startPos, const QPointF &endPos) {
ClipItem *item = getClipItemAt(startPos.x() + 1, startPos.y());
if (!item) {
}
qreal diff = endPos.x() - startPos.x();
if (resizeClipStart) {
- m_document->renderer()->mltResizeClipStart(m_tracksCount - item->track(), GenTime(item->endPos(), m_document->fps()), GenTime(endPos.x(), m_document->fps()), GenTime(item->startPos(), m_document->fps()), GenTime(item->cropStart() + diff, m_document->fps()), GenTime(item->cropStart() + diff, m_document->fps()) + GenTime(item->endPos(), m_document->fps()) - GenTime(endPos.x(), m_document->fps()));
+ m_document->renderer()->mltResizeClipStart(m_tracksCount - item->track(), item->endPos(), GenTime(endPos.x(), m_document->fps()), item->startPos(), item->cropStart() + GenTime(diff, m_document->fps()), item->cropStart() + GenTime(diff, m_document->fps()) + item->endPos() - GenTime(endPos.x(), m_document->fps()));
item->resizeStart(endPos.x(), m_scale);
} else {
- m_document->renderer()->mltResizeClipEnd(m_tracksCount - item->track(), GenTime(item->startPos(), m_document->fps()), GenTime(item->cropStart(), m_document->fps()), GenTime(item->cropStart(), m_document->fps()) + GenTime(endPos.x(), m_document->fps()) - GenTime(item->startPos(), m_document->fps()));
+ m_document->renderer()->mltResizeClipEnd(m_tracksCount - item->track(), item->startPos(), item->cropStart(), item->cropStart() + GenTime(endPos.x(), m_document->fps()) - item->startPos());
item->resizeEnd(endPos.x(), m_scale);
}
m_document->renderer()->doRefresh();
double CustomTrackView::getSnapPointForPos(double pos) {
for (int i = 0; i < m_snapPoints.size(); ++i) {
- //kDebug()<<"SNAP POINT: "<<m_snapPoints.at(i);
- if (abs(pos - m_snapPoints.at(i) * m_scale) < 6 * m_scale) {
+ if (abs(pos - m_snapPoints.at(i).frames(m_document->fps()) * m_scale) < 10) {
//kDebug()<<" FOUND SNAP POINT AT: "<<m_snapPoints.at(i)<<", current pos: "<<pos / m_scale;
- return m_snapPoints.at(i) * m_scale + 0.5;
+ return m_snapPoints.at(i).frames(m_document->fps()) * m_scale + 0.5;
}
- if (m_snapPoints.at(i) > pos) break;
+ if (m_snapPoints.at(i).frames(m_document->fps() * m_scale) > pos) break;
}
return pos;
}
-void CustomTrackView::updateSnapPoints(ClipItem *selected) {
+void CustomTrackView::updateSnapPoints(AbstractClipItem *selected) {
m_snapPoints.clear();
- int offset = 0;
+ GenTime offset;
if (selected) offset = selected->duration();
QList<QGraphicsItem *> itemList = items();
for (int i = 0; i < itemList.count(); i++) {
- if (itemList.at(i)->type() == 70000 && itemList.at(i) != selected) {
+ if (itemList.at(i)->type() == AVWIDGET && itemList.at(i) != selected) {
ClipItem *item = (ClipItem *)itemList.at(i);
- int start = item->startPos();
- int fadein = item->fadeIn() + start;
- int end = item->endPos();
- int fadeout = end - item->fadeOut();
+ GenTime start = item->startPos();
+ GenTime end = item->endPos();
m_snapPoints.append(start);
- if (fadein != start) m_snapPoints.append(fadein);
m_snapPoints.append(end);
- if (fadeout != end) m_snapPoints.append(fadeout);
- if (offset != 0) {
- m_snapPoints.append(start - offset);
- if (fadein != start) m_snapPoints.append(fadein - offset);
- m_snapPoints.append(end - offset);
- if (fadeout != end) m_snapPoints.append(fadeout - offset);
+ if (offset != GenTime()) {
+ if (start > offset) m_snapPoints.append(start - offset);
+ if (end > offset) m_snapPoints.append(end - offset);
}
}
}
- kDebug() << " GOT SNAPPOINTS TOTAL: " << m_snapPoints.count();
qSort(m_snapPoints);
- for (int i = 0; i < m_snapPoints.size(); ++i)
- kDebug() << "SNAP POINT: " << m_snapPoints.at(i);
+ //for (int i = 0; i < m_snapPoints.size(); ++i)
+ // kDebug() << "SNAP POINT: " << m_snapPoints.at(i).frames(25);
}
void CustomTrackView::setScale(double scaleFactor) {
//scale(scaleFactor, scaleFactor);
+ double pos = cursorPos() / m_scale;
m_scale = scaleFactor;
kDebug() << " HHHHHHHH SCALING: " << m_scale;
QList<QGraphicsItem *> itemList = items();
- scene()->setSceneRect(0, 0, (m_projectDuration + 500) * m_scale, scene()->sceneRect().height()); //50 *
for (int i = 0; i < itemList.count(); i++) {
- if (itemList.at(i)->type() == 70000) {
- ClipItem *clip = (ClipItem *)itemList.at(i);
- clip->setRect(clip->startPos() * m_scale, clip->rect().y(), clip->duration() * m_scale, clip->rect().height());
+ if (itemList.at(i)->type() == AVWIDGET || itemList.at(i)->type() == TRANSITIONWIDGET) {
+ AbstractClipItem *clip = (AbstractClipItem *)itemList.at(i);
+ clip->setRect(clip->startPos().frames(m_document->fps()) * m_scale, clip->rect().y(), clip->duration().frames(m_document->fps()) * m_scale, clip->rect().height());
}
- /*else if (itemList.at(i)->type() == 70001) {
- LabelItem *label = (LabelItem *)itemList.at(i);
- QGraphicsItem *parent = label->parentItem();
- QRectF r = label->boundingRect();
- QRectF p = parent->boundingRect();
- label->setPos(p.x() + p.width() / 2 - r.width() / 2, p.y() + p.height() / 2 - r.height() / 2);
- //label->setRect(clip->startPos() * m_scale, clip->rect().y(), clip->duration() * m_scale, clip->rect().height());
- }*/
}
+ updateCursorPos();
+ centerOn(QPointF(cursorPos(), 50));
+ scene()->setSceneRect(0, 0, (m_projectDuration + 500) * m_scale, scene()->sceneRect().height());
}
void CustomTrackView::drawBackground(QPainter * painter, const QRectF & rect) {
painter->drawLine(rectInView.left(), 0, rectInView.right(), 0);
for (uint i = 0; i < m_tracksCount;i++) {
painter->drawLine(rectInView.left(), 50 * (i + 1), rectInView.right(), 50 * (i + 1));
- painter->drawText(QRectF(10, 50 * i, 100, 50 * i + 49), Qt::AlignLeft, i18n(" Track ") + QString::number(i + 1));
+ //painter->drawText(QRectF(10, 50 * i, 100, 50 * i + 49), Qt::AlignLeft, i18n(" Track ") + QString::number(i + 1));
}
int lowerLimit = 50 * m_tracksCount + 1;
if (height() > lowerLimit)