From 8191e28c244126b4a6e6eedbf3f56a88ab983825 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 22 Dec 2008 16:54:47 +0000 Subject: [PATCH] Fix several issues with clip move and resize, should solve: http://www.kdenlive.org:80/mantis/view.php?id=362 svn path=/branches/KDE4/; revision=2816 --- src/abstractclipitem.cpp | 4 +++- src/clipitem.cpp | 6 ++++-- src/customtrackview.cpp | 20 +++++++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/abstractclipitem.cpp b/src/abstractclipitem.cpp index 3ec2abf6..427aa0d8 100644 --- a/src/abstractclipitem.cpp +++ b/src/abstractclipitem.cpp @@ -92,14 +92,16 @@ void AbstractClipItem::resizeStart(int posx, double speed) { if (type() == AVWIDGET) m_cropStart += durationDiff * speed; m_cropDuration = m_cropDuration - durationDiff * speed; + setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height()); setPos(m_startPos.frames(m_fps), pos().y()); if (pos().x() != m_startPos.frames(m_fps)) { GenTime diff = GenTime(pos().x(), m_fps) - m_startPos; m_startPos += diff; m_cropDuration = m_cropDuration - diff; if (type() == AVWIDGET) m_cropStart = m_cropStart + diff; + setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height()); } - setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height()); + //kDebug() << "-- NEW CLIP=" << startPos().frames(25) << "-" << endPos().frames(25); //setRect((double) m_startPos.frames(m_fps) * scale, rect().y(), (double) m_cropDuration.frames(m_fps) * scale, rect().height()); diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 16a3ad5f..204e6c28 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -1015,7 +1015,7 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value) // calculate new position. if (group()) return pos(); QPointF newPos = value.toPointF(); - kDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++"; + // kDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++"; int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints()); xpos = qMax(xpos, 0); newPos.setX(xpos); @@ -1034,7 +1034,9 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value) if (items.at(i)->type() == type()) { // Collision! QPointF otherPos = items.at(i)->pos(); - if ((int) otherPos.y() != (int) pos().y()) return pos(); + if ((int) otherPos.y() != (int) pos().y()) { + return pos(); + } if (pos().x() < otherPos.x()) { // move clip just before colliding clip int npos = (static_cast < AbstractClipItem* >(items.at(i))->startPos() - m_cropDuration).frames(m_fps); diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index ea7ae03b..cebd5569 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -141,6 +141,8 @@ void CustomTrackView::checkTrackHeight() { QList itemList = items(); ClipItem *item; Transition *transitionitem; + bool snap = KdenliveSettings::snaptopoints(); + KdenliveSettings::setSnaptopoints(false); for (int i = 0; i < itemList.count(); i++) { if (itemList.at(i)->type() == AVWIDGET) { item = (ClipItem*) itemList.at(i); @@ -163,6 +165,7 @@ void CustomTrackView::checkTrackHeight() { setSceneRect(0, 0, sceneRect().width(), m_tracksHeight * m_document->tracksCount()); // verticalScrollBar()->setMaximum(m_tracksHeight * m_document->tracksCount()); + KdenliveSettings::setSnaptopoints(snap); update(); } @@ -728,6 +731,9 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) { QDomElement transition = MainWindow::transitions.getEffectByName("Luma").cloneNode().toElement(); EffectsList::setParameter(transition, "reverse", "1"); slotAddTransition((ClipItem *) m_dragItem, info, transitiontrack, transition); + } else if ((m_operationMode == RESIZESTART || m_operationMode == RESIZEEND) && m_selectionGroup) { + resetSelectionGroup(false); + m_dragItem->setSelected(true); } m_blockRefresh = false; @@ -762,11 +768,14 @@ void CustomTrackView::groupSelectedItems() { } if (m_selectionGroup) { + bool snap = KdenliveSettings::snaptopoints(); + KdenliveSettings::setSnaptopoints(false); QPointF top = m_selectionGroup->boundingRect().topLeft(); m_selectionGroup->setPos(top); m_selectionGroup->translate(-top.x(), -top.y() + 1); m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps()); m_selectionGroupInfo.track = m_selectionGroup->track(); + KdenliveSettings::setSnaptopoints(snap); } } else resetSelectionGroup(); } @@ -2188,6 +2197,8 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end) { } bool success = m_document->renderer()->mltMoveClip((int)(m_document->tracksCount() - start.track), (int)(m_document->tracksCount() - end.track), (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps()), item->baseClip()->producer(end.track)); if (success) { + bool snap = KdenliveSettings::snaptopoints(); + KdenliveSettings::setSnaptopoints(false); item->setPos((int) end.startPos.frames(m_document->fps()), (int)(end.track * m_tracksHeight + 1)); m_scene->clearSelection(); item->setSelected(true); @@ -2200,6 +2211,7 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end) { tr->setPos((int) end.startPos.frames(m_document->fps()), (int)(end.track * m_tracksHeight + 1)); } } + KdenliveSettings::setSnaptopoints(snap); } else { // undo last move and emit error message emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(end.startPos.frames(m_document->fps()))), ErrorMessage); @@ -2239,6 +2251,9 @@ void CustomTrackView::moveGroup(QList startClip, QList sta QPointF pos = m_selectionGroup->pos(); qreal posx = pos.x() + offset.frames(m_document->fps()); qreal posy = pos.y() + trackOffset * (qreal) m_tracksHeight; + bool snap = KdenliveSettings::snaptopoints(); + KdenliveSettings::setSnaptopoints(false); + m_selectionGroup->setPos(posx, posy); QPointF top = m_selectionGroup->sceneBoundingRect().topLeft(); @@ -2269,6 +2284,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta m_document->renderer()->mltAddTransition(tr->transitionTag(), newTrack, m_document->tracksCount() - info.track, info.startPos, info.endPos, tr->toXML()); } } + KdenliveSettings::setSnaptopoints(snap); } } @@ -2281,7 +2297,8 @@ void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end) { return; } //kDebug() << "----------------  Move TRANSITION FROM: " << startPos.x() << ", END:" << endPos.x() << ",TRACKS: " << oldtrack << " TO " << newtrack; - + bool snap = KdenliveSettings::snaptopoints(); + KdenliveSettings::setSnaptopoints(false); //kDebug()<<"/// RESIZE TRANS START: ("<< startPos.x()<<"x"<< startPos.y()<<") / ("<resizeEnd((int) end.endPos.frames(m_document->fps())); } //item->moveTransition(GenTime((int) (endPos.x() - startPos.x()), m_document->fps())); + KdenliveSettings::setSnaptopoints(snap); item->updateTransitionEndTrack(getPreviousVideoTrack(end.track)); m_document->renderer()->mltMoveTransition(item->transitionTag(), m_document->tracksCount() - start.track, m_document->tracksCount() - end.track, item->transitionEndTrack(), start.startPos, start.endPos, end.startPos, end.endPos); } -- 2.39.2