Merge branch 'transition-offsets'
This commit is contained in:
+2
-120
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "node/output/track/track.h"
|
||||
#include "transition/transition.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
#include "widget/slider/rationalslider.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -32,18 +31,13 @@ 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");
|
||||
const QString Block::kSpeedInput = QStringLiteral("speed_in");
|
||||
const QString Block::kReverseInput = QStringLiteral("reverse_in");
|
||||
|
||||
Block::Block() :
|
||||
previous_(nullptr),
|
||||
next_(nullptr),
|
||||
track_(nullptr),
|
||||
index_(-1),
|
||||
in_transition_(nullptr),
|
||||
out_transition_(nullptr)
|
||||
index_(-1)
|
||||
{
|
||||
AddInput(kLengthInput, NodeValue::kRational, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kLengthInput, QStringLiteral("min"), QVariant::fromValue(rational(0, 1)));
|
||||
@@ -51,23 +45,7 @@ Block::Block() :
|
||||
SetInputProperty(kLengthInput, QStringLiteral("viewlock"), true);
|
||||
IgnoreHashingFrom(kLengthInput);
|
||||
|
||||
AddInput(kMediaInInput, NodeValue::kRational, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kMediaInInput, QStringLiteral("view"), RationalSlider::kTime);
|
||||
SetInputProperty(kMediaInInput, QStringLiteral("viewlock"), true);
|
||||
IgnoreHashingFrom(kMediaInInput);
|
||||
|
||||
AddInput(kEnabledInput, NodeValue::kBoolean, true, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kSpeedInput, NodeValue::kFloat, 1.0, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kSpeedInput, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
SetInputProperty(kSpeedInput, QStringLiteral("min"), 0.0);
|
||||
IgnoreHashingFrom(kSpeedInput);
|
||||
|
||||
AddInput(kReverseInput, NodeValue::kBoolean, false, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
IgnoreHashingFrom(kReverseInput);
|
||||
|
||||
// A block's length must be greater than 0
|
||||
set_length_and_media_out(1);
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> Block::Category() const
|
||||
@@ -82,47 +60,23 @@ rational Block::length() const
|
||||
|
||||
void Block::set_length_and_media_out(const rational &length)
|
||||
{
|
||||
Q_ASSERT(length > 0);
|
||||
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (reverse()) {
|
||||
// Calculate media_in adjustment
|
||||
set_media_in(SequenceToMediaTime(length - this->length(), true));
|
||||
}
|
||||
|
||||
set_length_internal(length);
|
||||
}
|
||||
|
||||
void Block::set_length_and_media_in(const rational &length)
|
||||
{
|
||||
Q_ASSERT(length > 0);
|
||||
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reverse()) {
|
||||
// Calculate media_in adjustment
|
||||
set_media_in(SequenceToMediaTime(this->length() - length));
|
||||
}
|
||||
|
||||
// Set the length without setting media out
|
||||
set_length_internal(length);
|
||||
}
|
||||
|
||||
rational Block::media_in() const
|
||||
{
|
||||
return GetStandardValue(kMediaInInput).value<rational>();
|
||||
}
|
||||
|
||||
void Block::set_media_in(const rational &media_in)
|
||||
{
|
||||
SetStandardValue(kMediaInInput, QVariant::fromValue(media_in));
|
||||
}
|
||||
|
||||
bool Block::is_enabled() const
|
||||
{
|
||||
return GetStandardValue(kEnabledInput).toBool();
|
||||
@@ -135,65 +89,9 @@ void Block::set_enabled(bool e)
|
||||
emit EnabledChanged();
|
||||
}
|
||||
|
||||
rational Block::SequenceToMediaTime(const rational &sequence_time, bool ignore_reverse) const
|
||||
{
|
||||
// These constants are not considered "values" per se, so we don't modify them
|
||||
if (sequence_time == RATIONAL_MIN || sequence_time == RATIONAL_MAX) {
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
rational local_time = sequence_time;
|
||||
|
||||
double speed_value = speed();
|
||||
|
||||
if (qIsNull(speed_value)) {
|
||||
// Effectively holds the frame at the in point
|
||||
local_time = 0;
|
||||
} else if (!qFuzzyCompare(speed_value, 1.0)) {
|
||||
// Multiply time
|
||||
local_time = rational::fromDouble(local_time.toDouble() * speed_value);
|
||||
}
|
||||
|
||||
rational media_time = local_time + media_in();
|
||||
|
||||
if (reverse() && !ignore_reverse) {
|
||||
media_time = length() - media_time;
|
||||
}
|
||||
|
||||
return media_time;
|
||||
}
|
||||
|
||||
rational Block::MediaToSequenceTime(const rational &media_time) const
|
||||
{
|
||||
// These constants are not considered "values" per se, so we don't modify them
|
||||
if (media_time == RATIONAL_MIN || media_time == RATIONAL_MAX) {
|
||||
return media_time;
|
||||
}
|
||||
|
||||
rational sequence_time = media_time;
|
||||
|
||||
if (reverse()) {
|
||||
sequence_time = length() - sequence_time;
|
||||
}
|
||||
|
||||
sequence_time -= media_in();
|
||||
|
||||
double speed_value = speed();
|
||||
|
||||
if (qIsNull(speed_value)) {
|
||||
// Effectively holds the frame at the in point, also prevents divide by zero
|
||||
sequence_time = 0;
|
||||
} else if (!qFuzzyCompare(speed_value, 1.0)) {
|
||||
// Multiply time
|
||||
sequence_time = rational::fromDouble(sequence_time.toDouble() / speed_value);
|
||||
}
|
||||
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
void Block::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
super::InputValueChangedEvent(input, element);
|
||||
|
||||
if (input == kLengthInput) {
|
||||
emit LengthChanged();
|
||||
@@ -202,19 +100,6 @@ void Block::InputValueChangedEvent(const QString &input, int element)
|
||||
}
|
||||
}
|
||||
|
||||
void Block::LinkChangeEvent()
|
||||
{
|
||||
block_links_.clear();
|
||||
|
||||
foreach (Node* n, links()) {
|
||||
Block* b = dynamic_cast<Block*>(n);
|
||||
|
||||
if (b) {
|
||||
block_links_.append(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Block::HashPassthrough(const QString &input, const QString &output, QCryptographicHash &hash, const rational &time, const VideoParams &video_params) const
|
||||
{
|
||||
if (IsInputConnected(input)) {
|
||||
@@ -239,10 +124,7 @@ void Block::Retranslate()
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kLengthInput, tr("Length"));
|
||||
SetInputName(kMediaInInput, tr("Media In"));
|
||||
SetInputName(kEnabledInput, tr("Enabled"));
|
||||
SetInputName(kSpeedInput, tr("Speed"));
|
||||
SetInputName(kReverseInput, tr("Reverse"));
|
||||
}
|
||||
|
||||
void Block::Hash(const QString &, QCryptographicHash &, const rational &, const VideoParams &) const
|
||||
|
||||
+4
-59
@@ -62,8 +62,8 @@ public:
|
||||
}
|
||||
|
||||
rational length() const;
|
||||
void set_length_and_media_out(const rational &length);
|
||||
void set_length_and_media_in(const rational &length);
|
||||
virtual void set_length_and_media_out(const rational &length);
|
||||
virtual void set_length_and_media_in(const rational &length);
|
||||
|
||||
TimeRange range() const
|
||||
{
|
||||
@@ -90,9 +90,6 @@ public:
|
||||
next_ = next;
|
||||
}
|
||||
|
||||
rational media_in() const;
|
||||
void set_media_in(const rational& media_in);
|
||||
|
||||
Track* track() const
|
||||
{
|
||||
return track_;
|
||||
@@ -108,26 +105,6 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
TransitionBlock* in_transition()
|
||||
{
|
||||
return in_transition_;
|
||||
}
|
||||
|
||||
void set_in_transition(TransitionBlock* t)
|
||||
{
|
||||
in_transition_ = t;
|
||||
}
|
||||
|
||||
TransitionBlock* out_transition()
|
||||
{
|
||||
return out_transition_;
|
||||
}
|
||||
|
||||
void set_out_transition(TransitionBlock* t)
|
||||
{
|
||||
out_transition_ = t;
|
||||
}
|
||||
|
||||
int index() const
|
||||
{
|
||||
return index_;
|
||||
@@ -138,35 +115,12 @@ public:
|
||||
index_ = i;
|
||||
}
|
||||
|
||||
const QVector<Block*>& block_links() const
|
||||
{
|
||||
return block_links_;
|
||||
}
|
||||
|
||||
double speed() const
|
||||
{
|
||||
return GetStandardValue(kSpeedInput).toDouble();
|
||||
}
|
||||
|
||||
void set_speed(double s)
|
||||
{
|
||||
SetStandardValue(kSpeedInput, s);
|
||||
}
|
||||
|
||||
bool reverse() const
|
||||
{
|
||||
return GetStandardValue(kReverseInput).toBool();
|
||||
}
|
||||
|
||||
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;
|
||||
static const QString kSpeedInput;
|
||||
static const QString kReverseInput;
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -175,15 +129,11 @@ signals:
|
||||
|
||||
void LengthChanged();
|
||||
|
||||
void PreviewChanged();
|
||||
|
||||
protected:
|
||||
rational SequenceToMediaTime(const rational& sequence_time, bool ignore_reverse = false) const;
|
||||
|
||||
rational MediaToSequenceTime(const rational& media_time) const;
|
||||
|
||||
virtual void InputValueChangedEvent(const QString& input, int element) override;
|
||||
|
||||
virtual void LinkChangeEvent() override;
|
||||
|
||||
bool HashPassthrough(const QString &input, const QString& output, QCryptographicHash &hash, const rational &time, const VideoParams& video_params) const;
|
||||
|
||||
Block* previous_;
|
||||
@@ -197,11 +147,6 @@ private:
|
||||
Track* track_;
|
||||
int index_;
|
||||
|
||||
TransitionBlock* in_transition_;
|
||||
TransitionBlock* out_transition_;
|
||||
|
||||
QVector<Block*> block_links_;
|
||||
|
||||
rational last_length_;
|
||||
|
||||
};
|
||||
|
||||
@@ -20,17 +20,36 @@
|
||||
|
||||
#include "clip.h"
|
||||
|
||||
#include "widget/slider/floatslider.h"
|
||||
#include "widget/slider/rationalslider.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super Block
|
||||
|
||||
const QString ClipBlock::kBufferIn = QStringLiteral("buffer_in");
|
||||
const QString ClipBlock::kMediaInInput = QStringLiteral("media_in_in");
|
||||
const QString ClipBlock::kSpeedInput = QStringLiteral("speed_in");
|
||||
const QString ClipBlock::kReverseInput = QStringLiteral("reverse_in");
|
||||
|
||||
ClipBlock::ClipBlock(bool create_buffer_in)
|
||||
ClipBlock::ClipBlock() :
|
||||
in_transition_(nullptr),
|
||||
out_transition_(nullptr)
|
||||
{
|
||||
if (create_buffer_in) {
|
||||
AddInput(kBufferIn, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable));
|
||||
}
|
||||
AddInput(kMediaInInput, NodeValue::kRational, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kMediaInInput, QStringLiteral("view"), RationalSlider::kTime);
|
||||
SetInputProperty(kMediaInInput, QStringLiteral("viewlock"), true);
|
||||
IgnoreHashingFrom(kMediaInInput);
|
||||
|
||||
AddInput(kSpeedInput, NodeValue::kFloat, 1.0, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kSpeedInput, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
SetInputProperty(kSpeedInput, QStringLiteral("min"), 0.0);
|
||||
IgnoreHashingFrom(kSpeedInput);
|
||||
|
||||
AddInput(kReverseInput, NodeValue::kBoolean, false, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
IgnoreHashingFrom(kReverseInput);
|
||||
|
||||
AddInput(kBufferIn, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable));
|
||||
}
|
||||
|
||||
Node *ClipBlock::copy() const
|
||||
@@ -53,6 +72,100 @@ QString ClipBlock::Description() const
|
||||
return tr("A time-based node that represents a media source.");
|
||||
}
|
||||
|
||||
void ClipBlock::set_length_and_media_out(const rational &length)
|
||||
{
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (reverse()) {
|
||||
// Calculate media_in adjustment
|
||||
set_media_in(SequenceToMediaTime(length - this->length(), true));
|
||||
}
|
||||
|
||||
super::set_length_and_media_out(length);
|
||||
}
|
||||
|
||||
void ClipBlock::set_length_and_media_in(const rational &length)
|
||||
{
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reverse()) {
|
||||
// Calculate media_in adjustment
|
||||
set_media_in(SequenceToMediaTime(this->length() - length));
|
||||
}
|
||||
|
||||
super::set_length_and_media_in(length);
|
||||
}
|
||||
|
||||
rational ClipBlock::media_in() const
|
||||
{
|
||||
return GetStandardValue(kMediaInInput).value<rational>();
|
||||
}
|
||||
|
||||
void ClipBlock::set_media_in(const rational &media_in)
|
||||
{
|
||||
SetStandardValue(kMediaInInput, QVariant::fromValue(media_in));
|
||||
}
|
||||
|
||||
rational ClipBlock::SequenceToMediaTime(const rational &sequence_time, bool ignore_reverse) const
|
||||
{
|
||||
// These constants are not considered "values" per se, so we don't modify them
|
||||
if (sequence_time == RATIONAL_MIN || sequence_time == RATIONAL_MAX) {
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
rational local_time = sequence_time;
|
||||
|
||||
double speed_value = speed();
|
||||
|
||||
if (qIsNull(speed_value)) {
|
||||
// Effectively holds the frame at the in point
|
||||
local_time = 0;
|
||||
} else if (!qFuzzyCompare(speed_value, 1.0)) {
|
||||
// Multiply time
|
||||
local_time = rational::fromDouble(local_time.toDouble() * speed_value);
|
||||
}
|
||||
|
||||
rational media_time = local_time + media_in();
|
||||
|
||||
if (reverse() && !ignore_reverse) {
|
||||
media_time = length() - media_time;
|
||||
}
|
||||
|
||||
return media_time;
|
||||
}
|
||||
|
||||
rational ClipBlock::MediaToSequenceTime(const rational &media_time) const
|
||||
{
|
||||
// These constants are not considered "values" per se, so we don't modify them
|
||||
if (media_time == RATIONAL_MIN || media_time == RATIONAL_MAX) {
|
||||
return media_time;
|
||||
}
|
||||
|
||||
rational sequence_time = media_time;
|
||||
|
||||
if (reverse()) {
|
||||
sequence_time = length() - sequence_time;
|
||||
}
|
||||
|
||||
sequence_time -= media_in();
|
||||
|
||||
double speed_value = speed();
|
||||
|
||||
if (qIsNull(speed_value)) {
|
||||
// Effectively holds the frame at the in point, also prevents divide by zero
|
||||
sequence_time = 0;
|
||||
} else if (!qFuzzyCompare(speed_value, 1.0)) {
|
||||
// Multiply time
|
||||
sequence_time = rational::fromDouble(sequence_time.toDouble() / speed_value);
|
||||
}
|
||||
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
@@ -70,6 +183,32 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::LinkChangeEvent()
|
||||
{
|
||||
block_links_.clear();
|
||||
|
||||
foreach (Node* n, links()) {
|
||||
ClipBlock* b = dynamic_cast<ClipBlock*>(n);
|
||||
|
||||
if (b) {
|
||||
block_links_.append(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
super::InputValueChangedEvent(input, element);
|
||||
|
||||
if (input == kMediaInInput) {
|
||||
// Shift waveform in the inverse that the media in moved
|
||||
rational diff = media_in() - last_media_in_;
|
||||
waveform_.TrimIn(diff);
|
||||
|
||||
last_media_in_ = media_in();
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::InputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
@@ -110,9 +249,10 @@ void ClipBlock::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
|
||||
if (HasInputWithID(kBufferIn)) {
|
||||
SetInputName(kBufferIn, tr("Buffer"));
|
||||
}
|
||||
SetInputName(kBufferIn, tr("Buffer"));
|
||||
SetInputName(kMediaInInput, tr("Media In"));
|
||||
SetInputName(kSpeedInput, tr("Speed"));
|
||||
SetInputName(kReverseInput, tr("Reverse"));
|
||||
}
|
||||
|
||||
void ClipBlock::Hash(const QString &out, QCryptographicHash &hash, const rational &time, const VideoParams &video_params) const
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef CLIPBLOCK_H
|
||||
#define CLIPBLOCK_H
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "node/block/block.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -32,7 +33,7 @@ class ClipBlock : public Block
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClipBlock(bool create_buffer_in = true);
|
||||
ClipBlock();
|
||||
|
||||
NODE_DEFAULT_DESTRUCTOR(ClipBlock)
|
||||
|
||||
@@ -42,6 +43,12 @@ public:
|
||||
virtual QString id() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void set_length_and_media_out(const rational &length) override;
|
||||
virtual void set_length_and_media_in(const rational &length) override;
|
||||
|
||||
rational media_in() const;
|
||||
void set_media_in(const rational& media_in);
|
||||
|
||||
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;
|
||||
@@ -54,7 +61,71 @@ public:
|
||||
|
||||
virtual void Hash(const QString& output, QCryptographicHash &hash, const rational &time, const VideoParams& video_params) const override;
|
||||
|
||||
double speed() const
|
||||
{
|
||||
return GetStandardValue(kSpeedInput).toDouble();
|
||||
}
|
||||
|
||||
bool reverse() const
|
||||
{
|
||||
return GetStandardValue(kReverseInput).toBool();
|
||||
}
|
||||
|
||||
TransitionBlock* in_transition()
|
||||
{
|
||||
return in_transition_;
|
||||
}
|
||||
|
||||
void set_in_transition(TransitionBlock* t)
|
||||
{
|
||||
in_transition_ = t;
|
||||
}
|
||||
|
||||
TransitionBlock* out_transition()
|
||||
{
|
||||
return out_transition_;
|
||||
}
|
||||
|
||||
void set_out_transition(TransitionBlock* t)
|
||||
{
|
||||
out_transition_ = t;
|
||||
}
|
||||
|
||||
const QVector<Block*>& block_links() const
|
||||
{
|
||||
return block_links_;
|
||||
}
|
||||
|
||||
AudioVisualWaveform& waveform()
|
||||
{
|
||||
return waveform_;
|
||||
}
|
||||
|
||||
static const QString kBufferIn;
|
||||
static const QString kMediaInInput;
|
||||
static const QString kSpeedInput;
|
||||
static const QString kReverseInput;
|
||||
|
||||
protected:
|
||||
virtual void LinkChangeEvent() override;
|
||||
|
||||
virtual void InputValueChangedEvent(const QString &input, int element) override;
|
||||
|
||||
private:
|
||||
rational SequenceToMediaTime(const rational& sequence_time, bool ignore_reverse = false) const;
|
||||
|
||||
rational MediaToSequenceTime(const rational& media_time) const;
|
||||
|
||||
QVector<Block*> block_links_;
|
||||
|
||||
TransitionBlock* in_transition_;
|
||||
TransitionBlock* out_transition_;
|
||||
|
||||
private:
|
||||
AudioVisualWaveform waveform_;
|
||||
|
||||
rational last_media_in_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ namespace olive {
|
||||
|
||||
const QString SubtitleBlock::kTextIn = QStringLiteral("text_in");
|
||||
|
||||
SubtitleBlock::SubtitleBlock() :
|
||||
super(false)
|
||||
SubtitleBlock::SubtitleBlock()
|
||||
{
|
||||
AddInput(kTextIn, NodeValue::kText, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
#include "transition.h"
|
||||
|
||||
#include "common/clamp.h"
|
||||
#include "node/block/clip/clip.h"
|
||||
#include "node/output/track/track.h"
|
||||
#include "widget/slider/rationalslider.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -30,6 +32,7 @@ namespace olive {
|
||||
const QString TransitionBlock::kOutBlockInput = QStringLiteral("out_block_in");
|
||||
const QString TransitionBlock::kInBlockInput = QStringLiteral("in_block_in");
|
||||
const QString TransitionBlock::kCurveInput = QStringLiteral("curve_in");
|
||||
const QString TransitionBlock::kCenterInput = QStringLiteral("center_in");
|
||||
|
||||
TransitionBlock::TransitionBlock() :
|
||||
connected_out_block_(nullptr),
|
||||
@@ -40,6 +43,11 @@ TransitionBlock::TransitionBlock() :
|
||||
AddInput(kInBlockInput, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kCurveInput, NodeValue::kCombo, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
|
||||
AddInput(kCenterInput, NodeValue::kRational, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
SetInputProperty(kCenterInput, QStringLiteral("view"), RationalSlider::kTime);
|
||||
SetInputProperty(kCenterInput, QStringLiteral("viewlock"), true);
|
||||
IgnoreHashingFrom(kCenterInput);
|
||||
}
|
||||
|
||||
void TransitionBlock::Retranslate()
|
||||
@@ -49,6 +57,7 @@ void TransitionBlock::Retranslate()
|
||||
SetInputName(kOutBlockInput, tr("From"));
|
||||
SetInputName(kInBlockInput, tr("To"));
|
||||
SetInputName(kCurveInput, tr("Curve"));
|
||||
SetInputName(kCenterInput, tr("Center Offset"));
|
||||
|
||||
// These must correspond to the CurveType enum
|
||||
SetComboBoxStrings(kCurveInput, { tr("Linear"), tr("Exponential"), tr("Logarithmic") });
|
||||
@@ -56,34 +65,43 @@ void TransitionBlock::Retranslate()
|
||||
|
||||
rational TransitionBlock::in_offset() const
|
||||
{
|
||||
// If no in block is connected, there's no in offset
|
||||
if (!connected_in_block()) {
|
||||
if (is_dual_transition()) {
|
||||
return length()/2 + offset_center();
|
||||
} else if (connected_in_block()) {
|
||||
return length();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!connected_out_block()) {
|
||||
// Assume only an in block is connected, in which case this entire transition length
|
||||
return length();
|
||||
}
|
||||
|
||||
// Assume both are connected
|
||||
return length() + media_in();
|
||||
}
|
||||
|
||||
rational TransitionBlock::out_offset() const
|
||||
{
|
||||
// If no in block is connected, there's no in offset
|
||||
if (!connected_out_block()) {
|
||||
if (is_dual_transition()) {
|
||||
return length()/2 - offset_center();
|
||||
} else if (connected_out_block()) {
|
||||
return length();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!connected_in_block()) {
|
||||
// Assume only an in block is connected, in which case this entire transition length
|
||||
return length();
|
||||
}
|
||||
rational TransitionBlock::offset_center() const
|
||||
{
|
||||
return GetStandardValue(kCenterInput).value<rational>();
|
||||
}
|
||||
|
||||
// Assume both are connected
|
||||
return -media_in();
|
||||
void TransitionBlock::set_offset_center(const rational &r)
|
||||
{
|
||||
SetStandardValue(kCenterInput, QVariant::fromValue(r));
|
||||
}
|
||||
|
||||
void TransitionBlock::set_offsets_and_length(const rational &in_offset, const rational &out_offset)
|
||||
{
|
||||
rational len = in_offset + out_offset;
|
||||
rational center = len / 2 - in_offset;
|
||||
|
||||
set_length_and_media_out(len);
|
||||
set_offset_center(center);
|
||||
}
|
||||
|
||||
Block *TransitionBlock::connected_out_block() const
|
||||
@@ -267,12 +285,12 @@ void TransitionBlock::InputConnectedEvent(const QString &input, int element, con
|
||||
|
||||
if (input == kOutBlockInput) {
|
||||
// If node is not a block, this will just be null
|
||||
if ((connected_out_block_ = dynamic_cast<Block*>(output.node()))) {
|
||||
if ((connected_out_block_ = dynamic_cast<ClipBlock*>(output.node()))) {
|
||||
connected_out_block_->set_out_transition(this);
|
||||
}
|
||||
} else if (input == kInBlockInput) {
|
||||
// If node is not a block, this will just be null
|
||||
if ((connected_in_block_ = dynamic_cast<Block*>(output.node()))) {
|
||||
if ((connected_in_block_ = dynamic_cast<ClipBlock*>(output.node()))) {
|
||||
connected_in_block_->set_in_transition(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ClipBlock;
|
||||
|
||||
class TransitionBlock : public Block
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -38,6 +40,24 @@ public:
|
||||
rational in_offset() const;
|
||||
rational out_offset() const;
|
||||
|
||||
/**
|
||||
* @brief Return the "middle point" of the transition, relative to the transition
|
||||
*
|
||||
* Used to calculate in/out offsets.
|
||||
*
|
||||
* 0 means the center of the transition is right in the middle and the in and out offsets will
|
||||
* be equal.
|
||||
*/
|
||||
rational offset_center() const;
|
||||
void set_offset_center(const rational &r);
|
||||
|
||||
void set_offsets_and_length(const rational &in_offset, const rational &out_offset);
|
||||
|
||||
bool is_dual_transition() const
|
||||
{
|
||||
return connected_out_block() && connected_in_block();
|
||||
}
|
||||
|
||||
Block* connected_out_block() const;
|
||||
Block* connected_in_block() const;
|
||||
|
||||
@@ -54,6 +74,7 @@ public:
|
||||
static const QString kOutBlockInput;
|
||||
static const QString kInBlockInput;
|
||||
static const QString kCurveInput;
|
||||
static const QString kCenterInput;
|
||||
|
||||
protected:
|
||||
virtual void ShaderJobEvent(NodeValueDatabase &value, ShaderJob& job) const;
|
||||
@@ -81,9 +102,9 @@ private:
|
||||
|
||||
void InsertTransitionTimes(AcceleratedJob* job, const double& time) const;
|
||||
|
||||
Block* connected_out_block_;
|
||||
ClipBlock* connected_out_block_;
|
||||
|
||||
Block* connected_in_block_;
|
||||
ClipBlock* connected_in_block_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#ifndef TRACK_H
|
||||
#define TRACK_H
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "node/block/block.h"
|
||||
#include "timeline/timelinecommon.h"
|
||||
|
||||
@@ -364,11 +363,6 @@ public:
|
||||
|
||||
virtual void Hash(const QString& output, QCryptographicHash& hash, const rational &time, const VideoParams& video_params) const override;
|
||||
|
||||
AudioVisualWaveform& waveform()
|
||||
{
|
||||
return waveform_;
|
||||
}
|
||||
|
||||
static const double kTrackHeightDefault;
|
||||
static const double kTrackHeightMinimum;
|
||||
static const double kTrackHeightInterval;
|
||||
@@ -412,11 +406,6 @@ signals:
|
||||
*/
|
||||
void IndexChanged(int old, int now);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when preview (waveform) has changed and UI should be updated
|
||||
*/
|
||||
void PreviewChanged();
|
||||
|
||||
/**
|
||||
* @brief Emitted when a block changes length and all the subsequent blocks had to update
|
||||
*/
|
||||
@@ -455,8 +444,6 @@ private:
|
||||
|
||||
bool locked_;
|
||||
|
||||
AudioVisualWaveform waveform_;
|
||||
|
||||
private slots:
|
||||
void BlockLengthChanged();
|
||||
|
||||
|
||||
@@ -163,13 +163,6 @@ void Sequence::InputDisconnectedEvent(const QString &input, int element, const N
|
||||
super::InputDisconnectedEvent(input, element, output);
|
||||
}
|
||||
|
||||
void Sequence::ShiftAudioEvent(const rational &from, const rational &to)
|
||||
{
|
||||
foreach (Track* track, track_lists_.at(Track::kAudio)->GetTracks()) {
|
||||
track->waveform().Shift(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::UpdateTrackCache()
|
||||
{
|
||||
track_cache_.clear();
|
||||
|
||||
@@ -97,8 +97,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void ShiftAudioEvent(const rational &from, const rational &to) override;
|
||||
|
||||
virtual void InputConnectedEvent(const QString &input, int element, const NodeOutput &output) override;
|
||||
|
||||
virtual void InputDisconnectedEvent(const QString &input, int element, const NodeOutput &output) override;
|
||||
|
||||
Reference in New Issue
Block a user