} else if (m_operationMode == SPACER && move) {
// spacer tool
int mappedClick = (int)(mapToScene(m_clickEvent).x() + 0.5);
- if (mappedXPos > mappedClick)
- m_selectionGroup->setPos(mappedXPos + (m_spacerStart - mappedClick) , m_selectionGroup->pos().y());
+ m_selectionGroup->setPos(mappedXPos + (m_spacerStart - mappedClick) , m_selectionGroup->pos().y());
}
}
if (!add) diff = -diff;
QList<QGraphicsItem *> itemList;
if (track == -1) itemList = items();
- else itemList = scene()->items(pos.frames(m_document->fps()) , track * m_tracksHeight + m_tracksHeight / 2, sceneRect().width() - pos.frames(m_document->fps()), m_tracksHeight / 4);
+ else itemList = scene()->items(pos.frames(m_document->fps()) , track * m_tracksHeight + 1, sceneRect().width() - pos.frames(m_document->fps()), m_tracksHeight - 2);
if (m_selectionGroup) {
scene()->destroyItemGroup(m_selectionGroup);
m_selectionGroup = NULL;
m_selectionGroup = NULL;
}
if (track != -1) track = m_scene->m_tracksList.count() - track;
- m_document->renderer()->mltInsertSpace(pos, track, duration, add);
+ if (!add) m_document->renderer()->mltInsertSpace(pos, track, GenTime() - duration);
+ else m_document->renderer()->mltInsertSpace(pos, track, duration);
}
void CustomTrackView::deleteClip(const QString &clipId) {
} else if (m_operationMode == SPACER) {
int endClick = (int)(mapToScene(event->pos()).x() + 0.5);
int mappedClick = (int)(mapToScene(m_clickEvent).x() + 0.5);
- int diff = endClick - mappedClick;
+ int diff = m_selectionGroup->pos().x() - m_spacerStart;//endClick - mappedClick;
+ kDebug() << "// MOVING SPACER DIFF:" << diff;
int track = (int)(mapToScene(m_clickEvent).y() / m_tracksHeight);
+ if (diff < 0) mappedClick += diff;
InsertSpaceCommand *command = new InsertSpaceCommand(this, GenTime(mappedClick, m_document->fps()), track, GenTime(diff, m_document->fps()), false);
m_commandStack->push(command);
track = m_scene->m_tracksList.count() - track;
- m_document->renderer()->mltInsertSpace(GenTime(mappedClick, m_document->fps()), track, GenTime(diff, m_document->fps()), true);
+ m_document->renderer()->mltInsertSpace(GenTime(mappedClick, m_document->fps()), track, GenTime(diff, m_document->fps()));
if (m_selectionGroup) {
scene()->destroyItemGroup(m_selectionGroup);
m_selectionGroup = NULL;
return true;
}
-void Render::mltInsertSpace(const GenTime pos, int track, const GenTime duration, bool add) {
+void Render::mltInsertSpace(const GenTime pos, int track, const GenTime duration) {
if (!m_mltProducer) {
kDebug() << "PLAYLIST NOT INITIALISED //////";
return;
Mlt::Tractor tractor(service);
mlt_service_lock(service.get_service());
int insertPos = pos.frames(m_fps);
- int diff = duration.frames(m_fps) - 1;
+ int diff = duration.frames(m_fps);
if (track != -1) {
// insert space in one track only
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
int clipIndex = trackPlaylist.get_clip_index_at(insertPos);
- if (add) trackPlaylist.insert_blank(clipIndex, duration.frames(m_fps) - 1);
+ if (diff > 0) trackPlaylist.insert_blank(clipIndex, diff - 1);
else {
int position = trackPlaylist.clip_start(clipIndex);
- trackPlaylist.remove_region(position, diff);
+ trackPlaylist.remove_region(position, -diff - 1);
}
// now move transitions
- if (!add) diff = -diff;
mlt_service serv = m_mltProducer->parent().get_service();
mlt_service nextservice = mlt_service_get_producer(serv);
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
Mlt::Producer trackProducer(tractor.track(trackNb - 1));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
int clipIndex = trackPlaylist.get_clip_index_at(insertPos);
- if (add) trackPlaylist.insert_blank(clipIndex, diff);
+ if (diff > 0) trackPlaylist.insert_blank(clipIndex, diff - 1);
else {
int position = trackPlaylist.clip_start(clipIndex);
- trackPlaylist.remove_region(position, diff);
+ trackPlaylist.remove_region(position, -diff - 1);
}
trackNb--;
}
// now move transitions
- if (!add) diff = -diff;
mlt_service serv = m_mltProducer->parent().get_service();
mlt_service nextservice = mlt_service_get_producer(serv);
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
void mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
void mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
void mltCutClip(int track, GenTime position);
- void mltInsertSpace(const GenTime pos, int track, const GenTime duration, bool add);
+ void mltInsertSpace(const GenTime pos, int track, const GenTime duration);
bool mltResizeClipEnd(ItemInfo info, GenTime clipDuration);
bool mltResizeClipStart(ItemInfo info, GenTime diff);
bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart, Mlt::Producer *prod);