]> git.sesse.net Git - kdenlive/commitdiff
Fix several issues with clip move and resize, should solve:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 22 Dec 2008 16:54:47 +0000 (16:54 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 22 Dec 2008 16:54:47 +0000 (16:54 +0000)
http://www.kdenlive.org:80/mantis/view.php?id=362

svn path=/branches/KDE4/; revision=2816

src/abstractclipitem.cpp
src/clipitem.cpp
src/customtrackview.cpp

index 3ec2abf617a506a0e2d1aee00fcd0f5be4477124..427aa0d8bde5cdf330567f28fc228f4ec81e0848 100644 (file)
@@ -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());
index 16a3ad5fbbfd4f0a5c540918692b60089a6a0f0c..204e6c282574c21ccc7c0affbffb33d22144dc18 100644 (file)
@@ -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);
index ea7ae03b853e09a73659bf2700bc40ba3959b0c5..cebd5569a8d55d2c3a9e0de62c2a64b01adf563a 100644 (file)
@@ -141,6 +141,8 @@ void CustomTrackView::checkTrackHeight() {
     QList<QGraphicsItem *> 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 <ItemInfo> startClip, QList <ItemInfo> 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 <ItemInfo> startClip, QList <ItemInfo> 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()<<") / ("<<endPos.x()<<"x"<< endPos.y()<<")";
     if (end.endPos - end.startPos == start.endPos - start.startPos) {
         // Transition was moved
@@ -2299,6 +2316,7 @@ void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end) {
         item->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);
 }