ui: draw clip cache on timeline
This commit is contained in:
@@ -127,6 +127,32 @@ void PlaybackCache::SaveState()
|
||||
}
|
||||
}
|
||||
|
||||
void PlaybackCache::Draw(QPainter *p, const rational &start, double scale, const QRect &rect) const
|
||||
{
|
||||
p->fillRect(rect, Qt::red);
|
||||
|
||||
foreach (const TimeRange& range, GetValidatedRanges()) {
|
||||
int range_left = rect.left() + (range.in() - start).toDouble() * scale;
|
||||
if (range_left >= rect.right()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int range_right = rect.left() + (range.out() - start).toDouble() * scale;
|
||||
if (range_right < rect.left()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int adjusted_left = std::max(range_left, rect.left());
|
||||
int adjusted_right = std::min(range_right, rect.right());
|
||||
|
||||
p->fillRect(adjusted_left,
|
||||
rect.top(),
|
||||
adjusted_right - adjusted_left,
|
||||
rect.height(),
|
||||
Qt::green);
|
||||
}
|
||||
}
|
||||
|
||||
void PlaybackCache::InvalidateAll()
|
||||
{
|
||||
Invalidate(TimeRange(0, RATIONAL_MAX));
|
||||
@@ -156,7 +182,7 @@ PlaybackCache::PlaybackCache(QObject *parent) :
|
||||
uuid_ = QUuid::createUuid();
|
||||
}
|
||||
|
||||
TimeRangeList PlaybackCache::GetInvalidatedRanges(TimeRange intersecting)
|
||||
TimeRangeList PlaybackCache::GetInvalidatedRanges(TimeRange intersecting) const
|
||||
{
|
||||
TimeRangeList invalidated;
|
||||
|
||||
@@ -174,7 +200,7 @@ TimeRangeList PlaybackCache::GetInvalidatedRanges(TimeRange intersecting)
|
||||
return invalidated;
|
||||
}
|
||||
|
||||
bool PlaybackCache::HasInvalidatedRanges(const TimeRange &intersecting)
|
||||
bool PlaybackCache::HasInvalidatedRanges(const TimeRange &intersecting) const
|
||||
{
|
||||
return !validated_.contains(intersecting);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QPainter>
|
||||
#include <QUuid>
|
||||
|
||||
#include "common/jobtime.h"
|
||||
@@ -43,14 +44,14 @@ public:
|
||||
const QUuid &GetUuid() const { return uuid_; }
|
||||
void SetUuid(const QUuid &u) { uuid_ = u; }
|
||||
|
||||
TimeRangeList GetInvalidatedRanges(TimeRange intersecting);
|
||||
TimeRangeList GetInvalidatedRanges(const rational &length)
|
||||
TimeRangeList GetInvalidatedRanges(TimeRange intersecting) const;
|
||||
TimeRangeList GetInvalidatedRanges(const rational &length) const
|
||||
{
|
||||
return GetInvalidatedRanges(TimeRange(0, length));
|
||||
}
|
||||
|
||||
bool HasInvalidatedRanges(const TimeRange &intersecting);
|
||||
bool HasInvalidatedRanges(const rational &length)
|
||||
bool HasInvalidatedRanges(const TimeRange &intersecting) const;
|
||||
bool HasInvalidatedRanges(const rational &length) const
|
||||
{
|
||||
return HasInvalidatedRanges(TimeRange(0, length));
|
||||
}
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
|
||||
void Invalidate(const TimeRange& r);
|
||||
|
||||
bool HasValidatedRanges() const { return !validated_.isEmpty(); }
|
||||
const TimeRangeList &GetValidatedRanges() const { return validated_; }
|
||||
|
||||
Node *parent() const;
|
||||
@@ -69,6 +71,13 @@ public:
|
||||
void LoadState();
|
||||
void SaveState();
|
||||
|
||||
void Draw(QPainter *painter, const rational &start, double scale, const QRect &rect) const;
|
||||
|
||||
static int GetCacheIndicatorHeight()
|
||||
{
|
||||
return QFontMetrics(QFont()).height()/4;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void InvalidateAll();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user