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);
}
}