- return pos();
- //TODO: improve movement when collision happens
- /*if (startTrack != newTrack) return pos();
- if (collision->pos().x() > pos().x()) {
- return QPointF(collision->sceneBoundingRect().x() - sceneBoundingRect().width() + pos().x() - start.x() - 1, newPos.y());
- }*/
- }
- }
- return newPos;
- }
-
- //else posx -= startx;
- //posx = qMax(posx, 0);
- //newPos.setX(posx);
- //kDebug()<<"Y POS: "<<start.y() + newPos.y()<<"SCN MP: "<<sc;
- /*int newTrack = (start.y() + newPos.y()) / KdenliveSettings::trackheight();
- int oldTrack = (start.y() + pos().y()) / KdenliveSettings::trackheight();
- newPos.setY((newTrack) * KdenliveSettings::trackheight() - start.y() + 1);*/
-
-
- //if (start.y() + newPos.y() < 1) newTrack = oldTrack;
-
- return newPos;
-
- // Only one clip is moving
-
- QList<QGraphicsItem*> items = scene()->items(sceneShape, Qt::IntersectsItemShape);
-
-
- if (!items.isEmpty()) {
- for (int i = 0; i < items.count(); i++) {
- if (items.at(i)->type() == AVWIDGET) {
- // Collision!
- //kDebug()<<"/// COLLISION WITH ITEM: "<<items.at(i)->sceneBoundingRect();
- return pos();
- QPointF otherPos = items.at(i)->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()).frames(m_fps) - sceneBoundingRect().width();
- newPos.setX(npos);
+ //kDebug()<<"// COLLISION WIT:"<<collision->sceneBoundingRect();
+ if (newPos.y() != start.y()) {
+ // Track change results in collision, restore original position
+ return start;
+ }
+ AbstractClipItem *item = static_cast <AbstractClipItem *>(collision);
+ if (forwardMove) {
+ // Moving forward, determine best pos
+ QPainterPath clipPath;
+ clipPath.addRect(item->sceneBoundingRect());
+ QPainterPath res = shape.intersected(clipPath);
+ offset = qMax(offset, (int)(res.boundingRect().width() + 0.5));