use raw time values independent of timebase for scaling timeline ui

This commit is contained in:
itsmattkc
2019-08-09 16:41:17 +10:00
parent 0a56dbe429
commit 09d73ebc2b
14 changed files with 123 additions and 60 deletions
@@ -1,11 +1,13 @@
#include "timelineviewplayheaditem.h"
#include <QDebug>
#include <QGraphicsScene>
#include <QPainter>
#include <QtMath>
TimelineViewPlayheadItem::TimelineViewPlayheadItem(QGraphicsItem *parent) :
TimelineViewRect(parent)
TimelineViewRect(parent),
playhead_(0)
{
}
@@ -17,6 +19,13 @@ void TimelineViewPlayheadItem::SetPlayhead(const int64_t &playhead)
UpdateRect();
}
void TimelineViewPlayheadItem::SetTimebase(const rational &timebase)
{
timebase_ = timebase;
UpdateRect();
}
void TimelineViewPlayheadItem::UpdateRect()
{
double x = TimeToScreenCoord(rational(playhead_ * timebase_.numerator(), timebase_.denominator()));
@@ -33,10 +42,10 @@ void TimelineViewPlayheadItem::paint(QPainter *painter, const QStyleOptionGraphi
// FIXME: Make adjustable through CSS
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(255, 255, 255, 128));
painter->setBrush(style_.PlayheadHighlightColor());
painter->drawRect(rect());
painter->setPen(Qt::red);
painter->setPen(style_.PlayheadColor());
painter->setBrush(Qt::NoBrush);
painter->drawLine(QLineF(rect().topLeft(), rect().bottomLeft()));
}