From 4b5d8f772540812feec69f6d03a860379278912f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 25 Mar 2009 22:02:43 +0000 Subject: [PATCH] Several move & resize fixes svn path=/trunk/kdenlive/; revision=3184 --- src/abstractclipitem.cpp | 7 ++++--- src/abstractgroupitem.cpp | 19 +++++++++++-------- src/clipitem.cpp | 2 +- src/customtrackview.cpp | 34 ++++++++++++++++++++++++++-------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/abstractclipitem.cpp b/src/abstractclipitem.cpp index e889ba53..7636b0a5 100644 --- a/src/abstractclipitem.cpp +++ b/src/abstractclipitem.cpp @@ -85,14 +85,15 @@ void AbstractClipItem::resizeStart(int posx, double speed) { if (m_cropDuration > GenTime(3, m_fps)) durationDiff = GenTime(3, m_fps); else return; } - + //kDebug()<<"// DURATION DIFF: "<getSnapPointForPos((int)(start.x() + newPos.x() - scenePos().x() + 0.5), KdenliveSettings::snaptopoints()); + //kDebug()<<"REAL:"<getSnapPointForPos((int)(start.x() + newPos.x() - pos().x()), KdenliveSettings::snaptopoints()); xpos = qMax(xpos, 0); - newPos.setX((int)(scenePos().x() + xpos - (int) start.x())); + //kDebug()<<"GRP XPOS:"<tracksCount() - (int)(boundingRect().height() + 5) / trackHeight); - newTrack = qMax(newTrack, 0); + int correctedTrack = qMin(realTrack, projectScene()->tracksCount() - (int)(boundingRect().height() + 5) / trackHeight); + correctedTrack = qMax(correctedTrack, 0); + + proposedTrack += (correctedTrack - realTrack); // Check if top item is a clip or a transition int offset = 0; @@ -137,7 +140,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant } } } - newPos.setY((int)((currTrack2) * trackHeight) + offset); + newPos.setY((int)((proposedTrack) * trackHeight) + offset); //if (newPos == start) return start; /*if (newPos.x() < 0) { diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 87927087..773a810a 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -1057,7 +1057,7 @@ void ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionChange && scene()) { // calculate new position. - if (parentItem()) return pos(); + //if (parentItem()) return pos(); QPointF newPos = value.toPointF(); //kDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++"; int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints()); diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 756d2d1b..6bb7d6c2 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -2344,7 +2344,17 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) { } } - + if (m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) { + // Item was resized, rebuild group; + AbstractGroupItem *group = static_cast (m_dragItem->parentItem()); + QList children = group->childItems(); + m_document->clipManager()->removeGroup(group); + scene()->destroyItemGroup(group); + for (int i = 0; i < children.count(); i++) { + children.at(i)->setSelected(true); + } + groupSelectedItems(false, true); + } //m_document->renderer()->doRefresh(); } else if (m_operationMode == RESIZEEND && m_dragItem->endPos() != m_dragItemInfo.endPos) { // resize end @@ -2395,6 +2405,17 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) { m_commandStack->push(command); } } + if (m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) { + // Item was resized, rebuild group; + AbstractGroupItem *group = static_cast (m_dragItem->parentItem()); + QList children = group->childItems(); + m_document->clipManager()->removeGroup(group); + scene()->destroyItemGroup(group); + for (int i = 0; i < children.count(); i++) { + children.at(i)->setSelected(true); + } + groupSelectedItems(false, true); + } //m_document->renderer()->doRefresh(); } else if (m_operationMode == FADEIN) { // resize fade in effect @@ -2626,10 +2647,9 @@ void CustomTrackView::cutSelectedClips() { for (int i = 0; i < itemList.count(); i++) { if (itemList.at(i)->type() == AVWIDGET) { ClipItem *item = static_cast (itemList.at(i)); - if (item->parentItem() && item->parentItem() != m_selectionGroup) { - emit displayMessage(i18n("Cannot cut a clip in a group"), ErrorMessage); - } - else if (currentPos > item->startPos() && currentPos < item->endPos()) { + if (item->parentItem() && item->parentItem() != m_selectionGroup) { + emit displayMessage(i18n("Cannot cut a clip in a group"), ErrorMessage); + } else if (currentPos > item->startPos() && currentPos < item->endPos()) { RazorClipCommand *command = new RazorClipCommand(this, item->info(), currentPos, true); m_commandStack->push(command); } @@ -2797,9 +2817,7 @@ ClipItem *CustomTrackView::getClipItemAtStart(GenTime pos, int track) { } ClipItem *CustomTrackView::getClipItemAt(int pos, int track) { - QPointF p(pos, track * m_tracksHeight + m_tracksHeight / 2); - kDebug() << "LKING POINT:" << p; - QList list = scene()->items(p); + QList list = scene()->items(QPointF(pos, track * m_tracksHeight + m_tracksHeight / 2)); ClipItem *clip = NULL; for (int i = 0; i < list.size(); i++) { if (list.at(i)->type() == AVWIDGET) { -- 2.39.2