+void AbstractClipItem::drawKeyFrames(QPainter *painter, bool limitedKeyFrames)
+{
+ 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 start = cropStart().frames(m_fps);
+ double x1, y1, x2, y2;
+ bool antialiasing = painter->renderHints() & QPainter::Antialiasing;
+
+ // draw line showing default value
+ bool active = isSelected() || (parentItem() && parentItem()->isSelected());
+ if (active) {
+ x1 = br.x();
+ x2 = br.right();
+ if (limitedKeyFrames) {
+ QMap<int, int>::const_iterator end = m_keyframes.constEnd();
+ end--;
+ x2 = x1 + maxw * (end.key() - start);
+ x1 += maxw * (m_keyframes.constBegin().key() - start);
+ }
+ y1 = br.bottom() - (m_keyframeDefault - m_keyframeOffset) * maxh;
+ QLineF l(x1, y1, x2, y1);
+ QLineF l2 = painter->worldTransform().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));
+ painter->setRenderHint(QPainter::Antialiasing);
+ }
+
+ // draw keyframes
+ QMap<int, int>::const_iterator i = m_keyframes.constBegin();
+ QColor color(Qt::blue);
+ QLineF l2;
+ x1 = br.x() + maxw * (i.key() - start);
+ y1 = br.bottom() - (i.value() - m_keyframeOffset) * maxh;
+
+
+
+ // make sure line begins with clip beginning
+ if (!limitedKeyFrames && i.key() != start) {
+ QLineF l(br.x(), y1, x1, y1);
+ l2 = painter->worldTransform().map(l);
+ painter->drawLine(l2);
+ }
+ 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->worldTransform().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 (!limitedKeyFrames && x1 != br.right()) {
+ QLineF l(x1, y1, br.right(), y1);
+ painter->drawLine(painter->worldTransform().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);