// a button was pressed, delete visual tips
if (m_operationMode == MOVE) {
double snappedPos = getSnapPointForPos(mapToScene(event->pos()).x() - m_clickPoint);
- double moveX = snappedPos; //mapToScene(event->pos()).x();
//kDebug()<<"/////// MOVE CLIP, EVENTĀ Y: "<<event->scenePos().y()<<", SCENE HEIGHT: "<<scene()->sceneRect().height();
int moveTrack = (int) mapToScene(event->pos()).y() / 50;
int currentTrack = m_dragItem->track();
int offset = moveTrack - currentTrack;
if (offset != 0) offset = 50 * offset;
- m_dragItem->moveTo(moveX / m_scale, m_scale, offset, moveTrack);
+ m_dragItem->moveTo(snappedPos / m_scale, m_scale, offset, moveTrack);
} else if (m_operationMode == RESIZESTART) {
- int pos = mapToScene(event->pos()).x();
- m_dragItem->resizeStart(pos / m_scale, m_scale);
+ double snappedPos = getSnapPointForPos(mapToScene(event->pos()).x());
+ m_dragItem->resizeStart(snappedPos / m_scale, m_scale);
} else if (m_operationMode == RESIZEEND) {
- int pos = mapToScene(event->pos()).x();
- m_dragItem->resizeEnd(pos / m_scale, m_scale);
+ double snappedPos = getSnapPointForPos(mapToScene(event->pos()).x());
+ m_dragItem->resizeEnd(snappedPos / m_scale, m_scale);
} else if (m_operationMode == FADEIN) {
int pos = mapToScene(event->pos()).x() / m_scale;
m_dragItem->setFadeIn(pos - m_dragItem->startPos().frames(m_document->fps()), m_scale);
double CustomTrackView::getSnapPointForPos(double pos) {
for (int i = 0; i < m_snapPoints.size(); ++i) {
- //kDebug()<<"SNAP POINT: "<<m_snapPoints.at(i);
- if (abs(pos - m_snapPoints.at(i) * m_scale) < 6 * m_scale) {
+ if (abs(pos - m_snapPoints.at(i).frames(m_document->fps()) * m_scale) < 10) {
//kDebug()<<" FOUNDĀ SNAP POINT AT: "<<m_snapPoints.at(i)<<", current pos: "<<pos / m_scale;
- return m_snapPoints.at(i) * m_scale + 0.5;
+ return m_snapPoints.at(i).frames(m_document->fps()) * m_scale + 0.5;
}
- if (m_snapPoints.at(i) > pos) break;
+ if (m_snapPoints.at(i).frames(m_document->fps() * m_scale) > pos) break;
}
return pos;
}
void CustomTrackView::updateSnapPoints(ClipItem *selected) {
m_snapPoints.clear();
- int offset = 0;
- if (selected) offset = selected->duration().frames(m_document->fps());
+ GenTime offset;
+ if (selected) offset = selected->duration();
QList<QGraphicsItem *> itemList = items();
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == 70000 && itemList.at(i) != selected) {
ClipItem *item = (ClipItem *)itemList.at(i);
- int start = item->startPos().frames(m_document->fps());
- int fadein = item->fadeIn() + start;
- int end = item->endPos().frames(m_document->fps());
- int fadeout = end - item->fadeOut();
+ GenTime start = item->startPos();
+ GenTime end = item->endPos();
m_snapPoints.append(start);
- if (fadein != start) m_snapPoints.append(fadein);
m_snapPoints.append(end);
- if (fadeout != end) m_snapPoints.append(fadeout);
- if (offset != 0) {
- m_snapPoints.append(start - offset);
- if (fadein != start) m_snapPoints.append(fadein - offset);
- m_snapPoints.append(end - offset);
- if (fadeout != end) m_snapPoints.append(fadeout - offset);
+ if (offset != GenTime()) {
+ if (start > offset) m_snapPoints.append(start - offset);
+ if (end > offset) m_snapPoints.append(end - offset);
}
}
}
- kDebug() << " GOT SNAPPOINTS TOTAL: " << m_snapPoints.count();
qSort(m_snapPoints);
- for (int i = 0; i < m_snapPoints.size(); ++i)
- kDebug() << "SNAP POINT: " << m_snapPoints.at(i);
+ //for (int i = 0; i < m_snapPoints.size(); ++i)
+ // kDebug() << "SNAP POINT: " << m_snapPoints.at(i).frames(25);
}