nodes: rewrote and simplified length signaling system

This commit is contained in:
itsmattkc
2021-07-15 21:00:18 -07:00
parent 8350ce300f
commit 4bbc75392a
20 changed files with 148 additions and 241 deletions
+24 -2
View File
@@ -22,6 +22,7 @@
#include <QDebug>
#include "core.h"
#include "node/output/track/track.h"
#include "transition/transition.h"
#include "widget/slider/floatslider.h"
@@ -29,6 +30,8 @@
namespace olive {
#define super Node
const QString Block::kLengthInput = QStringLiteral("length_in");
const QString Block::kMediaInInput = QStringLiteral("media_in_in");
const QString Block::kEnabledInput = QStringLiteral("enabled_in");
@@ -47,7 +50,6 @@ Block::Block() :
SetInputProperty(kLengthInput, QStringLiteral("min"), QVariant::fromValue(rational(0, 1)));
SetInputProperty(kLengthInput, QStringLiteral("view"), RationalSlider::kTime);
SetInputProperty(kLengthInput, QStringLiteral("viewlock"), true);
IgnoreInvalidationsFrom(kLengthInput);
IgnoreHashingFrom(kLengthInput);
AddInput(kMediaInInput, NodeValue::kRational, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
@@ -221,7 +223,7 @@ void Block::set_length_internal(const rational &length)
void Block::Retranslate()
{
Node::Retranslate();
super::Retranslate();
SetInputName(kLengthInput, tr("Length"));
SetInputName(kMediaInInput, tr("Media In"));
@@ -235,4 +237,24 @@ void Block::Hash(const QString &, QCryptographicHash &, const rational &, const
// A block does nothing by default, so we hash nothing
}
void Block::InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options)
{
TimeRange r;
if (from == kLengthInput) {
// We must intercept the signal here
r = TimeRange(qMin(length(), last_length_), RATIONAL_MAX);
if (!Core::instance()->EffectsSliderIsBeingDragged()) {
last_length_ = length();
}
options.insert(QStringLiteral("lengthevent"), true);
} else {
r = range;
}
super::InvalidateCache(r, from, element, options);
}
}
+4
View File
@@ -155,6 +155,8 @@ public:
virtual void Hash(const QString& output, QCryptographicHash &hash, const rational &time, const VideoParams& video_params) const override;
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element = -1, InvalidateCacheOptions options = InvalidateCacheOptions()) override;
static const QString kLengthInput;
static const QString kMediaInInput;
static const QString kEnabledInput;
@@ -193,6 +195,8 @@ private:
QVector<Block*> block_links_;
rational last_length_;
};
}
+3 -3
View File
@@ -53,7 +53,7 @@ QString ClipBlock::Description() const
return tr("A time-based node that represents a media source.");
}
void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int element)
void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options)
{
Q_UNUSED(element)
@@ -63,10 +63,10 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int
rational start = MediaToSequenceTime(range.in());
rational end = MediaToSequenceTime(range.out());
super::InvalidateCache(TimeRange(start, end), from, element);
super::InvalidateCache(TimeRange(start, end), from, element, options);
} else {
// Otherwise, pass signal along normally
super::InvalidateCache(range, from, element);
super::InvalidateCache(range, from, element, options);
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ public:
virtual QString id() const override;
virtual QString Description() const override;
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element) override;
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options) override;
virtual TimeRange InputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const override;