QRectF r(children.at(i)->sceneBoundingRect());
r.translate(offset);
path.addRect(r);
+ } else if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ if (subchildren.at(j)->type() == AVWIDGET) {
+ QRectF r(subchildren.at(j)->sceneBoundingRect());
+ r.translate(offset);
+ path.addRect(r);
+ }
+ }
}
}
return path;
QRectF r(children.at(i)->sceneBoundingRect());
r.translate(offset);
path.addRect(r);
+ } else if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ if (subchildren.at(j)->type() == TRANSITIONWIDGET) {
+ QRectF r(subchildren.at(j)->sceneBoundingRect());
+ r.translate(offset);
+ path.addRect(r);
+ }
+ }
}
}
return path;
const int trackHeight = KdenliveSettings::trackheight();
QPointF start = sceneBoundingRect().topLeft();
QPointF newPos = value.toPointF();
- //kDebug()<<"REAL:"<<start.x()<<", PROPOSED:"<<(int)(start.x() - pos().x() + newPos.x());
int xpos = projectScene()->getSnapPointForPos((int)(start.x() + newPos.x() - pos().x()), KdenliveSettings::snaptopoints());
xpos = qMax(xpos, 0);
return QPointF(pos().x() - start.x(), pos().y());
}*/
- QList<QGraphicsItem*> collindingItems;
+ QList<QGraphicsItem*> collidingItems;
QPainterPath shape;
if (projectScene()->editMode() == NORMALEDIT) {
shape = clipGroupShape(newPos - pos());
- collindingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems.removeAll(this);
for (int i = 0; i < children.count(); i++) {
- collindingItems.removeAll(children.at(i));
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
+ collidingItems.removeAll(children.at(i));
}
}
- if (!collindingItems.isEmpty()) {
+ if (!collidingItems.isEmpty()) {
bool forwardMove = xpos > start.x();
int offset = 0;
- for (int i = 0; i < collindingItems.count(); i++) {
- QGraphicsItem *collision = collindingItems.at(i);
+ for (int i = 0; i < collidingItems.count(); i++) {
+ QGraphicsItem *collision = collidingItems.at(i);
if (collision->type() == AVWIDGET) {
// Collision
if (newPos.y() != pos().y()) {
newPos.setX(newPos.x() + offset);
}
// If there is still a collision after our position adjust, restore original pos
- collindingItems = scene()->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape);
+ collidingItems = scene()->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape);
+ collidingItems.removeAll(this);
for (int i = 0; i < children.count(); i++) {
- collindingItems.removeAll(children.at(i));
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
+ collidingItems.removeAll(children.at(i));
}
- for (int i = 0; i < collindingItems.count(); i++)
- if (collindingItems.at(i)->type() == AVWIDGET) return pos();
+ for (int i = 0; i < collidingItems.count(); i++)
+ if (collidingItems.at(i)->type() == AVWIDGET) return pos();
}
}
if (projectScene()->editMode() == NORMALEDIT) {
shape = transitionGroupShape(newPos - pos());
- collindingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems.removeAll(this);
for (int i = 0; i < children.count(); i++) {
- collindingItems.removeAll(children.at(i));
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
+ collidingItems.removeAll(children.at(i));
}
}
- if (collindingItems.isEmpty()) return newPos;
+ if (collidingItems.isEmpty()) return newPos;
else {
bool forwardMove = xpos > start.x();
int offset = 0;
- for (int i = 0; i < collindingItems.count(); i++) {
- QGraphicsItem *collision = collindingItems.at(i);
+ for (int i = 0; i < collidingItems.count(); i++) {
+ QGraphicsItem *collision = collidingItems.at(i);
if (collision->type() == TRANSITIONWIDGET) {
// Collision
if (newPos.y() != pos().y()) {
newPos.setX(newPos.x() + offset);
}
// If there is still a collision after our position adjust, restore original pos
- collindingItems = scene()->items(transitionGroupShape(newPos - pos()), Qt::IntersectsItemShape);
+ collidingItems = scene()->items(transitionGroupShape(newPos - pos()), Qt::IntersectsItemShape);
for (int i = 0; i < children.count(); i++) {
- collindingItems.removeAll(children.at(i));
+ collidingItems.removeAll(children.at(i));
}
- for (int i = 0; i < collindingItems.count(); i++)
- if (collindingItems.at(i)->type() == TRANSITIONWIDGET) return pos();
+ for (int i = 0; i < collidingItems.count(); i++)
+ if (collidingItems.at(i)->type() == TRANSITIONWIDGET) return pos();
}
}
return newPos;
// spacer tool
snappedPos = getSnapPointForPos(mappedXPos + m_spacerOffset);
if (snappedPos < 0) snappedPos = 0;
+
// Make sure there is no collision
QList<QGraphicsItem *> children = m_selectionGroup->childItems();
QPainterPath shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
QList<QGraphicsItem*> collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(m_selectionGroup);
for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
collidingItems.removeAll(children.at(i));
}
bool collision = false;
+ int offset = 0;
+ for (int i = 0; i < collidingItems.count(); i++) {
+ if (!collidingItems.at(i)->isEnabled()) continue;
+ if (collidingItems.at(i)->type() == AVWIDGET && snappedPos < m_selectionGroup->sceneBoundingRect().left()) {
+ AbstractClipItem *item = static_cast <AbstractClipItem *>(collidingItems.at(i));
+ // Moving backward, determine best pos
+ QPainterPath clipPath;
+ clipPath.addRect(item->sceneBoundingRect());
+ QPainterPath res = shape.intersected(clipPath);
+ offset = qMax(offset, (int)(res.boundingRect().width() + 0.5));
+ }
+ }
+ snappedPos += offset;
+ // make sure we have no collision
+ shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
+ collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems.removeAll(m_selectionGroup);
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
+ collidingItems.removeAll(children.at(i));
+ }
+
for (int i = 0; i < collidingItems.count(); i++) {
if (!collidingItems.at(i)->isEnabled()) continue;
if (collidingItems.at(i)->type() == AVWIDGET) {
break;
}
}
+
+
if (!collision) {
// Check transitions
shape = m_selectionGroup->transitionGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
collidingItems.removeAll(m_selectionGroup);
for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
+ collidingItems.removeAll(children.at(i));
+ }
+ offset = 0;
+
+ for (int i = 0; i < collidingItems.count(); i++) {
+ if (collidingItems.at(i)->type() == TRANSITIONWIDGET && snappedPos < m_selectionGroup->sceneBoundingRect().left()) {
+ AbstractClipItem *item = static_cast <AbstractClipItem *>(collidingItems.at(i));
+ // Moving backward, determine best pos
+ QPainterPath clipPath;
+ clipPath.addRect(item->sceneBoundingRect());
+ QPainterPath res = shape.intersected(clipPath);
+ offset = qMax(offset, (int)(res.boundingRect().width() + 0.5));
+ }
+ }
+
+ snappedPos += offset;
+ // make sure we have no collision
+ shape = m_selectionGroup->transitionGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
+ collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
+ collidingItems.removeAll(m_selectionGroup);
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == GROUPWIDGET) {
+ QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+ for (int j = 0; j < subchildren.count(); j++) {
+ collidingItems.removeAll(subchildren.at(j));
+ }
+ }
collidingItems.removeAll(children.at(i));
}
for (int i = 0; i < collidingItems.count(); i++) {
kDebug() << "SELELCTING ELEMENTS WITHIN =" << event->pos().x() << "/" << 1 << ", " << mapFromScene(sceneRect().width(), 0).x() - event->pos().x() << "/" << sceneRect().height();
}
+ QList <GenTime> offsetList;
// create group to hold selected items
m_selectionGroup = new AbstractGroupItem(m_document->fps());
scene()->addItem(m_selectionGroup);
- QList <GenTime> offsetList;
+
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET)) {
AbstractClipItem *item = static_cast<AbstractClipItem *>(selection.at(i));
offsetList.append(item->endPos());
m_selectionGroup->addToGroup(selection.at(i));
selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- } else if (selection.at(i)->parentItem() == 0 && selection.at(i)->type() == GROUPWIDGET) {
+ } else if (/*selection.at(i)->parentItem() == 0 && */selection.at(i)->type() == GROUPWIDGET) {
if (static_cast<AbstractGroupItem *>(selection.at(i))->isItemLocked()) continue;
QList<QGraphicsItem *> children = selection.at(i)->childItems();
for (int j = 0; j < children.count(); j++) {
}
m_selectionGroup->addToGroup(selection.at(i));
selection.at(i)->setFlag(QGraphicsItem::ItemIsMovable, false);
- } else if (selection.at(i)->parentItem()) {
+ } else if (selection.at(i)->parentItem() && !selection.contains(selection.at(i)->parentItem())) {
if (static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())->isItemLocked()) continue;
+ AbstractGroupItem *grp = static_cast<AbstractGroupItem *>(selection.at(i)->parentItem());
m_selectionGroup->addToGroup(selection.at(i)->parentItem());
selection.at(i)->parentItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
}