- 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());
+
+ m_info.cropDuration += durationDiff;
+
+ setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
+ if (durationDiff > GenTime()) {
+ QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
+ for (int i = 0; i < collisionList.size(); ++i) {
+ if (!collisionList.at(i)->isEnabled()) continue;
+ 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() - startPos();
+ m_info.cropDuration = diff;
+ setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
+ break;
+ }
+ }
+ }
+}
+
+GenTime AbstractClipItem::startPos() const
+{
+ return m_info.startPos;
+}
+
+void AbstractClipItem::setTrack(int track)
+{
+ m_info.track = track;
+}
+
+double AbstractClipItem::fps() const
+{
+ return m_fps;
+}
+
+void AbstractClipItem::updateFps(double fps)
+{
+ m_fps = fps;
+ setPos((qreal) startPos().frames(m_fps), pos().y());
+ updateRectGeometry();
+}
+
+GenTime AbstractClipItem::maxDuration() const
+{
+ return m_maxDuration;
+}
+
+void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/)
+{
+ if (m_keyframes.count() < 1) return;
+ QRectF br = rect();
+ double maxw = br.width() / cropDuration().frames(m_fps);
+ double maxh = br.height() / 100.0 * m_keyframeFactor;
+ double x1;
+ double y1;
+ double x2;
+ double y2;
+
+ // draw line showing default value
+ bool active = isSelected() || (parentItem() && parentItem()->isSelected());
+ if (active) {
+ x1 = br.x();
+ x2 = br.right();
+ y1 = br.bottom() - m_keyframeDefault * maxh;
+ QLineF l(x1, y1, x2, y1);
+ QLineF l2 = painter->matrix().map(l);
+ painter->setPen(QColor(168, 168, 168, 180));
+ painter->drawLine(l2);
+ painter->setPen(QColor(108, 108, 108, 180));
+ painter->drawLine(l2.translated(0, 1));
+ painter->setPen(QColor(Qt::white));
+ }
+
+ // draw keyframes
+ QMap<int, int>::const_iterator i = m_keyframes.constBegin();
+ QColor color(Qt::blue);
+ x1 = br.x() + maxw * (i.key() - cropStart().frames(m_fps));
+ y1 = br.bottom() - i.value() * maxh;
+ QLineF l2;
+ while (i != m_keyframes.constEnd()) {
+ if (i.key() == m_selectedKeyframe) color = QColor(Qt::red);
+ else color = QColor(Qt::blue);
+ ++i;
+ if (i == m_keyframes.constEnd() && m_keyframes.count() != 1) {