- roundRectPathLower.moveTo(br_startx, br_halfy);
- roundRectPathLower.arcTo(br_startx , br_endy - roundingY , roundingX, roundingY, 180.0, 90.0);
- roundRectPathLower.lineTo(br_endx - roundingX , br_endy);
- roundRectPathLower.arcTo(br_endx - roundingX , br_endy - roundingY, roundingX, roundingY, 270.0, 90.0);
- roundRectPathLower.lineTo(br_endx , br_halfy);
- return roundRectPathLower;
+ while (i != m_keyframes.constEnd()) {
+ if (i.key() == m_editedKeyframe)
+ color = QColor(Qt::red);
+ else
+ color = QColor(Qt::blue);
+ ++i;
+ if (i == m_keyframes.constEnd() && m_keyframes.count() != 1)
+ break;
+
+ if (m_keyframes.count() == 1) {
+ x2 = br.right();
+ y2 = y1;
+ } else {
+ x2 = br.x() + maxw * (i.key() - start);
+ y2 = br.bottom() - (i.value() - m_keyframeOffset) * maxh;
+ }
+ QLineF l(x1, y1, x2, y2);
+ l2 = painter->matrix().map(l);
+ painter->drawLine(l2);
+ if (active) {
+ const QRectF frame(l2.x1() - 3, l2.y1() - 3, 6, 6);
+ painter->fillRect(frame, color);
+ }
+ x1 = x2;
+ y1 = y2;
+ }
+
+ // make sure line ends at clip end
+ if (x1 != br.right()) {
+ QLineF l(x1, y1, br.right(), y1);
+ painter->drawLine(painter->matrix().map(l));
+ }
+
+ if (active && m_keyframes.count() > 1) {
+ const QRectF frame(l2.x2() - 3, l2.y2() - 3, 6, 6);
+ painter->fillRect(frame, color);
+ }
+
+ painter->setRenderHint(QPainter::Antialiasing, antialiasing);
+}
+
+int AbstractClipItem::mouseOverKeyFrames(QPointF pos, double maxOffset)
+{
+ const QRectF br = sceneBoundingRect();
+ double maxw = br.width() / cropDuration().frames(m_fps);
+ double maxh = br.height() / 100.0 * m_keyframeFactor;
+ if (m_keyframes.count() > 0) {
+ QMap<int, int>::const_iterator i = m_keyframes.constBegin();
+ double x1;
+ double y1;
+ while (i != m_keyframes.constEnd()) {
+ x1 = br.x() + maxw * (i.key() - cropStart().frames(m_fps));
+ y1 = br.bottom() - (i.value() - m_keyframeOffset) * maxh;
+ if (qAbs(pos.x() - x1) < maxOffset && qAbs(pos.y() - y1) < 10) {
+ setToolTip('[' + QString::number((GenTime(i.key(), m_fps) - cropStart()).seconds(), 'f', 2) + i18n("seconds") + ", " + QString::number(i.value(), 'f', 1) + "]");
+ return i.key();
+ } else if (x1 > pos.x()) {
+ break;
+ }
+ ++i;
+ }
+ }
+ setToolTip(QString());
+ return -1;
+}
+
+void AbstractClipItem::updateSelectedKeyFrame()
+{
+ if (m_editedKeyframe == -1)
+ return;
+ QRectF br = sceneBoundingRect();
+ double maxw = br.width() / cropDuration().frames(m_fps);
+ double maxh = br.height() / 100.0 * m_keyframeFactor;
+ update(br.x() + maxw *(m_selectedKeyframe - cropStart().frames(m_fps)) - 3, br.bottom() - (m_keyframes.value(m_selectedKeyframe) - m_keyframeOffset) * maxh - 3, 12, 12);
+ m_selectedKeyframe = m_editedKeyframe;
+ update(br.x() + maxw *(m_selectedKeyframe - cropStart().frames(m_fps)) - 3, br.bottom() - (m_keyframes.value(m_selectedKeyframe) - m_keyframeOffset) * maxh - 3, 12, 12);