#include "timelineviewplayheaditem.h" #include #include #include #include TimelineViewPlayheadItem::TimelineViewPlayheadItem(QGraphicsItem *parent) : TimelineViewRect(parent), playhead_(0) { } void TimelineViewPlayheadItem::SetPlayhead(const int64_t &playhead) { playhead_ = playhead; UpdateRect(); } void TimelineViewPlayheadItem::SetTimebase(const rational &timebase) { timebase_ = timebase; UpdateRect(); } void TimelineViewPlayheadItem::UpdateRect() { double x = TimeToScreenCoord(rational(playhead_ * timebase_.numerator(), timebase_.denominator())); double width = TimeToScreenCoord(timebase_); setRect(0, 0, width, scene()->height()); setPos(x, 0); } void TimelineViewPlayheadItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option) Q_UNUSED(widget) // FIXME: Make adjustable through CSS painter->setPen(Qt::NoPen); painter->setBrush(style_.PlayheadHighlightColor()); painter->drawRect(rect()); painter->setPen(style_.PlayheadColor()); painter->setBrush(Qt::NoBrush); painter->drawLine(QLineF(rect().topLeft(), rect().bottomLeft())); }