}
void AbstractClipItem::moveTo(int x, double scale, int offset, int newTrack, bool checkCollision) {
- double origX = rect().x();
- double origY = rect().y();
+ qreal origX = pos().x();
+ qreal origY = pos().y();
bool success = true;
if (x < 0) return;
- setRect(x * scale, origY + offset, rect().width(), rect().height());
+ //setRect(x * scale, origY + offset, rect().width(), rect().height());
+ //double xoffset = (x - m_startPos.frames(m_fps)) * scale;// - origX;
+ setPos((qreal) x * scale, (qreal) pos().y() + offset);
+
QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
if (collisionList.size() == 0) m_track = newTrack;
if (checkCollision)
if (x < m_startPos.frames(m_fps)) {
kDebug() << "COLLISION, MOVING TO------";
m_startPos = ((AbstractClipItem *)item)->endPos();
- origX = m_startPos.frames(m_fps) * scale;
+ origX = (qreal) m_startPos.frames(m_fps) * scale;
} else if (x > m_startPos.frames(m_fps)) {
//kDebug() << "COLLISION, MOVING TO+++: "<<x<<", CLIP CURR POS: "<<m_startPos.frames(m_fps)<<", COLLIDING START: "<<((AbstractClipItem *)item)->startPos().frames(m_fps);
m_startPos = ((AbstractClipItem *)item)->startPos() - m_cropDuration;
- origX = m_startPos.frames(m_fps) * scale;
+ origX = (qreal) m_startPos.frames(m_fps) * scale;
}
}
- setRect(origX, origY, rect().width(), rect().height());
+ setPos(origX, origY);
offset = 0;
- origX = rect().x();
success = false;
break;
}
m_track = newTrack;
m_startPos = GenTime(x, m_fps);
}
- /* QList <QGraphicsItem *> childrenList = QGraphicsItem::children();
- for (int i = 0; i < childrenList.size(); ++i) {
- childrenList.at(i)->moveBy(rect().x() - origX , offset);
- }*/
}
GenTime AbstractClipItem::endPos() const {
m_startPos += durationDiff;
if (type() == AVWIDGET) m_cropStart += durationDiff;
m_cropDuration = m_cropDuration - durationDiff;
- setRect(m_startPos.frames(m_fps) * scale, rect().y(), m_cropDuration.frames(m_fps) * scale, rect().height());
- QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
- for (int i = 0; i < collisionList.size(); ++i) {
- QGraphicsItem *item = collisionList.at(i);
- if (item->type() == type()) {
- GenTime diff = ((AbstractClipItem *)item)->endPos() + GenTime(1, m_fps) - m_startPos;
- setRect((m_startPos + diff).frames(m_fps) * scale, rect().y(), (m_cropDuration - diff).frames(m_fps) * scale, rect().height());
- m_startPos += diff;
- if (type() == AVWIDGET) m_cropStart += diff;
- m_cropDuration = m_cropDuration - diff;
- break;
+
+ setRect(0, 0, (qreal) m_cropDuration.frames(m_fps) * scale - .5, rect().height());
+ setPos((qreal) m_startPos.frames(m_fps) * scale, pos().y());
+ //setRect((double) m_startPos.frames(m_fps) * scale, rect().y(), (double) m_cropDuration.frames(m_fps) * scale, rect().height());
+ if (durationDiff < GenTime()) {
+ QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
+ for (int i = 0; i < collisionList.size(); ++i) {
+ QGraphicsItem *item = collisionList.at(i);
+ if (item->type() == type() && item->pos().x() < pos().x()) {
+ kDebug() << "///////// COLLISION DETECTED!!!!!!!!!";
+ GenTime diff = ((AbstractClipItem *)item)->endPos() + GenTime(1, m_fps) - m_startPos;
+ setRect(0, 0, (qreal)(m_cropDuration - diff).frames(m_fps) * scale - .5, rect().height());
+ setPos((qreal)(m_startPos + diff).frames(m_fps) * scale, pos().y());
+ m_startPos += diff;
+ if (type() == AVWIDGET) m_cropStart += diff;
+ m_cropDuration = m_cropDuration - diff;
+ break;
+ }
}
}
}
durationDiff = maxDuration() - m_cropDuration - m_cropStart;
}
m_cropDuration += durationDiff;
- setRect(m_startPos.frames(m_fps) * scale, rect().y(), m_cropDuration.frames(m_fps) * scale, rect().height());
- QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
- for (int i = 0; i < collisionList.size(); ++i) {
- QGraphicsItem *item = collisionList.at(i);
- if (item->type() == type()) {
- GenTime diff = ((AbstractClipItem *)item)->startPos() - GenTime(1, m_fps) - startPos();
- m_cropDuration = diff;
- setRect(m_startPos.frames(m_fps) * scale, rect().y(), (m_cropDuration.frames(m_fps)) * scale, rect().height());
- break;
+ setRect(0, 0, (qreal) m_cropDuration.frames(m_fps) * scale - .5, rect().height());
+ if (durationDiff > GenTime()) {
+ QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
+ for (int i = 0; i < collisionList.size(); ++i) {
+ QGraphicsItem *item = collisionList.at(i);
+ if (item->type() == type() && item->pos().x() > pos().x()) {
+ kDebug() << "///////// COLLISION DETECTED!!!!!!!!!";
+ kDebug() << "///////// CURRENT: " << startPos().frames(25) << "x" << endPos().frames(25) << ", RECT: " << rect() << "-" << pos();
+ kDebug() << "///////// COLLISION: " << ((AbstractClipItem *)item)->startPos().frames(25) << "x" << ((AbstractClipItem *)item)->endPos().frames(25) << ", RECT: " << ((AbstractClipItem *)item)->rect() << "-" << item->pos();
+ GenTime diff = ((AbstractClipItem *)item)->startPos() - GenTime(1, m_fps) - startPos();
+ m_cropDuration = diff;
+ setRect(0, 0, (qreal)(m_cropDuration.frames(m_fps)) * scale - .5, rect().height());
+ break;
+ }
}
}
}
}
int AbstractClipItem::mouseOverKeyFrames(QPointF pos) {
- QRectF br = rect();
+ QRectF br = sceneBoundingRect();
double maxw = br.width() / m_cropDuration.frames(m_fps);
double maxh = br.height() / 100.0 * m_keyframeFactor;
if (m_keyframes.count() > 1) {
void AbstractClipItem::updateSelectedKeyFrame() {
if (m_editedKeyframe == -1) return;
- QRectF br = rect();
+ QRectF br = sceneBoundingRect();
double maxw = br.width() / m_cropDuration.frames(m_fps);
double maxh = br.height() / 100.0 * m_keyframeFactor;
update(br.x() + maxw * (m_selectedKeyframe - m_cropStart.frames(m_fps)) - 3, br.bottom() - m_keyframes[m_selectedKeyframe] * maxh - 3, 12, 12);
}
void AbstractClipItem::addKeyFrame(const GenTime pos, const double value) {
- QRectF br = rect();
+ QRectF br = sceneBoundingRect();
double maxh = 100.0 / br.height() / m_keyframeFactor;
double newval = (br.bottom() - value) * maxh;
+ kDebug() << "Rect: " << br << "/ SCENE: " << sceneBoundingRect() << ", VALUE: " << value << ", MAX: " << maxh << ", NEWVAL: " << newval;
int newpos = (int) pos.frames(m_fps) ;
m_keyframes[newpos] = newval;
m_selectedKeyframe = newpos;