return m_maxDuration;
}
-void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/)
+void AbstractClipItem::drawKeyFrames(QPainter *painter, bool limitedKeyFrames)
{
if (m_keyframes.count() < 1)
return;
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->matrix().map(l);
x1 = br.x() + maxw * (i.key() - start);
y1 = br.bottom() - (i.value() - m_keyframeOffset) * maxh;
+
+
// make sure line begins with clip beginning
- if (i.key() != start) {
+ if (!limitedKeyFrames && i.key() != start) {
QLineF l(br.x(), y1, x1, y1);
l2 = painter->matrix().map(l);
painter->drawLine(l2);
}
// make sure line ends at clip end
- if (x1 != br.right()) {
+ if (!limitedKeyFrames && x1 != br.right()) {
QLineF l(x1, y1, br.right(), y1);
painter->drawLine(painter->matrix().map(l));
}
/** The (keyframe) parameter that is visible and editable in timeline (on the clip) */
int m_visibleParam;
double m_fps;
- //QRect visibleRect();
- void drawKeyFrames(QPainter *painter, QRectF exposedRect);
+ /** @brief Draw the keyframes of a clip
+ * @param painter The painter device for the clip
+ * @param limitedKeyFrames The keyframes can be of type "keyframe" or "simplekeyframe". In the
+ * "simplekeyframe" type, the effect always starts on clip start and ends on clip end. With the
+ * "keyframe" type, the effect starts on the first keyframe and ends on the last keyframe
+ */
+ void drawKeyFrames(QPainter *painter, bool limitedKeyFrames);
int mouseOverKeyFrames(QPointF pos, double maxOffset);
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
//m_hover(false),
m_speed(speed),
m_strobe(strobe),
- m_framePixelWidth(0)
+ m_framePixelWidth(0),
+ m_limitedKeyFrames(false)
{
setZValue(2);
setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double) itemHeight());
QDomElement e = params.item(i).toElement();
if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
m_keyframes.clear();
+ m_limitedKeyFrames = e.attribute("type") == "keyframe";
m_visibleParam = i;
double max = e.attribute("max").toDouble();
double min = e.attribute("min").toDouble();
painter->setPen(QPen(Qt::lightGray));
// draw effect or transition keyframes
- if (mapped.width() > 20) drawKeyFrames(painter, exposed);
+ if (mapped.width() > 20) drawKeyFrames(painter, m_limitedKeyFrames);
//painter->setMatrixEnabled(true);
setSelectedEffect(m_selectedEffect);
return;
}
+ m_limitedKeyFrames = e.attribute("type") == "keyframe";
const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
foreach(const QString &str, keyframes) {
int pos = str.section(':', 0, 0).toInt();
QPixmap m_videoPix;
QPixmap m_audioPix;
+ /** @brief Keyframes type can be "keyframe" or "simplekeyframe" which have to be painted differently.
+ * True if keyframe type is "keyframe" */
+ bool m_limitedKeyFrames;
private slots:
void slotGetStartThumb();