style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
+30
-30
@@ -26,27 +26,27 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString PanNode::kSamplesInput = QStringLiteral("samples_in");
|
||||
const QString PanNode::kPanningInput = QStringLiteral("panning_in");
|
||||
const QString PanNode::k_samples_input = QStringLiteral("samples_in");
|
||||
const QString PanNode::k_panning_input = QStringLiteral("panning_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
PanNode::PanNode()
|
||||
{
|
||||
AddInput(kSamplesInput, NodeValue::kSamples,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_samples_input, NodeValue::k_samples,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kPanningInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("min"), -1.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("max"), 1.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
add_input(k_panning_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_panning_input, QStringLiteral("min"), -1.0);
|
||||
set_input_property(k_panning_input, QStringLiteral("max"), 1.0);
|
||||
set_input_property(k_panning_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
|
||||
SetFlag(kAudioEffect);
|
||||
SetEffectInput(kSamplesInput);
|
||||
set_flag(k_audio_effect);
|
||||
set_effect_input(k_samples_input);
|
||||
}
|
||||
|
||||
QString PanNode::Name() const
|
||||
QString PanNode::name() const
|
||||
{
|
||||
return tr("Pan");
|
||||
}
|
||||
@@ -56,27 +56,27 @@ QString PanNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.pan");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> PanNode::Category() const
|
||||
QVector<Node::CategoryID> PanNode::category() const
|
||||
{
|
||||
return { kCategoryFilter };
|
||||
return { k_category_filter };
|
||||
}
|
||||
|
||||
QString PanNode::Description() const
|
||||
QString PanNode::description() const
|
||||
{
|
||||
return tr("Adjust the stereo panning of an audio source.");
|
||||
}
|
||||
|
||||
void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void PanNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Create a sample job
|
||||
SampleBuffer samples = value[kSamplesInput].toSamples();
|
||||
SampleBuffer samples = value[k_samples_input].to_samples();
|
||||
if (samples.is_allocated()) {
|
||||
// This node is only compatible with stereo audio
|
||||
if (samples.audio_params().channel_count() == 2) {
|
||||
// If the input is static, we can just do it now which will be faster
|
||||
if (IsInputStatic(kPanningInput)) {
|
||||
float pan_volume = value[kPanningInput].toDouble();
|
||||
if (is_input_static(k_panning_input)) {
|
||||
float pan_volume = value[k_panning_input].to_double();
|
||||
if (!qIsNull(pan_volume)) {
|
||||
if (pan_volume > 0) {
|
||||
samples.transform_volume_for_channel(0,
|
||||
@@ -87,26 +87,26 @@ void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue(NodeValue::kSamples, samples, this));
|
||||
table->push(NodeValue(NodeValue::k_samples, samples, this));
|
||||
} else {
|
||||
// Requires job
|
||||
SampleJob job(globals.time(), kSamplesInput, value);
|
||||
job.Insert(kPanningInput, value);
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(job),
|
||||
SampleJob job(globals.time(), k_samples_input, value);
|
||||
job.insert(k_panning_input, value);
|
||||
table->push(NodeValue::k_samples, QVariant::fromValue(job),
|
||||
this);
|
||||
}
|
||||
} else {
|
||||
// Pass right through
|
||||
table->Push(value[kSamplesInput]);
|
||||
table->push(value[k_samples_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PanNode::ProcessSamples(const NodeValueRow &values,
|
||||
void PanNode::process_samples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const
|
||||
{
|
||||
float pan_val = values[kPanningInput].toDouble();
|
||||
float pan_val = values[k_panning_input].to_double();
|
||||
|
||||
for (int i = 0; i < input.audio_params().channel_count(); i++) {
|
||||
output.data(i)[index] = input.data(i)[index];
|
||||
@@ -119,12 +119,12 @@ void PanNode::ProcessSamples(const NodeValueRow &values,
|
||||
}
|
||||
}
|
||||
|
||||
void PanNode::Retranslate()
|
||||
void PanNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kSamplesInput, tr("Samples"));
|
||||
SetInputName(kPanningInput, tr("Pan"));
|
||||
set_input_name(k_samples_input, tr("Samples"));
|
||||
set_input_name(k_panning_input, tr("Pan"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-11
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PANNODE_H
|
||||
#define PANNODE_H
|
||||
#ifndef OAK_PANNODE_H
|
||||
#define OAK_PANNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,22 +34,22 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(PanNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void ProcessSamples(const NodeValueRow &values,
|
||||
virtual void process_samples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
static const QString kSamplesInput;
|
||||
static const QString kPanningInput;
|
||||
static const QString k_samples_input;
|
||||
static const QString k_panning_input;
|
||||
|
||||
private:
|
||||
NodeInput *samples_input_;
|
||||
@@ -58,4 +58,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // PANNODE_H
|
||||
#endif // OAK_PANNODE_H
|
||||
|
||||
@@ -26,26 +26,26 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString VolumeNode::kSamplesInput = QStringLiteral("samples_in");
|
||||
const QString VolumeNode::kVolumeInput = QStringLiteral("volume_in");
|
||||
const QString VolumeNode::k_samples_input = QStringLiteral("samples_in");
|
||||
const QString VolumeNode::k_volume_input = QStringLiteral("volume_in");
|
||||
|
||||
#define super MathNodeBase
|
||||
|
||||
VolumeNode::VolumeNode()
|
||||
{
|
||||
AddInput(kSamplesInput, NodeValue::kSamples,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_samples_input, NodeValue::k_samples,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kVolumeInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kVolumeInput, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(kVolumeInput, QStringLiteral("view"),
|
||||
FloatSlider::kDecibel);
|
||||
add_input(k_volume_input, NodeValue::k_float, 1.0);
|
||||
set_input_property(k_volume_input, QStringLiteral("min"), 0.0);
|
||||
set_input_property(k_volume_input, QStringLiteral("view"),
|
||||
FloatSlider::k_decibel);
|
||||
|
||||
SetFlag(kAudioEffect);
|
||||
SetEffectInput(kSamplesInput);
|
||||
set_flag(k_audio_effect);
|
||||
set_effect_input(k_samples_input);
|
||||
}
|
||||
|
||||
QString VolumeNode::Name() const
|
||||
QString VolumeNode::name() const
|
||||
{
|
||||
return tr("Volume");
|
||||
}
|
||||
@@ -55,55 +55,55 @@ QString VolumeNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.volume");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> VolumeNode::Category() const
|
||||
QVector<Node::CategoryID> VolumeNode::category() const
|
||||
{
|
||||
return { kCategoryFilter };
|
||||
return { k_category_filter };
|
||||
}
|
||||
|
||||
QString VolumeNode::Description() const
|
||||
QString VolumeNode::description() const
|
||||
{
|
||||
return tr("Adjusts the volume of an audio source.");
|
||||
}
|
||||
|
||||
void VolumeNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void VolumeNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Create a sample job
|
||||
SampleBuffer buffer = value[kSamplesInput].toSamples();
|
||||
SampleBuffer buffer = value[k_samples_input].to_samples();
|
||||
|
||||
if (buffer.is_allocated()) {
|
||||
// If the input is static, we can just do it now which will be faster
|
||||
if (IsInputStatic(kVolumeInput)) {
|
||||
auto volume = value[kVolumeInput].toDouble();
|
||||
if (is_input_static(k_volume_input)) {
|
||||
auto volume = value[k_volume_input].to_double();
|
||||
|
||||
if (!qFuzzyCompare(volume, 1.0)) {
|
||||
buffer.transform_volume(volume);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(buffer), this);
|
||||
table->push(NodeValue::k_samples, QVariant::fromValue(buffer), this);
|
||||
} else {
|
||||
// Requires job
|
||||
SampleJob job(globals.time(), kSamplesInput, value);
|
||||
job.Insert(kVolumeInput, value);
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(job), this);
|
||||
SampleJob job(globals.time(), k_samples_input, value);
|
||||
job.insert(k_volume_input, value);
|
||||
table->push(NodeValue::k_samples, QVariant::fromValue(job), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeNode::ProcessSamples(const NodeValueRow &values,
|
||||
void VolumeNode::process_samples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const
|
||||
{
|
||||
return ProcessSamplesInternal(values, kOpMultiply, kSamplesInput,
|
||||
kVolumeInput, input, output, index);
|
||||
return process_samples_internal(values, k_op_multiply, k_samples_input,
|
||||
k_volume_input, input, output, index);
|
||||
}
|
||||
|
||||
void VolumeNode::Retranslate()
|
||||
void VolumeNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kSamplesInput, tr("Samples"));
|
||||
SetInputName(kVolumeInput, tr("Volume"));
|
||||
set_input_name(k_samples_input, tr("Samples"));
|
||||
set_input_name(k_volume_input, tr("Volume"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef VOLUMENODE_H
|
||||
#define VOLUMENODE_H
|
||||
#ifndef OAK_VOLUMENODE_H
|
||||
#define OAK_VOLUMENODE_H
|
||||
|
||||
#include "node/math/math/mathbase.h"
|
||||
|
||||
@@ -34,24 +34,24 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(VolumeNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void ProcessSamples(const NodeValueRow &values,
|
||||
virtual void process_samples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
static const QString kSamplesInput;
|
||||
static const QString kVolumeInput;
|
||||
static const QString k_samples_input;
|
||||
static const QString k_volume_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // VOLUMENODE_H
|
||||
#endif // OAK_VOLUMENODE_H
|
||||
|
||||
+35
-35
@@ -31,39 +31,39 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString Block::kLengthInput = QStringLiteral("length_in");
|
||||
const QString Block::k_length_input = QStringLiteral("length_in");
|
||||
|
||||
Block::Block()
|
||||
: previous_(nullptr)
|
||||
, next_(nullptr)
|
||||
, track_(nullptr)
|
||||
{
|
||||
AddInput(kLengthInput, NodeValue::kRational,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable |
|
||||
kInputFlagHidden));
|
||||
SetInputProperty(kLengthInput, QStringLiteral("min"),
|
||||
QVariant::fromValue(rational(0, 1)));
|
||||
SetInputProperty(kLengthInput, QStringLiteral("view"),
|
||||
RationalSlider::kTime);
|
||||
SetInputProperty(kLengthInput, QStringLiteral("viewlock"), true);
|
||||
add_input(k_length_input, NodeValue::k_rational,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable |
|
||||
k_input_flag_hidden));
|
||||
set_input_property(k_length_input, QStringLiteral("min"),
|
||||
QVariant::fromValue(Rational(0, 1)));
|
||||
set_input_property(k_length_input, QStringLiteral("view"),
|
||||
RationalSlider::k_time);
|
||||
set_input_property(k_length_input, QStringLiteral("viewlock"), true);
|
||||
|
||||
SetInputFlag(kEnabledInput, kInputFlagNotConnectable);
|
||||
SetInputFlag(kEnabledInput, kInputFlagNotKeyframable);
|
||||
set_input_flag(k_enabled_input, k_input_flag_not_connectable);
|
||||
set_input_flag(k_enabled_input, k_input_flag_not_keyframable);
|
||||
|
||||
SetFlag(kDontShowInParamView);
|
||||
set_flag(k_dont_show_in_param_view);
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> Block::Category() const
|
||||
QVector<Node::CategoryID> Block::category() const
|
||||
{
|
||||
return { kCategoryTimeline };
|
||||
return { k_category_timeline };
|
||||
}
|
||||
|
||||
rational Block::length() const
|
||||
Rational Block::length() const
|
||||
{
|
||||
return GetStandardValue(kLengthInput).value<rational>();
|
||||
return get_standard_value(k_length_input).value<Rational>();
|
||||
}
|
||||
|
||||
void Block::set_length_and_media_out(const rational &length)
|
||||
void Block::set_length_and_media_out(const Rational &length)
|
||||
{
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
@@ -72,7 +72,7 @@ void Block::set_length_and_media_out(const rational &length)
|
||||
set_length_internal(length);
|
||||
}
|
||||
|
||||
void Block::set_length_and_media_in(const rational &length)
|
||||
void Block::set_length_and_media_in(const Rational &length)
|
||||
{
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
@@ -84,50 +84,50 @@ void Block::set_length_and_media_in(const rational &length)
|
||||
|
||||
bool Block::is_enabled() const
|
||||
{
|
||||
return GetStandardValue(kEnabledInput).toBool();
|
||||
return get_standard_value(k_enabled_input).toBool();
|
||||
}
|
||||
|
||||
void Block::set_enabled(bool e)
|
||||
{
|
||||
SetStandardValue(kEnabledInput, e);
|
||||
set_standard_value(k_enabled_input, e);
|
||||
|
||||
emit EnabledChanged();
|
||||
emit enabled_changed();
|
||||
}
|
||||
|
||||
void Block::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
super::InputValueChangedEvent(input, element);
|
||||
|
||||
if (input == kLengthInput) {
|
||||
emit LengthChanged();
|
||||
} else if (input == kEnabledInput) {
|
||||
emit EnabledChanged();
|
||||
if (input == k_length_input) {
|
||||
emit length_changed();
|
||||
} else if (input == k_enabled_input) {
|
||||
emit enabled_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void Block::set_length_internal(const rational &length)
|
||||
void Block::set_length_internal(const Rational &length)
|
||||
{
|
||||
SetStandardValue(kLengthInput, QVariant::fromValue(length));
|
||||
set_standard_value(k_length_input, QVariant::fromValue(length));
|
||||
}
|
||||
|
||||
void Block::Retranslate()
|
||||
void Block::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kLengthInput, tr("Length"));
|
||||
SetInputName(kEnabledInput, tr("Enabled"));
|
||||
set_input_name(k_length_input, tr("Length"));
|
||||
set_input_name(k_enabled_input, tr("Enabled"));
|
||||
}
|
||||
|
||||
void Block::InvalidateCache(const TimeRange &range, const QString &from,
|
||||
void Block::invalidate_cache(const TimeRange &range, const QString &from,
|
||||
int element, InvalidateCacheOptions options)
|
||||
{
|
||||
TimeRange r;
|
||||
|
||||
if (from == kLengthInput) {
|
||||
if (from == k_length_input) {
|
||||
// We must intercept the signal here
|
||||
r = TimeRange(qMin(length(), last_length_), RATIONAL_MAX);
|
||||
|
||||
if (!NodeInputDragger::IsInputBeingDragged()) {
|
||||
if (!NodeInputDragger::is_input_being_dragged()) {
|
||||
last_length_ = length();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void Block::InvalidateCache(const TimeRange &range, const QString &from,
|
||||
r = range;
|
||||
}
|
||||
|
||||
super::InvalidateCache(r, from, element, options);
|
||||
super::invalidate_cache(r, from, element, options);
|
||||
}
|
||||
|
||||
void Block::set_previous_next(Block *previous, Block *next)
|
||||
|
||||
+23
-23
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef BLOCK_H
|
||||
#define BLOCK_H
|
||||
#ifndef OAK_BLOCK_H
|
||||
#define OAK_BLOCK_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "timeline/timelinecommon.h"
|
||||
@@ -38,31 +38,31 @@ class Block : public Node {
|
||||
public:
|
||||
Block();
|
||||
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
|
||||
const rational &in() const
|
||||
const Rational &in() const
|
||||
{
|
||||
return in_point_;
|
||||
}
|
||||
|
||||
const rational &out() const
|
||||
const Rational &out() const
|
||||
{
|
||||
return out_point_;
|
||||
}
|
||||
|
||||
void set_in(const rational &in)
|
||||
void set_in(const Rational &in)
|
||||
{
|
||||
in_point_ = in;
|
||||
}
|
||||
|
||||
void set_out(const rational &out)
|
||||
void set_out(const Rational &out)
|
||||
{
|
||||
out_point_ = out;
|
||||
}
|
||||
|
||||
rational length() const;
|
||||
virtual void set_length_and_media_out(const rational &length);
|
||||
virtual void set_length_and_media_in(const rational &length);
|
||||
Rational length() const;
|
||||
virtual void set_length_and_media_out(const Rational &length);
|
||||
virtual void set_length_and_media_in(const Rational &length);
|
||||
|
||||
TimeRange range() const
|
||||
{
|
||||
@@ -97,32 +97,32 @@ public:
|
||||
void set_track(Track *track)
|
||||
{
|
||||
track_ = track;
|
||||
emit TrackChanged(track_);
|
||||
emit track_changed(track_);
|
||||
}
|
||||
|
||||
bool is_enabled() const;
|
||||
void set_enabled(bool e);
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void InvalidateCache(
|
||||
virtual void invalidate_cache(
|
||||
const TimeRange &range, const QString &from, int element = -1,
|
||||
InvalidateCacheOptions options = InvalidateCacheOptions()) override;
|
||||
|
||||
static const QString kLengthInput;
|
||||
static const QString k_length_input;
|
||||
|
||||
static void set_previous_next(Block *previous, Block *next);
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
void EnabledChanged();
|
||||
void enabled_changed();
|
||||
|
||||
void LengthChanged();
|
||||
void length_changed();
|
||||
|
||||
void PreviewChanged();
|
||||
void preview_changed();
|
||||
|
||||
void TrackChanged(Track *track);
|
||||
void track_changed(Track *track);
|
||||
|
||||
protected:
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
@@ -132,15 +132,15 @@ protected:
|
||||
Block *next_;
|
||||
|
||||
private:
|
||||
void set_length_internal(const rational &length);
|
||||
void set_length_internal(const Rational &length);
|
||||
|
||||
rational in_point_;
|
||||
rational out_point_;
|
||||
Rational in_point_;
|
||||
Rational out_point_;
|
||||
Track *track_;
|
||||
|
||||
rational last_length_;
|
||||
Rational last_length_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // BLOCK_H
|
||||
#endif // OAK_BLOCK_H
|
||||
|
||||
+226
-226
@@ -34,59 +34,59 @@ 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");
|
||||
const QString ClipBlock::kMaintainAudioPitchInput =
|
||||
const QString ClipBlock::k_buffer_in = QStringLiteral("buffer_in");
|
||||
const QString ClipBlock::k_media_in_input = QStringLiteral("media_in_in");
|
||||
const QString ClipBlock::k_speed_input = QStringLiteral("speed_in");
|
||||
const QString ClipBlock::k_reverse_input = QStringLiteral("reverse_in");
|
||||
const QString ClipBlock::k_maintain_audio_pitch_input =
|
||||
QStringLiteral("maintain_audio_pitch_in");
|
||||
const QString ClipBlock::kAutoCacheInput = QStringLiteral("autocache_in");
|
||||
const QString ClipBlock::kLoopModeInput = QStringLiteral("loop_in");
|
||||
const QString ClipBlock::k_auto_cache_input = QStringLiteral("autocache_in");
|
||||
const QString ClipBlock::k_loop_mode_input = QStringLiteral("loop_in");
|
||||
|
||||
ClipBlock::ClipBlock()
|
||||
: in_transition_(nullptr)
|
||||
, out_transition_(nullptr)
|
||||
, connected_viewer_(nullptr)
|
||||
{
|
||||
AddInput(kMediaInInput, NodeValue::kRational,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kMediaInInput, QStringLiteral("view"),
|
||||
RationalSlider::kTime);
|
||||
SetInputProperty(kMediaInInput, QStringLiteral("viewlock"), true);
|
||||
add_input(k_media_in_input, NodeValue::k_rational,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
set_input_property(k_media_in_input, QStringLiteral("view"),
|
||||
RationalSlider::k_time);
|
||||
set_input_property(k_media_in_input, QStringLiteral("viewlock"), true);
|
||||
|
||||
AddInput(kSpeedInput, NodeValue::kFloat, 1.0,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kSpeedInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kSpeedInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_speed_input, NodeValue::k_float, 1.0,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
set_input_property(k_speed_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_speed_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
AddInput(kReverseInput, NodeValue::kBoolean, false,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_reverse_input, NodeValue::k_boolean, false,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kMaintainAudioPitchInput, NodeValue::kBoolean, false,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_maintain_audio_pitch_input, NodeValue::k_boolean, false,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kAutoCacheInput, NodeValue::kBoolean, false,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_auto_cache_input, NodeValue::k_boolean, false,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
|
||||
PrependInput(kBufferIn, NodeValue::kNone,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
prepend_input(k_buffer_in, NodeValue::k_none,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
//SetValueHintForInput(kBufferIn, ValueHint(NodeValue::kBuffer));
|
||||
|
||||
SetEffectInput(kBufferIn);
|
||||
set_effect_input(k_buffer_in);
|
||||
|
||||
AddInput(kLoopModeInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_loop_mode_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
}
|
||||
|
||||
QString ClipBlock::Name() const
|
||||
QString ClipBlock::name() const
|
||||
{
|
||||
if (connected_viewer_ && !connected_viewer_->GetLabel().isEmpty()) {
|
||||
return connected_viewer_->GetLabel();
|
||||
if (connected_viewer_ && !connected_viewer_->get_label().isEmpty()) {
|
||||
return connected_viewer_->get_label();
|
||||
} else if (track()) {
|
||||
if (track()->type() == Track::kVideo) {
|
||||
if (track()->type() == Track::k_video) {
|
||||
return tr("Video Clip");
|
||||
} else if (track()->type() == Track::kAudio) {
|
||||
} else if (track()->type() == Track::k_audio) {
|
||||
return tr("Audio Clip");
|
||||
}
|
||||
}
|
||||
@@ -99,12 +99,12 @@ QString ClipBlock::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.clip");
|
||||
}
|
||||
|
||||
QString ClipBlock::Description() const
|
||||
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)
|
||||
void ClipBlock::set_length_and_media_out(const Rational &length)
|
||||
{
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
@@ -112,39 +112,39 @@ void ClipBlock::set_length_and_media_out(const rational &length)
|
||||
|
||||
if (reverse()) {
|
||||
// Calculate media_in adjustment
|
||||
rational proposed_media_in = SequenceToMediaTime(
|
||||
this->length() - length, kSTMIgnoreReverse | kSTMIgnoreLoop);
|
||||
Rational proposed_media_in = sequence_to_media_time(
|
||||
this->length() - length, k_stm_ignore_reverse | k_stm_ignore_loop);
|
||||
set_media_in(proposed_media_in);
|
||||
}
|
||||
|
||||
super::set_length_and_media_out(length);
|
||||
}
|
||||
|
||||
void ClipBlock::set_length_and_media_in(const rational &length)
|
||||
void ClipBlock::set_length_and_media_in(const Rational &length)
|
||||
{
|
||||
if (length == this->length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
rational old_length = this->length();
|
||||
Rational old_length = this->length();
|
||||
|
||||
super::set_length_and_media_in(length);
|
||||
|
||||
if (!reverse()) {
|
||||
// Calculate media_in adjustment
|
||||
set_media_in(SequenceToMediaTime(old_length - length, kSTMIgnoreLoop));
|
||||
set_media_in(sequence_to_media_time(old_length - length, k_stm_ignore_loop));
|
||||
}
|
||||
}
|
||||
|
||||
rational ClipBlock::media_in() const
|
||||
Rational ClipBlock::media_in() const
|
||||
{
|
||||
return GetStandardValue(kMediaInInput).value<rational>();
|
||||
return get_standard_value(k_media_in_input).value<Rational>();
|
||||
}
|
||||
|
||||
Node::ValueHint ClipBlock::GetValueHintForInput(const QString &input,
|
||||
Node::ValueHint ClipBlock::get_value_hint_for_input(const QString &input,
|
||||
int element) const
|
||||
{
|
||||
if (input == kBufferIn) {
|
||||
if (input == k_buffer_in) {
|
||||
// The buffer input takes whatever the connected node provides, so it
|
||||
// is declared as kNone and carries no stored hint. When the connected
|
||||
// node pushes more than one value type (a footage pushes both a
|
||||
@@ -152,46 +152,46 @@ Node::ValueHint ClipBlock::GetValueHintForInput(const QString &input,
|
||||
// the last value in the table, which may feed audio samples into a
|
||||
// video clip and produce a black frame. Prefer the value type that
|
||||
// matches this clip's track.
|
||||
switch (GetTrackType()) {
|
||||
case Track::kVideo:
|
||||
return ValueHint(QVector<NodeValue::Type>{ NodeValue::kTexture });
|
||||
case Track::kAudio:
|
||||
return ValueHint(QVector<NodeValue::Type>{ NodeValue::kSamples });
|
||||
switch (get_track_type()) {
|
||||
case Track::k_video:
|
||||
return ValueHint(QVector<NodeValue::Type>{ NodeValue::k_texture });
|
||||
case Track::k_audio:
|
||||
return ValueHint(QVector<NodeValue::Type>{ NodeValue::k_samples });
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return super::GetValueHintForInput(input, element);
|
||||
return super::get_value_hint_for_input(input, element);
|
||||
}
|
||||
|
||||
void ClipBlock::set_media_in(const rational &media_in)
|
||||
void ClipBlock::set_media_in(const Rational &media_in)
|
||||
{
|
||||
SetStandardValue(kMediaInInput, QVariant::fromValue(media_in));
|
||||
set_standard_value(k_media_in_input, QVariant::fromValue(media_in));
|
||||
|
||||
RequestInvalidatedFromConnected();
|
||||
request_invalidated_from_connected();
|
||||
}
|
||||
|
||||
void ClipBlock::SetAutocache(bool e)
|
||||
void ClipBlock::set_autocache(bool e)
|
||||
{
|
||||
SetStandardValue(kAutoCacheInput, e);
|
||||
set_standard_value(k_auto_cache_input, e);
|
||||
}
|
||||
|
||||
void ClipBlock::DiscardCache()
|
||||
void ClipBlock::discard_cache()
|
||||
{
|
||||
if (Node *connected = GetConnectedOutput(kBufferIn)) {
|
||||
Track::Type type = GetTrackType();
|
||||
if (type == Track::kVideo) {
|
||||
connected->video_frame_cache()->Invalidate(
|
||||
if (Node *connected = get_connected_output(k_buffer_in)) {
|
||||
Track::Type type = get_track_type();
|
||||
if (type == Track::k_video) {
|
||||
connected->video_frame_cache()->invalidate(
|
||||
TimeRange(RATIONAL_MIN, RATIONAL_MAX));
|
||||
} else if (type == Track::kAudio) {
|
||||
connected->audio_playback_cache()->Invalidate(
|
||||
} else if (type == Track::k_audio) {
|
||||
connected->audio_playback_cache()->invalidate(
|
||||
TimeRange(RATIONAL_MIN, RATIONAL_MAX));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rational ClipBlock::SequenceToMediaTime(const rational &sequence_time,
|
||||
Rational ClipBlock::sequence_to_media_time(const Rational &sequence_time,
|
||||
uint64_t flags) const
|
||||
{
|
||||
// These constants are not considered "values" per se, so we don't modify them
|
||||
@@ -199,13 +199,13 @@ rational ClipBlock::SequenceToMediaTime(const rational &sequence_time,
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
rational media_time = sequence_time;
|
||||
Rational media_time = sequence_time;
|
||||
|
||||
if (reverse() && !(flags & kSTMIgnoreReverse)) {
|
||||
if (reverse() && !(flags & k_stm_ignore_reverse)) {
|
||||
media_time = length() - media_time;
|
||||
}
|
||||
|
||||
if (!(flags & kSTMIgnoreSpeed)) {
|
||||
if (!(flags & k_stm_ignore_speed)) {
|
||||
double speed_value = speed();
|
||||
if (qIsNull(speed_value)) {
|
||||
// Effectively holds the frame at the in point
|
||||
@@ -213,7 +213,7 @@ rational ClipBlock::SequenceToMediaTime(const rational &sequence_time,
|
||||
} else if (!qFuzzyCompare(speed_value, 1.0)) {
|
||||
// Multiply time
|
||||
media_time =
|
||||
rational::fromDouble(media_time.toDouble() * speed_value);
|
||||
Rational::from_double(media_time.to_double() * speed_value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,21 +232,21 @@ rational ClipBlock::SequenceToMediaTime(const rational &sequence_time,
|
||||
media_time -= connected_viewer_->GetLength();
|
||||
}
|
||||
} else if (loop_mode() == kLoopModeClamp) {
|
||||
media_time = std::clamp(media_time, rational(0), connected_viewer_->GetLength()-connected_viewer_->GetVideoParams().frame_rate_as_time_base());
|
||||
media_time = std::clamp(media_time, Rational(0), connected_viewer_->GetLength()-connected_viewer_->GetVideoParams().frame_rate_as_time_base());
|
||||
}
|
||||
}*/
|
||||
|
||||
return media_time;
|
||||
}
|
||||
|
||||
rational ClipBlock::MediaToSequenceTime(const rational &media_time) const
|
||||
Rational ClipBlock::media_to_sequence_time(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 - media_in();
|
||||
Rational sequence_time = media_time - media_in();
|
||||
|
||||
double speed_value = speed();
|
||||
if (qIsNull(speed_value)) {
|
||||
@@ -255,7 +255,7 @@ rational ClipBlock::MediaToSequenceTime(const rational &media_time) const
|
||||
} else if (!qFuzzyCompare(speed_value, 1.0)) {
|
||||
// Divide time
|
||||
sequence_time =
|
||||
rational::fromDouble(sequence_time.toDouble() / speed_value);
|
||||
Rational::from_double(sequence_time.to_double() / speed_value);
|
||||
}
|
||||
|
||||
if (reverse()) {
|
||||
@@ -265,80 +265,80 @@ rational ClipBlock::MediaToSequenceTime(const rational &media_time) const
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
void ClipBlock::RequestRangeFromConnected(const TimeRange &range)
|
||||
void ClipBlock::request_range_from_connected(const TimeRange &range)
|
||||
{
|
||||
Track::Type type = GetTrackType();
|
||||
Track::Type type = get_track_type();
|
||||
|
||||
if (type == Track::kVideo || type == Track::kAudio) {
|
||||
if (Node *connected = GetConnectedOutput(kBufferIn)) {
|
||||
if (type == Track::k_video || type == Track::k_audio) {
|
||||
if (Node *connected = get_connected_output(k_buffer_in)) {
|
||||
TimeRange max_range = media_range();
|
||||
if (type == Track::kVideo) {
|
||||
if (type == Track::k_video) {
|
||||
// Handle thumbnails
|
||||
RequestRangeForCache(connected->thumbnail_cache(), max_range,
|
||||
request_range_for_cache(connected->thumbnail_cache(), max_range,
|
||||
range, true, false);
|
||||
{
|
||||
TimeRange thumb_range = range.Intersected(max_range);
|
||||
if (GetAdjustedThumbnailRange(&thumb_range)) {
|
||||
connected->thumbnail_cache()->Request(
|
||||
TimeRange thumb_range = range.intersected(max_range);
|
||||
if (get_adjusted_thumbnail_range(&thumb_range)) {
|
||||
connected->thumbnail_cache()->request(
|
||||
this->track()->sequence(), thumb_range);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle video cache
|
||||
RequestRangeForCache(connected->video_frame_cache(), max_range,
|
||||
range, true, IsAutocaching());
|
||||
} else if (type == Track::kAudio) {
|
||||
request_range_for_cache(connected->video_frame_cache(), max_range,
|
||||
range, true, is_autocaching());
|
||||
} else if (type == Track::k_audio) {
|
||||
// Handle waveforms
|
||||
RequestRangeForCache(
|
||||
request_range_for_cache(
|
||||
connected->waveform_cache(), max_range, range, true,
|
||||
(OLIVE_CONFIG("TimelineWaveformMode").toInt() ==
|
||||
Timeline::kWaveformsEnabled));
|
||||
(OAK_CONFIG("TimelineWaveformMode").toInt() ==
|
||||
Timeline::k_waveforms_enabled));
|
||||
|
||||
// Handle audio cache
|
||||
RequestRangeForCache(connected->audio_playback_cache(),
|
||||
max_range, range, true, IsAutocaching());
|
||||
request_range_for_cache(connected->audio_playback_cache(),
|
||||
max_range, range, true, is_autocaching());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::RequestInvalidatedFromConnected(bool force_all,
|
||||
void ClipBlock::request_invalidated_from_connected(bool force_all,
|
||||
const TimeRange &intersect)
|
||||
{
|
||||
Track::Type type = GetTrackType();
|
||||
Track::Type type = get_track_type();
|
||||
|
||||
if (type == Track::kVideo || type == Track::kAudio) {
|
||||
if (Node *connected = GetConnectedOutput(kBufferIn)) {
|
||||
if (type == Track::k_video || type == Track::k_audio) {
|
||||
if (Node *connected = get_connected_output(k_buffer_in)) {
|
||||
TimeRange max_range = media_range();
|
||||
|
||||
if (!intersect.length().isNull()) {
|
||||
max_range = max_range.Intersected(intersect);
|
||||
max_range = max_range.intersected(intersect);
|
||||
}
|
||||
|
||||
if (type == Track::kVideo) {
|
||||
if (type == Track::k_video) {
|
||||
// Handle thumbnails
|
||||
TimeRange thumb_range = max_range;
|
||||
if (GetAdjustedThumbnailRange(&thumb_range)) {
|
||||
RequestInvalidatedForCache(connected->thumbnail_cache(),
|
||||
if (get_adjusted_thumbnail_range(&thumb_range)) {
|
||||
request_invalidated_for_cache(connected->thumbnail_cache(),
|
||||
thumb_range);
|
||||
}
|
||||
|
||||
// Handle video cache
|
||||
if (IsAutocaching() || force_all) {
|
||||
RequestInvalidatedForCache(connected->video_frame_cache(),
|
||||
if (is_autocaching() || force_all) {
|
||||
request_invalidated_for_cache(connected->video_frame_cache(),
|
||||
max_range);
|
||||
}
|
||||
} else if (type == Track::kAudio) {
|
||||
} else if (type == Track::k_audio) {
|
||||
// Handle waveforms
|
||||
if (OLIVE_CONFIG("TimelineWaveformMode").toInt() ==
|
||||
Timeline::kWaveformsEnabled) {
|
||||
RequestInvalidatedForCache(connected->waveform_cache(),
|
||||
if (OAK_CONFIG("TimelineWaveformMode").toInt() ==
|
||||
Timeline::k_waveforms_enabled) {
|
||||
request_invalidated_for_cache(connected->waveform_cache(),
|
||||
max_range);
|
||||
}
|
||||
|
||||
// Handle audio cache
|
||||
if (IsAutocaching() || force_all) {
|
||||
RequestInvalidatedForCache(
|
||||
if (is_autocaching() || force_all) {
|
||||
request_invalidated_for_cache(
|
||||
connected->audio_playback_cache(), max_range);
|
||||
}
|
||||
}
|
||||
@@ -346,56 +346,56 @@ void ClipBlock::RequestInvalidatedFromConnected(bool force_all,
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::RequestRangeForCache(PlaybackCache *cache,
|
||||
void ClipBlock::request_range_for_cache(PlaybackCache *cache,
|
||||
const TimeRange &max_range,
|
||||
const TimeRange &range, bool invalidate,
|
||||
bool request)
|
||||
{
|
||||
TimeRange r = range.Intersected(max_range);
|
||||
TimeRange r = range.intersected(max_range);
|
||||
|
||||
if (invalidate) {
|
||||
cache->Invalidate(r);
|
||||
cache->invalidate(r);
|
||||
}
|
||||
|
||||
if (request) {
|
||||
cache->Request(this->track()->sequence(), r);
|
||||
cache->request(this->track()->sequence(), r);
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::RequestInvalidatedForCache(PlaybackCache *cache,
|
||||
void ClipBlock::request_invalidated_for_cache(PlaybackCache *cache,
|
||||
const TimeRange &max_range)
|
||||
{
|
||||
TimeRangeList invalid = cache->GetInvalidatedRanges(max_range);
|
||||
TimeRangeList invalid = cache->get_invalidated_ranges(max_range);
|
||||
|
||||
for (const PlaybackCache::Passthrough &p : cache->GetPassthroughs()) {
|
||||
for (const PlaybackCache::Passthrough &p : cache->get_passthroughs()) {
|
||||
invalid.remove(p);
|
||||
}
|
||||
|
||||
for (const TimeRange &r : invalid) {
|
||||
RequestRangeForCache(cache, max_range, r, false, true);
|
||||
request_range_for_cache(cache, max_range, r, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
bool ClipBlock::GetAdjustedThumbnailRange(TimeRange *r) const
|
||||
bool ClipBlock::get_adjusted_thumbnail_range(TimeRange *r) const
|
||||
{
|
||||
switch (static_cast<Timeline::ThumbnailMode>(
|
||||
OLIVE_CONFIG("TimelineThumbnailMode").toInt())) {
|
||||
case Timeline::kThumbnailOff:
|
||||
OAK_CONFIG("TimelineThumbnailMode").toInt())) {
|
||||
case Timeline::k_thumbnail_off:
|
||||
// Don't cache any range
|
||||
return false;
|
||||
case Timeline::kThumbnailInOut: {
|
||||
case Timeline::k_thumbnail_in_out: {
|
||||
// Only cache in point
|
||||
rational in = this->media_range().in();
|
||||
if (r->Contains(in)) {
|
||||
Rational in = this->media_range().in();
|
||||
if (r->contains(in)) {
|
||||
// Cache only the in point
|
||||
*r = TimeRange(in, in + thumbnail_cache()->GetTimebase());
|
||||
*r = TimeRange(in, in + thumbnail_cache()->get_timebase());
|
||||
return true;
|
||||
} else {
|
||||
// Cache nothing
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case Timeline::kThumbnailOn:
|
||||
case Timeline::k_thumbnail_on:
|
||||
// Cache entire range
|
||||
return true;
|
||||
}
|
||||
@@ -404,16 +404,16 @@ bool ClipBlock::GetAdjustedThumbnailRange(TimeRange *r) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClipBlock::InvalidateCache(const TimeRange &range, const QString &from,
|
||||
void ClipBlock::invalidate_cache(const TimeRange &range, const QString &from,
|
||||
int element, InvalidateCacheOptions options)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
// If signal is from texture input, transform all times from media time to sequence time
|
||||
if (from == kBufferIn) {
|
||||
if (from == k_buffer_in) {
|
||||
// Render caches where necessary
|
||||
if (AreCachesEnabled()) {
|
||||
RequestRangeFromConnected(range);
|
||||
if (are_caches_enabled()) {
|
||||
request_range_from_connected(range);
|
||||
}
|
||||
|
||||
// Adjust range from media time to sequence time
|
||||
@@ -424,48 +424,48 @@ void ClipBlock::InvalidateCache(const TimeRange &range, const QString &from,
|
||||
// Handle 0 speed by invalidating the whole clip
|
||||
adj = TimeRange(RATIONAL_MIN, RATIONAL_MAX);
|
||||
} else {
|
||||
adj = TimeRange(MediaToSequenceTime(range.in()),
|
||||
MediaToSequenceTime(range.out()));
|
||||
adj = TimeRange(media_to_sequence_time(range.in()),
|
||||
media_to_sequence_time(range.out()));
|
||||
}
|
||||
|
||||
// Find connected viewer node
|
||||
auto viewers = FindInputNodesConnectedToInput<ViewerOutput>(
|
||||
NodeInput(this, kBufferIn), 1);
|
||||
auto viewers = find_input_nodes_connected_to_input<ViewerOutput>(
|
||||
NodeInput(this, k_buffer_in), 1);
|
||||
ViewerOutput *new_connected_viewer =
|
||||
viewers.isEmpty() ? nullptr : viewers.first();
|
||||
|
||||
if (new_connected_viewer != connected_viewer_) {
|
||||
if (connected_viewer_) {
|
||||
disconnect(connected_viewer_->GetMarkers(),
|
||||
&TimelineMarkerList::MarkerAdded, this,
|
||||
&ClipBlock::PreviewChanged);
|
||||
disconnect(connected_viewer_->GetMarkers(),
|
||||
&TimelineMarkerList::MarkerRemoved, this,
|
||||
&ClipBlock::PreviewChanged);
|
||||
disconnect(connected_viewer_->GetMarkers(),
|
||||
&TimelineMarkerList::MarkerModified, this,
|
||||
&ClipBlock::PreviewChanged);
|
||||
disconnect(connected_viewer_->get_markers(),
|
||||
&TimelineMarkerList::marker_added, this,
|
||||
&ClipBlock::preview_changed);
|
||||
disconnect(connected_viewer_->get_markers(),
|
||||
&TimelineMarkerList::marker_removed, this,
|
||||
&ClipBlock::preview_changed);
|
||||
disconnect(connected_viewer_->get_markers(),
|
||||
&TimelineMarkerList::marker_modified, this,
|
||||
&ClipBlock::preview_changed);
|
||||
}
|
||||
|
||||
connected_viewer_ = new_connected_viewer;
|
||||
|
||||
if (connected_viewer_) {
|
||||
connect(connected_viewer_->GetMarkers(),
|
||||
&TimelineMarkerList::MarkerAdded, this,
|
||||
&ClipBlock::PreviewChanged);
|
||||
connect(connected_viewer_->GetMarkers(),
|
||||
&TimelineMarkerList::MarkerRemoved, this,
|
||||
&ClipBlock::PreviewChanged);
|
||||
connect(connected_viewer_->GetMarkers(),
|
||||
&TimelineMarkerList::MarkerModified, this,
|
||||
&ClipBlock::PreviewChanged);
|
||||
connect(connected_viewer_->get_markers(),
|
||||
&TimelineMarkerList::marker_added, this,
|
||||
&ClipBlock::preview_changed);
|
||||
connect(connected_viewer_->get_markers(),
|
||||
&TimelineMarkerList::marker_removed, this,
|
||||
&ClipBlock::preview_changed);
|
||||
connect(connected_viewer_->get_markers(),
|
||||
&TimelineMarkerList::marker_modified, this,
|
||||
&ClipBlock::preview_changed);
|
||||
}
|
||||
}
|
||||
|
||||
super::InvalidateCache(adj, from, element, options);
|
||||
super::invalidate_cache(adj, from, element, options);
|
||||
} else {
|
||||
// Otherwise, pass signal along normally
|
||||
super::InvalidateCache(range, from, element, options);
|
||||
super::invalidate_cache(range, from, element, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,23 +487,23 @@ void ClipBlock::InputConnectedEvent(const QString &input, int element,
|
||||
{
|
||||
super::InputConnectedEvent(input, element, output);
|
||||
|
||||
if (input == kBufferIn) {
|
||||
connect(output->thumbnail_cache(), &FrameHashCache::Invalidated, this,
|
||||
&Block::PreviewChanged);
|
||||
connect(output->waveform_cache(), &AudioPlaybackCache::Invalidated,
|
||||
this, &Block::PreviewChanged);
|
||||
connect(output->video_frame_cache(), &FrameHashCache::Invalidated, this,
|
||||
&Block::PreviewChanged);
|
||||
if (input == k_buffer_in) {
|
||||
connect(output->thumbnail_cache(), &FrameHashCache::invalidated, this,
|
||||
&Block::preview_changed);
|
||||
connect(output->waveform_cache(), &AudioPlaybackCache::invalidated,
|
||||
this, &Block::preview_changed);
|
||||
connect(output->video_frame_cache(), &FrameHashCache::invalidated, this,
|
||||
&Block::preview_changed);
|
||||
connect(output->audio_playback_cache(),
|
||||
&AudioPlaybackCache::Invalidated, this, &Block::PreviewChanged);
|
||||
connect(output->thumbnail_cache(), &FrameHashCache::Validated, this,
|
||||
&Block::PreviewChanged);
|
||||
connect(output->waveform_cache(), &AudioPlaybackCache::Validated, this,
|
||||
&Block::PreviewChanged);
|
||||
connect(output->video_frame_cache(), &FrameHashCache::Validated, this,
|
||||
&Block::PreviewChanged);
|
||||
connect(output->audio_playback_cache(), &AudioPlaybackCache::Validated,
|
||||
this, &Block::PreviewChanged);
|
||||
&AudioPlaybackCache::invalidated, this, &Block::preview_changed);
|
||||
connect(output->thumbnail_cache(), &FrameHashCache::validated, this,
|
||||
&Block::preview_changed);
|
||||
connect(output->waveform_cache(), &AudioPlaybackCache::validated, this,
|
||||
&Block::preview_changed);
|
||||
connect(output->video_frame_cache(), &FrameHashCache::validated, this,
|
||||
&Block::preview_changed);
|
||||
connect(output->audio_playback_cache(), &AudioPlaybackCache::validated,
|
||||
this, &Block::preview_changed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,25 +512,25 @@ void ClipBlock::InputDisconnectedEvent(const QString &input, int element,
|
||||
{
|
||||
super::InputDisconnectedEvent(input, element, output);
|
||||
|
||||
if (input == kBufferIn) {
|
||||
disconnect(output->thumbnail_cache(), &FrameHashCache::Invalidated,
|
||||
this, &Block::PreviewChanged);
|
||||
disconnect(output->waveform_cache(), &AudioPlaybackCache::Invalidated,
|
||||
this, &Block::PreviewChanged);
|
||||
disconnect(output->video_frame_cache(), &FrameHashCache::Invalidated,
|
||||
this, &Block::PreviewChanged);
|
||||
if (input == k_buffer_in) {
|
||||
disconnect(output->thumbnail_cache(), &FrameHashCache::invalidated,
|
||||
this, &Block::preview_changed);
|
||||
disconnect(output->waveform_cache(), &AudioPlaybackCache::invalidated,
|
||||
this, &Block::preview_changed);
|
||||
disconnect(output->video_frame_cache(), &FrameHashCache::invalidated,
|
||||
this, &Block::preview_changed);
|
||||
disconnect(output->audio_playback_cache(),
|
||||
&AudioPlaybackCache::Invalidated, this,
|
||||
&Block::PreviewChanged);
|
||||
disconnect(output->thumbnail_cache(), &FrameHashCache::Validated, this,
|
||||
&Block::PreviewChanged);
|
||||
disconnect(output->waveform_cache(), &AudioPlaybackCache::Validated,
|
||||
this, &Block::PreviewChanged);
|
||||
disconnect(output->video_frame_cache(), &FrameHashCache::Validated,
|
||||
this, &Block::PreviewChanged);
|
||||
&AudioPlaybackCache::invalidated, this,
|
||||
&Block::preview_changed);
|
||||
disconnect(output->thumbnail_cache(), &FrameHashCache::validated, this,
|
||||
&Block::preview_changed);
|
||||
disconnect(output->waveform_cache(), &AudioPlaybackCache::validated,
|
||||
this, &Block::preview_changed);
|
||||
disconnect(output->video_frame_cache(), &FrameHashCache::validated,
|
||||
this, &Block::preview_changed);
|
||||
disconnect(output->audio_playback_cache(),
|
||||
&AudioPlaybackCache::Validated, this,
|
||||
&Block::PreviewChanged);
|
||||
&AudioPlaybackCache::validated, this,
|
||||
&Block::preview_changed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,120 +538,120 @@ void ClipBlock::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
super::InputValueChangedEvent(input, element);
|
||||
|
||||
if (input == kAutoCacheInput) {
|
||||
if (IsAutocaching()) {
|
||||
RequestInvalidatedFromConnected();
|
||||
if (input == k_auto_cache_input) {
|
||||
if (is_autocaching()) {
|
||||
request_invalidated_from_connected();
|
||||
} else {
|
||||
Track::Type type = GetTrackType();
|
||||
Track::Type type = get_track_type();
|
||||
|
||||
if (Node *connected = GetConnectedOutput(kBufferIn)) {
|
||||
if (type == Track::kVideo) {
|
||||
emit connected->video_frame_cache()->CancelAll();
|
||||
} else if (type == Track::kAudio) {
|
||||
emit connected->audio_playback_cache()->CancelAll();
|
||||
if (Node *connected = get_connected_output(k_buffer_in)) {
|
||||
if (type == Track::k_video) {
|
||||
emit connected->video_frame_cache()->cancel_all();
|
||||
} else if (type == Track::k_audio) {
|
||||
emit connected->audio_playback_cache()->cancel_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (input == kLoopModeInput) {
|
||||
emit PreviewChanged();
|
||||
} else if (input == k_loop_mode_input) {
|
||||
emit preview_changed();
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::InputTimeAdjustment(const QString &input, int element,
|
||||
TimeRange ClipBlock::input_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time,
|
||||
bool clamp) const
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kBufferIn) {
|
||||
return TimeRange(SequenceToMediaTime(input_time.in()),
|
||||
SequenceToMediaTime(input_time.out()));
|
||||
if (input == k_buffer_in) {
|
||||
return TimeRange(sequence_to_media_time(input_time.in()),
|
||||
sequence_to_media_time(input_time.out()));
|
||||
}
|
||||
|
||||
return super::InputTimeAdjustment(input, element, input_time, clamp);
|
||||
return super::input_time_adjustment(input, element, input_time, clamp);
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::OutputTimeAdjustment(const QString &input, int element,
|
||||
TimeRange ClipBlock::output_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time) const
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kBufferIn) {
|
||||
return TimeRange(MediaToSequenceTime(input_time.in()),
|
||||
MediaToSequenceTime(input_time.out()));
|
||||
if (input == k_buffer_in) {
|
||||
return TimeRange(media_to_sequence_time(input_time.in()),
|
||||
media_to_sequence_time(input_time.out()));
|
||||
}
|
||||
|
||||
return super::OutputTimeAdjustment(input, element, input_time);
|
||||
return super::output_time_adjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
void ClipBlock::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void ClipBlock::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
Q_UNUSED(globals)
|
||||
|
||||
// We discard most values here except for the buffer we received
|
||||
NodeValue data = value[kBufferIn];
|
||||
NodeValue data = value[k_buffer_in];
|
||||
|
||||
table->Clear();
|
||||
if (data.type() != NodeValue::kNone) {
|
||||
table->Push(data);
|
||||
table->clear();
|
||||
if (data.type() != NodeValue::k_none) {
|
||||
table->push(data);
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::Retranslate()
|
||||
void ClipBlock::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBufferIn, tr("Buffer"));
|
||||
SetInputName(kMediaInInput, tr("Media In"));
|
||||
SetInputName(kSpeedInput, tr("Speed"));
|
||||
SetInputName(kReverseInput, tr("Reverse"));
|
||||
SetInputName(kMaintainAudioPitchInput, tr("Maintain Audio Pitch"));
|
||||
SetInputName(kLoopModeInput, tr("Loop"));
|
||||
SetComboBoxStrings(kLoopModeInput, { tr("None"), tr("Loop"), tr("Clamp") });
|
||||
set_input_name(k_buffer_in, tr("Buffer"));
|
||||
set_input_name(k_media_in_input, tr("Media In"));
|
||||
set_input_name(k_speed_input, tr("Speed"));
|
||||
set_input_name(k_reverse_input, tr("Reverse"));
|
||||
set_input_name(k_maintain_audio_pitch_input, tr("Maintain Audio Pitch"));
|
||||
set_input_name(k_loop_mode_input, tr("Loop"));
|
||||
set_combo_box_strings(k_loop_mode_input, { tr("None"), tr("Loop"), tr("Clamp") });
|
||||
}
|
||||
|
||||
void ClipBlock::AddCachePassthroughFrom(ClipBlock *other)
|
||||
void ClipBlock::add_cache_passthrough_from(ClipBlock *other)
|
||||
{
|
||||
if (auto tc = this->video_frame_cache()) {
|
||||
if (auto oc = other->video_frame_cache()) {
|
||||
tc->SetPassthrough(oc);
|
||||
tc->set_passthrough(oc);
|
||||
}
|
||||
}
|
||||
|
||||
if (auto tc = this->audio_playback_cache()) {
|
||||
if (auto oc = other->audio_playback_cache()) {
|
||||
tc->SetPassthrough(oc);
|
||||
tc->set_passthrough(oc);
|
||||
}
|
||||
}
|
||||
|
||||
if (auto tc = this->thumbnails()) {
|
||||
if (auto oc = other->thumbnails()) {
|
||||
tc->SetPassthrough(oc);
|
||||
tc->set_passthrough(oc);
|
||||
}
|
||||
}
|
||||
|
||||
if (auto tc = this->waveform()) {
|
||||
if (auto oc = other->waveform()) {
|
||||
tc->SetPassthrough(oc);
|
||||
tc->set_passthrough(oc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClipBlock::ConnectedToPreviewEvent()
|
||||
{
|
||||
RequestInvalidatedFromConnected();
|
||||
request_invalidated_from_connected();
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::media_range() const
|
||||
{
|
||||
return InputTimeAdjustment(kBufferIn, -1, TimeRange(0, length()), false);
|
||||
return input_time_adjustment(k_buffer_in, -1, TimeRange(0, length()), false);
|
||||
}
|
||||
|
||||
MultiCamNode *ClipBlock::FindMulticam()
|
||||
MultiCamNode *ClipBlock::find_multicam()
|
||||
{
|
||||
auto v = FindInputNodesConnectedToInput<MultiCamNode>(
|
||||
NodeInput(this, kBufferIn), 1);
|
||||
auto v = find_input_nodes_connected_to_input<MultiCamNode>(
|
||||
NodeInput(this, k_buffer_in), 1);
|
||||
if (v.empty()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
|
||||
+55
-55
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CLIPBLOCK_H
|
||||
#define CLIPBLOCK_H
|
||||
#ifndef OAK_CLIPBLOCK_H
|
||||
#define OAK_CLIPBLOCK_H
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "codec/decoder.h"
|
||||
@@ -43,80 +43,80 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(ClipBlock)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QString Description() 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;
|
||||
virtual void set_length_and_media_out(const Rational &length) override;
|
||||
virtual void set_length_and_media_in(const Rational &length) override;
|
||||
|
||||
Track::Type GetTrackType() const
|
||||
Track::Type get_track_type() const
|
||||
{
|
||||
if (track()) {
|
||||
return track()->type();
|
||||
} else {
|
||||
return Track::kNone;
|
||||
return Track::k_none;
|
||||
}
|
||||
}
|
||||
|
||||
virtual Node::ValueHint
|
||||
GetValueHintForInput(const QString &input, int element = -1) const override;
|
||||
get_value_hint_for_input(const QString &input, int element = -1) const override;
|
||||
|
||||
rational media_in() const;
|
||||
void set_media_in(const rational &media_in);
|
||||
Rational media_in() const;
|
||||
void set_media_in(const Rational &media_in);
|
||||
|
||||
bool IsAutocaching() const
|
||||
bool is_autocaching() const
|
||||
{
|
||||
return GetStandardValue(kAutoCacheInput).toBool();
|
||||
return get_standard_value(k_auto_cache_input).toBool();
|
||||
}
|
||||
void SetAutocache(bool e);
|
||||
void set_autocache(bool e);
|
||||
|
||||
void DiscardCache();
|
||||
void discard_cache();
|
||||
|
||||
virtual void InvalidateCache(const TimeRange &range, const QString &from,
|
||||
virtual void invalidate_cache(const TimeRange &range, const QString &from,
|
||||
int element,
|
||||
InvalidateCacheOptions options) override;
|
||||
|
||||
virtual TimeRange InputTimeAdjustment(const QString &input, int element,
|
||||
virtual TimeRange input_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time,
|
||||
bool clamp) const override;
|
||||
|
||||
virtual TimeRange
|
||||
OutputTimeAdjustment(const QString &input, int element,
|
||||
output_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time) const override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
void
|
||||
RequestInvalidatedFromConnected(bool force_all = false,
|
||||
request_invalidated_from_connected(bool force_all = false,
|
||||
const TimeRange &intersect = TimeRange());
|
||||
|
||||
double speed() const
|
||||
{
|
||||
return GetStandardValue(kSpeedInput).toDouble();
|
||||
return get_standard_value(k_speed_input).toDouble();
|
||||
}
|
||||
|
||||
bool reverse() const
|
||||
{
|
||||
return GetStandardValue(kReverseInput).toBool();
|
||||
return get_standard_value(k_reverse_input).toBool();
|
||||
}
|
||||
|
||||
void set_reverse(bool e)
|
||||
{
|
||||
SetStandardValue(kReverseInput, e);
|
||||
set_standard_value(k_reverse_input, e);
|
||||
}
|
||||
|
||||
bool maintain_audio_pitch() const
|
||||
{
|
||||
return GetStandardValue(kMaintainAudioPitchInput).toBool();
|
||||
return get_standard_value(k_maintain_audio_pitch_input).toBool();
|
||||
}
|
||||
|
||||
void set_maintain_audio_pitch(bool e)
|
||||
{
|
||||
SetStandardValue(kMaintainAudioPitchInput, e);
|
||||
set_standard_value(k_maintain_audio_pitch_input, e);
|
||||
}
|
||||
|
||||
TransitionBlock *in_transition()
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
|
||||
FrameHashCache *connected_video_cache() const
|
||||
{
|
||||
if (Node *n = GetConnectedOutput(kBufferIn)) {
|
||||
if (Node *n = get_connected_output(k_buffer_in)) {
|
||||
return n->video_frame_cache();
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
|
||||
AudioPlaybackCache *connected_audio_cache() const
|
||||
{
|
||||
if (Node *n = GetConnectedOutput(kBufferIn)) {
|
||||
if (Node *n = get_connected_output(k_buffer_in)) {
|
||||
return n->audio_playback_cache();
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
|
||||
FrameHashCache *thumbnails()
|
||||
{
|
||||
if (Node *n = GetConnectedOutput(kBufferIn)) {
|
||||
if (Node *n = get_connected_output(k_buffer_in)) {
|
||||
return n->thumbnail_cache();
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -173,26 +173,26 @@ public:
|
||||
|
||||
AudioWaveformCache *waveform()
|
||||
{
|
||||
if (Node *n = GetConnectedOutput(kBufferIn)) {
|
||||
if (Node *n = get_connected_output(k_buffer_in)) {
|
||||
return n->waveform_cache();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AddCachePassthroughFrom(ClipBlock *other);
|
||||
void add_cache_passthrough_from(ClipBlock *other);
|
||||
|
||||
ViewerOutput *connected_viewer() const
|
||||
{
|
||||
return connected_viewer_;
|
||||
}
|
||||
|
||||
virtual TimeRange GetVideoCacheRange() const override
|
||||
virtual TimeRange get_video_cache_range() const override
|
||||
{
|
||||
return TimeRange(0, length());
|
||||
}
|
||||
|
||||
virtual TimeRange GetAudioCacheRange() const override
|
||||
virtual TimeRange get_audio_cache_range() const override
|
||||
{
|
||||
return TimeRange(0, length());
|
||||
}
|
||||
@@ -206,24 +206,24 @@ public:
|
||||
*/
|
||||
LoopMode loop_mode() const
|
||||
{
|
||||
return static_cast<LoopMode>(GetStandardValue(kLoopModeInput).toInt());
|
||||
return static_cast<LoopMode>(get_standard_value(k_loop_mode_input).toInt());
|
||||
}
|
||||
|
||||
void set_loop_mode(LoopMode l)
|
||||
{
|
||||
SetStandardValue(kLoopModeInput, int(l));
|
||||
set_standard_value(k_loop_mode_input, int(l));
|
||||
}
|
||||
|
||||
MultiCamNode *FindMulticam();
|
||||
MultiCamNode *find_multicam();
|
||||
|
||||
static const QString kBufferIn;
|
||||
static const QString kMediaInInput;
|
||||
static const QString kSpeedInput;
|
||||
static const QString kReverseInput;
|
||||
static const QString kMaintainAudioPitchInput;
|
||||
static const QString kLoopModeInput;
|
||||
static const QString k_buffer_in;
|
||||
static const QString k_media_in_input;
|
||||
static const QString k_speed_input;
|
||||
static const QString k_reverse_input;
|
||||
static const QString k_maintain_audio_pitch_input;
|
||||
static const QString k_loop_mode_input;
|
||||
|
||||
static const QString kAutoCacheInput;
|
||||
static const QString k_auto_cache_input;
|
||||
|
||||
protected:
|
||||
virtual void LinkChangeEvent() override;
|
||||
@@ -239,26 +239,26 @@ protected:
|
||||
|
||||
private:
|
||||
enum SequenceToMediaTimeFlag {
|
||||
kSTMNone = 0x0,
|
||||
kSTMIgnoreReverse = 0x1,
|
||||
kSTMIgnoreSpeed = 0x2,
|
||||
kSTMIgnoreLoop = 0x4
|
||||
k_stm_none = 0x0,
|
||||
k_stm_ignore_reverse = 0x1,
|
||||
k_stm_ignore_speed = 0x2,
|
||||
k_stm_ignore_loop = 0x4
|
||||
};
|
||||
|
||||
rational SequenceToMediaTime(const rational &sequence_time,
|
||||
uint64_t flags = kSTMNone) const;
|
||||
Rational sequence_to_media_time(const Rational &sequence_time,
|
||||
uint64_t flags = k_stm_none) const;
|
||||
|
||||
rational MediaToSequenceTime(const rational &media_time) const;
|
||||
Rational media_to_sequence_time(const Rational &media_time) const;
|
||||
|
||||
void RequestRangeFromConnected(const TimeRange &range);
|
||||
void request_range_from_connected(const TimeRange &range);
|
||||
|
||||
void RequestRangeForCache(PlaybackCache *cache, const TimeRange &max_range,
|
||||
void request_range_for_cache(PlaybackCache *cache, const TimeRange &max_range,
|
||||
const TimeRange &range, bool invalidate,
|
||||
bool request);
|
||||
void RequestInvalidatedForCache(PlaybackCache *cache,
|
||||
void request_invalidated_for_cache(PlaybackCache *cache,
|
||||
const TimeRange &max_range);
|
||||
|
||||
bool GetAdjustedThumbnailRange(TimeRange *r) const;
|
||||
bool get_adjusted_thumbnail_range(TimeRange *r) const;
|
||||
|
||||
QVector<Block *> block_links_;
|
||||
|
||||
@@ -268,7 +268,7 @@ private:
|
||||
ViewerOutput *connected_viewer_;
|
||||
|
||||
private:
|
||||
rational last_media_in_;
|
||||
Rational last_media_in_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ GapBlock::GapBlock()
|
||||
{
|
||||
}
|
||||
|
||||
QString GapBlock::Name() const
|
||||
QString GapBlock::name() const
|
||||
{
|
||||
return tr("Gap");
|
||||
}
|
||||
@@ -38,7 +38,7 @@ QString GapBlock::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.gap");
|
||||
}
|
||||
|
||||
QString GapBlock::Description() const
|
||||
QString GapBlock::description() const
|
||||
{
|
||||
return tr("A time-based node that represents an empty space.");
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef GAPBLOCK_H
|
||||
#define GAPBLOCK_H
|
||||
#ifndef OAK_GAPBLOCK_H
|
||||
#define OAK_GAPBLOCK_H
|
||||
|
||||
#include "node/block/block.h"
|
||||
|
||||
@@ -37,9 +37,9 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(GapBlock)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString description() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,30 +26,30 @@ namespace olive
|
||||
|
||||
#define super ClipBlock
|
||||
|
||||
const QString SubtitleBlock::kTextIn = QStringLiteral("text_in");
|
||||
const QString SubtitleBlock::k_text_in = QStringLiteral("text_in");
|
||||
|
||||
SubtitleBlock::SubtitleBlock()
|
||||
{
|
||||
AddInput(kTextIn, NodeValue::kText,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_text_in, NodeValue::k_text,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
|
||||
SetInputFlag(kBufferIn, kInputFlagHidden);
|
||||
SetInputFlag(kLengthInput, kInputFlagHidden);
|
||||
SetInputFlag(kMediaInInput, kInputFlagHidden);
|
||||
SetInputFlag(kSpeedInput, kInputFlagHidden);
|
||||
SetInputFlag(kReverseInput, kInputFlagHidden);
|
||||
SetInputFlag(kMaintainAudioPitchInput, kInputFlagHidden);
|
||||
set_input_flag(k_buffer_in, k_input_flag_hidden);
|
||||
set_input_flag(k_length_input, k_input_flag_hidden);
|
||||
set_input_flag(k_media_in_input, k_input_flag_hidden);
|
||||
set_input_flag(k_speed_input, k_input_flag_hidden);
|
||||
set_input_flag(k_reverse_input, k_input_flag_hidden);
|
||||
set_input_flag(k_maintain_audio_pitch_input, k_input_flag_hidden);
|
||||
|
||||
// Undo block flag that hides in param view
|
||||
SetFlag(kDontShowInParamView, false);
|
||||
set_flag(k_dont_show_in_param_view, false);
|
||||
}
|
||||
|
||||
QString SubtitleBlock::Name() const
|
||||
QString SubtitleBlock::name() const
|
||||
{
|
||||
if (GetText().isEmpty()) {
|
||||
if (get_text().isEmpty()) {
|
||||
return tr("Subtitle");
|
||||
} else {
|
||||
return GetText();
|
||||
return get_text();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,17 +58,17 @@ QString SubtitleBlock::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.subtitle");
|
||||
}
|
||||
|
||||
QString SubtitleBlock::Description() const
|
||||
QString SubtitleBlock::description() const
|
||||
{
|
||||
return tr(
|
||||
"A time-based node representing a single subtitle element for a certain period of time.");
|
||||
}
|
||||
|
||||
void SubtitleBlock::Retranslate()
|
||||
void SubtitleBlock::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextIn, tr("Text"));
|
||||
set_input_name(k_text_in, tr("Text"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SUBTITLEBLOCK_H
|
||||
#define SUBTITLEBLOCK_H
|
||||
#ifndef OAK_SUBTITLEBLOCK_H
|
||||
#define OAK_SUBTITLEBLOCK_H
|
||||
|
||||
#include "node/block/clip/clip.h"
|
||||
|
||||
@@ -34,25 +34,25 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(SubtitleBlock)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
static const QString kTextIn;
|
||||
static const QString k_text_in;
|
||||
|
||||
QString GetText() const
|
||||
QString get_text() const
|
||||
{
|
||||
return GetStandardValue(kTextIn).toString();
|
||||
return get_standard_value(k_text_in).toString();
|
||||
}
|
||||
|
||||
void SetText(const QString &text)
|
||||
void set_text(const QString &text)
|
||||
{
|
||||
SetStandardValue(kTextIn, text);
|
||||
set_standard_value(k_text_in, text);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SUBTITLEBLOCK_H
|
||||
#endif // OAK_SUBTITLEBLOCK_H
|
||||
|
||||
@@ -28,7 +28,7 @@ CrossDissolveTransition::CrossDissolveTransition()
|
||||
{
|
||||
}
|
||||
|
||||
QString CrossDissolveTransition::Name() const
|
||||
QString CrossDissolveTransition::name() const
|
||||
{
|
||||
return tr("Cross Dissolve");
|
||||
}
|
||||
@@ -38,23 +38,23 @@ QString CrossDissolveTransition::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.crossdissolve");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> CrossDissolveTransition::Category() const
|
||||
QVector<Node::CategoryID> CrossDissolveTransition::category() const
|
||||
{
|
||||
return { kCategoryTransition };
|
||||
return { k_category_transition };
|
||||
}
|
||||
|
||||
QString CrossDissolveTransition::Description() const
|
||||
QString CrossDissolveTransition::description() const
|
||||
{
|
||||
return tr("Smoothly transition between two clips.");
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
CrossDissolveTransition::GetShaderCode(const ShaderRequest &request) const
|
||||
CrossDissolveTransition::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/crossdissolve.frag"),
|
||||
FileFunctions::read_file_as_string(":/shaders/crossdissolve.frag"),
|
||||
QString());
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ void CrossDissolveTransition::SampleJobEvent(const SampleBuffer &from_samples,
|
||||
{
|
||||
for (size_t i = 0; i < out_samples.sample_count(); i++) {
|
||||
double this_sample_time =
|
||||
out_samples.audio_params().samples_to_time(i).toDouble() + time_in;
|
||||
double progress = GetTotalProgress(this_sample_time);
|
||||
out_samples.audio_params().samples_to_time(i).to_double() + time_in;
|
||||
double progress = get_total_progress(this_sample_time);
|
||||
|
||||
for (int j = 0; j < out_samples.audio_params().channel_count(); j++) {
|
||||
out_samples.data(j)[i] = 0;
|
||||
@@ -74,7 +74,7 @@ void CrossDissolveTransition::SampleJobEvent(const SampleBuffer &from_samples,
|
||||
if (from_samples.is_allocated()) {
|
||||
if (i < from_samples.sample_count()) {
|
||||
out_samples.data(j)[i] += from_samples.data(j)[i] *
|
||||
TransformCurve(1.0 - progress);
|
||||
transform_curve(1.0 - progress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void CrossDissolveTransition::SampleJobEvent(const SampleBuffer &from_samples,
|
||||
if (i >= remain) {
|
||||
qint64 in_index = i - remain;
|
||||
out_samples.data(j)[i] +=
|
||||
to_samples.data(j)[in_index] * TransformCurve(progress);
|
||||
to_samples.data(j)[in_index] * transform_curve(progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CROSSDISSOLVETRANSITION_H
|
||||
#define CROSSDISSOLVETRANSITION_H
|
||||
#ifndef OAK_CROSSDISSOLVETRANSITION_H
|
||||
#define OAK_CROSSDISSOLVETRANSITION_H
|
||||
|
||||
#include "node/block/transition/transition.h"
|
||||
|
||||
@@ -34,15 +34,15 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(CrossDissolveTransition)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
//virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
protected:
|
||||
virtual void SampleJobEvent(const SampleBuffer &from_samples,
|
||||
@@ -53,4 +53,4 @@ protected:
|
||||
|
||||
}
|
||||
|
||||
#endif // CROSSDISSOLVETRANSITION_H
|
||||
#endif // OAK_CROSSDISSOLVETRANSITION_H
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString DipToColorTransition::kColorInput = QStringLiteral("color_in");
|
||||
const QString DipToColorTransition::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
#define super TransitionBlock
|
||||
|
||||
DipToColorTransition::DipToColorTransition()
|
||||
{
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(0, 0, 0)));
|
||||
}
|
||||
|
||||
QString DipToColorTransition::Name() const
|
||||
QString DipToColorTransition::name() const
|
||||
{
|
||||
return tr("Dip To Color");
|
||||
}
|
||||
@@ -44,37 +44,37 @@ QString DipToColorTransition::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.diptocolor");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> DipToColorTransition::Category() const
|
||||
QVector<Node::CategoryID> DipToColorTransition::category() const
|
||||
{
|
||||
return { kCategoryTransition };
|
||||
return { k_category_transition };
|
||||
}
|
||||
|
||||
QString DipToColorTransition::Description() const
|
||||
QString DipToColorTransition::description() const
|
||||
{
|
||||
return tr("Transition between clips by dipping to a color.");
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
DipToColorTransition::GetShaderCode(const ShaderRequest &request) const
|
||||
DipToColorTransition::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/diptoblack.frag"),
|
||||
FileFunctions::read_file_as_string(":/shaders/diptoblack.frag"),
|
||||
QString());
|
||||
}
|
||||
|
||||
void DipToColorTransition::Retranslate()
|
||||
void DipToColorTransition::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
void DipToColorTransition::ShaderJobEvent(const NodeValueRow &value,
|
||||
ShaderJob *job) const
|
||||
{
|
||||
job->Insert(kColorInput, value);
|
||||
job->insert(k_color_input, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DIPTOCOLORTRANSITION_H
|
||||
#define DIPTOCOLORTRANSITION_H
|
||||
#ifndef OAK_DIPTOCOLORTRANSITION_H
|
||||
#define OAK_DIPTOCOLORTRANSITION_H
|
||||
|
||||
#include "node/block/transition/transition.h"
|
||||
|
||||
@@ -34,17 +34,17 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(DipToColorTransition)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
static const QString kColorInput;
|
||||
static const QString k_color_input;
|
||||
|
||||
protected:
|
||||
virtual void ShaderJobEvent(const NodeValueRow &value,
|
||||
@@ -53,4 +53,4 @@ protected:
|
||||
|
||||
}
|
||||
|
||||
#endif // DIPTOCOLORTRANSITION_H
|
||||
#endif // OAK_DIPTOCOLORTRANSITION_H
|
||||
|
||||
@@ -30,48 +30,48 @@ namespace olive
|
||||
|
||||
#define super Block
|
||||
|
||||
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");
|
||||
const QString TransitionBlock::k_out_block_input = QStringLiteral("out_block_in");
|
||||
const QString TransitionBlock::k_in_block_input = QStringLiteral("in_block_in");
|
||||
const QString TransitionBlock::k_curve_input = QStringLiteral("curve_in");
|
||||
const QString TransitionBlock::k_center_input = QStringLiteral("center_in");
|
||||
|
||||
TransitionBlock::TransitionBlock()
|
||||
: connected_out_block_(nullptr)
|
||||
, connected_in_block_(nullptr)
|
||||
{
|
||||
AddInput(kOutBlockInput, NodeValue::kNone,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_out_block_input, NodeValue::k_none,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kInBlockInput, NodeValue::kNone,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_in_block_input, NodeValue::k_none,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kCurveInput, NodeValue::kCombo,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_curve_input, NodeValue::k_combo,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
AddInput(kCenterInput, NodeValue::kRational,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
SetInputProperty(kCenterInput, QStringLiteral("view"),
|
||||
RationalSlider::kTime);
|
||||
SetInputProperty(kCenterInput, QStringLiteral("viewlock"), true);
|
||||
add_input(k_center_input, NodeValue::k_rational,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
set_input_property(k_center_input, QStringLiteral("view"),
|
||||
RationalSlider::k_time);
|
||||
set_input_property(k_center_input, QStringLiteral("viewlock"), true);
|
||||
|
||||
SetFlag(kDontShowInParamView, false);
|
||||
set_flag(k_dont_show_in_param_view, false);
|
||||
}
|
||||
|
||||
void TransitionBlock::Retranslate()
|
||||
void TransitionBlock::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kOutBlockInput, tr("From"));
|
||||
SetInputName(kInBlockInput, tr("To"));
|
||||
SetInputName(kCurveInput, tr("Curve"));
|
||||
SetInputName(kCenterInput, tr("Center Offset"));
|
||||
set_input_name(k_out_block_input, tr("From"));
|
||||
set_input_name(k_in_block_input, tr("To"));
|
||||
set_input_name(k_curve_input, tr("Curve"));
|
||||
set_input_name(k_center_input, tr("Center Offset"));
|
||||
|
||||
// These must correspond to the CurveType enum
|
||||
SetComboBoxStrings(kCurveInput,
|
||||
set_combo_box_strings(k_curve_input,
|
||||
{ tr("Linear"), tr("Exponential"), tr("Logarithmic") });
|
||||
}
|
||||
|
||||
rational TransitionBlock::in_offset() const
|
||||
Rational TransitionBlock::in_offset() const
|
||||
{
|
||||
if (is_dual_transition()) {
|
||||
return length() / 2 + offset_center();
|
||||
@@ -82,7 +82,7 @@ rational TransitionBlock::in_offset() const
|
||||
}
|
||||
}
|
||||
|
||||
rational TransitionBlock::out_offset() const
|
||||
Rational TransitionBlock::out_offset() const
|
||||
{
|
||||
if (is_dual_transition()) {
|
||||
return length() / 2 - offset_center();
|
||||
@@ -93,21 +93,21 @@ rational TransitionBlock::out_offset() const
|
||||
}
|
||||
}
|
||||
|
||||
rational TransitionBlock::offset_center() const
|
||||
Rational TransitionBlock::offset_center() const
|
||||
{
|
||||
return GetStandardValue(kCenterInput).value<rational>();
|
||||
return get_standard_value(k_center_input).value<Rational>();
|
||||
}
|
||||
|
||||
void TransitionBlock::set_offset_center(const rational &r)
|
||||
void TransitionBlock::set_offset_center(const Rational &r)
|
||||
{
|
||||
SetStandardValue(kCenterInput, QVariant::fromValue(r));
|
||||
set_standard_value(k_center_input, QVariant::fromValue(r));
|
||||
}
|
||||
|
||||
void TransitionBlock::set_offsets_and_length(const rational &in_offset,
|
||||
const rational &out_offset)
|
||||
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;
|
||||
Rational len = in_offset + out_offset;
|
||||
Rational center = len / 2 - in_offset;
|
||||
|
||||
set_length_and_media_out(len);
|
||||
set_offset_center(center);
|
||||
@@ -123,101 +123,101 @@ Block *TransitionBlock::connected_in_block() const
|
||||
return connected_in_block_;
|
||||
}
|
||||
|
||||
double TransitionBlock::GetTotalProgress(const double &time) const
|
||||
double TransitionBlock::get_total_progress(const double &time) const
|
||||
{
|
||||
return GetInternalTransitionTime(time) / length().toDouble();
|
||||
return get_internal_transition_time(time) / length().to_double();
|
||||
}
|
||||
|
||||
double TransitionBlock::GetOutProgress(const double &time) const
|
||||
double TransitionBlock::get_out_progress(const double &time) const
|
||||
{
|
||||
if (out_offset() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return std::clamp(
|
||||
1.0 - (GetInternalTransitionTime(time) / out_offset().toDouble()), 0.0,
|
||||
1.0 - (get_internal_transition_time(time) / out_offset().to_double()), 0.0,
|
||||
1.0);
|
||||
}
|
||||
|
||||
double TransitionBlock::GetInProgress(const double &time) const
|
||||
double TransitionBlock::get_in_progress(const double &time) const
|
||||
{
|
||||
if (in_offset() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return std::clamp(
|
||||
(GetInternalTransitionTime(time) - out_offset().toDouble()) /
|
||||
in_offset().toDouble(),
|
||||
(get_internal_transition_time(time) - out_offset().to_double()) /
|
||||
in_offset().to_double(),
|
||||
0.0, 1.0);
|
||||
}
|
||||
|
||||
double TransitionBlock::GetInternalTransitionTime(const double &time) const
|
||||
double TransitionBlock::get_internal_transition_time(const double &time) const
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
||||
void TransitionBlock::InsertTransitionTimes(AcceleratedJob *job,
|
||||
void TransitionBlock::insert_transition_times(AcceleratedJob *job,
|
||||
const double &time) const
|
||||
{
|
||||
// Provides total transition progress from 0.0 (start) - 1.0 (end)
|
||||
job->Insert(QStringLiteral("ove_tprog_all"),
|
||||
NodeValue(NodeValue::kFloat, GetTotalProgress(time), this));
|
||||
job->insert(QStringLiteral("ove_tprog_all"),
|
||||
NodeValue(NodeValue::k_float, get_total_progress(time), this));
|
||||
|
||||
// Provides progress of out section from 1.0 (start) - 0.0 (end)
|
||||
job->Insert(QStringLiteral("ove_tprog_out"),
|
||||
NodeValue(NodeValue::kFloat, GetOutProgress(time), this));
|
||||
job->insert(QStringLiteral("ove_tprog_out"),
|
||||
NodeValue(NodeValue::k_float, get_out_progress(time), this));
|
||||
|
||||
// Provides progress of in section from 0.0 (start) - 1.0 (end)
|
||||
job->Insert(QStringLiteral("ove_tprog_in"),
|
||||
NodeValue(NodeValue::kFloat, GetInProgress(time), this));
|
||||
job->insert(QStringLiteral("ove_tprog_in"),
|
||||
NodeValue(NodeValue::k_float, get_in_progress(time), this));
|
||||
}
|
||||
|
||||
void TransitionBlock::Value(const NodeValueRow &value,
|
||||
void TransitionBlock::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
NodeValue out_buffer = value[kOutBlockInput];
|
||||
NodeValue in_buffer = value[kInBlockInput];
|
||||
NodeValue::Type data_type = (out_buffer.type() != NodeValue::kNone) ?
|
||||
NodeValue out_buffer = value[k_out_block_input];
|
||||
NodeValue in_buffer = value[k_in_block_input];
|
||||
NodeValue::Type data_type = (out_buffer.type() != NodeValue::k_none) ?
|
||||
out_buffer.type() :
|
||||
in_buffer.type();
|
||||
|
||||
NodeValue::Type job_type = NodeValue::kNone;
|
||||
NodeValue::Type job_type = NodeValue::k_none;
|
||||
QVariant push_job;
|
||||
|
||||
if (data_type == NodeValue::kTexture) {
|
||||
if (data_type == NodeValue::k_texture) {
|
||||
// This must be a visual transition
|
||||
ShaderJob job;
|
||||
|
||||
if (out_buffer.type() != NodeValue::kNone) {
|
||||
job.Insert(kOutBlockInput, out_buffer);
|
||||
if (out_buffer.type() != NodeValue::k_none) {
|
||||
job.insert(k_out_block_input, out_buffer);
|
||||
} else {
|
||||
job.Insert(kOutBlockInput, NodeValue(NodeValue::kTexture, nullptr));
|
||||
job.insert(k_out_block_input, NodeValue(NodeValue::k_texture, nullptr));
|
||||
}
|
||||
|
||||
if (in_buffer.type() != NodeValue::kNone) {
|
||||
job.Insert(kInBlockInput, in_buffer);
|
||||
if (in_buffer.type() != NodeValue::k_none) {
|
||||
job.insert(k_in_block_input, in_buffer);
|
||||
} else {
|
||||
job.Insert(kInBlockInput, NodeValue(NodeValue::kTexture, nullptr));
|
||||
job.insert(k_in_block_input, NodeValue(NodeValue::k_texture, nullptr));
|
||||
}
|
||||
|
||||
job.Insert(kCurveInput, value);
|
||||
job.insert(k_curve_input, value);
|
||||
|
||||
double time = globals.time().in().toDouble();
|
||||
InsertTransitionTimes(&job, time);
|
||||
double time = globals.time().in().to_double();
|
||||
insert_transition_times(&job, time);
|
||||
|
||||
ShaderJobEvent(value, &job);
|
||||
|
||||
job_type = NodeValue::kTexture;
|
||||
push_job = QVariant::fromValue(Texture::Job(globals.vparams(), job));
|
||||
} else if (data_type == NodeValue::kSamples) {
|
||||
job_type = NodeValue::k_texture;
|
||||
push_job = QVariant::fromValue(Texture::job(globals.vparams(), job));
|
||||
} else if (data_type == NodeValue::k_samples) {
|
||||
// This must be an audio transition
|
||||
SampleBuffer from_samples = out_buffer.toSamples();
|
||||
SampleBuffer to_samples = in_buffer.toSamples();
|
||||
SampleBuffer from_samples = out_buffer.to_samples();
|
||||
SampleBuffer to_samples = in_buffer.to_samples();
|
||||
|
||||
if (from_samples.is_allocated() || to_samples.is_allocated()) {
|
||||
double time_in = globals.time().in().toDouble();
|
||||
double time_out = globals.time().out().toDouble();
|
||||
double time_in = globals.time().in().to_double();
|
||||
double time_out = globals.time().out().to_double();
|
||||
|
||||
const AudioParams ¶ms = (from_samples.is_allocated()) ?
|
||||
from_samples.audio_params() :
|
||||
@@ -232,41 +232,41 @@ void TransitionBlock::Value(const NodeValueRow &value,
|
||||
SampleJobEvent(from_samples, to_samples, out_samples, time_in);
|
||||
}
|
||||
|
||||
job_type = NodeValue::kSamples;
|
||||
job_type = NodeValue::k_samples;
|
||||
push_job = QVariant::fromValue(out_samples);
|
||||
}
|
||||
}
|
||||
|
||||
if (!push_job.isNull()) {
|
||||
table->Push(job_type, push_job, this);
|
||||
table->push(job_type, push_job, this);
|
||||
}
|
||||
}
|
||||
|
||||
void TransitionBlock::InvalidateCache(const TimeRange &range,
|
||||
void TransitionBlock::invalidate_cache(const TimeRange &range,
|
||||
const QString &from, int element,
|
||||
InvalidateCacheOptions options)
|
||||
{
|
||||
TimeRange r = range;
|
||||
|
||||
if (from == kOutBlockInput || from == kInBlockInput) {
|
||||
Block *n = dynamic_cast<Block *>(GetConnectedOutput(from));
|
||||
if (from == k_out_block_input || from == k_in_block_input) {
|
||||
Block *n = dynamic_cast<Block *>(get_connected_output(from));
|
||||
if (n) {
|
||||
r = Track::TransformRangeFromBlock(n, r);
|
||||
r = Track::transform_range_from_block(n, r);
|
||||
}
|
||||
}
|
||||
|
||||
super::InvalidateCache(r, from, element, options);
|
||||
super::invalidate_cache(r, from, element, options);
|
||||
}
|
||||
|
||||
double TransitionBlock::TransformCurve(double linear) const
|
||||
double TransitionBlock::transform_curve(double linear) const
|
||||
{
|
||||
switch (static_cast<CurveType>(GetStandardValue(kCurveInput).toInt())) {
|
||||
case kLinear:
|
||||
switch (static_cast<CurveType>(get_standard_value(k_curve_input).toInt())) {
|
||||
case k_linear:
|
||||
break;
|
||||
case kExponential:
|
||||
case k_exponential:
|
||||
linear *= linear;
|
||||
break;
|
||||
case kLogarithmic:
|
||||
case k_logarithmic:
|
||||
linear = std::sqrt(linear);
|
||||
break;
|
||||
}
|
||||
@@ -279,12 +279,12 @@ void TransitionBlock::InputConnectedEvent(const QString &input, int element,
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kOutBlockInput) {
|
||||
if (input == k_out_block_input) {
|
||||
// If node is not a block, this will just be null
|
||||
if ((connected_out_block_ = dynamic_cast<ClipBlock *>(output))) {
|
||||
connected_out_block_->set_out_transition(this);
|
||||
}
|
||||
} else if (input == kInBlockInput) {
|
||||
} else if (input == k_in_block_input) {
|
||||
// If node is not a block, this will just be null
|
||||
if ((connected_in_block_ = dynamic_cast<ClipBlock *>(output))) {
|
||||
connected_in_block_->set_in_transition(this);
|
||||
@@ -298,12 +298,12 @@ void TransitionBlock::InputDisconnectedEvent(const QString &input, int element,
|
||||
Q_UNUSED(element)
|
||||
Q_UNUSED(output)
|
||||
|
||||
if (input == kOutBlockInput) {
|
||||
if (input == k_out_block_input) {
|
||||
if (connected_out_block_) {
|
||||
connected_out_block_->set_out_transition(nullptr);
|
||||
connected_out_block_ = nullptr;
|
||||
}
|
||||
} else if (input == kInBlockInput) {
|
||||
} else if (input == k_in_block_input) {
|
||||
if (connected_in_block_) {
|
||||
connected_in_block_->set_in_transition(nullptr);
|
||||
connected_in_block_ = nullptr;
|
||||
@@ -311,34 +311,34 @@ void TransitionBlock::InputDisconnectedEvent(const QString &input, int element,
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange TransitionBlock::InputTimeAdjustment(const QString &input,
|
||||
TimeRange TransitionBlock::input_time_adjustment(const QString &input,
|
||||
int element,
|
||||
const TimeRange &input_time,
|
||||
bool clamp) const
|
||||
{
|
||||
if (input == kInBlockInput || input == kOutBlockInput) {
|
||||
Block *block = dynamic_cast<Block *>(GetConnectedOutput(input));
|
||||
if (input == k_in_block_input || input == k_out_block_input) {
|
||||
Block *block = dynamic_cast<Block *>(get_connected_output(input));
|
||||
if (block) {
|
||||
// Retransform time as if it came from the track
|
||||
return input_time + in() - block->in();
|
||||
}
|
||||
}
|
||||
|
||||
return super::InputTimeAdjustment(input, element, input_time, clamp);
|
||||
return super::input_time_adjustment(input, element, input_time, clamp);
|
||||
}
|
||||
|
||||
TimeRange
|
||||
TransitionBlock::OutputTimeAdjustment(const QString &input, int element,
|
||||
TransitionBlock::output_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time) const
|
||||
{
|
||||
if (input == kInBlockInput || input == kOutBlockInput) {
|
||||
Block *block = dynamic_cast<Block *>(GetConnectedOutput(input));
|
||||
if (input == k_in_block_input || input == k_out_block_input) {
|
||||
Block *block = dynamic_cast<Block *>(get_connected_output(input));
|
||||
if (block) {
|
||||
return input_time + block->in() - in();
|
||||
}
|
||||
}
|
||||
|
||||
return super::OutputTimeAdjustment(input, element, input_time);
|
||||
return super::output_time_adjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRANSITIONBLOCK_H
|
||||
#define TRANSITIONBLOCK_H
|
||||
#ifndef OAK_TRANSITIONBLOCK_H
|
||||
#define OAK_TRANSITIONBLOCK_H
|
||||
|
||||
#include "node/block/block.h"
|
||||
|
||||
@@ -34,10 +34,10 @@ class TransitionBlock : public Block {
|
||||
public:
|
||||
TransitionBlock();
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
rational in_offset() const;
|
||||
rational out_offset() const;
|
||||
Rational in_offset() const;
|
||||
Rational out_offset() const;
|
||||
|
||||
/**
|
||||
* @brief Return the "middle point" of the transition, relative to the transition
|
||||
@@ -47,11 +47,11 @@ public:
|
||||
* 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);
|
||||
Rational offset_center() const;
|
||||
void set_offset_center(const Rational &r);
|
||||
|
||||
void set_offsets_and_length(const rational &in_offset,
|
||||
const rational &out_offset);
|
||||
void set_offsets_and_length(const Rational &in_offset,
|
||||
const Rational &out_offset);
|
||||
|
||||
bool is_dual_transition() const
|
||||
{
|
||||
@@ -61,21 +61,21 @@ public:
|
||||
Block *connected_out_block() const;
|
||||
Block *connected_in_block() const;
|
||||
|
||||
double GetTotalProgress(const double &time) const;
|
||||
double GetOutProgress(const double &time) const;
|
||||
double GetInProgress(const double &time) const;
|
||||
double get_total_progress(const double &time) const;
|
||||
double get_out_progress(const double &time) const;
|
||||
double get_in_progress(const double &time) const;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void InvalidateCache(
|
||||
virtual void invalidate_cache(
|
||||
const TimeRange &range, const QString &from, int element = -1,
|
||||
InvalidateCacheOptions options = InvalidateCacheOptions()) override;
|
||||
|
||||
static const QString kOutBlockInput;
|
||||
static const QString kInBlockInput;
|
||||
static const QString kCurveInput;
|
||||
static const QString kCenterInput;
|
||||
static const QString k_out_block_input;
|
||||
static const QString k_in_block_input;
|
||||
static const QString k_curve_input;
|
||||
static const QString k_center_input;
|
||||
|
||||
protected:
|
||||
virtual void ShaderJobEvent(const NodeValueRow &value, ShaderJob *job) const
|
||||
@@ -88,7 +88,7 @@ protected:
|
||||
{
|
||||
}
|
||||
|
||||
double TransformCurve(double linear) const;
|
||||
double transform_curve(double linear) const;
|
||||
|
||||
virtual void InputConnectedEvent(const QString &input, int element,
|
||||
Node *output) override;
|
||||
@@ -96,20 +96,20 @@ protected:
|
||||
virtual void InputDisconnectedEvent(const QString &input, int element,
|
||||
Node *output) override;
|
||||
|
||||
virtual TimeRange InputTimeAdjustment(const QString &input, int element,
|
||||
virtual TimeRange input_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time,
|
||||
bool clamp) const override;
|
||||
|
||||
virtual TimeRange
|
||||
OutputTimeAdjustment(const QString &input, int element,
|
||||
output_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time) const override;
|
||||
|
||||
private:
|
||||
enum CurveType { kLinear, kExponential, kLogarithmic };
|
||||
enum CurveType { k_linear, k_exponential, k_logarithmic };
|
||||
|
||||
double GetInternalTransitionTime(const double &time) const;
|
||||
double get_internal_transition_time(const double &time) const;
|
||||
|
||||
void InsertTransitionTimes(AcceleratedJob *job, const double &time) const;
|
||||
void insert_transition_times(AcceleratedJob *job, const double &time) const;
|
||||
|
||||
ClipBlock *connected_out_block_;
|
||||
|
||||
@@ -118,4 +118,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TRANSITIONBLOCK_H
|
||||
#endif // OAK_TRANSITIONBLOCK_H
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::default_config_ = nullptr;
|
||||
ocio::ConstConfigRcPtr ColorManager::default_config = nullptr;
|
||||
|
||||
ColorManager::ColorManager(Project *project)
|
||||
: QObject(project)
|
||||
@@ -42,51 +42,51 @@ ColorManager::ColorManager(Project *project)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorManager::Init()
|
||||
void ColorManager::init()
|
||||
{
|
||||
// Set config to our built-in default
|
||||
config_ = GetDefaultConfig();
|
||||
SetDefaultInputColorSpace(config_->getCanonicalName(OCIO::ROLE_DEFAULT));
|
||||
project()->SetColorReferenceSpace(OCIO::ROLE_SCENE_LINEAR);
|
||||
config_ = get_default_config();
|
||||
set_default_input_color_space(config_->getCanonicalName(ocio::ROLE_DEFAULT));
|
||||
project()->set_color_reference_space(ocio::ROLE_SCENE_LINEAR);
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
|
||||
ocio::ConstConfigRcPtr ColorManager::get_config() const
|
||||
{
|
||||
return config_;
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr
|
||||
ColorManager::CreateConfigFromFile(const QString &filename)
|
||||
ocio::ConstConfigRcPtr
|
||||
ColorManager::create_config_from_file(const QString &filename)
|
||||
{
|
||||
return OCIO::Config::CreateFromFile(filename.toUtf8());
|
||||
return ocio::Config::CreateFromFile(filename.toUtf8());
|
||||
}
|
||||
|
||||
QString ColorManager::GetConfigFilename() const
|
||||
QString ColorManager::get_config_filename() const
|
||||
{
|
||||
return project()->GetColorConfigFilename();
|
||||
return project()->get_color_config_filename();
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
|
||||
ocio::ConstConfigRcPtr ColorManager::get_default_config()
|
||||
{
|
||||
// Set up on first use: Project construction calls ColorManager::Init()
|
||||
// unconditionally, so without this any Project created before
|
||||
// SetUpDefaultConfig() crashed dereferencing a null config.
|
||||
if (!default_config_) {
|
||||
SetUpDefaultConfig();
|
||||
if (!default_config) {
|
||||
set_up_default_config();
|
||||
}
|
||||
|
||||
return default_config_;
|
||||
return default_config;
|
||||
}
|
||||
|
||||
void ColorManager::SetUpDefaultConfig()
|
||||
void ColorManager::set_up_default_config()
|
||||
{
|
||||
if (!qEnvironmentVariableIsEmpty("OCIO")) {
|
||||
// Attempt to set config from "OCIO" environment variable
|
||||
try {
|
||||
default_config_ = OCIO::Config::CreateFromEnv();
|
||||
default_config = ocio::Config::CreateFromEnv();
|
||||
|
||||
return;
|
||||
} catch (OCIO::Exception &e) {
|
||||
} catch (ocio::Exception &e) {
|
||||
qWarning()
|
||||
<< "Failed to load config from OCIO environment variable config:"
|
||||
<< e.what();
|
||||
@@ -98,20 +98,20 @@ void ColorManager::SetUpDefaultConfig()
|
||||
QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
.filePath(QStringLiteral("ocioconf"));
|
||||
|
||||
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"), dir, true);
|
||||
FileFunctions::copy_directory(QStringLiteral(":/ocioconf"), dir, true);
|
||||
|
||||
qDebug() << "Extracting default OCIO config to" << dir;
|
||||
|
||||
default_config_ =
|
||||
CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")));
|
||||
default_config =
|
||||
create_config_from_file(QDir(dir).filePath(QStringLiteral("config.ocio")));
|
||||
}
|
||||
|
||||
void ColorManager::SetConfigFilename(const QString &filename)
|
||||
void ColorManager::set_config_filename(const QString &filename)
|
||||
{
|
||||
project()->SetColorConfigFilename(filename);
|
||||
project()->set_color_config_filename(filename);
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableDisplays()
|
||||
QStringList ColorManager::list_available_displays()
|
||||
{
|
||||
QStringList displays;
|
||||
|
||||
@@ -124,12 +124,12 @@ QStringList ColorManager::ListAvailableDisplays()
|
||||
return displays;
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultDisplay()
|
||||
QString ColorManager::get_default_display()
|
||||
{
|
||||
return config_->getDefaultDisplay();
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableViews(QString display)
|
||||
QStringList ColorManager::list_available_views(QString display)
|
||||
{
|
||||
QStringList views;
|
||||
|
||||
@@ -142,12 +142,12 @@ QStringList ColorManager::ListAvailableViews(QString display)
|
||||
return views;
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultView(const QString &display)
|
||||
QString ColorManager::get_default_view(const QString &display)
|
||||
{
|
||||
return config_->getDefaultView(display.toUtf8());
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableLooks()
|
||||
QStringList ColorManager::list_available_looks()
|
||||
{
|
||||
QStringList looks;
|
||||
|
||||
@@ -160,37 +160,37 @@ QStringList ColorManager::ListAvailableLooks()
|
||||
return looks;
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableColorspaces() const
|
||||
QStringList ColorManager::list_available_colorspaces() const
|
||||
{
|
||||
return ListAvailableColorspaces(config_);
|
||||
return list_available_colorspaces(config_);
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultInputColorSpace() const
|
||||
QString ColorManager::get_default_input_color_space() const
|
||||
{
|
||||
return project()->GetDefaultInputColorSpace();
|
||||
return project()->get_default_input_color_space();
|
||||
}
|
||||
|
||||
void ColorManager::SetDefaultInputColorSpace(const QString &s)
|
||||
void ColorManager::set_default_input_color_space(const QString &s)
|
||||
{
|
||||
project()->SetDefaultInputColorSpace(s);
|
||||
project()->set_default_input_color_space(s);
|
||||
}
|
||||
|
||||
QString ColorManager::GetReferenceColorSpace() const
|
||||
QString ColorManager::get_reference_color_space() const
|
||||
{
|
||||
return project()->GetColorReferenceSpace();
|
||||
return project()->get_color_reference_space();
|
||||
}
|
||||
|
||||
QString ColorManager::GetCompliantColorSpace(const QString &s)
|
||||
QString ColorManager::get_compliant_color_space(const QString &s)
|
||||
{
|
||||
if (ListAvailableColorspaces().contains(s)) {
|
||||
if (list_available_colorspaces().contains(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return GetDefaultInputColorSpace();
|
||||
return get_default_input_color_space();
|
||||
}
|
||||
}
|
||||
|
||||
ColorTransform
|
||||
ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
ColorManager::get_compliant_color_space(const ColorTransform &transform,
|
||||
bool force_display)
|
||||
{
|
||||
if (transform.is_display() || force_display) {
|
||||
@@ -200,17 +200,17 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
QString look = transform.look();
|
||||
|
||||
// Check if display still exists in config
|
||||
if (!ListAvailableDisplays().contains(display)) {
|
||||
display = GetDefaultDisplay();
|
||||
if (!list_available_displays().contains(display)) {
|
||||
display = get_default_display();
|
||||
}
|
||||
|
||||
// Check if view still exists in display
|
||||
if (!ListAvailableViews(display).contains(view)) {
|
||||
view = GetDefaultView(display);
|
||||
if (!list_available_views(display).contains(view)) {
|
||||
view = get_default_view(display);
|
||||
}
|
||||
|
||||
// Check if looks still exists
|
||||
if (!ListAvailableLooks().contains(look)) {
|
||||
if (!list_available_looks().contains(look)) {
|
||||
look.clear();
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
} else {
|
||||
QString output = transform.output();
|
||||
|
||||
if (!ListAvailableColorspaces().contains(output)) {
|
||||
output = GetDefaultInputColorSpace();
|
||||
if (!list_available_colorspaces().contains(output)) {
|
||||
output = get_default_input_color_space();
|
||||
}
|
||||
|
||||
return ColorTransform(output);
|
||||
@@ -228,7 +228,7 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
}
|
||||
|
||||
QStringList
|
||||
ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
ColorManager::list_available_colorspaces(ocio::ConstConfigRcPtr config)
|
||||
{
|
||||
QStringList spaces;
|
||||
|
||||
@@ -243,7 +243,7 @@ ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
return spaces;
|
||||
}
|
||||
|
||||
void ColorManager::GetDefaultLumaCoefs(double *rgb) const
|
||||
void ColorManager::get_default_luma_coefs(double *rgb) const
|
||||
{
|
||||
config_->getDefaultLumaCoefs(rgb);
|
||||
}
|
||||
@@ -253,17 +253,17 @@ Project *ColorManager::project() const
|
||||
return static_cast<Project *>(parent());
|
||||
}
|
||||
|
||||
void ColorManager::UpdateConfigFromFilename()
|
||||
void ColorManager::update_config_from_filename()
|
||||
{
|
||||
try {
|
||||
QString config_filename = GetConfigFilename();
|
||||
QString old_default_cs = GetDefaultInputColorSpace();
|
||||
QString config_filename = get_config_filename();
|
||||
QString old_default_cs = get_default_input_color_space();
|
||||
|
||||
config_ = OCIO::Config::CreateFromFile(config_filename.toUtf8());
|
||||
config_ = ocio::Config::CreateFromFile(config_filename.toUtf8());
|
||||
|
||||
// Set new default colorspace appropriately
|
||||
QString new_default = old_default_cs;
|
||||
QStringList available_cs = ListAvailableColorspaces();
|
||||
QStringList available_cs = list_available_colorspaces();
|
||||
for (int i = 0; i < available_cs.size(); i++) {
|
||||
const QString &c = available_cs.at(i);
|
||||
if (c.compare(old_default_cs, Qt::CaseInsensitive)) {
|
||||
@@ -271,10 +271,10 @@ void ColorManager::UpdateConfigFromFilename()
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetDefaultInputColorSpace(new_default);
|
||||
set_default_input_color_space(new_default);
|
||||
|
||||
emit ConfigChanged(config_filename);
|
||||
} catch (OCIO::Exception &) {
|
||||
emit config_changed(config_filename);
|
||||
} catch (ocio::Exception &) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSERVICE_H
|
||||
#define COLORSERVICE_H
|
||||
#ifndef OAK_COLORSERVICE_H
|
||||
#define OAK_COLORSERVICE_H
|
||||
|
||||
#include <memory>
|
||||
#include <QMutex>
|
||||
@@ -37,64 +37,64 @@ class ColorManager : public QObject {
|
||||
public:
|
||||
ColorManager(Project *project);
|
||||
|
||||
void Init();
|
||||
void init();
|
||||
|
||||
OCIO::ConstConfigRcPtr GetConfig() const;
|
||||
ocio::ConstConfigRcPtr get_config() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString &filename);
|
||||
static ocio::ConstConfigRcPtr create_config_from_file(const QString &filename);
|
||||
|
||||
QString GetConfigFilename() const;
|
||||
QString get_config_filename() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr GetDefaultConfig();
|
||||
static ocio::ConstConfigRcPtr get_default_config();
|
||||
|
||||
static void SetUpDefaultConfig();
|
||||
static void set_up_default_config();
|
||||
|
||||
void SetConfigFilename(const QString &filename);
|
||||
void set_config_filename(const QString &filename);
|
||||
|
||||
QStringList ListAvailableDisplays();
|
||||
QStringList list_available_displays();
|
||||
|
||||
QString GetDefaultDisplay();
|
||||
QString get_default_display();
|
||||
|
||||
QStringList ListAvailableViews(QString display);
|
||||
QStringList list_available_views(QString display);
|
||||
|
||||
QString GetDefaultView(const QString &display);
|
||||
QString get_default_view(const QString &display);
|
||||
|
||||
QStringList ListAvailableLooks();
|
||||
QStringList list_available_looks();
|
||||
|
||||
QStringList ListAvailableColorspaces() const;
|
||||
QStringList list_available_colorspaces() const;
|
||||
|
||||
QString GetDefaultInputColorSpace() const;
|
||||
QString get_default_input_color_space() const;
|
||||
|
||||
void SetDefaultInputColorSpace(const QString &s);
|
||||
void set_default_input_color_space(const QString &s);
|
||||
|
||||
QString GetReferenceColorSpace() const;
|
||||
QString get_reference_color_space() const;
|
||||
|
||||
QString GetCompliantColorSpace(const QString &s);
|
||||
QString get_compliant_color_space(const QString &s);
|
||||
|
||||
ColorTransform GetCompliantColorSpace(const ColorTransform &transform,
|
||||
ColorTransform get_compliant_color_space(const ColorTransform &transform,
|
||||
bool force_display = false);
|
||||
|
||||
static QStringList ListAvailableColorspaces(OCIO::ConstConfigRcPtr config);
|
||||
static QStringList list_available_colorspaces(ocio::ConstConfigRcPtr config);
|
||||
|
||||
void GetDefaultLumaCoefs(double *rgb) const;
|
||||
void get_default_luma_coefs(double *rgb) const;
|
||||
|
||||
Project *project() const;
|
||||
|
||||
void UpdateConfigFromFilename();
|
||||
void update_config_from_filename();
|
||||
|
||||
signals:
|
||||
void ConfigChanged(const QString &s);
|
||||
void config_changed(const QString &s);
|
||||
|
||||
void ReferenceSpaceChanged(const QString &s);
|
||||
void reference_space_changed(const QString &s);
|
||||
|
||||
void DefaultInputChanged(const QString &s);
|
||||
void default_input_changed(const QString &s);
|
||||
|
||||
private:
|
||||
OCIO::ConstConfigRcPtr config_;
|
||||
ocio::ConstConfigRcPtr config_;
|
||||
|
||||
static OCIO::ConstConfigRcPtr default_config_;
|
||||
static ocio::ConstConfigRcPtr default_config;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSERVICE_H
|
||||
#endif // OAK_COLORSERVICE_H
|
||||
|
||||
@@ -26,26 +26,26 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString DisplayTransformNode::kDisplayInput =
|
||||
const QString DisplayTransformNode::k_display_input =
|
||||
QStringLiteral("display_in");
|
||||
const QString DisplayTransformNode::kViewInput = QStringLiteral("view_in");
|
||||
const QString DisplayTransformNode::kDirectionInput = QStringLiteral("dir_in");
|
||||
const QString DisplayTransformNode::k_view_input = QStringLiteral("view_in");
|
||||
const QString DisplayTransformNode::k_direction_input = QStringLiteral("dir_in");
|
||||
|
||||
#define super OCIOBaseNode
|
||||
|
||||
DisplayTransformNode::DisplayTransformNode()
|
||||
{
|
||||
AddInput(kDisplayInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_display_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
AddInput(kViewInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_view_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
AddInput(kDirectionInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_direction_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::Name() const
|
||||
QString DisplayTransformNode::name() const
|
||||
{
|
||||
return tr("Display Transform");
|
||||
}
|
||||
@@ -55,58 +55,58 @@ QString DisplayTransformNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.displaytransform");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> DisplayTransformNode::Category() const
|
||||
QVector<Node::CategoryID> DisplayTransformNode::category() const
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::Description() const
|
||||
QString DisplayTransformNode::description() const
|
||||
{
|
||||
return tr("Converts an image to or from a display color space.");
|
||||
}
|
||||
|
||||
void DisplayTransformNode::Retranslate()
|
||||
void DisplayTransformNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kDisplayInput, tr("Display"));
|
||||
SetInputName(kViewInput, tr("View"));
|
||||
SetInputName(kDirectionInput, tr("Direction"));
|
||||
SetComboBoxStrings(kDirectionInput, { tr("Forward"), tr("Inverse") });
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_display_input, tr("Display"));
|
||||
set_input_name(k_view_input, tr("View"));
|
||||
set_input_name(k_direction_input, tr("Direction"));
|
||||
set_combo_box_strings(k_direction_input, { tr("Forward"), tr("Inverse") });
|
||||
}
|
||||
|
||||
void DisplayTransformNode::InputValueChangedEvent(const QString &input,
|
||||
int element)
|
||||
{
|
||||
Q_UNUSED(element);
|
||||
if (input == kDisplayInput || input == kDirectionInput ||
|
||||
input == kViewInput) {
|
||||
if (input == kDisplayInput) {
|
||||
UpdateViews();
|
||||
if (input == k_display_input || input == k_direction_input ||
|
||||
input == k_view_input) {
|
||||
if (input == k_display_input) {
|
||||
update_views();
|
||||
}
|
||||
GenerateProcessor();
|
||||
generate_processor();
|
||||
}
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::GetDisplay() const
|
||||
QString DisplayTransformNode::get_display() const
|
||||
{
|
||||
if (manager()) {
|
||||
int index = GetStandardValue(kDisplayInput).toInt();
|
||||
if (index < manager()->ListAvailableDisplays().size()) {
|
||||
return manager()->ListAvailableDisplays().at(index);
|
||||
int index = get_standard_value(k_display_input).toInt();
|
||||
if (index < manager()->list_available_displays().size()) {
|
||||
return manager()->list_available_displays().at(index);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::GetView() const
|
||||
QString DisplayTransformNode::get_view() const
|
||||
{
|
||||
if (manager()) {
|
||||
QString display = GetDisplay();
|
||||
QString display = get_display();
|
||||
if (!display.isEmpty()) {
|
||||
int index = GetStandardValue(kViewInput).toInt();
|
||||
QStringList views = manager()->ListAvailableViews(display);
|
||||
int index = get_standard_value(k_view_input).toInt();
|
||||
QStringList views = manager()->list_available_views(display);
|
||||
if (index < views.size()) {
|
||||
return views.at(index);
|
||||
}
|
||||
@@ -115,42 +115,42 @@ QString DisplayTransformNode::GetView() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
ColorProcessor::Direction DisplayTransformNode::GetDirection() const
|
||||
ColorProcessor::Direction DisplayTransformNode::get_direction() const
|
||||
{
|
||||
return static_cast<ColorProcessor::Direction>(
|
||||
GetStandardValue(kDirectionInput).toInt());
|
||||
get_standard_value(k_direction_input).toInt());
|
||||
;
|
||||
}
|
||||
|
||||
void DisplayTransformNode::UpdateDisplays()
|
||||
void DisplayTransformNode::update_displays()
|
||||
{
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kDisplayInput, manager()->ListAvailableDisplays());
|
||||
set_combo_box_strings(k_display_input, manager()->list_available_displays());
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayTransformNode::UpdateViews()
|
||||
void DisplayTransformNode::update_views()
|
||||
{
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kViewInput,
|
||||
manager()->ListAvailableViews(GetDisplay()));
|
||||
set_combo_box_strings(k_view_input,
|
||||
manager()->list_available_views(get_display()));
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayTransformNode::ConfigChanged()
|
||||
void DisplayTransformNode::config_changed()
|
||||
{
|
||||
UpdateDisplays();
|
||||
UpdateViews();
|
||||
GenerateProcessor();
|
||||
update_displays();
|
||||
update_views();
|
||||
generate_processor();
|
||||
}
|
||||
|
||||
void DisplayTransformNode::GenerateProcessor()
|
||||
void DisplayTransformNode::generate_processor()
|
||||
{
|
||||
if (manager()) {
|
||||
ColorTransform transform(GetDisplay(), GetView(), QString());
|
||||
set_processor(ColorProcessor::Create(
|
||||
manager(), manager()->GetReferenceColorSpace(), transform,
|
||||
GetDirection()));
|
||||
ColorTransform transform(get_display(), get_view(), QString());
|
||||
set_processor(ColorProcessor::create(
|
||||
manager(), manager()->get_reference_color_space(), transform,
|
||||
get_direction()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DISPLAYTRANSFORMNODE_H
|
||||
#define DISPLAYTRANSFORMNODE_H
|
||||
#ifndef OAK_DISPLAYTRANSFORMNODE_H
|
||||
#define OAK_DISPLAYTRANSFORMNODE_H
|
||||
|
||||
#include "node/color/ociobase/ociobase.h"
|
||||
#include "render/colorprocessor.h"
|
||||
@@ -35,34 +35,34 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(DisplayTransformNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
|
||||
QString GetDisplay() const;
|
||||
QString GetView() const;
|
||||
ColorProcessor::Direction GetDirection() const;
|
||||
QString get_display() const;
|
||||
QString get_view() const;
|
||||
ColorProcessor::Direction get_direction() const;
|
||||
|
||||
static const QString kDisplayInput;
|
||||
static const QString kViewInput;
|
||||
static const QString kDirectionInput;
|
||||
static const QString k_display_input;
|
||||
static const QString k_view_input;
|
||||
static const QString k_direction_input;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void config_changed() override;
|
||||
|
||||
private:
|
||||
void GenerateProcessor();
|
||||
void generate_processor();
|
||||
|
||||
void UpdateDisplays();
|
||||
void update_displays();
|
||||
|
||||
void UpdateViews();
|
||||
void update_views();
|
||||
};
|
||||
|
||||
} // olive
|
||||
|
||||
#endif // DISPLAYTRANSFORMNODE_H
|
||||
#endif // OAK_DISPLAYTRANSFORMNODE_H
|
||||
|
||||
@@ -27,54 +27,54 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOBaseNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString OCIOBaseNode::k_texture_input = QStringLiteral("tex_in");
|
||||
|
||||
OCIOBaseNode::OCIOBaseNode()
|
||||
: manager_(nullptr)
|
||||
, processor_(nullptr)
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
SetEffectInput(kTextureInput);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
void OCIOBaseNode::AddedToGraphEvent(Project *p)
|
||||
{
|
||||
manager_ = p->color_manager();
|
||||
connect(manager_, &ColorManager::ConfigChanged, this,
|
||||
&OCIOBaseNode::ConfigChanged);
|
||||
ConfigChanged();
|
||||
connect(manager_, &ColorManager::config_changed, this,
|
||||
&OCIOBaseNode::config_changed);
|
||||
config_changed();
|
||||
}
|
||||
|
||||
void OCIOBaseNode::RemovedFromGraphEvent(Project *p)
|
||||
{
|
||||
if (manager_) {
|
||||
disconnect(manager_, &ColorManager::ConfigChanged, this,
|
||||
&OCIOBaseNode::ConfigChanged);
|
||||
disconnect(manager_, &ColorManager::config_changed, this,
|
||||
&OCIOBaseNode::config_changed);
|
||||
manager_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOBaseNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void OCIOBaseNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
auto tex_met = value[kTextureInput];
|
||||
TexturePtr t = tex_met.toTexture();
|
||||
auto tex_met = value[k_texture_input];
|
||||
TexturePtr t = tex_met.to_texture();
|
||||
if (t) {
|
||||
if (processor_) {
|
||||
ColorTransformJob job;
|
||||
|
||||
job.SetColorProcessor(processor_);
|
||||
job.SetInputTexture(tex_met);
|
||||
job.set_color_processor(processor_);
|
||||
job.set_input_texture(tex_met);
|
||||
|
||||
table->Push(NodeValue::kTexture, t->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, t->to_job(job), this);
|
||||
} else {
|
||||
// Processor isn't ready yet (e.g. still being generated
|
||||
// asynchronously), pass the input through unchanged.
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(t), this);
|
||||
table->push(NodeValue::k_texture, QVariant::fromValue(t), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OCIOBASENODE_H
|
||||
#define OCIOBASENODE_H
|
||||
#ifndef OAK_OCIOBASENODE_H
|
||||
#define OAK_OCIOBASENODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "render/job/colortransformjob.h"
|
||||
@@ -36,13 +36,13 @@ public:
|
||||
virtual void AddedToGraphEvent(Project *p) override;
|
||||
virtual void RemovedFromGraphEvent(Project *p) override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString k_texture_input;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() = 0;
|
||||
virtual void config_changed() = 0;
|
||||
|
||||
protected:
|
||||
ColorManager *manager() const
|
||||
@@ -67,4 +67,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // OCIOBASENODE_H
|
||||
#endif // OAK_OCIOBASENODE_H
|
||||
|
||||
@@ -31,74 +31,74 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOGradingTransformLinearNode::kContrastInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_contrast_input =
|
||||
QStringLiteral("ocio_grading_primary_contrast");
|
||||
const QString OCIOGradingTransformLinearNode::kOffsetInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_offset_input =
|
||||
QStringLiteral("ocio_grading_primary_offset");
|
||||
const QString OCIOGradingTransformLinearNode::kExposureInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_exposure_input =
|
||||
QStringLiteral("ocio_grading_primary_exposure");
|
||||
const QString OCIOGradingTransformLinearNode::kSaturationInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_saturation_input =
|
||||
QStringLiteral("ocio_grading_primary_saturation");
|
||||
const QString OCIOGradingTransformLinearNode::kPivotInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_pivot_input =
|
||||
QStringLiteral("ocio_grading_primary_pivot");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackEnableInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_black_enable_input =
|
||||
QStringLiteral("clamp_black_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_black_input =
|
||||
QStringLiteral("ocio_grading_primary_clampBlack");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteEnableInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_white_enable_input =
|
||||
QStringLiteral("clamp_white_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_white_input =
|
||||
QStringLiteral("ocio_grading_primary_clampWhite");
|
||||
|
||||
#define super OCIOBaseNode
|
||||
|
||||
OCIOGradingTransformLinearNode::OCIOGradingTransformLinearNode()
|
||||
{
|
||||
AddInput(kContrastInput, NodeValue::kVec4, QVector4D{ 1.0, 1.0, 1.0, 1.0 });
|
||||
// Minimum based on OCIO::GradingPrimary::validate
|
||||
SetInputProperty(kContrastInput, QStringLiteral("min"),
|
||||
add_input(k_contrast_input, NodeValue::k_vec4, QVector4D{ 1.0, 1.0, 1.0, 1.0 });
|
||||
// Minimum based on ocio::GradingPrimary::validate
|
||||
set_input_property(k_contrast_input, QStringLiteral("min"),
|
||||
QVector4D{ 0.01f, 0.01f, 0.01f, 0.01f });
|
||||
SetInputProperty(kContrastInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kContrastInput);
|
||||
set_input_property(k_contrast_input, QStringLiteral("base"), 0.01);
|
||||
set_vec4_input_colors(k_contrast_input);
|
||||
|
||||
AddInput(kOffsetInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
SetInputProperty(kOffsetInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kOffsetInput);
|
||||
add_input(k_offset_input, NodeValue::k_vec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
set_input_property(k_offset_input, QStringLiteral("base"), 0.01);
|
||||
set_vec4_input_colors(k_offset_input);
|
||||
|
||||
AddInput(kExposureInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
SetInputProperty(kExposureInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kExposureInput);
|
||||
add_input(k_exposure_input, NodeValue::k_vec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
set_input_property(k_exposure_input, QStringLiteral("base"), 0.01);
|
||||
set_vec4_input_colors(k_exposure_input);
|
||||
|
||||
AddInput(kSaturationInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_saturation_input, NodeValue::k_float, 1.0);
|
||||
set_input_property(k_saturation_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_saturation_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
AddInput(kPivotInput, NodeValue::kFloat,
|
||||
0.18); // Default listed in OCIO::GradingPrimary
|
||||
SetInputProperty(kPivotInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_pivot_input, NodeValue::k_float,
|
||||
0.18); // Default listed in ocio::GradingPrimary
|
||||
set_input_property(k_pivot_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kClampBlackEnableInput, NodeValue::kBoolean, false);
|
||||
add_input(k_clamp_black_enable_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kClampBlackInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampBlackEnableInput).toBool());
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_clamp_black_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_clamp_black_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_black_enable_input).toBool());
|
||||
set_input_property(k_clamp_black_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kClampWhiteEnableInput, NodeValue::kBoolean, false);
|
||||
add_input(k_clamp_white_enable_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kClampWhiteInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampWhiteEnableInput).toBool());
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_clamp_white_input, NodeValue::k_float, 1.0);
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_white_enable_input).toBool());
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
// Constrain the white clamp minimum to just above the (static) black clamp
|
||||
// as per OCIO::GradingPrimary::validate. When the black clamp is keyframed
|
||||
// as per ocio::GradingPrimary::validate. When the black clamp is keyframed
|
||||
// or connected, Value() enforces the invariant per frame instead.
|
||||
UpdateClampWhiteMinimum();
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
|
||||
QString OCIOGradingTransformLinearNode::Name() const
|
||||
QString OCIOGradingTransformLinearNode::name() const
|
||||
{
|
||||
return tr("OCIO Color Grading (Linear)");
|
||||
}
|
||||
@@ -109,32 +109,32 @@ QString OCIOGradingTransformLinearNode::id() const
|
||||
"org.olivevideoeditor.Olive.ociogradingtransformlinear");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> OCIOGradingTransformLinearNode::Category() const
|
||||
QVector<Node::CategoryID> OCIOGradingTransformLinearNode::category() const
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
QString OCIOGradingTransformLinearNode::Description() const
|
||||
QString OCIOGradingTransformLinearNode::description() const
|
||||
{
|
||||
return tr("Simple linear color grading using OpenColorIO.");
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::Retranslate()
|
||||
void OCIOGradingTransformLinearNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kContrastInput, tr("Contrast"));
|
||||
SetInputName(kOffsetInput, tr("Offset"));
|
||||
SetInputName(kExposureInput, tr("Exposure"));
|
||||
SetInputProperty(kExposureInput, QStringLiteral("tooltip"),
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_contrast_input, tr("Contrast"));
|
||||
set_input_name(k_offset_input, tr("Offset"));
|
||||
set_input_name(k_exposure_input, tr("Exposure"));
|
||||
set_input_property(k_exposure_input, QStringLiteral("tooltip"),
|
||||
tr("Exposure increments in stops."));
|
||||
SetInputName(kSaturationInput, tr("Saturation"));
|
||||
SetInputName(kPivotInput, tr("Pivot"));
|
||||
SetInputName(kClampBlackEnableInput, tr("Enable Black Clamp"));
|
||||
SetInputName(kClampBlackInput, tr("Black Clamp"));
|
||||
SetInputName(kClampWhiteEnableInput, tr("Enable White Clamp"));
|
||||
SetInputName(kClampWhiteInput, tr("White Clamp"));
|
||||
set_input_name(k_saturation_input, tr("Saturation"));
|
||||
set_input_name(k_pivot_input, tr("Pivot"));
|
||||
set_input_name(k_clamp_black_enable_input, tr("Enable Black Clamp"));
|
||||
set_input_name(k_clamp_black_input, tr("Black Clamp"));
|
||||
set_input_name(k_clamp_white_enable_input, tr("Enable White Clamp"));
|
||||
set_input_name(k_clamp_white_input, tr("White Clamp"));
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::InputValueChangedEvent(
|
||||
@@ -142,19 +142,19 @@ void OCIOGradingTransformLinearNode::InputValueChangedEvent(
|
||||
{
|
||||
Q_UNUSED(element);
|
||||
|
||||
if (input == kClampWhiteEnableInput) {
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampWhiteEnableInput).toBool());
|
||||
} else if (input == kClampBlackEnableInput) {
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampBlackEnableInput).toBool());
|
||||
} else if (input == kClampBlackInput) {
|
||||
if (input == k_clamp_white_enable_input) {
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_white_enable_input).toBool());
|
||||
} else if (input == k_clamp_black_enable_input) {
|
||||
set_input_property(k_clamp_black_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_black_enable_input).toBool());
|
||||
} else if (input == k_clamp_black_input) {
|
||||
// Ensure the white clamp is always greater than the black clamp as per
|
||||
// OCIO::GradingPrimary::validate
|
||||
UpdateClampWhiteMinimum();
|
||||
// ocio::GradingPrimary::validate
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
|
||||
GenerateProcessor();
|
||||
generate_processor();
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::InputConnectedEvent(const QString &input,
|
||||
@@ -162,8 +162,8 @@ void OCIOGradingTransformLinearNode::InputConnectedEvent(const QString &input,
|
||||
{
|
||||
super::InputConnectedEvent(input, element, output);
|
||||
|
||||
if (input == kClampBlackInput) {
|
||||
UpdateClampWhiteMinimum();
|
||||
if (input == k_clamp_black_input) {
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,139 +173,139 @@ void OCIOGradingTransformLinearNode::InputDisconnectedEvent(const QString &input
|
||||
{
|
||||
super::InputDisconnectedEvent(input, element, output);
|
||||
|
||||
if (input == kClampBlackInput) {
|
||||
UpdateClampWhiteMinimum();
|
||||
if (input == k_clamp_black_input) {
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::UpdateClampWhiteMinimum()
|
||||
void OCIOGradingTransformLinearNode::update_clamp_white_minimum()
|
||||
{
|
||||
// A static UI minimum cannot follow an animated black clamp; for keyframed
|
||||
// or connected values the white>black invariant is enforced per frame in
|
||||
// Value() instead
|
||||
if (IsInputKeyframing(kClampBlackInput) ||
|
||||
IsInputConnected(kClampBlackInput)) {
|
||||
if (is_input_keyframing(k_clamp_black_input) ||
|
||||
is_input_connected(k_clamp_black_input)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("min"),
|
||||
GetStandardValue(kClampBlackInput).toDouble() + 0.000001);
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("min"),
|
||||
get_standard_value(k_clamp_black_input).toDouble() + 0.000001);
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::GenerateProcessor()
|
||||
void OCIOGradingTransformLinearNode::generate_processor()
|
||||
{
|
||||
if (manager()) {
|
||||
OCIO::GradingPrimaryTransformRcPtr gp =
|
||||
OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
|
||||
ocio::GradingPrimaryTransformRcPtr gp =
|
||||
ocio::GradingPrimaryTransform::Create(ocio::GRADING_LIN);
|
||||
gp->makeDynamic();
|
||||
gp->setDirection(OCIO::TransformDirection::TRANSFORM_DIR_FORWARD);
|
||||
gp->setDirection(ocio::TransformDirection::TRANSFORM_DIR_FORWARD);
|
||||
|
||||
try {
|
||||
set_processor(ColorProcessor::Create(
|
||||
manager()->GetConfig()->getProcessor(gp)));
|
||||
} catch (const OCIO::Exception &e) {
|
||||
set_processor(ColorProcessor::create(
|
||||
manager()->get_config()->getProcessor(gp)));
|
||||
} catch (const ocio::Exception &e) {
|
||||
std::cerr << std::endl << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::Value(const NodeValueRow &value,
|
||||
void OCIOGradingTransformLinearNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
if (processor()) {
|
||||
ColorTransformJob job(value);
|
||||
|
||||
job.SetColorProcessor(processor());
|
||||
job.SetInputTexture(value[kTextureInput]);
|
||||
job.set_color_processor(processor());
|
||||
job.set_input_texture(value[k_texture_input]);
|
||||
|
||||
const int MASTER_CHANNEL = 0;
|
||||
const int RED_CHANNEL = 1;
|
||||
const int GREEN_CHANNEL = 2;
|
||||
const int BLUE_CHANNEL = 3;
|
||||
const int master_channel = 0;
|
||||
const int red_channel = 1;
|
||||
const int green_channel = 2;
|
||||
const int blue_channel = 3;
|
||||
|
||||
// Oddly, OCIO uses RGBMs when setting the GradingPrimary on the CPU, but uses vec3s on the GPU.
|
||||
// Even more oddly, the conversion from RGBM to vec3 does not appear to have a public API.
|
||||
// Therefore, this code has been duplicated from OCIO here:
|
||||
// https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/3abbe5b20521169580fcfe3692aca81859859953/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp#L157
|
||||
QVector4D offset = value[kOffsetInput].toVec4();
|
||||
offset[RED_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
offset[GREEN_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
offset[BLUE_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
job.Insert(kOffsetInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
QVector3D(offset[RED_CHANNEL],
|
||||
offset[GREEN_CHANNEL],
|
||||
offset[BLUE_CHANNEL])));
|
||||
QVector4D offset = value[k_offset_input].to_vec4();
|
||||
offset[red_channel] += offset[master_channel];
|
||||
offset[green_channel] += offset[master_channel];
|
||||
offset[blue_channel] += offset[master_channel];
|
||||
job.insert(k_offset_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
QVector3D(offset[red_channel],
|
||||
offset[green_channel],
|
||||
offset[blue_channel])));
|
||||
|
||||
QVector4D exposure = value[kExposureInput].toVec4();
|
||||
exposure[RED_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] +
|
||||
exposure[RED_CHANNEL]);
|
||||
exposure[GREEN_CHANNEL] = std::pow(
|
||||
2.0f, exposure[MASTER_CHANNEL] + exposure[GREEN_CHANNEL]);
|
||||
exposure[BLUE_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] +
|
||||
exposure[BLUE_CHANNEL]);
|
||||
job.Insert(kExposureInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
QVector3D(exposure[RED_CHANNEL],
|
||||
exposure[GREEN_CHANNEL],
|
||||
exposure[BLUE_CHANNEL])));
|
||||
QVector4D exposure = value[k_exposure_input].to_vec4();
|
||||
exposure[red_channel] = std::pow(2.0f, exposure[master_channel] +
|
||||
exposure[red_channel]);
|
||||
exposure[green_channel] = std::pow(
|
||||
2.0f, exposure[master_channel] + exposure[green_channel]);
|
||||
exposure[blue_channel] = std::pow(2.0f, exposure[master_channel] +
|
||||
exposure[blue_channel]);
|
||||
job.insert(k_exposure_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
QVector3D(exposure[red_channel],
|
||||
exposure[green_channel],
|
||||
exposure[blue_channel])));
|
||||
|
||||
QVector4D contrast = value[kContrastInput].toVec4();
|
||||
contrast[RED_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
contrast[GREEN_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
contrast[BLUE_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
job.Insert(kContrastInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
QVector3D(contrast[RED_CHANNEL],
|
||||
contrast[GREEN_CHANNEL],
|
||||
contrast[BLUE_CHANNEL])));
|
||||
QVector4D contrast = value[k_contrast_input].to_vec4();
|
||||
contrast[red_channel] *= contrast[master_channel];
|
||||
contrast[green_channel] *= contrast[master_channel];
|
||||
contrast[blue_channel] *= contrast[master_channel];
|
||||
job.insert(k_contrast_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
QVector3D(contrast[red_channel],
|
||||
contrast[green_channel],
|
||||
contrast[blue_channel])));
|
||||
|
||||
if (!value[kClampBlackEnableInput].toBool()) {
|
||||
job.Insert(kClampBlackInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
OCIO::GradingPrimary::NoClampBlack()));
|
||||
if (!value[k_clamp_black_enable_input].to_bool()) {
|
||||
job.insert(k_clamp_black_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
ocio::GradingPrimary::NoClampBlack()));
|
||||
}
|
||||
|
||||
if (!value[kClampWhiteEnableInput].toBool()) {
|
||||
job.Insert(kClampWhiteInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
OCIO::GradingPrimary::NoClampWhite()));
|
||||
if (!value[k_clamp_white_enable_input].to_bool()) {
|
||||
job.insert(k_clamp_white_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
ocio::GradingPrimary::NoClampWhite()));
|
||||
}
|
||||
|
||||
if (value[kClampBlackEnableInput].toBool() &&
|
||||
value[kClampWhiteEnableInput].toBool()) {
|
||||
// OCIO::GradingPrimary::validate requires the white clamp to be
|
||||
if (value[k_clamp_black_enable_input].to_bool() &&
|
||||
value[k_clamp_white_enable_input].to_bool()) {
|
||||
// ocio::GradingPrimary::validate requires the white clamp to be
|
||||
// greater than the black clamp. Keyframed or connected values
|
||||
// can violate this at arbitrary times, so enforce the invariant
|
||||
// per frame here.
|
||||
const double clamp_black = value[kClampBlackInput].toDouble();
|
||||
const double clamp_white = value[kClampWhiteInput].toDouble();
|
||||
const double clamp_black = value[k_clamp_black_input].to_double();
|
||||
const double clamp_white = value[k_clamp_white_input].to_double();
|
||||
if (clamp_white <= clamp_black) {
|
||||
job.Insert(kClampWhiteInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
job.insert(k_clamp_white_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
clamp_black + 0.000001));
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::ConfigChanged()
|
||||
void OCIOGradingTransformLinearNode::config_changed()
|
||||
{
|
||||
GenerateProcessor();
|
||||
generate_processor();
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::SetVec4InputColors(const QString &input)
|
||||
void OCIOGradingTransformLinearNode::set_vec4_input_colors(const QString &input)
|
||||
{
|
||||
SetInputProperty(input, QStringLiteral("color0"),
|
||||
set_input_property(input, QStringLiteral("color0"),
|
||||
QColor(192, 192, 192).name());
|
||||
SetInputProperty(input, QStringLiteral("color1"), QColor(255, 0, 0).name());
|
||||
SetInputProperty(input, QStringLiteral("color2"), QColor(0, 255, 0).name());
|
||||
SetInputProperty(input, QStringLiteral("color3"), QColor(0, 0, 255).name());
|
||||
set_input_property(input, QStringLiteral("color1"), QColor(255, 0, 0).name());
|
||||
set_input_property(input, QStringLiteral("color2"), QColor(0, 255, 0).name());
|
||||
set_input_property(input, QStringLiteral("color3"), QColor(0, 0, 255).name());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
#define OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
#ifndef OAK_OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
#define OAK_OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
|
||||
#include "node/color/ociobase/ociobase.h"
|
||||
#include "render/colorprocessor.h"
|
||||
@@ -35,48 +35,48 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(OCIOGradingTransformLinearNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
virtual void InputConnectedEvent(const QString &input, int element,
|
||||
Node *output) override;
|
||||
virtual void InputDisconnectedEvent(const QString &input, int element,
|
||||
Node *output) override;
|
||||
void GenerateProcessor();
|
||||
void generate_processor();
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kContrastInput;
|
||||
static const QString kOffsetInput;
|
||||
static const QString kExposureInput;
|
||||
static const QString kSaturationInput;
|
||||
static const QString kPivotInput;
|
||||
static const QString kClampBlackEnableInput;
|
||||
static const QString kClampBlackInput;
|
||||
static const QString kClampWhiteEnableInput;
|
||||
static const QString kClampWhiteInput;
|
||||
static const QString k_contrast_input;
|
||||
static const QString k_offset_input;
|
||||
static const QString k_exposure_input;
|
||||
static const QString k_saturation_input;
|
||||
static const QString k_pivot_input;
|
||||
static const QString k_clamp_black_enable_input;
|
||||
static const QString k_clamp_black_input;
|
||||
static const QString k_clamp_white_enable_input;
|
||||
static const QString k_clamp_white_input;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void config_changed() override;
|
||||
|
||||
private:
|
||||
void SetVec4InputColors(const QString &input);
|
||||
void set_vec4_input_colors(const QString &input);
|
||||
|
||||
/**
|
||||
* @brief Constrains the white clamp UI minimum to just above the black
|
||||
* clamp, as required by OCIO::GradingPrimary::validate
|
||||
* clamp, as required by ocio::GradingPrimary::validate
|
||||
*
|
||||
* Only applies while the black clamp is a static value; when it is
|
||||
* keyframed or connected the invariant is enforced per frame in Value()
|
||||
* instead.
|
||||
*/
|
||||
void UpdateClampWhiteMinimum();
|
||||
void update_clamp_white_minimum();
|
||||
};
|
||||
|
||||
} // olive
|
||||
|
||||
@@ -34,23 +34,23 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOLutNode::kFileInput = QStringLiteral("lut_file_in");
|
||||
const QString OCIOLutNode::kDirectionInput = QStringLiteral("lut_dir_in");
|
||||
const QString OCIOLutNode::k_file_input = QStringLiteral("lut_file_in");
|
||||
const QString OCIOLutNode::k_direction_input = QStringLiteral("lut_dir_in");
|
||||
|
||||
#define super OCIOBaseNode
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool IsMainProcess()
|
||||
bool is_main_process()
|
||||
{
|
||||
return qobject_cast<QApplication *>(QCoreApplication::instance()) !=
|
||||
nullptr;
|
||||
}
|
||||
|
||||
int ReadDirectionInput(const Node *node)
|
||||
int read_direction_input(const Node *node)
|
||||
{
|
||||
QVariant v = node->GetStandardValue(OCIOLutNode::kDirectionInput);
|
||||
QVariant v = node->get_standard_value(OCIOLutNode::k_direction_input);
|
||||
|
||||
bool ok = false;
|
||||
int direction = v.toInt(&ok);
|
||||
@@ -75,23 +75,23 @@ int ReadDirectionInput(const Node *node)
|
||||
|
||||
OCIOLutNode::OCIOLutNode()
|
||||
{
|
||||
AddInput(kFileInput, NodeValue::kFile, QString(),
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
SetInputProperty(
|
||||
kFileInput, QStringLiteral("filter"),
|
||||
add_input(k_file_input, NodeValue::k_file, QString(),
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
set_input_property(
|
||||
k_file_input, QStringLiteral("filter"),
|
||||
tr("LUT Files (*.cube *.3dl);;Cube LUT (*.cube);;3DL LUT (*.3dl);;All Files (*)"));
|
||||
SetInputProperty(kFileInput, QStringLiteral("placeholder"),
|
||||
set_input_property(k_file_input, QStringLiteral("placeholder"),
|
||||
tr("Select a .cube or .3dl LUT file"));
|
||||
// Allow the UI to offer the global LUT library for this input
|
||||
SetInputProperty(kFileInput, QStringLiteral("lut_library"), true);
|
||||
set_input_property(k_file_input, QStringLiteral("lut_library"), true);
|
||||
|
||||
AddInput(kDirectionInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_direction_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
qRegisterMetaType<olive::ColorProcessorPtr>();
|
||||
}
|
||||
|
||||
QString OCIOLutNode::Name() const
|
||||
QString OCIOLutNode::name() const
|
||||
{
|
||||
return tr("OCIO LUT");
|
||||
}
|
||||
@@ -101,37 +101,37 @@ QString OCIOLutNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ociolut");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> OCIOLutNode::Category() const
|
||||
QVector<Node::CategoryID> OCIOLutNode::category() const
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
QString OCIOLutNode::Description() const
|
||||
QString OCIOLutNode::description() const
|
||||
{
|
||||
return tr("Applies a LUT file through OpenColorIO.");
|
||||
}
|
||||
|
||||
void OCIOLutNode::Retranslate()
|
||||
void OCIOLutNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kFileInput, tr("LUT File"));
|
||||
SetInputName(kDirectionInput, tr("Direction"));
|
||||
SetComboBoxStrings(kDirectionInput, { tr("Forward"), tr("Inverse") });
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_file_input, tr("LUT File"));
|
||||
set_input_name(k_direction_input, tr("Direction"));
|
||||
set_combo_box_strings(k_direction_input, { tr("Forward"), tr("Inverse") });
|
||||
}
|
||||
|
||||
void OCIOLutNode::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kFileInput || input == kDirectionInput) {
|
||||
if (input == k_file_input || input == k_direction_input) {
|
||||
// In the worker process, creating the OCIO processor can be slow and we
|
||||
// are often called from LoadGraph while the main process is blocked
|
||||
// waiting for a response. Defer generation to Value() time so the worker
|
||||
// can ack the graph load immediately.
|
||||
if (IsMainProcess()) {
|
||||
GenerateProcessor();
|
||||
if (is_main_process()) {
|
||||
generate_processor();
|
||||
} else {
|
||||
QMutexLocker locker(&gen_mutex_);
|
||||
processor_dirty_ = true;
|
||||
@@ -139,60 +139,60 @@ void OCIOLutNode::InputValueChangedEvent(const QString &input, int element)
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOLutNode::ConfigChanged()
|
||||
void OCIOLutNode::config_changed()
|
||||
{
|
||||
if (IsMainProcess()) {
|
||||
GenerateProcessor();
|
||||
if (is_main_process()) {
|
||||
generate_processor();
|
||||
} else {
|
||||
QMutexLocker locker(&gen_mutex_);
|
||||
processor_dirty_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOLutNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void OCIOLutNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Ensure the processor is up-to-date before the base class emits the color
|
||||
// transform job. This is especially important in the render worker, where
|
||||
// processor creation is deferred until the first render.
|
||||
EnsureProcessor();
|
||||
ensure_processor();
|
||||
|
||||
super::Value(value, globals, table);
|
||||
super::value(value, globals, table);
|
||||
}
|
||||
|
||||
void OCIOLutNode::GenerateProcessor()
|
||||
void OCIOLutNode::generate_processor()
|
||||
{
|
||||
EnsureProcessor();
|
||||
ensure_processor();
|
||||
|
||||
// The processor has changed. In the main GUI process, refresh the viewer by
|
||||
// invalidating the cache and cancelling background cache jobs.
|
||||
// Invalidating first ensures any in-flight renders that complete afterwards
|
||||
// won't write stale frames back. The worker process uses QGuiApplication and
|
||||
// has no RenderManager/PreviewAutoCacher, so skip this step to avoid crashing.
|
||||
if (IsMainProcess()) {
|
||||
InvalidateAll(kTextureInput);
|
||||
if (is_main_process()) {
|
||||
invalidate_all(k_texture_input);
|
||||
if (RenderManager *rm = RenderManager::instance()) {
|
||||
if (PreviewAutoCacher *cacher = rm->GetCacher()) {
|
||||
cacher->CancelVideoTasks(false);
|
||||
if (PreviewAutoCacher *cacher = rm->get_cacher()) {
|
||||
cacher->cancel_video_tasks(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOLutNode::EnsureProcessor() const
|
||||
void OCIOLutNode::ensure_processor() const
|
||||
{
|
||||
QMutexLocker locker(&gen_mutex_);
|
||||
|
||||
if (!processor_dirty_ && last_processor_ &&
|
||||
GetStandardValue(kFileInput).toString() == last_path_ &&
|
||||
ReadDirectionInput(this) == last_direction_) {
|
||||
get_standard_value(k_file_input).toString() == last_path_ &&
|
||||
read_direction_input(this) == last_direction_) {
|
||||
return;
|
||||
}
|
||||
|
||||
CreateProcessorFromInputs();
|
||||
create_processor_from_inputs();
|
||||
}
|
||||
|
||||
void OCIOLutNode::SetLastError(const QString &error) const
|
||||
void OCIOLutNode::set_last_error(const QString &error) const
|
||||
{
|
||||
if (last_error_ == error) {
|
||||
return;
|
||||
@@ -202,12 +202,12 @@ void OCIOLutNode::SetLastError(const QString &error) const
|
||||
|
||||
// Make the error visible to the user instead of failing silently, but only
|
||||
// from the main process (the render worker has no status bar)
|
||||
if (!error.isEmpty() && IsMainProcess() && Core::instance()) {
|
||||
Core::instance()->ShowStatusBarMessage(error, 10000);
|
||||
if (!error.isEmpty() && is_main_process() && Core::instance()) {
|
||||
Core::instance()->show_status_bar_message(error, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
bool OCIOLutNode::create_processor_from_inputs() const
|
||||
{
|
||||
if (!manager()) {
|
||||
const_cast<OCIOLutNode *>(this)->set_processor(nullptr);
|
||||
@@ -218,8 +218,8 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString path = GetStandardValue(kFileInput).toString();
|
||||
const int direction = ReadDirectionInput(this);
|
||||
const QString path = get_standard_value(k_file_input).toString();
|
||||
const int direction = read_direction_input(this);
|
||||
|
||||
if (path.isEmpty()) {
|
||||
const_cast<OCIOLutNode *>(this)->set_processor(nullptr);
|
||||
@@ -227,7 +227,7 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
last_path_.clear();
|
||||
last_direction_ = -1;
|
||||
processor_dirty_ = false;
|
||||
SetLastError(QString());
|
||||
set_last_error(QString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -245,19 +245,19 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
last_path_.clear();
|
||||
last_direction_ = -1;
|
||||
processor_dirty_ = false;
|
||||
SetLastError(tr("OCIO LUT: file does not exist: %1").arg(path));
|
||||
set_last_error(tr("OCIO LUT: file does not exist: %1").arg(path));
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString suffix = info.suffix();
|
||||
if (!LUTLibrary::IsSupportedExtension(suffix)) {
|
||||
if (!LUTLibrary::is_supported_extension(suffix)) {
|
||||
qWarning() << "Unsupported OCIO LUT file extension:" << path;
|
||||
const_cast<OCIOLutNode *>(this)->set_processor(nullptr);
|
||||
last_processor_.reset();
|
||||
last_path_.clear();
|
||||
last_direction_ = -1;
|
||||
processor_dirty_ = false;
|
||||
SetLastError(
|
||||
set_last_error(
|
||||
tr("OCIO LUT: unsupported LUT file extension (expected .cube or "
|
||||
".3dl): %1")
|
||||
.arg(path));
|
||||
@@ -267,29 +267,29 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
ColorProcessorPtr processor;
|
||||
try {
|
||||
const bool forward = static_cast<ColorProcessor::Direction>(
|
||||
direction) == ColorProcessor::kNormal;
|
||||
direction) == ColorProcessor::k_normal;
|
||||
qDebug() << "OCIOLutNode: creating processor for" << path
|
||||
<< "direction=" << direction
|
||||
<< "ocio_dir=" << (forward ? "FORWARD" : "INVERSE")
|
||||
<< "process=" << (IsMainProcess() ? "main" : "worker");
|
||||
<< "process=" << (is_main_process() ? "main" : "worker");
|
||||
|
||||
OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create();
|
||||
ocio::FileTransformRcPtr transform = ocio::FileTransform::Create();
|
||||
transform->setSrc(path.toUtf8().constData());
|
||||
transform->setInterpolation(OCIO::INTERP_LINEAR);
|
||||
transform->setDirection(forward ? OCIO::TRANSFORM_DIR_FORWARD :
|
||||
OCIO::TRANSFORM_DIR_INVERSE);
|
||||
transform->setInterpolation(ocio::INTERP_LINEAR);
|
||||
transform->setDirection(forward ? ocio::TRANSFORM_DIR_FORWARD :
|
||||
ocio::TRANSFORM_DIR_INVERSE);
|
||||
|
||||
processor = ColorProcessor::Create(
|
||||
manager()->GetConfig()->getProcessor(transform));
|
||||
processor = ColorProcessor::create(
|
||||
manager()->get_config()->getProcessor(transform));
|
||||
} catch (const std::exception &e) {
|
||||
qWarning() << "OCIO LUT processor error:" << e.what();
|
||||
processor = nullptr;
|
||||
}
|
||||
|
||||
if (!processor) {
|
||||
SetLastError(tr("OCIO LUT: failed to load LUT file: %1").arg(path));
|
||||
set_last_error(tr("OCIO LUT: failed to load LUT file: %1").arg(path));
|
||||
} else {
|
||||
SetLastError(QString());
|
||||
set_last_error(QString());
|
||||
}
|
||||
|
||||
last_path_ = path;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OCIOLUTNODE_H
|
||||
#define OCIOLUTNODE_H
|
||||
#ifndef OAK_OCIOLUTNODE_H
|
||||
#define OAK_OCIOLUTNODE_H
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
@@ -36,19 +36,19 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(OCIOLutNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kFileInput;
|
||||
static const QString kDirectionInput;
|
||||
static const QString k_file_input;
|
||||
static const QString k_direction_input;
|
||||
|
||||
/**
|
||||
* @brief Human-readable description of why no LUT processor is active
|
||||
@@ -63,14 +63,14 @@ public:
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void config_changed() override;
|
||||
|
||||
private:
|
||||
void GenerateProcessor();
|
||||
void EnsureProcessor() const;
|
||||
bool CreateProcessorFromInputs() const;
|
||||
void generate_processor();
|
||||
void ensure_processor() const;
|
||||
bool create_processor_from_inputs() const;
|
||||
|
||||
void SetLastError(const QString &error) const;
|
||||
void set_last_error(const QString &error) const;
|
||||
|
||||
mutable QMutex gen_mutex_;
|
||||
mutable bool processor_dirty_ = true;
|
||||
@@ -82,4 +82,4 @@ private:
|
||||
|
||||
} // namespace olive
|
||||
|
||||
#endif // OCIOLUTNODE_H
|
||||
#endif // OAK_OCIOLUTNODE_H
|
||||
|
||||
@@ -31,92 +31,92 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString ThreeWayColorNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString ThreeWayColorNode::kShadowsColorInput =
|
||||
const QString ThreeWayColorNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString ThreeWayColorNode::k_shadows_color_input =
|
||||
QStringLiteral("shadows_color_in");
|
||||
const QString ThreeWayColorNode::kMidtonesColorInput =
|
||||
const QString ThreeWayColorNode::k_midtones_color_input =
|
||||
QStringLiteral("midtones_color_in");
|
||||
const QString ThreeWayColorNode::kHighlightsColorInput =
|
||||
const QString ThreeWayColorNode::k_highlights_color_input =
|
||||
QStringLiteral("highlights_color_in");
|
||||
const QString ThreeWayColorNode::kShadowsAmountInput =
|
||||
const QString ThreeWayColorNode::k_shadows_amount_input =
|
||||
QStringLiteral("shadows_amount_in");
|
||||
const QString ThreeWayColorNode::kMidtonesAmountInput =
|
||||
const QString ThreeWayColorNode::k_midtones_amount_input =
|
||||
QStringLiteral("midtones_amount_in");
|
||||
const QString ThreeWayColorNode::kHighlightsAmountInput =
|
||||
const QString ThreeWayColorNode::k_highlights_amount_input =
|
||||
QStringLiteral("highlights_amount_in");
|
||||
const QString ThreeWayColorNode::kLumaCoefficientsInput =
|
||||
const QString ThreeWayColorNode::k_luma_coefficients_input =
|
||||
QStringLiteral("luma_coefficients_in");
|
||||
|
||||
ThreeWayColorNode::ThreeWayColorNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
const QVariant neutral = QVariant::fromValue(Color(0.5, 0.5, 0.5, 1.0));
|
||||
AddInput(kShadowsColorInput, NodeValue::kColor, neutral);
|
||||
AddInput(kMidtonesColorInput, NodeValue::kColor, neutral);
|
||||
AddInput(kHighlightsColorInput, NodeValue::kColor, neutral);
|
||||
add_input(k_shadows_color_input, NodeValue::k_color, neutral);
|
||||
add_input(k_midtones_color_input, NodeValue::k_color, neutral);
|
||||
add_input(k_highlights_color_input, NodeValue::k_color, neutral);
|
||||
|
||||
AddInput(kShadowsAmountInput, NodeValue::kFloat, 1.0);
|
||||
AddInput(kMidtonesAmountInput, NodeValue::kFloat, 1.0);
|
||||
AddInput(kHighlightsAmountInput, NodeValue::kFloat, 1.0);
|
||||
add_input(k_shadows_amount_input, NodeValue::k_float, 1.0);
|
||||
add_input(k_midtones_amount_input, NodeValue::k_float, 1.0);
|
||||
add_input(k_highlights_amount_input, NodeValue::k_float, 1.0);
|
||||
|
||||
const QString min = QStringLiteral("min");
|
||||
const QString view = QStringLiteral("view");
|
||||
SetInputProperty(kShadowsAmountInput, min, 0.0);
|
||||
SetInputProperty(kMidtonesAmountInput, min, 0.0);
|
||||
SetInputProperty(kHighlightsAmountInput, min, 0.0);
|
||||
SetInputProperty(kShadowsAmountInput, view, FloatSlider::kPercentage);
|
||||
SetInputProperty(kMidtonesAmountInput, view, FloatSlider::kPercentage);
|
||||
SetInputProperty(kHighlightsAmountInput, view, FloatSlider::kPercentage);
|
||||
set_input_property(k_shadows_amount_input, min, 0.0);
|
||||
set_input_property(k_midtones_amount_input, min, 0.0);
|
||||
set_input_property(k_highlights_amount_input, min, 0.0);
|
||||
set_input_property(k_shadows_amount_input, view, FloatSlider::k_percentage);
|
||||
set_input_property(k_midtones_amount_input, view, FloatSlider::k_percentage);
|
||||
set_input_property(k_highlights_amount_input, view, FloatSlider::k_percentage);
|
||||
|
||||
SetEffectInput(kTextureInput);
|
||||
SetFlag(kVideoEffect);
|
||||
set_effect_input(k_texture_input);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
void ThreeWayColorNode::Retranslate()
|
||||
void ThreeWayColorNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kShadowsColorInput, tr("Shadows"));
|
||||
SetInputName(kMidtonesColorInput, tr("Midtones"));
|
||||
SetInputName(kHighlightsColorInput, tr("Highlights"));
|
||||
SetInputName(kShadowsAmountInput, tr("Shadows Amount"));
|
||||
SetInputName(kMidtonesAmountInput, tr("Midtones Amount"));
|
||||
SetInputName(kHighlightsAmountInput, tr("Highlights Amount"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_shadows_color_input, tr("Shadows"));
|
||||
set_input_name(k_midtones_color_input, tr("Midtones"));
|
||||
set_input_name(k_highlights_color_input, tr("Highlights"));
|
||||
set_input_name(k_shadows_amount_input, tr("Shadows Amount"));
|
||||
set_input_name(k_midtones_amount_input, tr("Midtones Amount"));
|
||||
set_input_name(k_highlights_amount_input, tr("Highlights Amount"));
|
||||
}
|
||||
|
||||
ShaderCode ThreeWayColorNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode ThreeWayColorNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/threewaycolor.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/threewaycolor.frag"));
|
||||
}
|
||||
|
||||
void ThreeWayColorNode::Value(const NodeValueRow &value,
|
||||
void ThreeWayColorNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
Q_UNUSED(globals)
|
||||
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
ShaderJob job(value);
|
||||
|
||||
double luma_coeffs[3] = { 0.0, 0.0, 0.0 };
|
||||
if (project() && project()->color_manager()) {
|
||||
project()->color_manager()->GetDefaultLumaCoefs(luma_coeffs);
|
||||
project()->color_manager()->get_default_luma_coefs(luma_coeffs);
|
||||
} else {
|
||||
luma_coeffs[0] = 0.2126;
|
||||
luma_coeffs[1] = 0.7152;
|
||||
luma_coeffs[2] = 0.0722;
|
||||
}
|
||||
job.Insert(kLumaCoefficientsInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
job.insert(k_luma_coefficients_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
QVector3D(luma_coeffs[0], luma_coeffs[1],
|
||||
luma_coeffs[2])));
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef THREEWAYCOLORNODE_H
|
||||
#define THREEWAYCOLORNODE_H
|
||||
#ifndef OAK_THREEWAYCOLORNODE_H
|
||||
#define OAK_THREEWAYCOLORNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(ThreeWayColorNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Three-Way Color");
|
||||
}
|
||||
@@ -44,34 +44,34 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.threewaycolor");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Adjusts shadows, midtones, and highlights separately.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kShadowsColorInput;
|
||||
static const QString kMidtonesColorInput;
|
||||
static const QString kHighlightsColorInput;
|
||||
static const QString kShadowsAmountInput;
|
||||
static const QString kMidtonesAmountInput;
|
||||
static const QString kHighlightsAmountInput;
|
||||
static const QString kLumaCoefficientsInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_shadows_color_input;
|
||||
static const QString k_midtones_color_input;
|
||||
static const QString k_highlights_color_input;
|
||||
static const QString k_shadows_amount_input;
|
||||
static const QString k_midtones_amount_input;
|
||||
static const QString k_highlights_amount_input;
|
||||
static const QString k_luma_coefficients_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // THREEWAYCOLORNODE_H
|
||||
#endif // OAK_THREEWAYCOLORNODE_H
|
||||
|
||||
@@ -28,95 +28,95 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString CornerPinDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString CornerPinDistortNode::kTopLeftInput =
|
||||
const QString CornerPinDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString CornerPinDistortNode::k_top_left_input =
|
||||
QStringLiteral("top_left_in");
|
||||
const QString CornerPinDistortNode::kTopRightInput =
|
||||
const QString CornerPinDistortNode::k_top_right_input =
|
||||
QStringLiteral("top_right_in");
|
||||
const QString CornerPinDistortNode::kBottomRightInput =
|
||||
const QString CornerPinDistortNode::k_bottom_right_input =
|
||||
QStringLiteral("bottom_right_in");
|
||||
const QString CornerPinDistortNode::kBottomLeftInput =
|
||||
const QString CornerPinDistortNode::k_bottom_left_input =
|
||||
QStringLiteral("bottom_left_in");
|
||||
const QString CornerPinDistortNode::kPerspectiveInput =
|
||||
const QString CornerPinDistortNode::k_perspective_input =
|
||||
QStringLiteral("perspective_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
CornerPinDistortNode::CornerPinDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kPerspectiveInput, NodeValue::kBoolean, true);
|
||||
AddInput(kTopLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kTopRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kBottomRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kBottomLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
add_input(k_perspective_input, NodeValue::k_boolean, true);
|
||||
add_input(k_top_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_top_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_bottom_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_bottom_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
|
||||
// Initiate gizmos
|
||||
gizmo_whole_rect_ = AddDraggableGizmo<PolygonGizmo>();
|
||||
gizmo_resize_handle_[0] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 1) });
|
||||
gizmo_resize_handle_[1] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 1) });
|
||||
gizmo_resize_handle_[2] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 1) });
|
||||
gizmo_resize_handle_[3] = AddDraggableGizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 1) });
|
||||
gizmo_whole_rect_ = add_draggable_gizmo<PolygonGizmo>();
|
||||
gizmo_resize_handle_[0] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 1) });
|
||||
gizmo_resize_handle_[1] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 1) });
|
||||
gizmo_resize_handle_[2] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 1) });
|
||||
gizmo_resize_handle_[3] = add_draggable_gizmo<PointGizmo>(
|
||||
{ NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 1) });
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::Retranslate()
|
||||
void CornerPinDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kPerspectiveInput, tr("Perspective"));
|
||||
SetInputName(kTopLeftInput, tr("Top Left"));
|
||||
SetInputName(kTopRightInput, tr("Top Right"));
|
||||
SetInputName(kBottomRightInput, tr("Bottom Right"));
|
||||
SetInputName(kBottomLeftInput, tr("Bottom Left"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_perspective_input, tr("Perspective"));
|
||||
set_input_name(k_top_left_input, tr("Top Left"));
|
||||
set_input_name(k_top_right_input, tr("Top Right"));
|
||||
set_input_name(k_bottom_right_input, tr("Bottom Right"));
|
||||
set_input_name(k_bottom_left_input, tr("Bottom Left"));
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::Value(const NodeValueRow &value,
|
||||
void CornerPinDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If no texture do nothing
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// In the special case that all sliders are in their default position just
|
||||
// push the texture.
|
||||
if (!(value[kTopLeftInput].toVec2().isNull() &&
|
||||
value[kTopRightInput].toVec2().isNull() &&
|
||||
value[kBottomRightInput].toVec2().isNull() &&
|
||||
value[kBottomLeftInput].toVec2().isNull())) {
|
||||
if (!(value[k_top_left_input].to_vec2().isNull() &&
|
||||
value[k_top_right_input].to_vec2().isNull() &&
|
||||
value[k_bottom_right_input].to_vec2().isNull() &&
|
||||
value[k_bottom_left_input].to_vec2().isNull())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
|
||||
// Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the
|
||||
// vertex coordinates.
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
QVector2D half_resolution = resolution * 0.5;
|
||||
QVector2D top_left = QVector2D(ValueToPixel(0, value, resolution)) /
|
||||
QVector2D top_left = QVector2D(value_to_pixel(0, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D top_right =
|
||||
QVector2D(ValueToPixel(1, value, resolution)) /
|
||||
QVector2D(value_to_pixel(1, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_right =
|
||||
QVector2D(ValueToPixel(2, value, resolution)) /
|
||||
QVector2D(value_to_pixel(2, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_left =
|
||||
QVector2D(ValueToPixel(3, value, resolution)) /
|
||||
QVector2D(value_to_pixel(3, value, resolution)) /
|
||||
half_resolution -
|
||||
QVector2D(1.0, 1.0);
|
||||
|
||||
@@ -130,27 +130,27 @@ void CornerPinDistortNode::Value(const NodeValueRow &value,
|
||||
bottom_left.x(), bottom_left.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f
|
||||
};
|
||||
job.SetVertexCoordinates(adjusted_vertices);
|
||||
job.set_vertex_coordinates(adjusted_vertices);
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
CornerPinDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
CornerPinDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/cornerpin.frag")),
|
||||
FileFunctions::ReadFileAsString(
|
||||
FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/cornerpin.vert")));
|
||||
}
|
||||
|
||||
QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow &row,
|
||||
QPointF CornerPinDistortNode::value_to_pixel(int value, const NodeValueRow &row,
|
||||
const QVector2D &resolution) const
|
||||
{
|
||||
Q_ASSERT(value >= 0 && value <= 3);
|
||||
@@ -159,65 +159,65 @@ QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow &row,
|
||||
|
||||
switch (value) {
|
||||
case 0: // Top left
|
||||
v = row[kTopLeftInput].toVec2();
|
||||
v = row[k_top_left_input].to_vec2();
|
||||
return QPointF(v.x(), v.y());
|
||||
case 1: // Top right
|
||||
v = row[kTopRightInput].toVec2();
|
||||
v = row[k_top_right_input].to_vec2();
|
||||
return QPointF(resolution.x() + v.x(), v.y());
|
||||
case 2: // Bottom right
|
||||
v = row[kBottomRightInput].toVec2();
|
||||
v = row[k_bottom_right_input].to_vec2();
|
||||
return QPointF(resolution.x() + v.x(), resolution.y() + v.y());
|
||||
case 3: //Bottom left
|
||||
v = row[kBottomLeftInput].toVec2();
|
||||
v = row[k_bottom_left_input].to_vec2();
|
||||
return QPointF(v.x(), v.y() + resolution.y());
|
||||
default: // We should never get here
|
||||
return QPointF();
|
||||
}
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::GizmoDragMove(double x, double y,
|
||||
void CornerPinDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo != gizmo_whole_rect_) {
|
||||
gizmo->GetDraggers()[0].Drag(
|
||||
gizmo->GetDraggers()[0].GetStartValue().toDouble() + x);
|
||||
gizmo->GetDraggers()[1].Drag(
|
||||
gizmo->GetDraggers()[1].GetStartValue().toDouble() + y);
|
||||
gizmo->get_draggers()[0].drag(
|
||||
gizmo->get_draggers()[0].get_start_value().toDouble() + x);
|
||||
gizmo->get_draggers()[1].drag(
|
||||
gizmo->get_draggers()[1].get_start_value().toDouble() + y);
|
||||
}
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void CornerPinDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
|
||||
QPointF top_left = ValueToPixel(0, row, resolution);
|
||||
QPointF top_right = ValueToPixel(1, row, resolution);
|
||||
QPointF bottom_right = ValueToPixel(2, row, resolution);
|
||||
QPointF bottom_left = ValueToPixel(3, row, resolution);
|
||||
QPointF top_left = value_to_pixel(0, row, resolution);
|
||||
QPointF top_right = value_to_pixel(1, row, resolution);
|
||||
QPointF bottom_right = value_to_pixel(2, row, resolution);
|
||||
QPointF bottom_left = value_to_pixel(3, row, resolution);
|
||||
|
||||
// Add the correct offset to each slider
|
||||
SetInputProperty(kTopLeftInput, QStringLiteral("offset"),
|
||||
set_input_property(k_top_left_input, QStringLiteral("offset"),
|
||||
QVector2D(0.0, 0.0));
|
||||
SetInputProperty(kTopRightInput, QStringLiteral("offset"),
|
||||
set_input_property(k_top_right_input, QStringLiteral("offset"),
|
||||
QVector2D(resolution.x(), 0.0));
|
||||
SetInputProperty(kBottomRightInput, QStringLiteral("offset"),
|
||||
set_input_property(k_bottom_right_input, QStringLiteral("offset"),
|
||||
resolution);
|
||||
SetInputProperty(kBottomLeftInput, QStringLiteral("offset"),
|
||||
set_input_property(k_bottom_left_input, QStringLiteral("offset"),
|
||||
QVector2D(0.0, resolution.y()));
|
||||
|
||||
// Draw bounding box
|
||||
gizmo_whole_rect_->SetPolygon(QPolygonF(
|
||||
gizmo_whole_rect_->set_polygon(QPolygonF(
|
||||
{ top_left, top_right, bottom_right, bottom_left, top_left }));
|
||||
|
||||
// Create handles
|
||||
gizmo_resize_handle_[0]->SetPoint(top_left);
|
||||
gizmo_resize_handle_[1]->SetPoint(top_right);
|
||||
gizmo_resize_handle_[2]->SetPoint(bottom_right);
|
||||
gizmo_resize_handle_[3]->SetPoint(bottom_left);
|
||||
gizmo_resize_handle_[0]->set_point(top_left);
|
||||
gizmo_resize_handle_[1]->set_point(top_right);
|
||||
gizmo_resize_handle_[2]->set_point(bottom_right);
|
||||
gizmo_resize_handle_[3]->set_point(bottom_left);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CORNERPINDISTORTNODE_H
|
||||
#define CORNERPINDISTORTNODE_H
|
||||
#ifndef OAK_CORNERPINDISTORTNODE_H
|
||||
#define OAK_CORNERPINDISTORTNODE_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(CornerPinDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Corner Pin");
|
||||
}
|
||||
@@ -48,52 +48,52 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.cornerpin");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Distort the image by dragging the corners.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
/**
|
||||
* @brief Convenience function - converts the 2D slider values from being
|
||||
* an offset to the actual pixel value.
|
||||
*/
|
||||
QPointF ValueToPixel(int value, const NodeValueRow &row,
|
||||
QPointF value_to_pixel(int value, const NodeValueRow &row,
|
||||
const QVector2D &resolution) const;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kPerspectiveInput;
|
||||
static const QString kTopLeftInput;
|
||||
static const QString kTopRightInput;
|
||||
static const QString kBottomRightInput;
|
||||
static const QString kBottomLeftInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_perspective_input;
|
||||
static const QString k_top_left_input;
|
||||
static const QString k_top_right_input;
|
||||
static const QString k_bottom_right_input;
|
||||
static const QString k_bottom_left_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
// Gizmo variables
|
||||
static const int kGizmoCornerCount = 4;
|
||||
PointGizmo *gizmo_resize_handle_[kGizmoCornerCount];
|
||||
static const int k_gizmo_corner_count = 4;
|
||||
PointGizmo *gizmo_resize_handle_[k_gizmo_corner_count];
|
||||
PolygonGizmo *gizmo_whole_rect_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CORNERPINDISTORTNODE_H
|
||||
#endif // OAK_CORNERPINDISTORTNODE_H
|
||||
|
||||
@@ -28,133 +28,133 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString CropDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString CropDistortNode::kLeftInput = QStringLiteral("left_in");
|
||||
const QString CropDistortNode::kTopInput = QStringLiteral("top_in");
|
||||
const QString CropDistortNode::kRightInput = QStringLiteral("right_in");
|
||||
const QString CropDistortNode::kBottomInput = QStringLiteral("bottom_in");
|
||||
const QString CropDistortNode::kFeatherInput = QStringLiteral("feather_in");
|
||||
const QString CropDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString CropDistortNode::k_left_input = QStringLiteral("left_in");
|
||||
const QString CropDistortNode::k_top_input = QStringLiteral("top_in");
|
||||
const QString CropDistortNode::k_right_input = QStringLiteral("right_in");
|
||||
const QString CropDistortNode::k_bottom_input = QStringLiteral("bottom_in");
|
||||
const QString CropDistortNode::k_feather_input = QStringLiteral("feather_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
CropDistortNode::CropDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
CreateCropSideInput(kLeftInput);
|
||||
CreateCropSideInput(kTopInput);
|
||||
CreateCropSideInput(kRightInput);
|
||||
CreateCropSideInput(kBottomInput);
|
||||
create_crop_side_input(k_left_input);
|
||||
create_crop_side_input(k_top_input);
|
||||
create_crop_side_input(k_right_input);
|
||||
create_crop_side_input(k_bottom_input);
|
||||
|
||||
AddInput(kFeatherInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kFeatherInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_feather_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_feather_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
// Initiate gizmos
|
||||
poly_gizmo_ = AddDraggableGizmo<PolygonGizmo>(
|
||||
{ kLeftInput, kTopInput, kRightInput, kBottomInput });
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>(
|
||||
{ k_left_input, k_top_input, k_right_input, k_bottom_input });
|
||||
|
||||
point_gizmo_[kGizmoScaleTopLeft] =
|
||||
AddDraggableGizmo<PointGizmo>({ kLeftInput, kTopInput });
|
||||
point_gizmo_[kGizmoScaleTopCenter] =
|
||||
AddDraggableGizmo<PointGizmo>({ kTopInput });
|
||||
point_gizmo_[kGizmoScaleTopRight] =
|
||||
AddDraggableGizmo<PointGizmo>({ kRightInput, kTopInput });
|
||||
point_gizmo_[kGizmoScaleBottomLeft] =
|
||||
AddDraggableGizmo<PointGizmo>({ kLeftInput, kBottomInput });
|
||||
point_gizmo_[kGizmoScaleBottomCenter] =
|
||||
AddDraggableGizmo<PointGizmo>({ kBottomInput });
|
||||
point_gizmo_[kGizmoScaleBottomRight] =
|
||||
AddDraggableGizmo<PointGizmo>({ kRightInput, kBottomInput });
|
||||
point_gizmo_[kGizmoScaleCenterLeft] =
|
||||
AddDraggableGizmo<PointGizmo>({ kLeftInput });
|
||||
point_gizmo_[kGizmoScaleCenterRight] =
|
||||
AddDraggableGizmo<PointGizmo>({ kRightInput });
|
||||
point_gizmo_[k_gizmo_scale_top_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input, k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_top_center] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_top_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input, k_top_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input, k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_center] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_bottom_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input, k_bottom_input });
|
||||
point_gizmo_[k_gizmo_scale_center_left] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_left_input });
|
||||
point_gizmo_[k_gizmo_scale_center_right] =
|
||||
add_draggable_gizmo<PointGizmo>({ k_right_input });
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void CropDistortNode::Retranslate()
|
||||
void CropDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kLeftInput, tr("Left"));
|
||||
SetInputName(kTopInput, tr("Top"));
|
||||
SetInputName(kRightInput, tr("Right"));
|
||||
SetInputName(kBottomInput, tr("Bottom"));
|
||||
SetInputName(kFeatherInput, tr("Feather"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_left_input, tr("Left"));
|
||||
set_input_name(k_top_input, tr("Top"));
|
||||
set_input_name(k_right_input, tr("Right"));
|
||||
set_input_name(k_bottom_input, tr("Bottom"));
|
||||
set_input_name(k_feather_input, tr("Feather"));
|
||||
}
|
||||
|
||||
void CropDistortNode::Value(const NodeValueRow &value,
|
||||
void CropDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
job.Insert(value);
|
||||
job.insert(value);
|
||||
|
||||
if (TexturePtr texture = job.Get(kTextureInput).toTexture()) {
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
if (TexturePtr texture = job.get(k_texture_input).to_texture()) {
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
QVector2D(texture->params().width(),
|
||||
texture->params().height()),
|
||||
this));
|
||||
|
||||
if (!qIsNull(job.Get(kLeftInput).toDouble()) ||
|
||||
!qIsNull(job.Get(kRightInput).toDouble()) ||
|
||||
!qIsNull(job.Get(kTopInput).toDouble()) ||
|
||||
!qIsNull(job.Get(kBottomInput).toDouble())) {
|
||||
table->Push(NodeValue::kTexture, texture->toJob(job), this);
|
||||
if (!qIsNull(job.get(k_left_input).to_double()) ||
|
||||
!qIsNull(job.get(k_right_input).to_double()) ||
|
||||
!qIsNull(job.get(k_top_input).to_double()) ||
|
||||
!qIsNull(job.get(k_bottom_input).to_double())) {
|
||||
table->push(NodeValue::k_texture, texture->to_job(job), this);
|
||||
} else {
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->push(job.get(k_texture_input));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode CropDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode CropDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/crop.frag")));
|
||||
FileFunctions::read_file_as_string(QStringLiteral(":/shaders/crop.frag")));
|
||||
}
|
||||
|
||||
void CropDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void CropDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
temp_resolution_ = resolution;
|
||||
|
||||
double left_pt = resolution.x() * row[kLeftInput].toDouble();
|
||||
double top_pt = resolution.y() * row[kTopInput].toDouble();
|
||||
double right_pt = resolution.x() * (1.0 - row[kRightInput].toDouble());
|
||||
double left_pt = resolution.x() * row[k_left_input].to_double();
|
||||
double top_pt = resolution.y() * row[k_top_input].to_double();
|
||||
double right_pt = resolution.x() * (1.0 - row[k_right_input].to_double());
|
||||
double bottom_pt =
|
||||
resolution.y() * (1.0 - row[kBottomInput].toDouble());
|
||||
resolution.y() * (1.0 - row[k_bottom_input].to_double());
|
||||
double center_x_pt = mid(left_pt, right_pt);
|
||||
double center_y_pt = mid(top_pt, bottom_pt);
|
||||
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(
|
||||
QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(
|
||||
QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
QPointF(center_x_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
QPointF(right_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
QPointF(left_pt, center_y_pt));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
QPointF(right_pt, center_y_pt));
|
||||
|
||||
poly_gizmo_->SetPolygon(
|
||||
poly_gizmo_->set_polygon(
|
||||
QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt));
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::GizmoDragMove(double x_diff, double y_diff,
|
||||
void CropDistortNode::gizmo_drag_move(double x_diff, double y_diff,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
@@ -163,27 +163,27 @@ void CropDistortNode::GizmoDragMove(double x_diff, double y_diff,
|
||||
x_diff /= res.x();
|
||||
y_diff /= res.y();
|
||||
|
||||
for (int j = 0; j < gizmo->GetDraggers().size(); j++) {
|
||||
NodeInputDragger &i = gizmo->GetDraggers()[j];
|
||||
double s = i.GetStartValue().toDouble();
|
||||
if (i.GetInput().input().input() == kLeftInput) {
|
||||
i.Drag(s + x_diff);
|
||||
} else if (i.GetInput().input().input() == kTopInput) {
|
||||
i.Drag(s + y_diff);
|
||||
} else if (i.GetInput().input().input() == kRightInput) {
|
||||
i.Drag(s - x_diff);
|
||||
} else if (i.GetInput().input().input() == kBottomInput) {
|
||||
i.Drag(s - y_diff);
|
||||
for (int j = 0; j < gizmo->get_draggers().size(); j++) {
|
||||
NodeInputDragger &i = gizmo->get_draggers()[j];
|
||||
double s = i.get_start_value().toDouble();
|
||||
if (i.get_input().input().input() == k_left_input) {
|
||||
i.drag(s + x_diff);
|
||||
} else if (i.get_input().input().input() == k_top_input) {
|
||||
i.drag(s + y_diff);
|
||||
} else if (i.get_input().input().input() == k_right_input) {
|
||||
i.drag(s - x_diff);
|
||||
} else if (i.get_input().input().input() == k_bottom_input) {
|
||||
i.drag(s - y_diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::CreateCropSideInput(const QString &id)
|
||||
void CropDistortNode::create_crop_side_input(const QString &id)
|
||||
{
|
||||
AddInput(id, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(id, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(id, QStringLiteral("max"), 1.0);
|
||||
SetInputProperty(id, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
add_input(id, NodeValue::k_float, 0.0);
|
||||
set_input_property(id, QStringLiteral("min"), 0.0);
|
||||
set_input_property(id, QStringLiteral("max"), 1.0);
|
||||
set_input_property(id, QStringLiteral("view"), FloatSlider::k_percentage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CROPDISTORTNODE_H
|
||||
#define CROPDISTORTNODE_H
|
||||
#ifndef OAK_CROPDISTORTNODE_H
|
||||
#define OAK_CROPDISTORTNODE_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(CropDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Crop");
|
||||
}
|
||||
@@ -49,47 +49,47 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.crop");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Crop the edges of an image.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kLeftInput;
|
||||
static const QString kTopInput;
|
||||
static const QString kRightInput;
|
||||
static const QString kBottomInput;
|
||||
static const QString kFeatherInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_left_input;
|
||||
static const QString k_top_input;
|
||||
static const QString k_right_input;
|
||||
static const QString k_bottom_input;
|
||||
static const QString k_feather_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double delta_x, double delta_y,
|
||||
virtual void gizmo_drag_move(double delta_x, double delta_y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
void CreateCropSideInput(const QString &id);
|
||||
void create_crop_side_input(const QString &id);
|
||||
|
||||
// Gizmo variables
|
||||
PointGizmo *point_gizmo_[kGizmoScaleCount];
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
QVector2D temp_resolution_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CROPDISTORTNODE_H
|
||||
#endif // OAK_CROPDISTORTNODE_H
|
||||
|
||||
@@ -24,26 +24,26 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString FlipDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString FlipDistortNode::kHorizontalInput = QStringLiteral("horiz_in");
|
||||
const QString FlipDistortNode::kVerticalInput = QStringLiteral("vert_in");
|
||||
const QString FlipDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString FlipDistortNode::k_horizontal_input = QStringLiteral("horiz_in");
|
||||
const QString FlipDistortNode::k_vertical_input = QStringLiteral("vert_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
FlipDistortNode::FlipDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kHorizontalInput, NodeValue::kBoolean, false);
|
||||
add_input(k_horizontal_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kVerticalInput, NodeValue::kBoolean, false);
|
||||
add_input(k_vertical_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
QString FlipDistortNode::Name() const
|
||||
QString FlipDistortNode::name() const
|
||||
{
|
||||
return tr("Flip");
|
||||
}
|
||||
@@ -53,45 +53,45 @@ QString FlipDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.flip");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> FlipDistortNode::Category() const
|
||||
QVector<Node::CategoryID> FlipDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString FlipDistortNode::Description() const
|
||||
QString FlipDistortNode::description() const
|
||||
{
|
||||
return tr("Flips an image horizontally or vertically");
|
||||
}
|
||||
|
||||
void FlipDistortNode::Retranslate()
|
||||
void FlipDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kHorizontalInput, tr("Horizontal"));
|
||||
SetInputName(kVerticalInput, tr("Vertical"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_horizontal_input, tr("Horizontal"));
|
||||
set_input_name(k_vertical_input, tr("Vertical"));
|
||||
}
|
||||
|
||||
ShaderCode FlipDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode FlipDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/flip.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/flip.frag"));
|
||||
}
|
||||
|
||||
void FlipDistortNode::Value(const NodeValueRow &value,
|
||||
void FlipDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (value[kHorizontalInput].toBool() ||
|
||||
value[kVerticalInput].toBool()) {
|
||||
table->Push(NodeValue::kTexture, tex->toJob(ShaderJob(value)),
|
||||
if (value[k_horizontal_input].to_bool() ||
|
||||
value[k_vertical_input].to_bool()) {
|
||||
table->push(NodeValue::k_texture, tex->to_job(ShaderJob(value)),
|
||||
this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef FLIPDISTORTNODE_H
|
||||
#define FLIPDISTORTNODE_H
|
||||
#ifndef OAK_FLIPDISTORTNODE_H
|
||||
#define OAK_FLIPDISTORTNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,23 +34,23 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(FlipDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kHorizontalInput;
|
||||
static const QString kVerticalInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_horizontal_input;
|
||||
static const QString k_vertical_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FLIPDISTORTNODE_H
|
||||
#endif // OAK_FLIPDISTORTNODE_H
|
||||
|
||||
@@ -28,105 +28,105 @@ namespace olive
|
||||
|
||||
#define super PolygonGenerator
|
||||
|
||||
const QString MaskDistortNode::kFeatherInput = QStringLiteral("feather_in");
|
||||
const QString MaskDistortNode::kInvertInput = QStringLiteral("invert_in");
|
||||
const QString MaskDistortNode::k_feather_input = QStringLiteral("feather_in");
|
||||
const QString MaskDistortNode::k_invert_input = QStringLiteral("invert_in");
|
||||
|
||||
MaskDistortNode::MaskDistortNode()
|
||||
{
|
||||
// Mask should always be (1.0, 1.0, 1.0) for multiply to work correctly
|
||||
SetInputFlag(kColorInput, kInputFlagHidden);
|
||||
set_input_flag(k_color_input, k_input_flag_hidden);
|
||||
|
||||
AddInput(kInvertInput, NodeValue::kBoolean, false);
|
||||
add_input(k_invert_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kFeatherInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kFeatherInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_feather_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_feather_input, QStringLiteral("min"), 0.0);
|
||||
}
|
||||
|
||||
ShaderCode MaskDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode MaskDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("mrg")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/multiply.frag")));
|
||||
} else if (request.id == QStringLiteral("feather")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/blur.frag")));
|
||||
} else if (request.id == QStringLiteral("invert")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/invertrgba.frag")));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void MaskDistortNode::Retranslate()
|
||||
void MaskDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBaseInput, tr("Texture"));
|
||||
SetInputName(kInvertInput, tr("Invert"));
|
||||
SetInputName(kFeatherInput, tr("Feather"));
|
||||
set_input_name(k_base_input, tr("Texture"));
|
||||
set_input_name(k_invert_input, tr("Invert"));
|
||||
set_input_name(k_feather_input, tr("Feather"));
|
||||
}
|
||||
|
||||
void MaskDistortNode::Value(const NodeValueRow &value,
|
||||
void MaskDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
TexturePtr texture = value[kBaseInput].toTexture();
|
||||
TexturePtr texture = value[k_base_input].to_texture();
|
||||
|
||||
VideoParams job_params = texture ? texture->params() : globals.vparams();
|
||||
NodeValue job(NodeValue::kTexture,
|
||||
Texture::Job(job_params, GetGenerateJob(value, job_params)),
|
||||
NodeValue job(NodeValue::k_texture,
|
||||
Texture::job(job_params, get_generate_job(value, job_params)),
|
||||
this);
|
||||
|
||||
if (value[kInvertInput].toBool()) {
|
||||
if (value[k_invert_input].to_bool()) {
|
||||
ShaderJob invert;
|
||||
invert.SetShaderID(QStringLiteral("invert"));
|
||||
invert.Insert(QStringLiteral("tex_in"), job);
|
||||
job.set_value(Texture::Job(job_params, invert));
|
||||
invert.set_shader_id(QStringLiteral("invert"));
|
||||
invert.insert(QStringLiteral("tex_in"), job);
|
||||
job.set_value(Texture::job(job_params, invert));
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
// Push as merge node
|
||||
ShaderJob merge;
|
||||
|
||||
merge.SetShaderID(QStringLiteral("mrg"));
|
||||
merge.Insert(QStringLiteral("tex_a"), value[kBaseInput]);
|
||||
merge.set_shader_id(QStringLiteral("mrg"));
|
||||
merge.insert(QStringLiteral("tex_a"), value[k_base_input]);
|
||||
|
||||
if (value[kFeatherInput].toDouble() > 0.0) {
|
||||
if (value[k_feather_input].to_double() > 0.0) {
|
||||
// Nest a blur shader in there too
|
||||
ShaderJob feather;
|
||||
|
||||
feather.SetShaderID(QStringLiteral("feather"));
|
||||
feather.Insert(BlurFilterNode::kTextureInput, job);
|
||||
feather.Insert(BlurFilterNode::kMethodInput,
|
||||
NodeValue(NodeValue::kInt,
|
||||
int(BlurFilterNode::kGaussian), this));
|
||||
feather.Insert(BlurFilterNode::kHorizInput,
|
||||
NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kVertInput,
|
||||
NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kRepeatEdgePixelsInput,
|
||||
NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kRadiusInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
value[kFeatherInput].toDouble(), this));
|
||||
feather.SetIterations(2, BlurFilterNode::kTextureInput);
|
||||
feather.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
feather.set_shader_id(QStringLiteral("feather"));
|
||||
feather.insert(BlurFilterNode::k_texture_input, job);
|
||||
feather.insert(BlurFilterNode::k_method_input,
|
||||
NodeValue(NodeValue::k_int,
|
||||
int(BlurFilterNode::k_gaussian), this));
|
||||
feather.insert(BlurFilterNode::k_horiz_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_vert_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_repeat_edge_pixels_input,
|
||||
NodeValue(NodeValue::k_boolean, true, this));
|
||||
feather.insert(BlurFilterNode::k_radius_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
value[k_feather_input].to_double(), this));
|
||||
feather.set_iterations(2, BlurFilterNode::k_texture_input);
|
||||
feather.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
texture ? texture->virtual_resolution() :
|
||||
globals.square_resolution(),
|
||||
this));
|
||||
|
||||
merge.Insert(QStringLiteral("tex_b"),
|
||||
NodeValue(NodeValue::kTexture,
|
||||
Texture::Job(job_params, feather), this));
|
||||
merge.insert(QStringLiteral("tex_b"),
|
||||
NodeValue(NodeValue::k_texture,
|
||||
Texture::job(job_params, feather), this));
|
||||
} else {
|
||||
merge.Insert(QStringLiteral("tex_b"), job);
|
||||
merge.insert(QStringLiteral("tex_b"), job);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, Texture::Job(job_params, merge), this);
|
||||
table->push(NodeValue::k_texture, Texture::job(job_params, merge), this);
|
||||
} else {
|
||||
table->Push(job);
|
||||
table->push(job);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MASKDISTORTNODE_H
|
||||
#define MASKDISTORTNODE_H
|
||||
#ifndef OAK_MASKDISTORTNODE_H
|
||||
#define OAK_MASKDISTORTNODE_H
|
||||
|
||||
#include "node/generator/polygon/polygon.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MaskDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Mask");
|
||||
}
|
||||
@@ -44,28 +44,28 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.mask");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Apply a polygonal mask.");
|
||||
}
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kInvertInput;
|
||||
static const QString kFeatherInput;
|
||||
static const QString k_invert_input;
|
||||
static const QString k_feather_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MASKDISTORTNODE_H
|
||||
#endif // OAK_MASKDISTORTNODE_H
|
||||
|
||||
@@ -24,43 +24,43 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString RippleDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString RippleDistortNode::kEvolutionInput =
|
||||
const QString RippleDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString RippleDistortNode::k_evolution_input =
|
||||
QStringLiteral("evolution_in");
|
||||
const QString RippleDistortNode::kIntensityInput =
|
||||
const QString RippleDistortNode::k_intensity_input =
|
||||
QStringLiteral("intensity_in");
|
||||
const QString RippleDistortNode::kFrequencyInput =
|
||||
const QString RippleDistortNode::k_frequency_input =
|
||||
QStringLiteral("frequency_in");
|
||||
const QString RippleDistortNode::kPositionInput = QStringLiteral("position_in");
|
||||
const QString RippleDistortNode::kStretchInput = QStringLiteral("stretch_in");
|
||||
const QString RippleDistortNode::k_position_input = QStringLiteral("position_in");
|
||||
const QString RippleDistortNode::k_stretch_input = QStringLiteral("stretch_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
RippleDistortNode::RippleDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kEvolutionInput, NodeValue::kFloat, 0);
|
||||
AddInput(kIntensityInput, NodeValue::kFloat, 100);
|
||||
add_input(k_evolution_input, NodeValue::k_float, 0);
|
||||
add_input(k_intensity_input, NodeValue::k_float, 100);
|
||||
|
||||
AddInput(kFrequencyInput, NodeValue::kFloat, 1);
|
||||
SetInputProperty(kFrequencyInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_frequency_input, NodeValue::k_float, 1);
|
||||
set_input_property(k_frequency_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
AddInput(kStretchInput, NodeValue::kBoolean, false);
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
add_input(k_stretch_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = AddDraggableGizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString RippleDistortNode::Name() const
|
||||
QString RippleDistortNode::name() const
|
||||
{
|
||||
return tr("Ripple");
|
||||
}
|
||||
@@ -70,72 +70,72 @@ QString RippleDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ripple");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> RippleDistortNode::Category() const
|
||||
QVector<Node::CategoryID> RippleDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString RippleDistortNode::Description() const
|
||||
QString RippleDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image with a ripple effect.");
|
||||
}
|
||||
|
||||
void RippleDistortNode::Retranslate()
|
||||
void RippleDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kFrequencyInput, tr("Frequency"));
|
||||
SetInputName(kIntensityInput, tr("Intensity"));
|
||||
SetInputName(kEvolutionInput, tr("Evolution"));
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kStretchInput, tr("Stretch"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_frequency_input, tr("Frequency"));
|
||||
set_input_name(k_intensity_input, tr("Intensity"));
|
||||
set_input_name(k_evolution_input, tr("Evolution"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_stretch_input, tr("Stretch"));
|
||||
}
|
||||
|
||||
ShaderCode RippleDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode RippleDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/ripple.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/ripple.frag"));
|
||||
}
|
||||
|
||||
void RippleDistortNode::Value(const NodeValueRow &value,
|
||||
void RippleDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[kIntensityInput].toDouble())) {
|
||||
if (!qIsNull(value[k_intensity_input].to_double())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void RippleDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
QPointF half_res(tex->virtual_resolution().x() / 2,
|
||||
tex->virtual_resolution().y() / 2);
|
||||
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
|
||||
gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF());
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::GizmoDragMove(double x, double y,
|
||||
void RippleDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef RIPPLEDISTORTNODE_H
|
||||
#define RIPPLEDISTORTNODE_H
|
||||
#ifndef OAK_RIPPLEDISTORTNODE_H
|
||||
#define OAK_RIPPLEDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
@@ -35,30 +35,30 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(RippleDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kEvolutionInput;
|
||||
static const QString kIntensityInput;
|
||||
static const QString kFrequencyInput;
|
||||
static const QString kPositionInput;
|
||||
static const QString kStretchInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_evolution_input;
|
||||
static const QString k_intensity_input;
|
||||
static const QString k_frequency_input;
|
||||
static const QString k_position_input;
|
||||
static const QString k_stretch_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
@@ -67,4 +67,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // RIPPLEDISTORTNODE_H
|
||||
#endif // OAK_RIPPLEDISTORTNODE_H
|
||||
|
||||
@@ -24,37 +24,37 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString SwirlDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString SwirlDistortNode::kRadiusInput = QStringLiteral("radius_in");
|
||||
const QString SwirlDistortNode::kAngleInput = QStringLiteral("angle_in");
|
||||
const QString SwirlDistortNode::kPositionInput = QStringLiteral("pos_in");
|
||||
const QString SwirlDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString SwirlDistortNode::k_radius_input = QStringLiteral("radius_in");
|
||||
const QString SwirlDistortNode::k_angle_input = QStringLiteral("angle_in");
|
||||
const QString SwirlDistortNode::k_position_input = QStringLiteral("pos_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
SwirlDistortNode::SwirlDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kRadiusInput, NodeValue::kFloat, 200);
|
||||
SetInputProperty(kRadiusInput, QStringLiteral("min"), 0);
|
||||
add_input(k_radius_input, NodeValue::k_float, 200);
|
||||
set_input_property(k_radius_input, QStringLiteral("min"), 0);
|
||||
|
||||
AddInput(kAngleInput, NodeValue::kFloat, 10);
|
||||
SetInputProperty(kAngleInput, QStringLiteral("base"), 0.1);
|
||||
add_input(k_angle_input, NodeValue::k_float, 10);
|
||||
set_input_property(k_angle_input, QStringLiteral("base"), 0.1);
|
||||
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = AddDraggableGizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString SwirlDistortNode::Name() const
|
||||
QString SwirlDistortNode::name() const
|
||||
{
|
||||
return tr("Swirl");
|
||||
}
|
||||
@@ -64,70 +64,70 @@ QString SwirlDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.swirl");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> SwirlDistortNode::Category() const
|
||||
QVector<Node::CategoryID> SwirlDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString SwirlDistortNode::Description() const
|
||||
QString SwirlDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image by swirling it around a center point.");
|
||||
}
|
||||
|
||||
void SwirlDistortNode::Retranslate()
|
||||
void SwirlDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kRadiusInput, tr("Radius"));
|
||||
SetInputName(kAngleInput, tr("Angle"));
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_radius_input, tr("Radius"));
|
||||
set_input_name(k_angle_input, tr("Angle"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
}
|
||||
|
||||
ShaderCode SwirlDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode SwirlDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/swirl.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/swirl.frag"));
|
||||
}
|
||||
|
||||
void SwirlDistortNode::Value(const NodeValueRow &value,
|
||||
void SwirlDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[kAngleInput].toDouble()) &&
|
||||
!qIsNull(value[kRadiusInput].toDouble())) {
|
||||
if (!qIsNull(value[k_angle_input].to_double()) &&
|
||||
!qIsNull(value[k_radius_input].to_double())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwirlDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void SwirlDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
QPointF half_res(globals.square_resolution().x() / 2,
|
||||
globals.square_resolution().y() / 2);
|
||||
|
||||
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
|
||||
gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF());
|
||||
}
|
||||
|
||||
void SwirlDistortNode::GizmoDragMove(double x, double y,
|
||||
void SwirlDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SWIRLDISTORTNODE_H
|
||||
#define SWIRLDISTORTNODE_H
|
||||
#ifndef OAK_SWIRLDISTORTNODE_H
|
||||
#define OAK_SWIRLDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
@@ -35,28 +35,28 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(SwirlDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kRadiusInput;
|
||||
static const QString kAngleInput;
|
||||
static const QString kPositionInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_radius_input;
|
||||
static const QString k_angle_input;
|
||||
static const QString k_position_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
@@ -65,4 +65,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // SWIRLDISTORTNODE_H
|
||||
#endif // OAK_SWIRLDISTORTNODE_H
|
||||
|
||||
@@ -26,43 +26,43 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString TileDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString TileDistortNode::kScaleInput = QStringLiteral("scale_in");
|
||||
const QString TileDistortNode::kPositionInput = QStringLiteral("position_in");
|
||||
const QString TileDistortNode::kAnchorInput = QStringLiteral("anchor_in");
|
||||
const QString TileDistortNode::kMirrorXInput = QStringLiteral("mirrorx_in");
|
||||
const QString TileDistortNode::kMirrorYInput = QStringLiteral("mirrory_in");
|
||||
const QString TileDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString TileDistortNode::k_scale_input = QStringLiteral("scale_in");
|
||||
const QString TileDistortNode::k_position_input = QStringLiteral("position_in");
|
||||
const QString TileDistortNode::k_anchor_input = QStringLiteral("anchor_in");
|
||||
const QString TileDistortNode::k_mirror_x_input = QStringLiteral("mirrorx_in");
|
||||
const QString TileDistortNode::k_mirror_y_input = QStringLiteral("mirrory_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
TileDistortNode::TileDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kScaleInput, NodeValue::kFloat, 0.5);
|
||||
SetInputProperty(kScaleInput, QStringLiteral("min"), 0);
|
||||
SetInputProperty(kScaleInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
add_input(k_scale_input, NodeValue::k_float, 0.5);
|
||||
set_input_property(k_scale_input, QStringLiteral("min"), 0);
|
||||
set_input_property(k_scale_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
|
||||
AddInput(kAnchorInput, NodeValue::kCombo, kMiddleCenter);
|
||||
add_input(k_anchor_input, NodeValue::k_combo, k_middle_center);
|
||||
|
||||
AddInput(kMirrorXInput, NodeValue::kBoolean, false);
|
||||
AddInput(kMirrorYInput, NodeValue::kBoolean, false);
|
||||
add_input(k_mirror_x_input, NodeValue::k_boolean, false);
|
||||
add_input(k_mirror_y_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
gizmo_ = AddDraggableGizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
gizmo_ = add_draggable_gizmo<PointGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
}
|
||||
|
||||
QString TileDistortNode::Name() const
|
||||
QString TileDistortNode::name() const
|
||||
{
|
||||
return tr("Tile");
|
||||
}
|
||||
@@ -72,28 +72,28 @@ QString TileDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.tile");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TileDistortNode::Category() const
|
||||
QVector<Node::CategoryID> TileDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString TileDistortNode::Description() const
|
||||
QString TileDistortNode::description() const
|
||||
{
|
||||
return tr("Infinitely tile an image horizontally and vertically.");
|
||||
}
|
||||
|
||||
void TileDistortNode::Retranslate()
|
||||
void TileDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kScaleInput, tr("Scale"));
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kMirrorXInput, tr("Mirror Horizontally"));
|
||||
SetInputName(kMirrorYInput, tr("Mirror Vertically"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_scale_input, tr("Scale"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_mirror_x_input, tr("Mirror Horizontally"));
|
||||
set_input_name(k_mirror_y_input, tr("Mirror Vertically"));
|
||||
|
||||
SetInputName(kAnchorInput, tr("Anchor"));
|
||||
SetComboBoxStrings(kAnchorInput, {
|
||||
set_input_name(k_anchor_input, tr("Anchor"));
|
||||
set_combo_box_strings(k_anchor_input, {
|
||||
tr("Top-Left"),
|
||||
tr("Top-Center"),
|
||||
tr("Top-Right"),
|
||||
@@ -106,72 +106,72 @@ void TileDistortNode::Retranslate()
|
||||
});
|
||||
}
|
||||
|
||||
ShaderCode TileDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode TileDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/tile.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/tile.frag"));
|
||||
}
|
||||
|
||||
void TileDistortNode::Value(const NodeValueRow &value,
|
||||
void TileDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qFuzzyCompare(value[kScaleInput].toDouble(), 1.0)) {
|
||||
if (!qFuzzyCompare(value[k_scale_input].to_double(), 1.0)) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void TileDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
QPointF res = tex->virtual_resolution().toPointF();
|
||||
QPointF pos = row[kPositionInput].toVec2().toPointF();
|
||||
QPointF pos = row[k_position_input].to_vec2().toPointF();
|
||||
qreal x = pos.x();
|
||||
qreal y = pos.y();
|
||||
|
||||
Anchor a = static_cast<Anchor>(row[kAnchorInput].toInt());
|
||||
if (a == kTopLeft || a == kTopCenter || a == kTopRight) {
|
||||
Anchor a = static_cast<Anchor>(row[k_anchor_input].to_int());
|
||||
if (a == k_top_left || a == k_top_center || a == k_top_right) {
|
||||
// Do nothing
|
||||
} else if (a == kMiddleLeft || a == kMiddleCenter ||
|
||||
a == kMiddleRight) {
|
||||
} else if (a == k_middle_left || a == k_middle_center ||
|
||||
a == k_middle_right) {
|
||||
y += res.y() / 2;
|
||||
} else if (a == kBottomLeft || a == kBottomCenter ||
|
||||
a == kBottomRight) {
|
||||
} else if (a == k_bottom_left || a == k_bottom_center ||
|
||||
a == k_bottom_right) {
|
||||
y += res.y();
|
||||
}
|
||||
if (a == kTopLeft || a == kMiddleLeft || a == kBottomLeft) {
|
||||
if (a == k_top_left || a == k_middle_left || a == k_bottom_left) {
|
||||
// Do nothing
|
||||
} else if (a == kTopCenter || a == kMiddleCenter ||
|
||||
a == kBottomCenter) {
|
||||
} else if (a == k_top_center || a == k_middle_center ||
|
||||
a == k_bottom_center) {
|
||||
x += res.x() / 2;
|
||||
} else if (a == kTopRight || a == kMiddleRight || a == kBottomRight) {
|
||||
} else if (a == k_top_right || a == k_middle_right || a == k_bottom_right) {
|
||||
x += res.x();
|
||||
}
|
||||
|
||||
gizmo_->SetPoint(QPointF(x, y));
|
||||
gizmo_->set_point(QPointF(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::GizmoDragMove(double x, double y,
|
||||
void TileDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
NodeInputDragger &x_drag = gizmo_->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo_->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo_->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TILEDISTORTNODE_H
|
||||
#define TILEDISTORTNODE_H
|
||||
#ifndef OAK_TILEDISTORTNODE_H
|
||||
#define OAK_TILEDISTORTNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
@@ -35,43 +35,43 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TileDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kScaleInput;
|
||||
static const QString kPositionInput;
|
||||
static const QString kAnchorInput;
|
||||
static const QString kMirrorXInput;
|
||||
static const QString kMirrorYInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_scale_input;
|
||||
static const QString k_position_input;
|
||||
static const QString k_anchor_input;
|
||||
static const QString k_mirror_x_input;
|
||||
static const QString k_mirror_y_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
enum Anchor {
|
||||
kTopLeft,
|
||||
kTopCenter,
|
||||
kTopRight,
|
||||
kMiddleLeft,
|
||||
kMiddleCenter,
|
||||
kMiddleRight,
|
||||
kBottomLeft,
|
||||
kBottomCenter,
|
||||
kBottomRight
|
||||
k_top_left,
|
||||
k_top_center,
|
||||
k_top_right,
|
||||
k_middle_left,
|
||||
k_middle_center,
|
||||
k_middle_right,
|
||||
k_bottom_left,
|
||||
k_bottom_center,
|
||||
k_bottom_right
|
||||
};
|
||||
|
||||
PointGizmo *gizmo_;
|
||||
@@ -79,4 +79,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TILEDISTORTNODE_H
|
||||
#endif // OAK_TILEDISTORTNODE_H
|
||||
|
||||
@@ -26,124 +26,124 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString TransformDistortNode::kParentInput = QStringLiteral("parent_in");
|
||||
const QString TransformDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString TransformDistortNode::kAutoscaleInput =
|
||||
const QString TransformDistortNode::k_parent_input = QStringLiteral("parent_in");
|
||||
const QString TransformDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString TransformDistortNode::k_autoscale_input =
|
||||
QStringLiteral("autoscale_in");
|
||||
const QString TransformDistortNode::kInterpolationInput =
|
||||
const QString TransformDistortNode::k_interpolation_input =
|
||||
QStringLiteral("interpolation_in");
|
||||
|
||||
#define super MatrixGenerator
|
||||
|
||||
TransformDistortNode::TransformDistortNode()
|
||||
{
|
||||
AddInput(kParentInput, NodeValue::kMatrix);
|
||||
add_input(k_parent_input, NodeValue::k_matrix);
|
||||
|
||||
AddInput(kAutoscaleInput, NodeValue::kCombo, 0);
|
||||
add_input(k_autoscale_input, NodeValue::k_combo, 0);
|
||||
|
||||
AddInput(kInterpolationInput, NodeValue::kCombo, 2);
|
||||
add_input(k_interpolation_input, NodeValue::k_combo, 2);
|
||||
|
||||
PrependInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
prepend_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
// Initiate gizmos
|
||||
rotation_gizmo_ = AddDraggableGizmo<ScreenGizmo>();
|
||||
rotation_gizmo_->AddInput(NodeInput(this, kRotationInput));
|
||||
rotation_gizmo_->SetDragValueBehavior(ScreenGizmo::kAbsolute);
|
||||
rotation_gizmo_ = add_draggable_gizmo<ScreenGizmo>();
|
||||
rotation_gizmo_->add_input(NodeInput(this, k_rotation_input));
|
||||
rotation_gizmo_->set_drag_value_behavior(ScreenGizmo::k_absolute);
|
||||
|
||||
poly_gizmo_ = AddDraggableGizmo<PolygonGizmo>();
|
||||
poly_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0));
|
||||
poly_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1));
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>();
|
||||
poly_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0));
|
||||
poly_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1));
|
||||
|
||||
anchor_gizmo_ = AddDraggableGizmo<PointGizmo>();
|
||||
anchor_gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kAnchorInput), 0));
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kAnchorInput), 1));
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0));
|
||||
anchor_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1));
|
||||
anchor_gizmo_ = add_draggable_gizmo<PointGizmo>();
|
||||
anchor_gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 0));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 1));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0));
|
||||
anchor_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1));
|
||||
|
||||
for (int i = 0; i < kGizmoScaleCount; i++) {
|
||||
point_gizmo_[i] = AddDraggableGizmo<PointGizmo>();
|
||||
point_gizmo_[i]->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kScaleInput), 0));
|
||||
point_gizmo_[i]->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kScaleInput), 1));
|
||||
point_gizmo_[i]->SetDragValueBehavior(PointGizmo::kAbsolute);
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
point_gizmo_[i] = add_draggable_gizmo<PointGizmo>();
|
||||
point_gizmo_[i]->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 0));
|
||||
point_gizmo_[i]->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 1));
|
||||
point_gizmo_[i]->set_drag_value_behavior(PointGizmo::k_absolute);
|
||||
}
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void TransformDistortNode::Retranslate()
|
||||
void TransformDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kParentInput, tr("Parent"));
|
||||
SetInputName(kAutoscaleInput, tr("Auto-Scale"));
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kInterpolationInput, tr("Interpolation"));
|
||||
set_input_name(k_parent_input, tr("Parent"));
|
||||
set_input_name(k_autoscale_input, tr("Auto-Scale"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_interpolation_input, tr("Interpolation"));
|
||||
|
||||
SetComboBoxStrings(kAutoscaleInput,
|
||||
set_combo_box_strings(k_autoscale_input,
|
||||
{ tr("None"), tr("Fit"), tr("Fill"), tr("Stretch") });
|
||||
SetComboBoxStrings(kInterpolationInput,
|
||||
set_combo_box_strings(k_interpolation_input,
|
||||
{ tr("Nearest Neighbor"), tr("Bilinear"),
|
||||
tr("Mipmapped Bilinear") });
|
||||
}
|
||||
|
||||
void TransformDistortNode::Value(const NodeValueRow &value,
|
||||
void TransformDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Generate matrix
|
||||
QMatrix4x4 generated_matrix = GenerateMatrix(
|
||||
value, false, false, false, value[kParentInput].toMatrix());
|
||||
QMatrix4x4 generated_matrix = generate_matrix(
|
||||
value, false, false, false, value[k_parent_input].to_matrix());
|
||||
|
||||
// Pop texture
|
||||
NodeValue texture_meta = value[kTextureInput];
|
||||
NodeValue texture_meta = value[k_texture_input];
|
||||
|
||||
TexturePtr job_to_push = nullptr;
|
||||
|
||||
// If we have a texture, generate a matrix and make it happen
|
||||
if (TexturePtr texture = texture_meta.toTexture()) {
|
||||
if (TexturePtr texture = texture_meta.to_texture()) {
|
||||
// Adjust our matrix by the resolutions involved
|
||||
QMatrix4x4 real_matrix = GenerateAutoScaledMatrix(
|
||||
QMatrix4x4 real_matrix = generate_auto_scaled_matrix(
|
||||
generated_matrix, value, globals, texture->params());
|
||||
|
||||
if (!real_matrix.isIdentity()) {
|
||||
// The matrix will transform things
|
||||
ShaderJob job;
|
||||
job.Insert(QStringLiteral("ove_maintex"), texture_meta);
|
||||
job.Insert(QStringLiteral("ove_mvpmat"),
|
||||
NodeValue(NodeValue::kMatrix, real_matrix, this));
|
||||
job.SetInterpolation(QStringLiteral("ove_maintex"),
|
||||
job.insert(QStringLiteral("ove_maintex"), texture_meta);
|
||||
job.insert(QStringLiteral("ove_mvpmat"),
|
||||
NodeValue(NodeValue::k_matrix, real_matrix, this));
|
||||
job.set_interpolation(QStringLiteral("ove_maintex"),
|
||||
static_cast<Texture::Interpolation>(
|
||||
value[kInterpolationInput].toInt()));
|
||||
value[k_interpolation_input].to_int()));
|
||||
|
||||
// Use global resolution rather than texture resolution because this may result in a size change
|
||||
job_to_push = Texture::Job(globals.vparams(), job);
|
||||
job_to_push = Texture::job(globals.vparams(), job);
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kMatrix, QVariant::fromValue(generated_matrix),
|
||||
table->push(NodeValue::k_matrix, QVariant::fromValue(generated_matrix),
|
||||
this);
|
||||
|
||||
if (!job_to_push) {
|
||||
// Re-push whatever value we received
|
||||
table->Push(texture_meta);
|
||||
table->push(texture_meta);
|
||||
} else {
|
||||
table->Push(NodeValue::kTexture, job_to_push, this);
|
||||
table->push(NodeValue::k_texture, job_to_push, this);
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode
|
||||
TransformDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
TransformDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request);
|
||||
|
||||
@@ -151,70 +151,70 @@ TransformDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
return ShaderCode();
|
||||
}
|
||||
|
||||
void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x,
|
||||
double y, const rational &time)
|
||||
void TransformDistortNode::gizmo_drag_start(const NodeValueRow &row, double x,
|
||||
double y, const Rational &time)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo == anchor_gizmo_) {
|
||||
gizmo_inverted_transform_ =
|
||||
GenerateMatrix(row, true, true, false, row[kParentInput].toMatrix())
|
||||
generate_matrix(row, true, true, false, row[k_parent_input].to_matrix())
|
||||
.toTransform()
|
||||
.inverted();
|
||||
|
||||
} else if (IsAScaleGizmo(gizmo)) {
|
||||
} else if (is_a_scale_gizmo(gizmo)) {
|
||||
// Dragging scale handle
|
||||
TexturePtr tex = row[kTextureInput].toTexture();
|
||||
TexturePtr tex = row[k_texture_input].to_texture();
|
||||
if (!tex) {
|
||||
return;
|
||||
}
|
||||
|
||||
gizmo_scale_uniform_ = row[kUniformScaleInput].toBool();
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() +
|
||||
gizmo->GetGlobals().nonsquare_resolution() / 2)
|
||||
gizmo_scale_uniform_ = row[k_uniform_scale_input].to_bool();
|
||||
gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() +
|
||||
gizmo->get_globals().nonsquare_resolution() / 2)
|
||||
.toPointF();
|
||||
|
||||
if (gizmo == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomRight]) {
|
||||
gizmo_scale_axes_ = kGizmoScaleBoth;
|
||||
} else if (gizmo == point_gizmo_[kGizmoScaleCenterLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleCenterRight]) {
|
||||
gizmo_scale_axes_ = kGizmoScaleXOnly;
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right]) {
|
||||
gizmo_scale_axes_ = k_gizmo_scale_both;
|
||||
} else if (gizmo == point_gizmo_[k_gizmo_scale_center_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_center_right]) {
|
||||
gizmo_scale_axes_ = k_gizmo_scale_x_only;
|
||||
} else {
|
||||
gizmo_scale_axes_ = kGizmoScaleYOnly;
|
||||
gizmo_scale_axes_ = k_gizmo_scale_y_only;
|
||||
}
|
||||
|
||||
// Store texture size
|
||||
VideoParams texture_params = tex->params();
|
||||
QVector2D texture_sz(texture_params.square_pixel_width(),
|
||||
texture_params.height());
|
||||
gizmo_scale_anchor_ = row[kAnchorInput].toVec2() + texture_sz / 2;
|
||||
gizmo_scale_anchor_ = row[k_anchor_input].to_vec2() + texture_sz / 2;
|
||||
|
||||
if (gizmo == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleCenterRight]) {
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_center_right]) {
|
||||
// Right handles, flip X axis
|
||||
gizmo_scale_anchor_.setX(texture_sz.x() - gizmo_scale_anchor_.x());
|
||||
}
|
||||
|
||||
if (gizmo == point_gizmo_[kGizmoScaleBottomLeft] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomRight] ||
|
||||
gizmo == point_gizmo_[kGizmoScaleBottomCenter]) {
|
||||
if (gizmo == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
gizmo == point_gizmo_[k_gizmo_scale_bottom_center]) {
|
||||
// Bottom handles, flip Y axis
|
||||
gizmo_scale_anchor_.setY(texture_sz.y() - gizmo_scale_anchor_.y());
|
||||
}
|
||||
|
||||
// Store current matrix
|
||||
gizmo_inverted_transform_ =
|
||||
GenerateMatrix(row, true, true, true, row[kParentInput].toMatrix())
|
||||
generate_matrix(row, true, true, true, row[k_parent_input].to_matrix())
|
||||
.toTransform()
|
||||
.inverted();
|
||||
|
||||
} else if (gizmo == rotation_gizmo_) {
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() +
|
||||
gizmo->GetGlobals().nonsquare_resolution() / 2)
|
||||
gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() +
|
||||
gizmo->get_globals().nonsquare_resolution() / 2)
|
||||
.toPointF();
|
||||
gizmo_start_angle_ =
|
||||
std::atan2(y - gizmo_anchor_pt_.y(), x - gizmo_anchor_pt_.x());
|
||||
@@ -222,36 +222,36 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x,
|
||||
gizmo_last_alt_angle_ =
|
||||
std::atan2(x - gizmo_anchor_pt_.x(), y - gizmo_anchor_pt_.y());
|
||||
gizmo_rotate_wrap_ = 0;
|
||||
gizmo_rotate_last_dir_ = kDirectionNone;
|
||||
gizmo_rotate_last_dir_ = k_direction_none;
|
||||
}
|
||||
}
|
||||
|
||||
void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
void TransformDistortNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo == poly_gizmo_) {
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
|
||||
} else if (gizmo == anchor_gizmo_) {
|
||||
NodeInputDragger &x_anchor_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_anchor_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_pos_drag = gizmo->GetDraggers()[2];
|
||||
NodeInputDragger &y_pos_drag = gizmo->GetDraggers()[3];
|
||||
NodeInputDragger &x_anchor_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_anchor_drag = gizmo->get_draggers()[1];
|
||||
NodeInputDragger &x_pos_drag = gizmo->get_draggers()[2];
|
||||
NodeInputDragger &y_pos_drag = gizmo->get_draggers()[3];
|
||||
|
||||
QPointF inverted_movement(gizmo_inverted_transform_.map(QPointF(x, y)));
|
||||
|
||||
x_anchor_drag.Drag(x_anchor_drag.GetStartValue().toDouble() +
|
||||
x_anchor_drag.drag(x_anchor_drag.get_start_value().toDouble() +
|
||||
inverted_movement.x());
|
||||
y_anchor_drag.Drag(y_anchor_drag.GetStartValue().toDouble() +
|
||||
y_anchor_drag.drag(y_anchor_drag.get_start_value().toDouble() +
|
||||
inverted_movement.y());
|
||||
x_pos_drag.Drag(x_pos_drag.GetStartValue().toDouble() + x);
|
||||
y_pos_drag.Drag(y_pos_drag.GetStartValue().toDouble() + y);
|
||||
x_pos_drag.drag(x_pos_drag.get_start_value().toDouble() + x);
|
||||
y_pos_drag.drag(y_pos_drag.get_start_value().toDouble() + y);
|
||||
|
||||
} else if (gizmo == rotation_gizmo_) {
|
||||
double raw_angle =
|
||||
@@ -263,11 +263,11 @@ void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
|
||||
// Detect rotation wrap around
|
||||
RotationDirection this_dir =
|
||||
GetDirectionFromAngles(gizmo_last_angle_, raw_angle);
|
||||
get_direction_from_angles(gizmo_last_angle_, raw_angle);
|
||||
RotationDirection alt_dir =
|
||||
GetDirectionFromAngles(gizmo_last_alt_angle_, alt_angle);
|
||||
get_direction_from_angles(gizmo_last_alt_angle_, alt_angle);
|
||||
|
||||
if (gizmo_rotate_last_dir_ != kDirectionNone &&
|
||||
if (gizmo_rotate_last_dir_ != k_direction_none &&
|
||||
this_dir != gizmo_rotate_last_dir_) {
|
||||
if (alt_dir == gizmo_rotate_last_alt_dir_) {
|
||||
if ((raw_angle - gizmo_last_angle_) < 0) {
|
||||
@@ -292,10 +292,10 @@ void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
double rotation_difference =
|
||||
(current_angle - gizmo_start_angle_) * 57.2958;
|
||||
|
||||
NodeInputDragger &d = gizmo->GetDraggers()[0];
|
||||
d.Drag(d.GetStartValue().toDouble() + rotation_difference);
|
||||
NodeInputDragger &d = gizmo->get_draggers()[0];
|
||||
d.drag(d.get_start_value().toDouble() + rotation_difference);
|
||||
|
||||
} else if (IsAScaleGizmo(gizmo)) {
|
||||
} else if (is_a_scale_gizmo(gizmo)) {
|
||||
QPointF mouse_relative =
|
||||
gizmo_inverted_transform_.map(QPointF(x, y) - gizmo_anchor_pt_);
|
||||
|
||||
@@ -304,38 +304,38 @@ void TransformDistortNode::GizmoDragMove(double x, double y,
|
||||
double y_scaled_movement =
|
||||
qAbs(mouse_relative.y() / gizmo_scale_anchor_.y());
|
||||
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
switch (gizmo_scale_axes_) {
|
||||
case kGizmoScaleXOnly:
|
||||
x_drag.Drag(x_scaled_movement);
|
||||
case k_gizmo_scale_x_only:
|
||||
x_drag.drag(x_scaled_movement);
|
||||
break;
|
||||
case kGizmoScaleYOnly:
|
||||
case k_gizmo_scale_y_only:
|
||||
if (gizmo_scale_uniform_) {
|
||||
x_drag.Drag(y_scaled_movement);
|
||||
x_drag.drag(y_scaled_movement);
|
||||
} else {
|
||||
y_drag.Drag(y_scaled_movement);
|
||||
y_drag.drag(y_scaled_movement);
|
||||
}
|
||||
break;
|
||||
case kGizmoScaleBoth:
|
||||
case k_gizmo_scale_both:
|
||||
if (gizmo_scale_uniform_) {
|
||||
double distance =
|
||||
std::hypot(mouse_relative.x(), mouse_relative.y());
|
||||
double texture_diag = std::hypot(gizmo_scale_anchor_.x(),
|
||||
gizmo_scale_anchor_.y());
|
||||
|
||||
x_drag.Drag(qAbs(distance / texture_diag));
|
||||
x_drag.drag(qAbs(distance / texture_diag));
|
||||
} else {
|
||||
x_drag.Drag(x_scaled_movement);
|
||||
y_drag.Drag(y_scaled_movement);
|
||||
x_drag.drag(x_scaled_movement);
|
||||
y_drag.drag(y_scaled_movement);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
QMatrix4x4 TransformDistortNode::adjust_matrix_by_resolutions(
|
||||
const QMatrix4x4 &mat, const QVector2D &sequence_res,
|
||||
const QVector2D &texture_res, const QVector2D &offset,
|
||||
AutoScaleType autoscale_type)
|
||||
@@ -356,8 +356,8 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
adjusted_matrix.scale(texture_res.x() * 0.5, texture_res.y() * 0.5, 1.0);
|
||||
|
||||
// If auto-scale is enabled, fit the texture to the sequence (without cropping)
|
||||
if (autoscale_type != kAutoScaleNone) {
|
||||
if (autoscale_type == kAutoScaleStretch) {
|
||||
if (autoscale_type != k_auto_scale_none) {
|
||||
if (autoscale_type == k_auto_scale_stretch) {
|
||||
adjusted_matrix.scale(sequence_res.x() / texture_res.x(),
|
||||
sequence_res.y() / texture_res.y(), 1.0);
|
||||
} else {
|
||||
@@ -368,7 +368,7 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
double scale_by_y = sequence_res.y() / texture_res.y();
|
||||
double autoscale_val;
|
||||
|
||||
if ((autoscale_type == kAutoScaleFit) ==
|
||||
if ((autoscale_type == k_auto_scale_fit) ==
|
||||
(sequence_real_ar > footage_real_ar)) {
|
||||
// Scale by height. Either the sequence is wider than the footage or we're using fill and
|
||||
// cutting off the sides
|
||||
@@ -386,10 +386,10 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(
|
||||
return adjusted_matrix;
|
||||
}
|
||||
|
||||
void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void TransformDistortNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
TexturePtr tex = row[kTextureInput].toTexture();
|
||||
TexturePtr tex = row[k_texture_input].to_texture();
|
||||
if (!tex) {
|
||||
return;
|
||||
}
|
||||
@@ -406,13 +406,13 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
|
||||
// Retrieve autoscale value
|
||||
AutoScaleType autoscale =
|
||||
static_cast<AutoScaleType>(row[kAutoscaleInput].toInt());
|
||||
static_cast<AutoScaleType>(row[k_autoscale_input].to_int());
|
||||
|
||||
// Fold values into a matrix for the rectangle
|
||||
QMatrix4x4 rectangle_matrix;
|
||||
rectangle_matrix.scale(sequence_half_res.x(), sequence_half_res.y());
|
||||
rectangle_matrix *= AdjustMatrixByResolutions(
|
||||
GenerateMatrix(row, false, false, false, row[kParentInput].toMatrix()),
|
||||
rectangle_matrix *= adjust_matrix_by_resolutions(
|
||||
generate_matrix(row, false, false, false, row[k_parent_input].to_matrix()),
|
||||
sequence_res, tex_sz, tex_offset, autoscale);
|
||||
|
||||
// Create rect and transform it
|
||||
@@ -422,63 +422,63 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
QTransform rectangle_transform = rectangle_matrix.toTransform();
|
||||
QPolygonF r = rectangle_transform.map(points);
|
||||
r.translate(sequence_half_res_pt);
|
||||
poly_gizmo_->SetPolygon(r);
|
||||
poly_gizmo_->set_polygon(r);
|
||||
|
||||
// Draw anchor point
|
||||
QMatrix4x4 anchor_matrix;
|
||||
anchor_matrix.scale(sequence_half_res.x(), sequence_half_res.y());
|
||||
anchor_matrix *= AdjustMatrixByResolutions(
|
||||
GenerateMatrix(row, true, false, false, row[kParentInput].toMatrix()),
|
||||
anchor_matrix *= adjust_matrix_by_resolutions(
|
||||
generate_matrix(row, true, false, false, row[k_parent_input].to_matrix()),
|
||||
sequence_res, tex_sz, tex_offset, autoscale);
|
||||
anchor_gizmo_->SetPoint(anchor_matrix.toTransform().map(QPointF(0, 0)) +
|
||||
anchor_gizmo_->set_point(anchor_matrix.toTransform().map(QPointF(0, 0)) +
|
||||
sequence_half_res_pt);
|
||||
|
||||
// Draw scale handles
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(
|
||||
CreateScalePoint(-1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(
|
||||
CreateScalePoint(0, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(
|
||||
CreateScalePoint(1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(
|
||||
CreateScalePoint(-1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(
|
||||
CreateScalePoint(0, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(
|
||||
CreateScalePoint(1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(
|
||||
CreateScalePoint(-1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(
|
||||
CreateScalePoint(1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(
|
||||
create_scale_point(-1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(
|
||||
create_scale_point(0, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(
|
||||
create_scale_point(1, -1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(
|
||||
create_scale_point(-1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
create_scale_point(0, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
create_scale_point(1, 1, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
create_scale_point(-1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
create_scale_point(1, 0, sequence_half_res_pt, rectangle_matrix));
|
||||
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"),
|
||||
set_input_property(k_position_input, QStringLiteral("offset"),
|
||||
sequence_half_res + tex_offset);
|
||||
SetInputProperty(kAnchorInput, QStringLiteral("offset"), tex_sz * 0.5);
|
||||
set_input_property(k_anchor_input, QStringLiteral("offset"), tex_sz * 0.5);
|
||||
}
|
||||
|
||||
QTransform
|
||||
TransformDistortNode::GizmoTransformation(const NodeValueRow &row,
|
||||
TransformDistortNode::gizmo_transformation(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) const
|
||||
{
|
||||
if (TexturePtr texture = row[kTextureInput].toTexture()) {
|
||||
if (TexturePtr texture = row[k_texture_input].to_texture()) {
|
||||
//auto m = GenerateMatrix(row, false, false, false, row[kParentInput].toMatrix());
|
||||
auto m = GenerateMatrix(row, false, false, false, QMatrix4x4());
|
||||
return GenerateAutoScaledMatrix(m, row, globals, texture->params())
|
||||
auto m = generate_matrix(row, false, false, false, QMatrix4x4());
|
||||
return generate_auto_scaled_matrix(m, row, globals, texture->params())
|
||||
.toTransform();
|
||||
}
|
||||
return super::GizmoTransformation(row, globals);
|
||||
return super::gizmo_transformation(row, globals);
|
||||
}
|
||||
|
||||
QPointF TransformDistortNode::CreateScalePoint(double x, double y,
|
||||
QPointF TransformDistortNode::create_scale_point(double x, double y,
|
||||
const QPointF &half_res,
|
||||
const QMatrix4x4 &mat)
|
||||
{
|
||||
return mat.map(QPointF(x, y)) + half_res;
|
||||
}
|
||||
|
||||
QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix(
|
||||
QMatrix4x4 TransformDistortNode::generate_auto_scaled_matrix(
|
||||
const QMatrix4x4 &generated_matrix, const NodeValueRow &value,
|
||||
const NodeGlobals &globals, const VideoParams &texture_params) const
|
||||
{
|
||||
@@ -486,16 +486,16 @@ QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix(
|
||||
QVector2D texture_res(texture_params.square_pixel_width(),
|
||||
texture_params.height());
|
||||
AutoScaleType autoscale =
|
||||
static_cast<AutoScaleType>(value[kAutoscaleInput].toInt());
|
||||
static_cast<AutoScaleType>(value[k_autoscale_input].to_int());
|
||||
|
||||
return AdjustMatrixByResolutions(generated_matrix, sequence_res,
|
||||
return adjust_matrix_by_resolutions(generated_matrix, sequence_res,
|
||||
texture_res, texture_params.offset(),
|
||||
autoscale);
|
||||
}
|
||||
|
||||
bool TransformDistortNode::IsAScaleGizmo(NodeGizmo *g) const
|
||||
bool TransformDistortNode::is_a_scale_gizmo(NodeGizmo *g) const
|
||||
{
|
||||
for (int i = 0; i < kGizmoScaleCount; i++) {
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
if (point_gizmo_[i] == g) {
|
||||
return true;
|
||||
}
|
||||
@@ -505,9 +505,9 @@ bool TransformDistortNode::IsAScaleGizmo(NodeGizmo *g) const
|
||||
}
|
||||
|
||||
TransformDistortNode::RotationDirection
|
||||
TransformDistortNode::GetDirectionFromAngles(double last, double current)
|
||||
TransformDistortNode::get_direction_from_angles(double last, double current)
|
||||
{
|
||||
return (current > last) ? kDirectionPositive : kDirectionNegative;
|
||||
return (current > last) ? k_direction_positive : k_direction_negative;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRANSFORMDISTORTNODE_H
|
||||
#define TRANSFORMDISTORTNODE_H
|
||||
#ifndef OAK_TRANSFORMDISTORTNODE_H
|
||||
#define OAK_TRANSFORMDISTORTNODE_H
|
||||
|
||||
#include "node/generator/matrix/matrix.h"
|
||||
#include "node/gizmo/point.h"
|
||||
@@ -37,15 +37,15 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TransformDistortNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Transform");
|
||||
}
|
||||
|
||||
virtual QString ShortName() const override
|
||||
virtual QString short_name() const override
|
||||
{
|
||||
// Override MatrixGenerator's short name "Ortho"
|
||||
return Name();
|
||||
return name();
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
@@ -53,65 +53,65 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.transform");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr(
|
||||
"Transform an image in 2D space. Equivalent to multiplying by an orthographic matrix.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
enum AutoScaleType {
|
||||
kAutoScaleNone,
|
||||
kAutoScaleFit,
|
||||
kAutoScaleFill,
|
||||
kAutoScaleStretch
|
||||
k_auto_scale_none,
|
||||
k_auto_scale_fit,
|
||||
k_auto_scale_fill,
|
||||
k_auto_scale_stretch
|
||||
};
|
||||
|
||||
static QMatrix4x4 AdjustMatrixByResolutions(
|
||||
static QMatrix4x4 adjust_matrix_by_resolutions(
|
||||
const QMatrix4x4 &mat, const QVector2D &sequence_res,
|
||||
const QVector2D &texture_res, const QVector2D &offset,
|
||||
AutoScaleType autoscale_type = kAutoScaleNone);
|
||||
AutoScaleType autoscale_type = k_auto_scale_none);
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
virtual QTransform
|
||||
GizmoTransformation(const NodeValueRow &row,
|
||||
gizmo_transformation(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) const override;
|
||||
|
||||
static const QString kParentInput;
|
||||
static const QString kTextureInput;
|
||||
static const QString kAutoscaleInput;
|
||||
static const QString kInterpolationInput;
|
||||
static const QString k_parent_input;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_autoscale_input;
|
||||
static const QString k_interpolation_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragStart(const olive::NodeValueRow &row, double x,
|
||||
double y, const olive::rational &time) override;
|
||||
virtual void gizmo_drag_start(const olive::NodeValueRow &row, double x,
|
||||
double y, const olive::Rational &time) override;
|
||||
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
static QPointF CreateScalePoint(double x, double y, const QPointF &half_res,
|
||||
static QPointF create_scale_point(double x, double y, const QPointF &half_res,
|
||||
const QMatrix4x4 &mat);
|
||||
|
||||
QMatrix4x4
|
||||
GenerateAutoScaledMatrix(const QMatrix4x4 &generated_matrix,
|
||||
generate_auto_scaled_matrix(const QMatrix4x4 &generated_matrix,
|
||||
const NodeValueRow &db, const NodeGlobals &globals,
|
||||
const VideoParams &texture_params) const;
|
||||
|
||||
bool IsAScaleGizmo(NodeGizmo *g) const;
|
||||
bool is_a_scale_gizmo(NodeGizmo *g) const;
|
||||
|
||||
// Gizmo variables
|
||||
double gizmo_start_angle_;
|
||||
@@ -123,23 +123,23 @@ private:
|
||||
int gizmo_rotate_wrap_;
|
||||
|
||||
enum RotationDirection {
|
||||
kDirectionNone,
|
||||
kDirectionPositive, // Clockwise
|
||||
kDirectionNegative // Counter-clockwise
|
||||
k_direction_none,
|
||||
k_direction_positive, // Clockwise
|
||||
k_direction_negative // Counter-clockwise
|
||||
};
|
||||
|
||||
static RotationDirection GetDirectionFromAngles(double last,
|
||||
static RotationDirection get_direction_from_angles(double last,
|
||||
double current);
|
||||
RotationDirection gizmo_rotate_last_dir_;
|
||||
RotationDirection gizmo_rotate_last_alt_dir_;
|
||||
|
||||
enum GizmoScaleType { kGizmoScaleXOnly, kGizmoScaleYOnly, kGizmoScaleBoth };
|
||||
enum GizmoScaleType { k_gizmo_scale_x_only, k_gizmo_scale_y_only, k_gizmo_scale_both };
|
||||
|
||||
GizmoScaleType gizmo_scale_axes_;
|
||||
QVector2D gizmo_scale_anchor_;
|
||||
|
||||
// Gizmo on screen object storage
|
||||
PointGizmo *point_gizmo_[kGizmoScaleCount];
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PointGizmo *anchor_gizmo_;
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
ScreenGizmo *rotation_gizmo_;
|
||||
@@ -147,4 +147,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TRANSFORMDISTORTNODE_H
|
||||
#endif // OAK_TRANSFORMDISTORTNODE_H
|
||||
|
||||
@@ -24,30 +24,30 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString WaveDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString WaveDistortNode::kFrequencyInput = QStringLiteral("frequency_in");
|
||||
const QString WaveDistortNode::kIntensityInput = QStringLiteral("intensity_in");
|
||||
const QString WaveDistortNode::kEvolutionInput = QStringLiteral("evolution_in");
|
||||
const QString WaveDistortNode::kVerticalInput = QStringLiteral("vertical_in");
|
||||
const QString WaveDistortNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString WaveDistortNode::k_frequency_input = QStringLiteral("frequency_in");
|
||||
const QString WaveDistortNode::k_intensity_input = QStringLiteral("intensity_in");
|
||||
const QString WaveDistortNode::k_evolution_input = QStringLiteral("evolution_in");
|
||||
const QString WaveDistortNode::k_vertical_input = QStringLiteral("vertical_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
WaveDistortNode::WaveDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kFrequencyInput, NodeValue::kFloat, 10);
|
||||
AddInput(kIntensityInput, NodeValue::kFloat, 10);
|
||||
AddInput(kEvolutionInput, NodeValue::kFloat, 0);
|
||||
add_input(k_frequency_input, NodeValue::k_float, 10);
|
||||
add_input(k_intensity_input, NodeValue::k_float, 10);
|
||||
add_input(k_evolution_input, NodeValue::k_float, 0);
|
||||
|
||||
AddInput(kVerticalInput, NodeValue::kCombo, false);
|
||||
add_input(k_vertical_input, NodeValue::k_combo, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
QString WaveDistortNode::Name() const
|
||||
QString WaveDistortNode::name() const
|
||||
{
|
||||
return tr("Wave");
|
||||
}
|
||||
@@ -57,48 +57,48 @@ QString WaveDistortNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.wave");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> WaveDistortNode::Category() const
|
||||
QVector<Node::CategoryID> WaveDistortNode::category() const
|
||||
{
|
||||
return { kCategoryDistort };
|
||||
return { k_category_distort };
|
||||
}
|
||||
|
||||
QString WaveDistortNode::Description() const
|
||||
QString WaveDistortNode::description() const
|
||||
{
|
||||
return tr("Distorts an image along a sine wave.");
|
||||
}
|
||||
|
||||
void WaveDistortNode::Retranslate()
|
||||
void WaveDistortNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kFrequencyInput, tr("Frequency"));
|
||||
SetInputName(kIntensityInput, tr("Intensity"));
|
||||
SetInputName(kEvolutionInput, tr("Evolution"));
|
||||
SetInputName(kVerticalInput, tr("Direction"));
|
||||
SetComboBoxStrings(kVerticalInput, { tr("Horizontal"), tr("Vertical") });
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_frequency_input, tr("Frequency"));
|
||||
set_input_name(k_intensity_input, tr("Intensity"));
|
||||
set_input_name(k_evolution_input, tr("Evolution"));
|
||||
set_input_name(k_vertical_input, tr("Direction"));
|
||||
set_combo_box_strings(k_vertical_input, { tr("Horizontal"), tr("Vertical") });
|
||||
}
|
||||
|
||||
ShaderCode WaveDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode WaveDistortNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/wave.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/wave.frag"));
|
||||
}
|
||||
|
||||
void WaveDistortNode::Value(const NodeValueRow &value,
|
||||
void WaveDistortNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr texture = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr texture = value[k_texture_input].to_texture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(value[kIntensityInput].toDouble())) {
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(texture->params(), ShaderJob(value)),
|
||||
if (!qIsNull(value[k_intensity_input].to_double())) {
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(texture->params(), ShaderJob(value)),
|
||||
this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef WAVEDISTORTNODE_H
|
||||
#define WAVEDISTORTNODE_H
|
||||
#ifndef OAK_WAVEDISTORTNODE_H
|
||||
#define OAK_WAVEDISTORTNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,25 +34,25 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(WaveDistortNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kFrequencyInput;
|
||||
static const QString kIntensityInput;
|
||||
static const QString kEvolutionInput;
|
||||
static const QString kVerticalInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_frequency_input;
|
||||
static const QString k_intensity_input;
|
||||
static const QString k_evolution_input;
|
||||
static const QString k_vertical_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // WAVEDISTORTNODE_H
|
||||
#endif // OAK_WAVEDISTORTNODE_H
|
||||
|
||||
@@ -26,65 +26,65 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString OpacityEffect::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString OpacityEffect::kValueInput = QStringLiteral("opacity_in");
|
||||
const QString OpacityEffect::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString OpacityEffect::k_value_input = QStringLiteral("opacity_in");
|
||||
|
||||
OpacityEffect::OpacityEffect()
|
||||
{
|
||||
MathNode *math = new MathNode();
|
||||
math->setParent(this);
|
||||
|
||||
math->SetOperation(MathNode::kOpMultiply);
|
||||
math->set_operation(MathNode::k_op_multiply);
|
||||
|
||||
SetNodePositionInContext(math, QPointF(0, 0));
|
||||
set_node_position_in_context(math, QPointF(0, 0));
|
||||
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kValueInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kValueInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kValueInput, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(kValueInput, QStringLiteral("max"), 1.0);
|
||||
add_input(k_value_input, NodeValue::k_float, 1.0);
|
||||
set_input_property(k_value_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_value_input, QStringLiteral("min"), 0.0);
|
||||
set_input_property(k_value_input, QStringLiteral("max"), 1.0);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void OpacityEffect::Retranslate()
|
||||
void OpacityEffect::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kValueInput, tr("Opacity"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_value_input, tr("Opacity"));
|
||||
}
|
||||
|
||||
ShaderCode OpacityEffect::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode OpacityEffect::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("rgbmult")) {
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/opacity_rgb.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/opacity_rgb.frag"));
|
||||
} else {
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/opacity.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/opacity.frag"));
|
||||
}
|
||||
}
|
||||
|
||||
void OpacityEffect::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void OpacityEffect::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr opacity_tex = value[kValueInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
if (TexturePtr opacity_tex = value[k_value_input].to_texture()) {
|
||||
ShaderJob job(value);
|
||||
job.SetShaderID(QStringLiteral("rgbmult"));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
} else if (!qFuzzyCompare(value[kValueInput].toDouble(), 1.0)) {
|
||||
table->Push(NodeValue::kTexture, tex->toJob(ShaderJob(value)),
|
||||
job.set_shader_id(QStringLiteral("rgbmult"));
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else if (!qFuzzyCompare(value[k_value_input].to_double(), 1.0)) {
|
||||
table->push(NodeValue::k_texture, tex->to_job(ShaderJob(value)),
|
||||
this);
|
||||
} else {
|
||||
// 1.0 float is a no-op, so just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPACITYEFFECT_H
|
||||
#define OPACITYEFFECT_H
|
||||
#ifndef OAK_OPACITYEFFECT_H
|
||||
#define OAK_OPACITYEFFECT_H
|
||||
|
||||
#include "node/group/group.h"
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(OpacityEffect)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Opacity");
|
||||
}
|
||||
@@ -40,28 +40,28 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.opacity");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryFilter };
|
||||
return { k_category_filter };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr(
|
||||
"Alter a video's opacity.\n\nThis is equivalent to multiplying a video by a number between 0.0 and 1.0.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kValueInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_value_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OPACITYEFFECT_H
|
||||
#endif // OAK_OPACITYEFFECT_H
|
||||
|
||||
+95
-95
@@ -35,7 +35,7 @@
|
||||
#include "color/ociogradingtransformlinear/ociogradingtransformlinear.h"
|
||||
#include "color/ociolut/ociolut.h"
|
||||
#include "color/threewaycolor/threewaycolor.h"
|
||||
#include "common/Current.h"
|
||||
#include "common/current.h"
|
||||
#include "distort/cornerpin/cornerpindistortnode.h"
|
||||
#include "distort/crop/cropdistortnode.h"
|
||||
#include "distort/flip/flipdistortnode.h"
|
||||
@@ -69,8 +69,8 @@
|
||||
#include "math/trigonometry/trigonometry.h"
|
||||
#include "output/track/track.h"
|
||||
#include "output/viewer/viewer.h"
|
||||
#include "pluginSupport/OliveHost.h"
|
||||
#include "plugins/Plugin.h"
|
||||
#include "pluginSupport/olivehost.h"
|
||||
#include "plugins/plugin.h"
|
||||
#include "project/folder/folder.h"
|
||||
#include "project/footage/footage.h"
|
||||
#include "project/sequence/sequence.h"
|
||||
@@ -81,58 +81,58 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
QList<Node *> NodeFactory::library_;
|
||||
QList<Node *> NodeFactory::library;
|
||||
|
||||
void NodeFactory::Initialize()
|
||||
void NodeFactory::initialize()
|
||||
{
|
||||
Destroy();
|
||||
destroy();
|
||||
|
||||
// Add internal types
|
||||
for (int i = 0; i < kInternalNodeCount; i++) {
|
||||
Node *created_node = CreateFromFactoryIndex(static_cast<InternalID>(i));
|
||||
for (int i = 0; i < k_internal_node_count; i++) {
|
||||
Node *created_node = create_from_factory_index(static_cast<InternalID>(i));
|
||||
|
||||
library_.append(created_node);
|
||||
library.append(created_node);
|
||||
}
|
||||
|
||||
RegisterPluginNodes();
|
||||
register_plugin_nodes();
|
||||
}
|
||||
|
||||
void NodeFactory::Destroy()
|
||||
void NodeFactory::destroy()
|
||||
{
|
||||
qDeleteAll(library_);
|
||||
library_.clear();
|
||||
qDeleteAll(library);
|
||||
library.clear();
|
||||
}
|
||||
|
||||
Menu *NodeFactory::CreateMenu(QWidget *parent, bool create_none_item,
|
||||
Menu *NodeFactory::create_menu(QWidget *parent, bool create_none_item,
|
||||
Node::CategoryID restrict_to,
|
||||
uint64_t restrict_flags)
|
||||
{
|
||||
Menu *menu = new Menu(parent);
|
||||
menu->setToolTipsVisible(true);
|
||||
|
||||
for (int i = 0; i < library_.size(); i++) {
|
||||
Node *n = library_.at(i);
|
||||
for (int i = 0; i < library.size(); i++) {
|
||||
Node *n = library.at(i);
|
||||
|
||||
if (restrict_to != Node::kCategoryUnknown &&
|
||||
!n->Category().contains(restrict_to)) {
|
||||
if (restrict_to != Node::k_category_unknown &&
|
||||
!n->category().contains(restrict_to)) {
|
||||
// Skip this node
|
||||
continue;
|
||||
}
|
||||
|
||||
if (restrict_flags && !(n->GetFlags() & restrict_flags)) {
|
||||
if (restrict_flags && !(n->get_flags() & restrict_flags)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (n->GetFlags() & Node::kDontShowInCreateMenu) {
|
||||
if (n->get_flags() & Node::k_dont_show_in_create_menu) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make sure nodes are up-to-date with the current translation
|
||||
n->Retranslate();
|
||||
n->retranslate();
|
||||
|
||||
QString category_name = Node::GetCategoryName(
|
||||
n->Category().isEmpty() ? Node::kCategoryUnknown :
|
||||
n->Category().first());
|
||||
QString category_name = Node::get_category_name(
|
||||
n->category().isEmpty() ? Node::k_category_unknown :
|
||||
n->category().first());
|
||||
|
||||
// Find or create top-level category menu
|
||||
Menu *top_menu = nullptr;
|
||||
@@ -145,13 +145,13 @@ Menu *NodeFactory::CreateMenu(QWidget *parent, bool create_none_item,
|
||||
}
|
||||
if (!top_menu) {
|
||||
top_menu = new Menu(category_name, menu);
|
||||
menu->InsertAlphabetically(top_menu);
|
||||
menu->insert_alphabetically(top_menu);
|
||||
}
|
||||
|
||||
// Determine final destination (support secondary grouping)
|
||||
Menu *destination = top_menu;
|
||||
QString sub = n->SubCategory();
|
||||
if (!sub.isEmpty() && n->Category().contains(Node::kCategoryOpenFX)) {
|
||||
QString sub = n->sub_category();
|
||||
if (!sub.isEmpty() && n->category().contains(Node::k_category_open_fx)) {
|
||||
QList<QAction *> sub_actions = top_menu->actions();
|
||||
foreach (QAction *action, sub_actions) {
|
||||
if (action->menu() && action->menu()->title() == sub) {
|
||||
@@ -161,14 +161,14 @@ Menu *NodeFactory::CreateMenu(QWidget *parent, bool create_none_item,
|
||||
}
|
||||
if (destination == top_menu) {
|
||||
destination = new Menu(sub, top_menu);
|
||||
top_menu->InsertAlphabetically(destination);
|
||||
top_menu->insert_alphabetically(destination);
|
||||
}
|
||||
}
|
||||
|
||||
// Add entry to menu
|
||||
QAction *a = destination->InsertAlphabetically(n->Name());
|
||||
QAction *a = destination->insert_alphabetically(n->name());
|
||||
a->setData(i);
|
||||
a->setToolTip(n->Description());
|
||||
a->setToolTip(n->description());
|
||||
}
|
||||
|
||||
if (create_none_item) {
|
||||
@@ -196,7 +196,7 @@ Node *NodeFactory::CreateFromMenuAction(QAction *action)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return library_.at(index)->copy();
|
||||
return library.at(index)->copy();
|
||||
}
|
||||
|
||||
QString NodeFactory::GetIDFromMenuAction(QAction *action)
|
||||
@@ -207,15 +207,15 @@ QString NodeFactory::GetIDFromMenuAction(QAction *action)
|
||||
return QString();
|
||||
}
|
||||
|
||||
return library_.at(action->data().toInt())->id();
|
||||
return library.at(action->data().toInt())->id();
|
||||
}
|
||||
|
||||
QString NodeFactory::GetNameFromID(const QString &id)
|
||||
QString NodeFactory::get_name_from_id(const QString &id)
|
||||
{
|
||||
if (!id.isEmpty()) {
|
||||
foreach (Node *n, library_) {
|
||||
foreach (Node *n, library) {
|
||||
if (n->id() == id) {
|
||||
return n->Name();
|
||||
return n->name();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,12 +223,12 @@ QString NodeFactory::GetNameFromID(const QString &id)
|
||||
return QString();
|
||||
}
|
||||
|
||||
Node *NodeFactory::CreateFromID(const QString &id)
|
||||
Node *NodeFactory::create_from_id(const QString &id)
|
||||
{
|
||||
QString resolved_id = id;
|
||||
|
||||
// Node IDs renamed after older project files were written
|
||||
static const QHash<QString, QString> kLegacyIDs = {
|
||||
static const QHash<QString, QString> k_legacy_i_ds = {
|
||||
{ QStringLiteral("org.oliveeditor.Olive.flip"),
|
||||
QStringLiteral("org.olivevideoeditor.Olive.flip") },
|
||||
{ QStringLiteral("org.oliveeditor.Olive.ripple"),
|
||||
@@ -240,9 +240,9 @@ Node *NodeFactory::CreateFromID(const QString &id)
|
||||
{ QStringLiteral("org.oliveeditor.Olive.wave"),
|
||||
QStringLiteral("org.olivevideoeditor.Olive.wave") },
|
||||
};
|
||||
resolved_id = kLegacyIDs.value(id, id);
|
||||
resolved_id = k_legacy_i_ds.value(id, id);
|
||||
|
||||
foreach (Node *n, library_) {
|
||||
foreach (Node *n, library) {
|
||||
if (n->id() == resolved_id) {
|
||||
return n->copy();
|
||||
}
|
||||
@@ -251,10 +251,10 @@ Node *NodeFactory::CreateFromID(const QString &id)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NodeFactory::RegisterPluginNodes()
|
||||
void NodeFactory::register_plugin_nodes()
|
||||
{
|
||||
QSet<QString> existing_ids;
|
||||
for (Node *node : library_) {
|
||||
for (Node *node : library) {
|
||||
existing_ids.insert(node->id());
|
||||
}
|
||||
|
||||
@@ -287,118 +287,118 @@ void NodeFactory::RegisterPluginNodes()
|
||||
}
|
||||
|
||||
plugin::PluginNode *plugin_node = new plugin::PluginNode(instance);
|
||||
library_.append(plugin_node);
|
||||
library.append(plugin_node);
|
||||
existing_ids.insert(plugin_id);
|
||||
}
|
||||
}
|
||||
|
||||
Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
|
||||
Node *NodeFactory::create_from_factory_index(const NodeFactory::InternalID &id)
|
||||
{
|
||||
switch (id) {
|
||||
case kClipBlock:
|
||||
case k_clip_block:
|
||||
return new ClipBlock();
|
||||
case kGapBlock:
|
||||
case k_gap_block:
|
||||
return new GapBlock();
|
||||
case kPolygonGenerator:
|
||||
case k_polygon_generator:
|
||||
return new PolygonGenerator();
|
||||
case kMatrixGenerator:
|
||||
case k_matrix_generator:
|
||||
return new MatrixGenerator();
|
||||
case kTransformDistort:
|
||||
case k_transform_distort:
|
||||
return new TransformDistortNode();
|
||||
case kTrackOutput:
|
||||
case k_track_output:
|
||||
return new Track();
|
||||
case kViewerOutput:
|
||||
case k_viewer_output:
|
||||
return new ViewerOutput();
|
||||
case kAudioVolume:
|
||||
case k_audio_volume:
|
||||
return new VolumeNode();
|
||||
case kAudioPanning:
|
||||
case k_audio_panning:
|
||||
return new PanNode();
|
||||
case kMath:
|
||||
case k_math:
|
||||
return new MathNode();
|
||||
case kTrigonometry:
|
||||
case k_trigonometry:
|
||||
return new TrigonometryNode();
|
||||
case kTime:
|
||||
case k_time:
|
||||
return new TimeInput();
|
||||
case kBlurFilter:
|
||||
case k_blur_filter:
|
||||
return new BlurFilterNode();
|
||||
case kSolidGenerator:
|
||||
case k_solid_generator:
|
||||
return new SolidGenerator();
|
||||
case kMerge:
|
||||
case k_merge:
|
||||
return new MergeNode();
|
||||
case kStrokeFilter:
|
||||
case k_stroke_filter:
|
||||
return new StrokeFilterNode();
|
||||
case kTextGeneratorV1:
|
||||
case k_text_generator_v1:
|
||||
return new TextGeneratorV1();
|
||||
case kTextGeneratorV2:
|
||||
case k_text_generator_v2:
|
||||
return new TextGeneratorV2();
|
||||
case kTextGeneratorV3:
|
||||
case k_text_generator_v3:
|
||||
return new TextGeneratorV3();
|
||||
case kCrossDissolveTransition:
|
||||
case k_cross_dissolve_transition:
|
||||
return new CrossDissolveTransition();
|
||||
case kDipToColorTransition:
|
||||
case k_dip_to_color_transition:
|
||||
return new DipToColorTransition();
|
||||
case kMosaicFilter:
|
||||
case k_mosaic_filter:
|
||||
return new MosaicFilterNode();
|
||||
case kCropDistort:
|
||||
case k_crop_distort:
|
||||
return new CropDistortNode();
|
||||
case kProjectFootage:
|
||||
case k_project_footage:
|
||||
return new Footage();
|
||||
case kProjectFolder:
|
||||
case k_project_folder:
|
||||
return new Folder();
|
||||
case kProjectSequence:
|
||||
case k_project_sequence:
|
||||
return new Sequence();
|
||||
case kValueNode:
|
||||
case k_value_node:
|
||||
return new ValueNode();
|
||||
case kTimeRemapNode:
|
||||
case k_time_remap_node:
|
||||
return new TimeRemapNode();
|
||||
case kSubtitleBlock:
|
||||
case k_subtitle_block:
|
||||
return new SubtitleBlock();
|
||||
case kShapeGenerator:
|
||||
case k_shape_generator:
|
||||
return new ShapeNode();
|
||||
case kColorDifferenceKeyKeying:
|
||||
case k_color_difference_key_keying:
|
||||
return new ColorDifferenceKeyNode();
|
||||
case kDespillKeying:
|
||||
case k_despill_keying:
|
||||
return new DespillNode();
|
||||
case kGroupNode:
|
||||
case k_group_node:
|
||||
return new NodeGroup();
|
||||
case kOpacityEffect:
|
||||
case k_opacity_effect:
|
||||
return new OpacityEffect();
|
||||
case kFlipDistort:
|
||||
case k_flip_distort:
|
||||
return new FlipDistortNode();
|
||||
case kNoiseGenerator:
|
||||
case k_noise_generator:
|
||||
return new NoiseGeneratorNode();
|
||||
case kTimeOffsetNode:
|
||||
case k_time_offset_node:
|
||||
return new TimeOffsetNode();
|
||||
case kCornerPinDistort:
|
||||
case k_corner_pin_distort:
|
||||
return new CornerPinDistortNode();
|
||||
case kDisplayTransform:
|
||||
case k_display_transform:
|
||||
return new DisplayTransformNode();
|
||||
case kOCIOGradingTransformLinear:
|
||||
case k_ocio_grading_transform_linear:
|
||||
return new OCIOGradingTransformLinearNode();
|
||||
case kOCIOLut:
|
||||
case k_ocio_lut:
|
||||
return new OCIOLutNode();
|
||||
case kThreeWayColor:
|
||||
case k_three_way_color:
|
||||
return new ThreeWayColorNode();
|
||||
case kChromaKey:
|
||||
case k_chroma_key:
|
||||
return new ChromaKeyNode();
|
||||
case kMaskDistort:
|
||||
case k_mask_distort:
|
||||
return new MaskDistortNode();
|
||||
case kDropShadowFilter:
|
||||
case k_drop_shadow_filter:
|
||||
return new DropShadowFilter();
|
||||
case kTimeFormat:
|
||||
case k_time_format:
|
||||
return new TimeFormatNode();
|
||||
case kWaveDistort:
|
||||
case k_wave_distort:
|
||||
return new WaveDistortNode();
|
||||
case kTileDistort:
|
||||
case k_tile_distort:
|
||||
return new TileDistortNode();
|
||||
case kSwirlDistort:
|
||||
case k_swirl_distort:
|
||||
return new SwirlDistortNode();
|
||||
case kRippleDistort:
|
||||
case k_ripple_distort:
|
||||
return new RippleDistortNode();
|
||||
case kMulticamNode:
|
||||
case k_multicam_node:
|
||||
return new MultiCamNode();
|
||||
|
||||
case kInternalNodeCount:
|
||||
case k_internal_node_count:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+64
-64
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEFACTORY_H
|
||||
#define NODEFACTORY_H
|
||||
#ifndef OAK_NODEFACTORY_H
|
||||
#define OAK_NODEFACTORY_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
@@ -33,88 +33,88 @@ namespace olive
|
||||
class NodeFactory {
|
||||
public:
|
||||
enum InternalID {
|
||||
kViewerOutput,
|
||||
kClipBlock,
|
||||
kGapBlock,
|
||||
kPolygonGenerator,
|
||||
kMatrixGenerator,
|
||||
kTransformDistort,
|
||||
kTrackOutput,
|
||||
kAudioVolume,
|
||||
kAudioPanning,
|
||||
kMath,
|
||||
kTime,
|
||||
kTrigonometry,
|
||||
kBlurFilter,
|
||||
kSolidGenerator,
|
||||
kMerge,
|
||||
kStrokeFilter,
|
||||
kTextGeneratorV1,
|
||||
kTextGeneratorV2,
|
||||
kTextGeneratorV3,
|
||||
kCrossDissolveTransition,
|
||||
kDipToColorTransition,
|
||||
kMosaicFilter,
|
||||
kCropDistort,
|
||||
kProjectFootage,
|
||||
kProjectFolder,
|
||||
kProjectSequence,
|
||||
kValueNode,
|
||||
kTimeRemapNode,
|
||||
kSubtitleBlock,
|
||||
kShapeGenerator,
|
||||
kColorDifferenceKeyKeying,
|
||||
kDespillKeying,
|
||||
kGroupNode,
|
||||
kOpacityEffect,
|
||||
kFlipDistort,
|
||||
kNoiseGenerator,
|
||||
kTimeOffsetNode,
|
||||
kCornerPinDistort,
|
||||
kDisplayTransform,
|
||||
kOCIOGradingTransformLinear,
|
||||
kOCIOLut,
|
||||
kThreeWayColor,
|
||||
kChromaKey,
|
||||
kMaskDistort,
|
||||
kDropShadowFilter,
|
||||
kTimeFormat,
|
||||
kWaveDistort,
|
||||
kRippleDistort,
|
||||
kTileDistort,
|
||||
kSwirlDistort,
|
||||
kMulticamNode,
|
||||
k_viewer_output,
|
||||
k_clip_block,
|
||||
k_gap_block,
|
||||
k_polygon_generator,
|
||||
k_matrix_generator,
|
||||
k_transform_distort,
|
||||
k_track_output,
|
||||
k_audio_volume,
|
||||
k_audio_panning,
|
||||
k_math,
|
||||
k_time,
|
||||
k_trigonometry,
|
||||
k_blur_filter,
|
||||
k_solid_generator,
|
||||
k_merge,
|
||||
k_stroke_filter,
|
||||
k_text_generator_v1,
|
||||
k_text_generator_v2,
|
||||
k_text_generator_v3,
|
||||
k_cross_dissolve_transition,
|
||||
k_dip_to_color_transition,
|
||||
k_mosaic_filter,
|
||||
k_crop_distort,
|
||||
k_project_footage,
|
||||
k_project_folder,
|
||||
k_project_sequence,
|
||||
k_value_node,
|
||||
k_time_remap_node,
|
||||
k_subtitle_block,
|
||||
k_shape_generator,
|
||||
k_color_difference_key_keying,
|
||||
k_despill_keying,
|
||||
k_group_node,
|
||||
k_opacity_effect,
|
||||
k_flip_distort,
|
||||
k_noise_generator,
|
||||
k_time_offset_node,
|
||||
k_corner_pin_distort,
|
||||
k_display_transform,
|
||||
k_ocio_grading_transform_linear,
|
||||
k_ocio_lut,
|
||||
k_three_way_color,
|
||||
k_chroma_key,
|
||||
k_mask_distort,
|
||||
k_drop_shadow_filter,
|
||||
k_time_format,
|
||||
k_wave_distort,
|
||||
k_ripple_distort,
|
||||
k_tile_distort,
|
||||
k_swirl_distort,
|
||||
k_multicam_node,
|
||||
|
||||
// Count value
|
||||
kInternalNodeCount
|
||||
k_internal_node_count
|
||||
};
|
||||
|
||||
NodeFactory() = default;
|
||||
|
||||
static void Initialize();
|
||||
static void initialize();
|
||||
|
||||
static void Destroy();
|
||||
static void destroy();
|
||||
|
||||
static Menu *
|
||||
CreateMenu(QWidget *parent, bool create_none_item = false,
|
||||
Node::CategoryID restrict_to = Node::kCategoryUnknown,
|
||||
create_menu(QWidget *parent, bool create_none_item = false,
|
||||
Node::CategoryID restrict_to = Node::k_category_unknown,
|
||||
uint64_t restrict_flags = 0);
|
||||
|
||||
static Node *CreateFromMenuAction(QAction *action);
|
||||
|
||||
static QString GetIDFromMenuAction(QAction *action);
|
||||
|
||||
static QString GetNameFromID(const QString &id);
|
||||
static QString get_name_from_id(const QString &id);
|
||||
|
||||
static Node *CreateFromID(const QString &id);
|
||||
static void RegisterPluginNodes();
|
||||
static Node *create_from_id(const QString &id);
|
||||
static void register_plugin_nodes();
|
||||
|
||||
static Node *CreateFromFactoryIndex(const InternalID &id);
|
||||
static Node *create_from_factory_index(const InternalID &id);
|
||||
|
||||
private:
|
||||
static QList<Node *> library_;
|
||||
static QList<Node *> library;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEFACTORY_H
|
||||
#endif // OAK_NODEFACTORY_H
|
||||
|
||||
@@ -24,67 +24,67 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString BlurFilterNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString BlurFilterNode::kMethodInput = QStringLiteral("method_in");
|
||||
const QString BlurFilterNode::kRadiusInput = QStringLiteral("radius_in");
|
||||
const QString BlurFilterNode::kHorizInput = QStringLiteral("horiz_in");
|
||||
const QString BlurFilterNode::kVertInput = QStringLiteral("vert_in");
|
||||
const QString BlurFilterNode::kRepeatEdgePixelsInput =
|
||||
const QString BlurFilterNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString BlurFilterNode::k_method_input = QStringLiteral("method_in");
|
||||
const QString BlurFilterNode::k_radius_input = QStringLiteral("radius_in");
|
||||
const QString BlurFilterNode::k_horiz_input = QStringLiteral("horiz_in");
|
||||
const QString BlurFilterNode::k_vert_input = QStringLiteral("vert_in");
|
||||
const QString BlurFilterNode::k_repeat_edge_pixels_input =
|
||||
QStringLiteral("repeat_edge_pixels_in");
|
||||
|
||||
const QString BlurFilterNode::kDirectionalDegreesInput =
|
||||
const QString BlurFilterNode::k_directional_degrees_input =
|
||||
QStringLiteral("directional_degrees_in");
|
||||
|
||||
const QString BlurFilterNode::kRadialCenterInput =
|
||||
const QString BlurFilterNode::k_radial_center_input =
|
||||
QStringLiteral("radial_center_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
BlurFilterNode::BlurFilterNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
Method default_method = kGaussian;
|
||||
Method default_method = k_gaussian;
|
||||
|
||||
AddInput(kMethodInput, NodeValue::kCombo, default_method,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_method_input, NodeValue::k_combo, default_method,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
AddInput(kRadiusInput, NodeValue::kFloat, 10.0);
|
||||
SetInputProperty(kRadiusInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_radius_input, NodeValue::k_float, 10.0);
|
||||
set_input_property(k_radius_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
{
|
||||
// Box and gaussian only
|
||||
AddInput(kHorizInput, NodeValue::kBoolean, true);
|
||||
AddInput(kVertInput, NodeValue::kBoolean, true);
|
||||
add_input(k_horiz_input, NodeValue::k_boolean, true);
|
||||
add_input(k_vert_input, NodeValue::k_boolean, true);
|
||||
}
|
||||
|
||||
{
|
||||
// Directional only
|
||||
AddInput(kDirectionalDegreesInput, NodeValue::kFloat, 0.0);
|
||||
add_input(k_directional_degrees_input, NodeValue::k_float, 0.0);
|
||||
}
|
||||
|
||||
{
|
||||
// Radial only
|
||||
AddInput(kRadialCenterInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
add_input(k_radial_center_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
}
|
||||
|
||||
UpdateInputs(default_method);
|
||||
update_inputs(default_method);
|
||||
|
||||
AddInput(kRepeatEdgePixelsInput, NodeValue::kBoolean, true);
|
||||
add_input(k_repeat_edge_pixels_input, NodeValue::k_boolean, true);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
radial_center_gizmo_ = AddDraggableGizmo<PointGizmo>();
|
||||
radial_center_gizmo_->SetShape(PointGizmo::kAnchorPoint);
|
||||
radial_center_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kRadialCenterInput), 0));
|
||||
radial_center_gizmo_->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kRadialCenterInput), 1));
|
||||
radial_center_gizmo_ = add_draggable_gizmo<PointGizmo>();
|
||||
radial_center_gizmo_->set_shape(PointGizmo::k_anchor_point);
|
||||
radial_center_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_radial_center_input), 0));
|
||||
radial_center_gizmo_->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_radial_center_input), 1));
|
||||
}
|
||||
|
||||
QString BlurFilterNode::Name() const
|
||||
QString BlurFilterNode::name() const
|
||||
{
|
||||
return tr("Blur");
|
||||
}
|
||||
@@ -94,58 +94,58 @@ QString BlurFilterNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.blur");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> BlurFilterNode::Category() const
|
||||
QVector<Node::CategoryID> BlurFilterNode::category() const
|
||||
{
|
||||
return { kCategoryFilter };
|
||||
return { k_category_filter };
|
||||
}
|
||||
|
||||
QString BlurFilterNode::Description() const
|
||||
QString BlurFilterNode::description() const
|
||||
{
|
||||
return tr("Blurs an image.");
|
||||
}
|
||||
|
||||
void BlurFilterNode::Retranslate()
|
||||
void BlurFilterNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kMethodInput, tr("Method"));
|
||||
SetComboBoxStrings(kMethodInput, { tr("Box"), tr("Gaussian"),
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_method_input, tr("Method"));
|
||||
set_combo_box_strings(k_method_input, { tr("Box"), tr("Gaussian"),
|
||||
tr("Directional"), tr("Radial") });
|
||||
SetInputName(kRadiusInput, tr("Radius"));
|
||||
SetInputName(kHorizInput, tr("Horizontal"));
|
||||
SetInputName(kVertInput, tr("Vertical"));
|
||||
SetInputName(kRepeatEdgePixelsInput, tr("Repeat Edge Pixels"));
|
||||
set_input_name(k_radius_input, tr("Radius"));
|
||||
set_input_name(k_horiz_input, tr("Horizontal"));
|
||||
set_input_name(k_vert_input, tr("Vertical"));
|
||||
set_input_name(k_repeat_edge_pixels_input, tr("Repeat Edge Pixels"));
|
||||
|
||||
SetInputName(kDirectionalDegreesInput, tr("Direction"));
|
||||
SetInputName(kRadialCenterInput, tr("Center"));
|
||||
set_input_name(k_directional_degrees_input, tr("Direction"));
|
||||
set_input_name(k_radial_center_input, tr("Center"));
|
||||
}
|
||||
|
||||
ShaderCode BlurFilterNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode BlurFilterNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/blur.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/blur.frag"));
|
||||
}
|
||||
|
||||
void BlurFilterNode::Value(const NodeValueRow &value,
|
||||
void BlurFilterNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// If there's no texture, no need to run an operation
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
Method method = static_cast<Method>(value[kMethodInput].toInt());
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
Method method = static_cast<Method>(value[k_method_input].to_int());
|
||||
|
||||
bool can_push_job = true;
|
||||
int iterations = 1;
|
||||
|
||||
// Check if radius is > 0
|
||||
if (value[kRadiusInput].toDouble() > 0.0) {
|
||||
if (value[k_radius_input].to_double() > 0.0) {
|
||||
// Method-specific considerations
|
||||
switch (method) {
|
||||
case kBox:
|
||||
case kGaussian: {
|
||||
bool horiz = value[kHorizInput].toBool();
|
||||
bool vert = value[kVertInput].toBool();
|
||||
case k_box:
|
||||
case k_gaussian: {
|
||||
bool horiz = value[k_horiz_input].to_bool();
|
||||
bool vert = value[k_vert_input].to_bool();
|
||||
|
||||
if (!horiz && !vert) {
|
||||
// Disable job if horiz and vert are unchecked
|
||||
@@ -156,8 +156,8 @@ void BlurFilterNode::Value(const NodeValueRow &value,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kDirectional:
|
||||
case kRadial:
|
||||
case k_directional:
|
||||
case k_radial:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -166,71 +166,71 @@ void BlurFilterNode::Value(const NodeValueRow &value,
|
||||
|
||||
if (can_push_job) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
job.SetIterations(iterations, kTextureInput);
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
job.set_iterations(iterations, k_texture_input);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
// If we're not performing the blur job, just push the texture
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlurFilterNode::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void BlurFilterNode::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
if (row[kMethodInput].toInt() == kRadial) {
|
||||
if (TexturePtr tex = row[k_texture_input].to_texture()) {
|
||||
if (row[k_method_input].to_int() == k_radial) {
|
||||
const QVector2D &sequence_res = tex->virtual_resolution();
|
||||
QVector2D sequence_half_res = sequence_res * 0.5;
|
||||
|
||||
radial_center_gizmo_->SetVisible(true);
|
||||
radial_center_gizmo_->SetPoint(
|
||||
radial_center_gizmo_->set_visible(true);
|
||||
radial_center_gizmo_->set_point(
|
||||
sequence_half_res.toPointF() +
|
||||
row[kRadialCenterInput].toVec2().toPointF());
|
||||
row[k_radial_center_input].to_vec2().toPointF());
|
||||
|
||||
SetInputProperty(kRadialCenterInput, QStringLiteral("offset"),
|
||||
set_input_property(k_radial_center_input, QStringLiteral("offset"),
|
||||
sequence_half_res);
|
||||
} else {
|
||||
radial_center_gizmo_->SetVisible(false);
|
||||
radial_center_gizmo_->set_visible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlurFilterNode::GizmoDragMove(double x, double y,
|
||||
void BlurFilterNode::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
if (gizmo == radial_center_gizmo_) {
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
}
|
||||
|
||||
void BlurFilterNode::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
if (input == kMethodInput) {
|
||||
UpdateInputs(GetMethod());
|
||||
if (input == k_method_input) {
|
||||
update_inputs(get_method());
|
||||
}
|
||||
|
||||
super::InputValueChangedEvent(input, element);
|
||||
}
|
||||
|
||||
void BlurFilterNode::UpdateInputs(Method method)
|
||||
void BlurFilterNode::update_inputs(Method method)
|
||||
{
|
||||
SetInputFlag(kHorizInput, kInputFlagHidden,
|
||||
!(method == kBox || method == kGaussian));
|
||||
SetInputFlag(kVertInput, kInputFlagHidden,
|
||||
!(method == kBox || method == kGaussian));
|
||||
SetInputFlag(kDirectionalDegreesInput, kInputFlagHidden,
|
||||
!(method == kDirectional));
|
||||
SetInputFlag(kRadialCenterInput, kInputFlagHidden, !(method == kRadial));
|
||||
set_input_flag(k_horiz_input, k_input_flag_hidden,
|
||||
!(method == k_box || method == k_gaussian));
|
||||
set_input_flag(k_vert_input, k_input_flag_hidden,
|
||||
!(method == k_box || method == k_gaussian));
|
||||
set_input_flag(k_directional_degrees_input, k_input_flag_hidden,
|
||||
!(method == k_directional));
|
||||
set_input_flag(k_radial_center_input, k_input_flag_hidden, !(method == k_radial));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+23
-23
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef BLURFILTERNODE_H
|
||||
#define BLURFILTERNODE_H
|
||||
#ifndef OAK_BLURFILTERNODE_H
|
||||
#define OAK_BLURFILTERNODE_H
|
||||
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/node.h"
|
||||
@@ -33,43 +33,43 @@ class BlurFilterNode : public Node {
|
||||
public:
|
||||
BlurFilterNode();
|
||||
|
||||
enum Method { kBox, kGaussian, kDirectional, kRadial };
|
||||
enum Method { k_box, k_gaussian, k_directional, k_radial };
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(BlurFilterNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
Method GetMethod() const
|
||||
Method get_method() const
|
||||
{
|
||||
return static_cast<Method>(GetStandardValue(kMethodInput).toInt());
|
||||
return static_cast<Method>(get_standard_value(k_method_input).toInt());
|
||||
}
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kMethodInput;
|
||||
static const QString kRadiusInput;
|
||||
static const QString kHorizInput;
|
||||
static const QString kVertInput;
|
||||
static const QString kRepeatEdgePixelsInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_method_input;
|
||||
static const QString k_radius_input;
|
||||
static const QString k_horiz_input;
|
||||
static const QString k_vert_input;
|
||||
static const QString k_repeat_edge_pixels_input;
|
||||
|
||||
static const QString kDirectionalDegreesInput;
|
||||
static const QString k_directional_degrees_input;
|
||||
|
||||
static const QString kRadialCenterInput;
|
||||
static const QString k_radial_center_input;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
protected:
|
||||
@@ -77,11 +77,11 @@ protected:
|
||||
int element) override;
|
||||
|
||||
private:
|
||||
void UpdateInputs(Method method);
|
||||
void update_inputs(Method method);
|
||||
|
||||
PointGizmo *radial_center_gizmo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // BLURFILTERNODE_H
|
||||
#endif // OAK_BLURFILTERNODE_H
|
||||
|
||||
@@ -28,79 +28,79 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString DropShadowFilter::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString DropShadowFilter::kColorInput = QStringLiteral("color_in");
|
||||
const QString DropShadowFilter::kDistanceInput = QStringLiteral("distance_in");
|
||||
const QString DropShadowFilter::kAngleInput = QStringLiteral("angle_in");
|
||||
const QString DropShadowFilter::kSoftnessInput = QStringLiteral("radius_in");
|
||||
const QString DropShadowFilter::kOpacityInput = QStringLiteral("opacity_in");
|
||||
const QString DropShadowFilter::kFastInput = QStringLiteral("fast_in");
|
||||
const QString DropShadowFilter::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString DropShadowFilter::k_color_input = QStringLiteral("color_in");
|
||||
const QString DropShadowFilter::k_distance_input = QStringLiteral("distance_in");
|
||||
const QString DropShadowFilter::k_angle_input = QStringLiteral("angle_in");
|
||||
const QString DropShadowFilter::k_softness_input = QStringLiteral("radius_in");
|
||||
const QString DropShadowFilter::k_opacity_input = QStringLiteral("opacity_in");
|
||||
const QString DropShadowFilter::k_fast_input = QStringLiteral("fast_in");
|
||||
|
||||
DropShadowFilter::DropShadowFilter()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(0.0, 0.0, 0.0)));
|
||||
|
||||
AddInput(kDistanceInput, NodeValue::kFloat, 10.0);
|
||||
add_input(k_distance_input, NodeValue::k_float, 10.0);
|
||||
|
||||
AddInput(kAngleInput, NodeValue::kFloat, 135.0);
|
||||
add_input(k_angle_input, NodeValue::k_float, 135.0);
|
||||
|
||||
AddInput(kSoftnessInput, NodeValue::kFloat, 10.0);
|
||||
SetInputProperty(kSoftnessInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_softness_input, NodeValue::k_float, 10.0);
|
||||
set_input_property(k_softness_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
AddInput(kOpacityInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kOpacityInput, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(kOpacityInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
add_input(k_opacity_input, NodeValue::k_float, 1.0);
|
||||
set_input_property(k_opacity_input, QStringLiteral("min"), 0.0);
|
||||
set_input_property(k_opacity_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
|
||||
AddInput(kFastInput, NodeValue::kBoolean, false);
|
||||
add_input(k_fast_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetEffectInput(kTextureInput);
|
||||
SetFlag(kVideoEffect);
|
||||
set_effect_input(k_texture_input);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
void DropShadowFilter::Retranslate()
|
||||
void DropShadowFilter::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
SetInputName(kDistanceInput, tr("Distance"));
|
||||
SetInputName(kAngleInput, tr("Angle"));
|
||||
SetInputName(kSoftnessInput, tr("Softness"));
|
||||
SetInputName(kOpacityInput, tr("Opacity"));
|
||||
SetInputName(kFastInput, tr("Faster (Lower Quality)"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
set_input_name(k_distance_input, tr("Distance"));
|
||||
set_input_name(k_angle_input, tr("Angle"));
|
||||
set_input_name(k_softness_input, tr("Softness"));
|
||||
set_input_name(k_opacity_input, tr("Opacity"));
|
||||
set_input_name(k_fast_input, tr("Faster (Lower Quality)"));
|
||||
}
|
||||
|
||||
ShaderCode DropShadowFilter::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode DropShadowFilter::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/dropshadow.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/dropshadow.frag"));
|
||||
}
|
||||
|
||||
void DropShadowFilter::Value(const NodeValueRow &value,
|
||||
void DropShadowFilter::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
ShaderJob job(value);
|
||||
|
||||
QString iterative = QStringLiteral("previous_iteration_in");
|
||||
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
job.Insert(iterative, value[kTextureInput]);
|
||||
job.insert(iterative, value[k_texture_input]);
|
||||
|
||||
if (!qIsNull(value[kSoftnessInput].toDouble())) {
|
||||
job.SetIterations(3, iterative);
|
||||
if (!qIsNull(value[k_softness_input].to_double())) {
|
||||
job.set_iterations(3, iterative);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DROPSHADOWFILTER_H
|
||||
#define DROPSHADOWFILTER_H
|
||||
#ifndef OAK_DROPSHADOWFILTER_H
|
||||
#define OAK_DROPSHADOWFILTER_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(DropShadowFilter)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Drop Shadow");
|
||||
}
|
||||
@@ -42,31 +42,31 @@ public:
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.dropshadow");
|
||||
}
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryFilter };
|
||||
return { k_category_filter };
|
||||
}
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Adds a drop shadow to an image.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kColorInput;
|
||||
static const QString kDistanceInput;
|
||||
static const QString kAngleInput;
|
||||
static const QString kSoftnessInput;
|
||||
static const QString kOpacityInput;
|
||||
static const QString kFastInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_color_input;
|
||||
static const QString k_distance_input;
|
||||
static const QString k_angle_input;
|
||||
static const QString k_softness_input;
|
||||
static const QString k_opacity_input;
|
||||
static const QString k_fast_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DROPSHADOWFILTER_H
|
||||
#endif // OAK_DROPSHADOWFILTER_H
|
||||
|
||||
@@ -24,60 +24,60 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString MosaicFilterNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString MosaicFilterNode::kHorizInput = QStringLiteral("horiz_in");
|
||||
const QString MosaicFilterNode::kVertInput = QStringLiteral("vert_in");
|
||||
const QString MosaicFilterNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString MosaicFilterNode::k_horiz_input = QStringLiteral("horiz_in");
|
||||
const QString MosaicFilterNode::k_vert_input = QStringLiteral("vert_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
MosaicFilterNode::MosaicFilterNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kHorizInput, NodeValue::kFloat, 32.0);
|
||||
SetInputProperty(kHorizInput, QStringLiteral("min"), 1.0);
|
||||
add_input(k_horiz_input, NodeValue::k_float, 32.0);
|
||||
set_input_property(k_horiz_input, QStringLiteral("min"), 1.0);
|
||||
|
||||
AddInput(kVertInput, NodeValue::kFloat, 18.0);
|
||||
SetInputProperty(kVertInput, QStringLiteral("min"), 1.0);
|
||||
add_input(k_vert_input, NodeValue::k_float, 18.0);
|
||||
set_input_property(k_vert_input, QStringLiteral("min"), 1.0);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
void MosaicFilterNode::Retranslate()
|
||||
void MosaicFilterNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kHorizInput, tr("Horizontal"));
|
||||
SetInputName(kVertInput, tr("Vertical"));
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
set_input_name(k_horiz_input, tr("Horizontal"));
|
||||
set_input_name(k_vert_input, tr("Vertical"));
|
||||
}
|
||||
|
||||
void MosaicFilterNode::Value(const NodeValueRow &value,
|
||||
void MosaicFilterNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr texture = value[kTextureInput].toTexture()) {
|
||||
if (texture && (value[kHorizInput].toInt() != texture->width() ||
|
||||
value[kVertInput].toInt() != texture->height())) {
|
||||
if (TexturePtr texture = value[k_texture_input].to_texture()) {
|
||||
if (texture && (value[k_horiz_input].to_int() != texture->width() ||
|
||||
value[k_vert_input].to_int() != texture->height())) {
|
||||
ShaderJob job(value);
|
||||
|
||||
// Mipmapping makes this look weird, so we just use bilinear for finding the color of each block
|
||||
job.SetInterpolation(kTextureInput, Texture::kLinear);
|
||||
job.set_interpolation(k_texture_input, Texture::k_linear);
|
||||
|
||||
table->Push(NodeValue::kTexture, texture->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, texture->to_job(job), this);
|
||||
} else {
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode MosaicFilterNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode MosaicFilterNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/mosaic.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/mosaic.frag"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MOSAICFILTERNODE_H
|
||||
#define MOSAICFILTERNODE_H
|
||||
#ifndef OAK_MOSAICFILTERNODE_H
|
||||
#define OAK_MOSAICFILTERNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MosaicFilterNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Mosaic");
|
||||
}
|
||||
@@ -44,28 +44,28 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.mosaicfilter");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryFilter };
|
||||
return { k_category_filter };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Apply a pixelated mosaic filter to video.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kHorizInput;
|
||||
static const QString kVertInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_horiz_input;
|
||||
static const QString k_vert_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MOSAICFILTERNODE_H
|
||||
#endif // OAK_MOSAICFILTERNODE_H
|
||||
|
||||
@@ -26,38 +26,38 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString StrokeFilterNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString StrokeFilterNode::kColorInput = QStringLiteral("color_in");
|
||||
const QString StrokeFilterNode::kRadiusInput = QStringLiteral("radius_in");
|
||||
const QString StrokeFilterNode::kOpacityInput = QStringLiteral("opacity_in");
|
||||
const QString StrokeFilterNode::kInnerInput = QStringLiteral("inner_in");
|
||||
const QString StrokeFilterNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString StrokeFilterNode::k_color_input = QStringLiteral("color_in");
|
||||
const QString StrokeFilterNode::k_radius_input = QStringLiteral("radius_in");
|
||||
const QString StrokeFilterNode::k_opacity_input = QStringLiteral("opacity_in");
|
||||
const QString StrokeFilterNode::k_inner_input = QStringLiteral("inner_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
StrokeFilterNode::StrokeFilterNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0f, 1.0f, 1.0f, 1.0f)));
|
||||
|
||||
AddInput(kRadiusInput, NodeValue::kFloat, 10.0);
|
||||
SetInputProperty(kRadiusInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_radius_input, NodeValue::k_float, 10.0);
|
||||
set_input_property(k_radius_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
AddInput(kOpacityInput, NodeValue::kFloat, 1.0f);
|
||||
SetInputProperty(kOpacityInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kOpacityInput, QStringLiteral("min"), 0.0f);
|
||||
SetInputProperty(kOpacityInput, QStringLiteral("max"), 1.0f);
|
||||
add_input(k_opacity_input, NodeValue::k_float, 1.0f);
|
||||
set_input_property(k_opacity_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_opacity_input, QStringLiteral("min"), 0.0f);
|
||||
set_input_property(k_opacity_input, QStringLiteral("max"), 1.0f);
|
||||
|
||||
AddInput(kInnerInput, NodeValue::kBoolean, false);
|
||||
add_input(k_inner_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetEffectInput(kTextureInput);
|
||||
set_flag(k_video_effect);
|
||||
set_effect_input(k_texture_input);
|
||||
}
|
||||
|
||||
QString StrokeFilterNode::Name() const
|
||||
QString StrokeFilterNode::name() const
|
||||
{
|
||||
return tr("Stroke");
|
||||
}
|
||||
@@ -67,50 +67,50 @@ QString StrokeFilterNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.stroke");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> StrokeFilterNode::Category() const
|
||||
QVector<Node::CategoryID> StrokeFilterNode::category() const
|
||||
{
|
||||
return { kCategoryFilter };
|
||||
return { k_category_filter };
|
||||
}
|
||||
|
||||
QString StrokeFilterNode::Description() const
|
||||
QString StrokeFilterNode::description() const
|
||||
{
|
||||
return tr("Creates a stroke outline around an image.");
|
||||
}
|
||||
|
||||
void StrokeFilterNode::Retranslate()
|
||||
void StrokeFilterNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
SetInputName(kRadiusInput, tr("Radius"));
|
||||
SetInputName(kOpacityInput, tr("Opacity"));
|
||||
SetInputName(kInnerInput, tr("Inner"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
set_input_name(k_radius_input, tr("Radius"));
|
||||
set_input_name(k_opacity_input, tr("Opacity"));
|
||||
set_input_name(k_inner_input, tr("Inner"));
|
||||
}
|
||||
|
||||
void StrokeFilterNode::Value(const NodeValueRow &value,
|
||||
void StrokeFilterNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (value[kRadiusInput].toDouble() > 0.0 &&
|
||||
value[kOpacityInput].toDouble() > 0.0) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
if (value[k_radius_input].to_double() > 0.0 &&
|
||||
value[k_opacity_input].to_double() > 0.0) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2, tex->virtual_resolution(),
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2, tex->virtual_resolution(),
|
||||
this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
} else {
|
||||
table->Push(value[kTextureInput]);
|
||||
table->push(value[k_texture_input]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode StrokeFilterNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode StrokeFilterNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/stroke.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/stroke.frag"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef STROKEFILTERNODE_H
|
||||
#define STROKEFILTERNODE_H
|
||||
#ifndef OAK_STROKEFILTERNODE_H
|
||||
#define OAK_STROKEFILTERNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,25 +34,25 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(StrokeFilterNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kColorInput;
|
||||
static const QString kRadiusInput;
|
||||
static const QString kOpacityInput;
|
||||
static const QString kInnerInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_color_input;
|
||||
static const QString k_radius_input;
|
||||
static const QString k_opacity_input;
|
||||
static const QString k_inner_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // STROKEFILTERNODE_H
|
||||
#endif // OAK_STROKEFILTERNODE_H
|
||||
|
||||
@@ -29,39 +29,39 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString MatrixGenerator::kPositionInput = QStringLiteral("pos_in");
|
||||
const QString MatrixGenerator::kRotationInput = QStringLiteral("rot_in");
|
||||
const QString MatrixGenerator::kScaleInput = QStringLiteral("scale_in");
|
||||
const QString MatrixGenerator::kUniformScaleInput =
|
||||
const QString MatrixGenerator::k_position_input = QStringLiteral("pos_in");
|
||||
const QString MatrixGenerator::k_rotation_input = QStringLiteral("rot_in");
|
||||
const QString MatrixGenerator::k_scale_input = QStringLiteral("scale_in");
|
||||
const QString MatrixGenerator::k_uniform_scale_input =
|
||||
QStringLiteral("uniform_scale_in");
|
||||
const QString MatrixGenerator::kAnchorInput = QStringLiteral("anchor_in");
|
||||
const QString MatrixGenerator::k_anchor_input = QStringLiteral("anchor_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
MatrixGenerator::MatrixGenerator()
|
||||
{
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
|
||||
AddInput(kRotationInput, NodeValue::kFloat, 0.0);
|
||||
add_input(k_rotation_input, NodeValue::k_float, 0.0);
|
||||
|
||||
AddInput(kScaleInput, NodeValue::kVec2, QVector2D(1.0f, 1.0f));
|
||||
SetInputProperty(kScaleInput, QStringLiteral("min"), QVector2D(0, 0));
|
||||
SetInputProperty(kScaleInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kScaleInput, QStringLiteral("disable1"), true);
|
||||
add_input(k_scale_input, NodeValue::k_vec2, QVector2D(1.0f, 1.0f));
|
||||
set_input_property(k_scale_input, QStringLiteral("min"), QVector2D(0, 0));
|
||||
set_input_property(k_scale_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_scale_input, QStringLiteral("disable1"), true);
|
||||
|
||||
AddInput(kUniformScaleInput, NodeValue::kBoolean, true,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_uniform_scale_input, NodeValue::k_boolean, true,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kAnchorInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_anchor_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
}
|
||||
|
||||
QString MatrixGenerator::Name() const
|
||||
QString MatrixGenerator::name() const
|
||||
{
|
||||
return tr("Orthographic Matrix");
|
||||
}
|
||||
|
||||
QString MatrixGenerator::ShortName() const
|
||||
QString MatrixGenerator::short_name() const
|
||||
{
|
||||
return tr("Ortho");
|
||||
}
|
||||
@@ -71,38 +71,38 @@ QString MatrixGenerator::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ortho");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> MatrixGenerator::Category() const
|
||||
QVector<Node::CategoryID> MatrixGenerator::category() const
|
||||
{
|
||||
return { kCategoryGenerator, kCategoryMath };
|
||||
return { k_category_generator, k_category_math };
|
||||
}
|
||||
|
||||
QString MatrixGenerator::Description() const
|
||||
QString MatrixGenerator::description() const
|
||||
{
|
||||
return tr(
|
||||
"Generate an orthographic matrix using position, rotation, and scale.");
|
||||
}
|
||||
|
||||
void MatrixGenerator::Retranslate()
|
||||
void MatrixGenerator::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kRotationInput, tr("Rotation"));
|
||||
SetInputName(kScaleInput, tr("Scale"));
|
||||
SetInputName(kUniformScaleInput, tr("Uniform Scale"));
|
||||
SetInputName(kAnchorInput, tr("Anchor Point"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_rotation_input, tr("Rotation"));
|
||||
set_input_name(k_scale_input, tr("Scale"));
|
||||
set_input_name(k_uniform_scale_input, tr("Uniform Scale"));
|
||||
set_input_name(k_anchor_input, tr("Anchor Point"));
|
||||
}
|
||||
|
||||
void MatrixGenerator::Value(const NodeValueRow &value,
|
||||
void MatrixGenerator::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Push matrix output
|
||||
QMatrix4x4 mat = GenerateMatrix(value, false, false, false, QMatrix4x4());
|
||||
table->Push(NodeValue::kMatrix, mat, this);
|
||||
QMatrix4x4 mat = generate_matrix(value, false, false, false, QMatrix4x4());
|
||||
table->push(NodeValue::k_matrix, mat, this);
|
||||
}
|
||||
|
||||
QMatrix4x4 MatrixGenerator::GenerateMatrix(const NodeValueRow &value,
|
||||
QMatrix4x4 MatrixGenerator::generate_matrix(const NodeValueRow &value,
|
||||
bool ignore_anchor,
|
||||
bool ignore_position,
|
||||
bool ignore_scale,
|
||||
@@ -113,23 +113,23 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(const NodeValueRow &value,
|
||||
QVector2D scale;
|
||||
|
||||
if (!ignore_anchor) {
|
||||
anchor = value[kAnchorInput].toVec2();
|
||||
anchor = value[k_anchor_input].to_vec2();
|
||||
}
|
||||
|
||||
if (!ignore_scale) {
|
||||
scale = value[kScaleInput].toVec2();
|
||||
scale = value[k_scale_input].to_vec2();
|
||||
}
|
||||
|
||||
if (!ignore_position) {
|
||||
position = value[kPositionInput].toVec2();
|
||||
position = value[k_position_input].to_vec2();
|
||||
}
|
||||
|
||||
return GenerateMatrix(position, value[kRotationInput].toDouble(), scale,
|
||||
value[kUniformScaleInput].toBool(), anchor, mat);
|
||||
return generate_matrix(position, value[k_rotation_input].to_double(), scale,
|
||||
value[k_uniform_scale_input].to_bool(), anchor, mat);
|
||||
}
|
||||
|
||||
QMatrix4x4
|
||||
MatrixGenerator::GenerateMatrix(const QVector2D &pos, const float &rot,
|
||||
MatrixGenerator::generate_matrix(const QVector2D &pos, const float &rot,
|
||||
const QVector2D &scale, bool uniform_scale,
|
||||
const QVector2D &anchor, QMatrix4x4 mat)
|
||||
{
|
||||
@@ -158,9 +158,9 @@ void MatrixGenerator::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kUniformScaleInput) {
|
||||
SetInputProperty(kScaleInput, QStringLiteral("disable1"),
|
||||
GetStandardValue(kUniformScaleInput).toBool());
|
||||
if (input == k_uniform_scale_input) {
|
||||
set_input_property(k_scale_input, QStringLiteral("disable1"),
|
||||
get_standard_value(k_uniform_scale_input).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MATRIXGENERATOR_H
|
||||
#define MATRIXGENERATOR_H
|
||||
#ifndef OAK_MATRIXGENERATOR_H
|
||||
#define OAK_MATRIXGENERATOR_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
@@ -37,28 +37,28 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MatrixGenerator)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString ShortName() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString short_name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kPositionInput;
|
||||
static const QString kRotationInput;
|
||||
static const QString kScaleInput;
|
||||
static const QString kUniformScaleInput;
|
||||
static const QString kAnchorInput;
|
||||
static const QString k_position_input;
|
||||
static const QString k_rotation_input;
|
||||
static const QString k_scale_input;
|
||||
static const QString k_uniform_scale_input;
|
||||
static const QString k_anchor_input;
|
||||
|
||||
protected:
|
||||
QMatrix4x4 GenerateMatrix(const NodeValueRow &value, bool ignore_anchor,
|
||||
QMatrix4x4 generate_matrix(const NodeValueRow &value, bool ignore_anchor,
|
||||
bool ignore_position, bool ignore_scale,
|
||||
const QMatrix4x4 &mat) const;
|
||||
static QMatrix4x4 GenerateMatrix(const QVector2D &pos, const float &rot,
|
||||
static QMatrix4x4 generate_matrix(const QVector2D &pos, const float &rot,
|
||||
const QVector2D &scale, bool uniform_scale,
|
||||
const QVector2D &anchor, QMatrix4x4 mat);
|
||||
|
||||
|
||||
@@ -26,30 +26,30 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString NoiseGeneratorNode::kBaseIn = QStringLiteral("base_in");
|
||||
const QString NoiseGeneratorNode::kColorInput = QStringLiteral("color_in");
|
||||
const QString NoiseGeneratorNode::kStrengthInput =
|
||||
const QString NoiseGeneratorNode::k_base_in = QStringLiteral("base_in");
|
||||
const QString NoiseGeneratorNode::k_color_input = QStringLiteral("color_in");
|
||||
const QString NoiseGeneratorNode::k_strength_input =
|
||||
QStringLiteral("strength_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
NoiseGeneratorNode::NoiseGeneratorNode()
|
||||
{
|
||||
AddInput(kBaseIn, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_base_in, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kStrengthInput, NodeValue::kFloat, 0.2);
|
||||
SetInputProperty(kStrengthInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kStrengthInput, QStringLiteral("min"), 0);
|
||||
add_input(k_strength_input, NodeValue::k_float, 0.2);
|
||||
set_input_property(k_strength_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_strength_input, QStringLiteral("min"), 0);
|
||||
|
||||
AddInput(kColorInput, NodeValue::kBoolean, false);
|
||||
add_input(k_color_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetEffectInput(kBaseIn);
|
||||
SetFlag(kVideoEffect);
|
||||
set_effect_input(k_base_in);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
QString NoiseGeneratorNode::Name() const
|
||||
QString NoiseGeneratorNode::name() const
|
||||
{
|
||||
return tr("Noise");
|
||||
}
|
||||
@@ -59,45 +59,45 @@ QString NoiseGeneratorNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.noise");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> NoiseGeneratorNode::Category() const
|
||||
QVector<Node::CategoryID> NoiseGeneratorNode::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString NoiseGeneratorNode::Description() const
|
||||
QString NoiseGeneratorNode::description() const
|
||||
{
|
||||
return tr("Generates noise patterns");
|
||||
}
|
||||
|
||||
void NoiseGeneratorNode::Retranslate()
|
||||
void NoiseGeneratorNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBaseIn, tr("Base"));
|
||||
SetInputName(kStrengthInput, tr("Strength"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_base_in, tr("Base"));
|
||||
set_input_name(k_strength_input, tr("Strength"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
ShaderCode NoiseGeneratorNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode NoiseGeneratorNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/noise.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/noise.frag"));
|
||||
}
|
||||
|
||||
void NoiseGeneratorNode::Value(const NodeValueRow &value,
|
||||
void NoiseGeneratorNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job(value);
|
||||
|
||||
job.Insert(value);
|
||||
job.Insert(QStringLiteral("time_in"),
|
||||
NodeValue(NodeValue::kFloat, globals.time().in().toDouble(),
|
||||
job.insert(value);
|
||||
job.insert(QStringLiteral("time_in"),
|
||||
NodeValue(NodeValue::k_float, globals.time().in().to_double(),
|
||||
this));
|
||||
|
||||
TexturePtr base = value[kBaseIn].toTexture();
|
||||
TexturePtr base = value[k_base_in].to_texture();
|
||||
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(base ? base->params() : globals.vparams(), job),
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(base ? base->params() : globals.vparams(), job),
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NOISEGENERATORNODE_H
|
||||
#define NOISEGENERATORNODE_H
|
||||
#ifndef OAK_NOISEGENERATORNODE_H
|
||||
#define OAK_NOISEGENERATORNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,23 +34,23 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(NoiseGeneratorNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kBaseIn;
|
||||
static const QString kColorInput;
|
||||
static const QString kStrengthInput;
|
||||
static const QString k_base_in;
|
||||
static const QString k_color_input;
|
||||
static const QString k_strength_input;
|
||||
};
|
||||
|
||||
} // namespace olive
|
||||
|
||||
#endif // NOISEGENERATORNODE_H
|
||||
#endif // OAK_NOISEGENERATORNODE_H
|
||||
|
||||
@@ -27,43 +27,43 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString PolygonGenerator::kPointsInput = QStringLiteral("points_in");
|
||||
const QString PolygonGenerator::kColorInput = QStringLiteral("color_in");
|
||||
const QString PolygonGenerator::k_points_input = QStringLiteral("points_in");
|
||||
const QString PolygonGenerator::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
#define super GeneratorWithMerge
|
||||
|
||||
PolygonGenerator::PolygonGenerator()
|
||||
{
|
||||
AddInput(kPointsInput, NodeValue::kBezier, QVector2D(0, 0),
|
||||
InputFlags(kInputFlagArray));
|
||||
add_input(k_points_input, NodeValue::k_bezier, QVector2D(0, 0),
|
||||
InputFlags(k_input_flag_array));
|
||||
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0, 1.0, 1.0)));
|
||||
|
||||
const int kMiddleX = 135;
|
||||
const int kMiddleY = 45;
|
||||
const int kBottomX = 90;
|
||||
const int kBottomY = 120;
|
||||
const int kTopY = 135;
|
||||
const int k_middle_x = 135;
|
||||
const int k_middle_y = 45;
|
||||
const int k_bottom_x = 90;
|
||||
const int k_bottom_y = 120;
|
||||
const int k_top_y = 135;
|
||||
|
||||
// The Default Pentagon(tm)
|
||||
InputArrayResize(kPointsInput, 5);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 0, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kTopY, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, kMiddleX, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, kBottomX, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, -kBottomX, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, -kMiddleX, 4);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 4);
|
||||
input_array_resize(k_points_input, 5);
|
||||
set_split_standard_value_on_track(k_points_input, 0, 0, 0);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_top_y, 0);
|
||||
set_split_standard_value_on_track(k_points_input, 0, k_middle_x, 1);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 1);
|
||||
set_split_standard_value_on_track(k_points_input, 0, k_bottom_x, 2);
|
||||
set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 2);
|
||||
set_split_standard_value_on_track(k_points_input, 0, -k_bottom_x, 3);
|
||||
set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 3);
|
||||
set_split_standard_value_on_track(k_points_input, 0, -k_middle_x, 4);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 4);
|
||||
|
||||
// Initiate gizmos
|
||||
poly_gizmo_ = new PathGizmo(this);
|
||||
}
|
||||
|
||||
QString PolygonGenerator::Name() const
|
||||
QString PolygonGenerator::name() const
|
||||
{
|
||||
return tr("Polygon");
|
||||
}
|
||||
@@ -73,52 +73,52 @@ QString PolygonGenerator::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.polygon");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> PolygonGenerator::Category() const
|
||||
QVector<Node::CategoryID> PolygonGenerator::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString PolygonGenerator::Description() const
|
||||
QString PolygonGenerator::description() const
|
||||
{
|
||||
return tr("Generate a 2D polygon of any amount of points.");
|
||||
}
|
||||
|
||||
void PolygonGenerator::Retranslate()
|
||||
void PolygonGenerator::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kPointsInput, tr("Points"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_points_input, tr("Points"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
ShaderJob PolygonGenerator::GetGenerateJob(const NodeValueRow &value,
|
||||
ShaderJob PolygonGenerator::get_generate_job(const NodeValueRow &value,
|
||||
const VideoParams ¶ms) const
|
||||
{
|
||||
VideoParams p = params;
|
||||
p.set_format(PixelFormat::U8);
|
||||
auto job = Texture::Job(p, GenerateJob(value));
|
||||
p.set_format(PixelFormat::u8);
|
||||
auto job = Texture::job(p, GenerateJob(value));
|
||||
|
||||
// Conversion to RGB
|
||||
ShaderJob rgb;
|
||||
rgb.SetShaderID(QStringLiteral("rgb"));
|
||||
rgb.Insert(QStringLiteral("texture_in"),
|
||||
NodeValue(NodeValue::kTexture, job, this));
|
||||
rgb.Insert(QStringLiteral("color_in"), value[kColorInput]);
|
||||
rgb.set_shader_id(QStringLiteral("rgb"));
|
||||
rgb.insert(QStringLiteral("texture_in"),
|
||||
NodeValue(NodeValue::k_texture, job, this));
|
||||
rgb.insert(QStringLiteral("color_in"), value[k_color_input]);
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
void PolygonGenerator::Value(const NodeValueRow &value,
|
||||
void PolygonGenerator::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
PushMergableJob(value,
|
||||
Texture::Job(globals.vparams(),
|
||||
GetGenerateJob(value, globals.vparams())),
|
||||
push_mergable_job(value,
|
||||
Texture::job(globals.vparams(),
|
||||
get_generate_job(value, globals.vparams())),
|
||||
table);
|
||||
}
|
||||
|
||||
void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
void PolygonGenerator::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
// This could probably be more optimized, but for now we use Qt to draw to a QImage.
|
||||
@@ -129,12 +129,12 @@ void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
frame->linesize_bytes(), QImage::Format_RGBA8888_Premultiplied);
|
||||
img.fill(Qt::transparent);
|
||||
|
||||
auto points = job.Get(kPointsInput).toArray();
|
||||
auto points = job.get(k_points_input).to_array();
|
||||
|
||||
QPainterPath path = GeneratePath(points, InputArraySize(kPointsInput));
|
||||
QPainterPath path = generate_path(points, input_array_size(k_points_input));
|
||||
|
||||
QPainter p(&img);
|
||||
double par = frame->video_params().pixel_aspect_ratio().toDouble();
|
||||
double par = frame->video_params().pixel_aspect_ratio().to_double();
|
||||
p.scale(1.0 / frame->video_params().divider() / par,
|
||||
1.0 / frame->video_params().divider());
|
||||
p.translate(frame->video_params().width() / 2 * par,
|
||||
@@ -145,18 +145,18 @@ void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
p.drawPath(path);
|
||||
}
|
||||
|
||||
template <typename T> NodeGizmo *PolygonGenerator::CreateAppropriateGizmo()
|
||||
template <typename T> NodeGizmo *PolygonGenerator::create_appropriate_gizmo()
|
||||
{
|
||||
return new T(this);
|
||||
}
|
||||
|
||||
template <> NodeGizmo *PolygonGenerator::CreateAppropriateGizmo<PointGizmo>()
|
||||
template <> NodeGizmo *PolygonGenerator::create_appropriate_gizmo<PointGizmo>()
|
||||
{
|
||||
return AddDraggableGizmo<PointGizmo>();
|
||||
return add_draggable_gizmo<PointGizmo>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void PolygonGenerator::ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz)
|
||||
void PolygonGenerator::validate_gizmo_vector_size(QVector<T *> &vec, int new_sz)
|
||||
{
|
||||
int old_sz = vec.size();
|
||||
|
||||
@@ -171,17 +171,17 @@ void PolygonGenerator::ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz)
|
||||
|
||||
if (old_sz < new_sz) {
|
||||
for (int i = old_sz; i < new_sz; i++) {
|
||||
vec[i] = static_cast<T *>(CreateAppropriateGizmo<T>());
|
||||
vec[i] = static_cast<T *>(create_appropriate_gizmo<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void PolygonGenerator::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
QVector2D res;
|
||||
if (TexturePtr tex = row[kBaseInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_base_input].to_texture()) {
|
||||
res = tex->virtual_resolution();
|
||||
} else {
|
||||
res = globals.square_resolution();
|
||||
@@ -189,72 +189,72 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
|
||||
Imath::V2d half_res(res.x() / 2, res.y() / 2);
|
||||
|
||||
auto points = row[kPointsInput].toArray();
|
||||
auto points = row[k_points_input].to_array();
|
||||
|
||||
int current_pos_sz = gizmo_position_handles_.size();
|
||||
|
||||
ValidateGizmoVectorSize(gizmo_position_handles_, points.size());
|
||||
ValidateGizmoVectorSize(gizmo_bezier_handles_, points.size() * 2);
|
||||
ValidateGizmoVectorSize(gizmo_bezier_lines_, points.size() * 2);
|
||||
validate_gizmo_vector_size(gizmo_position_handles_, points.size());
|
||||
validate_gizmo_vector_size(gizmo_bezier_handles_, points.size() * 2);
|
||||
validate_gizmo_vector_size(gizmo_bezier_lines_, points.size() * 2);
|
||||
|
||||
for (int i = current_pos_sz; i < gizmo_position_handles_.size(); i++) {
|
||||
gizmo_position_handles_.at(i)->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 0));
|
||||
gizmo_position_handles_.at(i)->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 1));
|
||||
gizmo_position_handles_.at(i)->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 0));
|
||||
gizmo_position_handles_.at(i)->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 1));
|
||||
|
||||
PointGizmo *bez_gizmo1 = gizmo_bezier_handles_.at(i * 2 + 0);
|
||||
bez_gizmo1->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 2));
|
||||
bez_gizmo1->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 3));
|
||||
bez_gizmo1->SetShape(PointGizmo::kCircle);
|
||||
bez_gizmo1->SetSmaller(true);
|
||||
bez_gizmo1->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 2));
|
||||
bez_gizmo1->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 3));
|
||||
bez_gizmo1->set_shape(PointGizmo::k_circle);
|
||||
bez_gizmo1->set_smaller(true);
|
||||
|
||||
PointGizmo *bez_gizmo2 = gizmo_bezier_handles_.at(i * 2 + 1);
|
||||
bez_gizmo2->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 4));
|
||||
bez_gizmo2->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 5));
|
||||
bez_gizmo2->SetShape(PointGizmo::kCircle);
|
||||
bez_gizmo2->SetSmaller(true);
|
||||
bez_gizmo2->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 4));
|
||||
bez_gizmo2->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 5));
|
||||
bez_gizmo2->set_shape(PointGizmo::k_circle);
|
||||
bez_gizmo2->set_smaller(true);
|
||||
}
|
||||
|
||||
int pts_sz = InputArraySize(kPointsInput);
|
||||
int pts_sz = input_array_size(k_points_input);
|
||||
if (!points.empty()) {
|
||||
for (int i = 0; i < pts_sz; i++) {
|
||||
const Bezier &pt = points.at(i).toBezier();
|
||||
const Bezier &pt = points.at(i).to_bezier();
|
||||
|
||||
Imath::V2d main = pt.to_vec() + half_res;
|
||||
Imath::V2d cp1 = main + pt.control_point_1_to_vec();
|
||||
Imath::V2d cp2 = main + pt.control_point_2_to_vec();
|
||||
|
||||
gizmo_position_handles_[i]->SetPoint(QPointF(main.x, main.y));
|
||||
gizmo_position_handles_[i]->set_point(QPointF(main.x, main.y));
|
||||
|
||||
gizmo_bezier_handles_[i * 2]->SetPoint(QPointF(cp1.x, cp1.y));
|
||||
gizmo_bezier_lines_[i * 2]->SetLine(
|
||||
gizmo_bezier_handles_[i * 2]->set_point(QPointF(cp1.x, cp1.y));
|
||||
gizmo_bezier_lines_[i * 2]->set_line(
|
||||
QLineF(QPointF(main.x, main.y), QPointF(cp1.x, cp1.y)));
|
||||
gizmo_bezier_handles_[i * 2 + 1]->SetPoint(QPointF(cp2.x, cp2.y));
|
||||
gizmo_bezier_lines_[i * 2 + 1]->SetLine(
|
||||
gizmo_bezier_handles_[i * 2 + 1]->set_point(QPointF(cp2.x, cp2.y));
|
||||
gizmo_bezier_lines_[i * 2 + 1]->set_line(
|
||||
QLineF(QPointF(main.x, main.y), QPointF(cp2.x, cp2.y)));
|
||||
}
|
||||
}
|
||||
|
||||
poly_gizmo_->SetPath(GeneratePath(points, pts_sz)
|
||||
poly_gizmo_->set_path(generate_path(points, pts_sz)
|
||||
.translated(QPointF(half_res.x, half_res.y)));
|
||||
}
|
||||
|
||||
ShaderCode PolygonGenerator::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode PolygonGenerator::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("rgb")) {
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/rgb.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/rgb.frag"));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::GizmoDragMove(double x, double y,
|
||||
void PolygonGenerator::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
@@ -262,14 +262,14 @@ void PolygonGenerator::GizmoDragMove(double x, double y,
|
||||
if (gizmo == poly_gizmo_) {
|
||||
// FIXME: Drag all points
|
||||
} else {
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
void PolygonGenerator::add_point_to_path(QPainterPath *path, const Bezier &before,
|
||||
const Bezier &after)
|
||||
{
|
||||
Imath::V2d a = before.to_vec() + before.control_point_2_to_vec();
|
||||
@@ -279,22 +279,22 @@ void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
path->cubicTo(QPointF(a.x, a.y), QPointF(b.x, b.y), QPointF(c.x, c.y));
|
||||
}
|
||||
|
||||
QPainterPath PolygonGenerator::GeneratePath(const NodeValueArray &points,
|
||||
QPainterPath PolygonGenerator::generate_path(const NodeValueArray &points,
|
||||
int size)
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
if (!points.empty()) {
|
||||
const Bezier &first_pt = points.at(0).toBezier();
|
||||
const Bezier &first_pt = points.at(0).to_bezier();
|
||||
Imath::V2d v = first_pt.to_vec();
|
||||
path.moveTo(QPointF(v.x, v.y));
|
||||
|
||||
for (int i = 1; i < size; i++) {
|
||||
AddPointToPath(&path, points.at(i - 1).toBezier(),
|
||||
points.at(i).toBezier());
|
||||
add_point_to_path(&path, points.at(i - 1).to_bezier(),
|
||||
points.at(i).to_bezier());
|
||||
}
|
||||
|
||||
AddPointToPath(&path, points.at(size - 1).toBezier(), first_pt);
|
||||
add_point_to_path(&path, points.at(size - 1).to_bezier(), first_pt);
|
||||
}
|
||||
|
||||
return path;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef POLYGONGENERATOR_H
|
||||
#define POLYGONGENERATOR_H
|
||||
#ifndef OAK_POLYGONGENERATOR_H
|
||||
#define OAK_POLYGONGENERATOR_H
|
||||
|
||||
#include <QPainterPath>
|
||||
|
||||
@@ -41,46 +41,46 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(PolygonGenerator)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kPointsInput;
|
||||
static const QString kColorInput;
|
||||
static const QString k_points_input;
|
||||
static const QString k_color_input;
|
||||
|
||||
protected:
|
||||
ShaderJob GetGenerateJob(const NodeValueRow &value,
|
||||
ShaderJob get_generate_job(const NodeValueRow &value,
|
||||
const VideoParams ¶ms) const;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
static void AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
static void add_point_to_path(QPainterPath *path, const Bezier &before,
|
||||
const Bezier &after);
|
||||
|
||||
static QPainterPath GeneratePath(const NodeValueArray &points, int size);
|
||||
static QPainterPath generate_path(const NodeValueArray &points, int size);
|
||||
|
||||
template <typename T>
|
||||
void ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz);
|
||||
void validate_gizmo_vector_size(QVector<T *> &vec, int new_sz);
|
||||
|
||||
template <typename T> NodeGizmo *CreateAppropriateGizmo();
|
||||
template <typename T> NodeGizmo *create_appropriate_gizmo();
|
||||
|
||||
PathGizmo *poly_gizmo_;
|
||||
QVector<PointGizmo *> gizmo_position_handles_;
|
||||
@@ -90,4 +90,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // POLYGONGENERATOR_H
|
||||
#endif // OAK_POLYGONGENERATOR_H
|
||||
|
||||
@@ -28,50 +28,50 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString GeneratorWithMerge::kBaseInput = QStringLiteral("base_in");
|
||||
const QString GeneratorWithMerge::k_base_input = QStringLiteral("base_in");
|
||||
|
||||
GeneratorWithMerge::GeneratorWithMerge()
|
||||
{
|
||||
AddInput(kBaseInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
SetEffectInput(kBaseInput);
|
||||
SetFlag(kVideoEffect);
|
||||
add_input(k_base_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
set_effect_input(k_base_input);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
void GeneratorWithMerge::Retranslate()
|
||||
void GeneratorWithMerge::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBaseInput, tr("Base"));
|
||||
set_input_name(k_base_input, tr("Base"));
|
||||
}
|
||||
|
||||
ShaderCode GeneratorWithMerge::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode GeneratorWithMerge::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("mrg")) {
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/alphaover.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/alphaover.frag"));
|
||||
}
|
||||
|
||||
return ShaderCode();
|
||||
}
|
||||
|
||||
void GeneratorWithMerge::PushMergableJob(const NodeValueRow &value,
|
||||
void GeneratorWithMerge::push_mergable_job(const NodeValueRow &value,
|
||||
TexturePtr job,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr base = value[kBaseInput].toTexture()) {
|
||||
if (TexturePtr base = value[k_base_input].to_texture()) {
|
||||
// Push as merge node
|
||||
ShaderJob merge;
|
||||
|
||||
merge.SetShaderID(QStringLiteral("mrg"));
|
||||
merge.Insert(MergeNode::kBaseIn, value[kBaseInput]);
|
||||
merge.Insert(MergeNode::kBlendIn,
|
||||
NodeValue(NodeValue::kTexture, job, this));
|
||||
merge.set_shader_id(QStringLiteral("mrg"));
|
||||
merge.insert(MergeNode::k_base_in, value[k_base_input]);
|
||||
merge.insert(MergeNode::k_blend_in,
|
||||
NodeValue(NodeValue::k_texture, job, this));
|
||||
|
||||
table->Push(NodeValue::kTexture, base->toJob(merge), this);
|
||||
table->push(NodeValue::k_texture, base->to_job(merge), this);
|
||||
} else {
|
||||
// Just push generate job
|
||||
table->Push(NodeValue::kTexture, job, this);
|
||||
table->push(NodeValue::k_texture, job, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef GENERATORWITHMERGE_H
|
||||
#define GENERATORWITHMERGE_H
|
||||
#ifndef OAK_GENERATORWITHMERGE_H
|
||||
#define OAK_GENERATORWITHMERGE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -32,18 +32,18 @@ class GeneratorWithMerge : public Node {
|
||||
public:
|
||||
GeneratorWithMerge();
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kBaseInput;
|
||||
static const QString k_base_input;
|
||||
|
||||
protected:
|
||||
void PushMergableJob(const NodeValueRow &value, TexturePtr job,
|
||||
void push_mergable_job(const NodeValueRow &value, TexturePtr job,
|
||||
NodeValueTable *table) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GENERATORWITHMERGE_H
|
||||
#endif // OAK_GENERATORWITHMERGE_H
|
||||
|
||||
@@ -26,18 +26,18 @@ namespace olive
|
||||
|
||||
#define super ShapeNodeBase
|
||||
|
||||
QString ShapeNode::kTypeInput = QStringLiteral("type_in");
|
||||
QString ShapeNode::kRadiusInput = QStringLiteral("radius_in");
|
||||
QString ShapeNode::k_type_input = QStringLiteral("type_in");
|
||||
QString ShapeNode::k_radius_input = QStringLiteral("radius_in");
|
||||
|
||||
ShapeNode::ShapeNode()
|
||||
{
|
||||
PrependInput(kTypeInput, NodeValue::kCombo);
|
||||
prepend_input(k_type_input, NodeValue::k_combo);
|
||||
|
||||
AddInput(kRadiusInput, NodeValue::kFloat, 20.0);
|
||||
SetInputProperty(kRadiusInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_radius_input, NodeValue::k_float, 20.0);
|
||||
set_input_property(k_radius_input, QStringLiteral("min"), 0.0);
|
||||
}
|
||||
|
||||
QString ShapeNode::Name() const
|
||||
QString ShapeNode::name() const
|
||||
{
|
||||
return tr("Shape");
|
||||
}
|
||||
@@ -47,63 +47,63 @@ QString ShapeNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.shape");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> ShapeNode::Category() const
|
||||
QVector<Node::CategoryID> ShapeNode::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString ShapeNode::Description() const
|
||||
QString ShapeNode::description() const
|
||||
{
|
||||
return tr("Generate a 2D primitive shape.");
|
||||
}
|
||||
|
||||
void ShapeNode::Retranslate()
|
||||
void ShapeNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTypeInput, tr("Type"));
|
||||
SetInputName(kRadiusInput, tr("Radius"));
|
||||
set_input_name(k_type_input, tr("Type"));
|
||||
set_input_name(k_radius_input, tr("Radius"));
|
||||
|
||||
// Coordinate with Type enum
|
||||
SetComboBoxStrings(kTypeInput, { tr("Rectangle"), tr("Ellipse"),
|
||||
set_combo_box_strings(k_type_input, { tr("Rectangle"), tr("Ellipse"),
|
||||
tr("Rounded Rectangle") });
|
||||
}
|
||||
|
||||
ShaderCode ShapeNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode ShapeNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("shape")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/shape.frag")));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void ShapeNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
TexturePtr base = value[kBaseInput].toTexture();
|
||||
TexturePtr base = value[k_base_input].to_texture();
|
||||
|
||||
ShaderJob job(value);
|
||||
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
base ? base->virtual_resolution() :
|
||||
globals.square_resolution(),
|
||||
this));
|
||||
job.SetShaderID(QStringLiteral("shape"));
|
||||
job.set_shader_id(QStringLiteral("shape"));
|
||||
|
||||
PushMergableJob(
|
||||
value, Texture::Job(base ? base->params() : globals.vparams(), job),
|
||||
push_mergable_job(
|
||||
value, Texture::job(base ? base->params() : globals.vparams(), job),
|
||||
table);
|
||||
}
|
||||
|
||||
void ShapeNode::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
if (input == kTypeInput) {
|
||||
SetInputFlag(kRadiusInput, kInputFlagHidden,
|
||||
(GetStandardValue(kTypeInput).toInt() !=
|
||||
kRoundedRectangle));
|
||||
if (input == k_type_input) {
|
||||
set_input_flag(k_radius_input, k_input_flag_hidden,
|
||||
(get_standard_value(k_type_input).toInt() !=
|
||||
k_rounded_rectangle));
|
||||
}
|
||||
super::InputValueChangedEvent(input, element);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SHAPENODE_H
|
||||
#define SHAPENODE_H
|
||||
#ifndef OAK_SHAPENODE_H
|
||||
#define OAK_SHAPENODE_H
|
||||
|
||||
#include "shapenodebase.h"
|
||||
|
||||
@@ -32,24 +32,24 @@ class ShapeNode : public ShapeNodeBase {
|
||||
public:
|
||||
ShapeNode();
|
||||
|
||||
enum Type { kRectangle, kEllipse, kRoundedRectangle };
|
||||
enum Type { k_rectangle, k_ellipse, k_rounded_rectangle };
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(ShapeNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static QString kTypeInput;
|
||||
static QString kRadiusInput;
|
||||
static QString k_type_input;
|
||||
static QString k_radius_input;
|
||||
|
||||
protected:
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
@@ -58,4 +58,4 @@ protected:
|
||||
|
||||
}
|
||||
|
||||
#endif // SHAPENODE_H
|
||||
#endif // OAK_SHAPENODE_H
|
||||
|
||||
@@ -33,60 +33,60 @@ namespace olive
|
||||
|
||||
#define super GeneratorWithMerge
|
||||
|
||||
const QString ShapeNodeBase::kPositionInput = QStringLiteral("pos_in");
|
||||
const QString ShapeNodeBase::kSizeInput = QStringLiteral("size_in");
|
||||
const QString ShapeNodeBase::kColorInput = QStringLiteral("color_in");
|
||||
const QString ShapeNodeBase::k_position_input = QStringLiteral("pos_in");
|
||||
const QString ShapeNodeBase::k_size_input = QStringLiteral("size_in");
|
||||
const QString ShapeNodeBase::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
ShapeNodeBase::ShapeNodeBase(bool create_color_input)
|
||||
{
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
AddInput(kSizeInput, NodeValue::kVec2, QVector2D(100, 100));
|
||||
SetInputProperty(kSizeInput, QStringLiteral("min"), QVector2D(0, 0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
add_input(k_size_input, NodeValue::k_vec2, QVector2D(100, 100));
|
||||
set_input_property(k_size_input, QStringLiteral("min"), QVector2D(0, 0));
|
||||
|
||||
if (create_color_input) {
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0, 0.0, 0.0, 1.0)));
|
||||
}
|
||||
|
||||
// Initiate gizmos
|
||||
QVector<NodeKeyframeTrackReference> pos_n_sz = {
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 1)
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_size_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_size_input), 1)
|
||||
};
|
||||
poly_gizmo_ = AddDraggableGizmo<PolygonGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
for (int i = 0; i < kGizmoScaleCount; i++) {
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
point_gizmo_[i] =
|
||||
AddDraggableGizmo<PointGizmo>(pos_n_sz, PointGizmo::kAbsolute);
|
||||
add_draggable_gizmo<PointGizmo>(pos_n_sz, PointGizmo::k_absolute);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNodeBase::Retranslate()
|
||||
void ShapeNodeBase::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kSizeInput, tr("Size"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_size_input, tr("Size"));
|
||||
|
||||
if (HasInputWithID(kColorInput)) {
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
if (has_input_with_id(k_color_input)) {
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void ShapeNodeBase::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
QVector2D center_pt = globals.square_resolution() * 0.5;
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"), center_pt);
|
||||
set_input_property(k_position_input, QStringLiteral("offset"), center_pt);
|
||||
|
||||
QVector2D pos = row[kPositionInput].toVec2();
|
||||
QVector2D sz = row[kSizeInput].toVec2();
|
||||
QVector2D pos = row[k_position_input].to_vec2();
|
||||
QVector2D sz = row[k_size_input].to_vec2();
|
||||
QVector2D half_sz = sz * 0.5;
|
||||
|
||||
double left_pt = pos.x() + center_pt.x() - half_sz.x();
|
||||
@@ -96,32 +96,32 @@ void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
double center_x_pt = mid(left_pt, right_pt);
|
||||
double center_y_pt = mid(top_pt, bottom_pt);
|
||||
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
QPointF(center_x_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
QPointF(right_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
QPointF(left_pt, center_y_pt));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
QPointF(right_pt, center_y_pt));
|
||||
|
||||
poly_gizmo_->SetPolygon(
|
||||
poly_gizmo_->set_polygon(
|
||||
QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt));
|
||||
}
|
||||
|
||||
void ShapeNodeBase::SetRect(QRectF rect, const VideoParams &sequence_res,
|
||||
void ShapeNodeBase::set_rect(QRectF rect, const VideoParams &sequence_res,
|
||||
MultiUndoCommand *command)
|
||||
{
|
||||
// Normalize around center of sequence
|
||||
rect.translate(-sequence_res.width() * 0.5, -sequence_res.height() * 0.5);
|
||||
rect.translate(rect.width() * 0.5, rect.height() * 0.5);
|
||||
|
||||
NodeInput pos(this, ShapeNodeBase::kPositionInput);
|
||||
NodeInput sz(this, ShapeNodeBase::kSizeInput);
|
||||
NodeInput pos(this, ShapeNodeBase::k_position_input);
|
||||
NodeInput sz(this, ShapeNodeBase::k_size_input);
|
||||
|
||||
command->add_child(new NodeParamSetStandardValueCommand(
|
||||
NodeKeyframeTrackReference(sz, 0), rect.width()));
|
||||
@@ -133,40 +133,40 @@ void ShapeNodeBase::SetRect(QRectF rect, const VideoParams &sequence_res,
|
||||
NodeKeyframeTrackReference(pos, 1), rect.y()));
|
||||
}
|
||||
|
||||
void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
void ShapeNodeBase::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
if (gizmo == poly_gizmo_) {
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
} else {
|
||||
bool from_center = modifiers & Qt::AltModifier;
|
||||
bool keep_ratio = modifiers & Qt::ShiftModifier;
|
||||
|
||||
NodeInputDragger &w_drag = gizmo->GetDraggers()[2];
|
||||
NodeInputDragger &h_drag = gizmo->GetDraggers()[3];
|
||||
NodeInputDragger &w_drag = gizmo->get_draggers()[2];
|
||||
NodeInputDragger &h_drag = gizmo->get_draggers()[3];
|
||||
|
||||
QVector2D gizmo_sz_start(w_drag.GetStartValue().toDouble(),
|
||||
h_drag.GetStartValue().toDouble());
|
||||
QVector2D gizmo_pos_start(x_drag.GetStartValue().toDouble(),
|
||||
y_drag.GetStartValue().toDouble());
|
||||
QVector2D gizmo_half_res = gizmo->GetGlobals().square_resolution() / 2;
|
||||
QVector2D gizmo_sz_start(w_drag.get_start_value().toDouble(),
|
||||
h_drag.get_start_value().toDouble());
|
||||
QVector2D gizmo_pos_start(x_drag.get_start_value().toDouble(),
|
||||
y_drag.get_start_value().toDouble());
|
||||
QVector2D gizmo_half_res = gizmo->get_globals().square_resolution() / 2;
|
||||
QVector2D adjusted_pt(x, y);
|
||||
QVector2D new_size;
|
||||
QVector2D new_pos;
|
||||
QVector2D anchor;
|
||||
static const int kXYCount = 2;
|
||||
bool negative[kXYCount] = { false };
|
||||
static const int k_xy_count = 2;
|
||||
bool negative[k_xy_count] = { false };
|
||||
|
||||
double original_ratio;
|
||||
if (keep_ratio) {
|
||||
original_ratio = w_drag.GetStartValue().toDouble() /
|
||||
h_drag.GetStartValue().toDouble();
|
||||
original_ratio = w_drag.get_start_value().toDouble() /
|
||||
h_drag.get_start_value().toDouble();
|
||||
}
|
||||
|
||||
// Calculate new size
|
||||
@@ -174,11 +174,11 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
// Calculate new size by using distance from center and doubling it
|
||||
new_size = (adjusted_pt - gizmo_half_res - gizmo_pos_start) * 2;
|
||||
|
||||
if (IsGizmoTop(gizmo)) {
|
||||
if (is_gizmo_top(gizmo)) {
|
||||
new_size.setY(-new_size.y());
|
||||
}
|
||||
|
||||
if (IsGizmoLeft(gizmo)) {
|
||||
if (is_gizmo_left(gizmo)) {
|
||||
new_size.setX(-new_size.x());
|
||||
}
|
||||
} else {
|
||||
@@ -186,7 +186,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
// from the gizmo being dragged
|
||||
adjusted_pt -= gizmo_half_res;
|
||||
|
||||
anchor = GenerateGizmoAnchor(gizmo_pos_start, gizmo_sz_start, gizmo,
|
||||
anchor = generate_gizmo_anchor(gizmo_pos_start, gizmo_sz_start, gizmo,
|
||||
&adjusted_pt) +
|
||||
gizmo_half_res;
|
||||
|
||||
@@ -196,7 +196,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
new_size = adjusted_pt - anchor;
|
||||
|
||||
// Abs size so neither coord is negative
|
||||
for (int i = 0; i < kXYCount; i++) {
|
||||
for (int i = 0; i < k_xy_count; i++) {
|
||||
if (new_size[i] < 0) {
|
||||
negative[i] = true;
|
||||
new_size[i] = -new_size[i];
|
||||
@@ -205,7 +205,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
}
|
||||
|
||||
// Restrict sizes by constraints
|
||||
if (IsGizmoVerticalCenter(gizmo)) {
|
||||
if (is_gizmo_vertical_center(gizmo)) {
|
||||
if (keep_ratio) {
|
||||
// Calculate width from new height
|
||||
new_size.setX(new_size.y() * original_ratio);
|
||||
@@ -215,7 +215,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoHorizontalCenter(gizmo)) {
|
||||
if (is_gizmo_horizontal_center(gizmo)) {
|
||||
if (keep_ratio) {
|
||||
// Calculate height from new width
|
||||
new_size.setY(new_size.x() / original_ratio);
|
||||
@@ -225,7 +225,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoCorner(gizmo)) {
|
||||
if (is_gizmo_corner(gizmo)) {
|
||||
if (keep_ratio) {
|
||||
float hypot = std::hypot(new_size.x(), new_size.y());
|
||||
|
||||
@@ -245,34 +245,34 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
QVector2D using_size = new_size;
|
||||
|
||||
// Un-abs size
|
||||
for (int i = 0; i < kXYCount; i++) {
|
||||
for (int i = 0; i < k_xy_count; i++) {
|
||||
if (negative[i]) {
|
||||
using_size[i] = -using_size[i];
|
||||
}
|
||||
}
|
||||
|
||||
// I'm pretty sure there's an algorithmic way of doing this, but I'm tired and this works
|
||||
if (IsGizmoHorizontalCenter(gizmo)) {
|
||||
if (is_gizmo_horizontal_center(gizmo)) {
|
||||
using_size.setY(0);
|
||||
}
|
||||
|
||||
if (IsGizmoVerticalCenter(gizmo)) {
|
||||
if (is_gizmo_vertical_center(gizmo)) {
|
||||
using_size.setX(0);
|
||||
}
|
||||
|
||||
new_pos =
|
||||
GenerateGizmoAnchor(gizmo_pos_start, gizmo_sz_start, gizmo) +
|
||||
generate_gizmo_anchor(gizmo_pos_start, gizmo_sz_start, gizmo) +
|
||||
using_size / 2;
|
||||
}
|
||||
|
||||
x_drag.Drag(new_pos.x());
|
||||
y_drag.Drag(new_pos.y());
|
||||
w_drag.Drag(new_size.x());
|
||||
h_drag.Drag(new_size.y());
|
||||
x_drag.drag(new_pos.x());
|
||||
y_drag.drag(new_pos.y());
|
||||
w_drag.drag(new_size.x());
|
||||
h_drag.drag(new_size.y());
|
||||
}
|
||||
}
|
||||
|
||||
QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos,
|
||||
QVector2D ShapeNodeBase::generate_gizmo_anchor(const QVector2D &pos,
|
||||
const QVector2D &size,
|
||||
NodeGizmo *gizmo,
|
||||
QVector2D *pt) const
|
||||
@@ -280,28 +280,28 @@ QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos,
|
||||
QVector2D anchor = pos;
|
||||
QVector2D half_sz = size / 2;
|
||||
|
||||
if (IsGizmoLeft(gizmo)) {
|
||||
if (is_gizmo_left(gizmo)) {
|
||||
anchor.setX(anchor.x() + half_sz.x());
|
||||
if (pt && pt->x() > anchor.x()) {
|
||||
pt->setX(anchor.x());
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoRight(gizmo)) {
|
||||
if (is_gizmo_right(gizmo)) {
|
||||
anchor.setX(anchor.x() - half_sz.x());
|
||||
if (pt && pt->x() < anchor.x()) {
|
||||
pt->setX(anchor.x());
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoTop(gizmo)) {
|
||||
if (is_gizmo_top(gizmo)) {
|
||||
anchor.setY(anchor.y() + half_sz.y());
|
||||
if (pt && pt->y() > anchor.y()) {
|
||||
pt->setY(anchor.y());
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoBottom(gizmo)) {
|
||||
if (is_gizmo_bottom(gizmo)) {
|
||||
anchor.setY(anchor.y() - half_sz.y());
|
||||
if (pt && pt->y() < anchor.y()) {
|
||||
pt->setY(anchor.y());
|
||||
@@ -311,52 +311,52 @@ QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos,
|
||||
return anchor;
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoTop(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_top(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopCenter] ||
|
||||
g == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleTopRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_center] ||
|
||||
g == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_top_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoBottom(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_bottom(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleBottomCenter] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_bottom_center] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoLeft(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_left(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleCenterLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomLeft];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_center_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_left];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoRight(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_right(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
g == point_gizmo_[kGizmoScaleCenterRight] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_center_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoHorizontalCenter(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_horizontal_center(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleCenterLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleCenterRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_center_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_center_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoVerticalCenter(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_vertical_center(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopCenter] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomCenter];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_center] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_center];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoCorner(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_corner(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomRight] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomLeft];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_left];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SHAPENODEBASE_H
|
||||
#define SHAPENODEBASE_H
|
||||
#ifndef OAK_SHAPENODEBASE_H
|
||||
#define OAK_SHAPENODEBASE_H
|
||||
|
||||
#include "generatorwithmerge.h"
|
||||
#include "node/gizmo/point.h"
|
||||
@@ -36,17 +36,17 @@ class ShapeNodeBase : public GeneratorWithMerge {
|
||||
public:
|
||||
ShapeNodeBase(bool create_color_input = true);
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
void SetRect(QRectF rect, const VideoParams &sequence_res,
|
||||
void set_rect(QRectF rect, const VideoParams &sequence_res,
|
||||
MultiUndoCommand *command);
|
||||
|
||||
static const QString kPositionInput;
|
||||
static const QString kSizeInput;
|
||||
static const QString kColorInput;
|
||||
static const QString k_position_input;
|
||||
static const QString k_size_input;
|
||||
static const QString k_color_input;
|
||||
|
||||
protected:
|
||||
PolygonGizmo *poly_gizmo() const
|
||||
@@ -55,28 +55,28 @@ protected:
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
QVector2D GenerateGizmoAnchor(const QVector2D &pos, const QVector2D &size,
|
||||
QVector2D generate_gizmo_anchor(const QVector2D &pos, const QVector2D &size,
|
||||
NodeGizmo *gizmo,
|
||||
QVector2D *pt = nullptr) const;
|
||||
|
||||
bool IsGizmoTop(NodeGizmo *g) const;
|
||||
bool IsGizmoBottom(NodeGizmo *g) const;
|
||||
bool IsGizmoLeft(NodeGizmo *g) const;
|
||||
bool IsGizmoRight(NodeGizmo *g) const;
|
||||
bool IsGizmoHorizontalCenter(NodeGizmo *g) const;
|
||||
bool IsGizmoVerticalCenter(NodeGizmo *g) const;
|
||||
bool IsGizmoCorner(NodeGizmo *g) const;
|
||||
bool is_gizmo_top(NodeGizmo *g) const;
|
||||
bool is_gizmo_bottom(NodeGizmo *g) const;
|
||||
bool is_gizmo_left(NodeGizmo *g) const;
|
||||
bool is_gizmo_right(NodeGizmo *g) const;
|
||||
bool is_gizmo_horizontal_center(NodeGizmo *g) const;
|
||||
bool is_gizmo_vertical_center(NodeGizmo *g) const;
|
||||
bool is_gizmo_corner(NodeGizmo *g) const;
|
||||
|
||||
// Gizmo variables
|
||||
static const int kGizmoWholeRect = kGizmoScaleCount;
|
||||
PointGizmo *point_gizmo_[kGizmoScaleCount];
|
||||
static const int k_gizmo_whole_rect = k_gizmo_scale_count;
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SHAPENODEBASE_H
|
||||
#endif // OAK_SHAPENODEBASE_H
|
||||
|
||||
@@ -24,18 +24,18 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString SolidGenerator::kColorInput = QStringLiteral("color_in");
|
||||
const QString SolidGenerator::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
SolidGenerator::SolidGenerator()
|
||||
{
|
||||
// Default to a color that isn't black
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||
}
|
||||
|
||||
QString SolidGenerator::Name() const
|
||||
QString SolidGenerator::name() const
|
||||
{
|
||||
return tr("Solid");
|
||||
}
|
||||
@@ -45,36 +45,36 @@ QString SolidGenerator::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.solidgenerator");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> SolidGenerator::Category() const
|
||||
QVector<Node::CategoryID> SolidGenerator::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString SolidGenerator::Description() const
|
||||
QString SolidGenerator::description() const
|
||||
{
|
||||
return tr("Generate a solid color.");
|
||||
}
|
||||
|
||||
void SolidGenerator::Retranslate()
|
||||
void SolidGenerator::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
void SolidGenerator::Value(const NodeValueRow &value,
|
||||
void SolidGenerator::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(globals.vparams(), ShaderJob(value)), this);
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(globals.vparams(), ShaderJob(value)), this);
|
||||
}
|
||||
|
||||
ShaderCode SolidGenerator::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode SolidGenerator::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/solid.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/solid.frag"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SOLIDGENERATOR_H
|
||||
#define SOLIDGENERATOR_H
|
||||
#ifndef OAK_SOLIDGENERATOR_H
|
||||
#define OAK_SOLIDGENERATOR_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,21 +34,21 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(SolidGenerator)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kColorInput;
|
||||
static const QString k_color_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SOLIDGENERATOR_H
|
||||
#endif // OAK_SOLIDGENERATOR_H
|
||||
|
||||
@@ -28,39 +28,39 @@ namespace olive
|
||||
{
|
||||
|
||||
enum TextVerticalAlign {
|
||||
kVerticalAlignTop,
|
||||
kVerticalAlignCenter,
|
||||
kVerticalAlignBottom,
|
||||
k_vertical_align_top,
|
||||
k_vertical_align_center,
|
||||
k_vertical_align_bottom,
|
||||
};
|
||||
|
||||
const QString TextGeneratorV1::kTextInput = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV1::kHtmlInput = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV1::kColorInput = QStringLiteral("color_in");
|
||||
const QString TextGeneratorV1::kVAlignInput = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV1::kFontInput = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV1::kFontSizeInput = QStringLiteral("font_size_in");
|
||||
const QString TextGeneratorV1::k_text_input = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV1::k_html_input = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV1::k_color_input = QStringLiteral("color_in");
|
||||
const QString TextGeneratorV1::k_v_align_input = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV1::k_font_input = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV1::k_font_size_input = QStringLiteral("font_size_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
TextGeneratorV1::TextGeneratorV1()
|
||||
{
|
||||
AddInput(kTextInput, NodeValue::kText, tr("Sample Text"));
|
||||
add_input(k_text_input, NodeValue::k_text, tr("Sample Text"));
|
||||
|
||||
AddInput(kHtmlInput, NodeValue::kBoolean, false);
|
||||
add_input(k_html_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
|
||||
AddInput(kVAlignInput, NodeValue::kCombo, 1);
|
||||
add_input(k_v_align_input, NodeValue::k_combo, 1);
|
||||
|
||||
AddInput(kFontInput, NodeValue::kFont);
|
||||
add_input(k_font_input, NodeValue::k_font);
|
||||
|
||||
AddInput(kFontSizeInput, NodeValue::kFloat, 72.0f);
|
||||
add_input(k_font_size_input, NodeValue::k_float, 72.0f);
|
||||
|
||||
SetFlag(kDontShowInCreateMenu);
|
||||
set_flag(k_dont_show_in_create_menu);
|
||||
}
|
||||
|
||||
QString TextGeneratorV1::Name() const
|
||||
QString TextGeneratorV1::name() const
|
||||
{
|
||||
return tr("Text (Legacy)");
|
||||
}
|
||||
@@ -70,40 +70,40 @@ QString TextGeneratorV1::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.textgenerator");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TextGeneratorV1::Category() const
|
||||
QVector<Node::CategoryID> TextGeneratorV1::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString TextGeneratorV1::Description() const
|
||||
QString TextGeneratorV1::description() const
|
||||
{
|
||||
return tr("Generate rich text.");
|
||||
}
|
||||
|
||||
void TextGeneratorV1::Retranslate()
|
||||
void TextGeneratorV1::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextInput, tr("Text"));
|
||||
SetInputName(kHtmlInput, tr("Enable HTML"));
|
||||
SetInputName(kFontInput, tr("Font"));
|
||||
SetInputName(kFontSizeInput, tr("Font Size"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
SetInputName(kVAlignInput, tr("Vertical Align"));
|
||||
SetComboBoxStrings(kVAlignInput, { tr("Top"), tr("Center"), tr("Bottom") });
|
||||
set_input_name(k_text_input, tr("Text"));
|
||||
set_input_name(k_html_input, tr("Enable HTML"));
|
||||
set_input_name(k_font_input, tr("Font"));
|
||||
set_input_name(k_font_size_input, tr("Font Size"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
set_input_name(k_v_align_input, tr("Vertical Align"));
|
||||
set_combo_box_strings(k_v_align_input, { tr("Top"), tr("Center"), tr("Bottom") });
|
||||
}
|
||||
|
||||
void TextGeneratorV1::Value(const NodeValueRow &value,
|
||||
void TextGeneratorV1::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (!value[kTextInput].toString().isEmpty()) {
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(globals.vparams(), GenerateJob(value)), this);
|
||||
if (!value[k_text_input].to_string().isEmpty()) {
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(globals.vparams(), GenerateJob(value)), this);
|
||||
}
|
||||
}
|
||||
|
||||
void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
void TextGeneratorV1::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
// This could probably be more optimized, but for now we use Qt to draw to a QImage.
|
||||
@@ -117,15 +117,15 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
|
||||
// Set default font
|
||||
QFont default_font;
|
||||
default_font.setFamily(job.Get(kFontInput).toString());
|
||||
default_font.setPointSizeF(job.Get(kFontSizeInput).toDouble());
|
||||
default_font.setFamily(job.get(k_font_input).to_string());
|
||||
default_font.setPointSizeF(job.get(k_font_size_input).to_double());
|
||||
text_doc.setDefaultFont(default_font);
|
||||
|
||||
// Center by default
|
||||
text_doc.setDefaultTextOption(QTextOption(Qt::AlignCenter));
|
||||
|
||||
QString html = job.Get(kTextInput).toString();
|
||||
if (job.Get(kHtmlInput).toBool()) {
|
||||
QString html = job.get(k_text_input).to_string();
|
||||
if (job.get(k_html_input).to_bool()) {
|
||||
html.replace('\n', QStringLiteral("<br>"));
|
||||
text_doc.setHtml(html);
|
||||
} else {
|
||||
@@ -145,19 +145,19 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
p.translate(tenth_of_width, 0);
|
||||
|
||||
TextVerticalAlign valign =
|
||||
static_cast<TextVerticalAlign>(job.Get(kVAlignInput).toInt());
|
||||
static_cast<TextVerticalAlign>(job.get(k_v_align_input).to_int());
|
||||
int doc_height = text_doc.size().height();
|
||||
|
||||
switch (valign) {
|
||||
case kVerticalAlignTop:
|
||||
case k_vertical_align_top:
|
||||
// Push 10% inwards for title safe area
|
||||
p.translate(0, frame->video_params().height() / 10);
|
||||
break;
|
||||
case kVerticalAlignCenter:
|
||||
case k_vertical_align_center:
|
||||
// Center align
|
||||
p.translate(0, frame->video_params().height() / 2 - doc_height / 2);
|
||||
break;
|
||||
case kVerticalAlignBottom:
|
||||
case k_vertical_align_bottom:
|
||||
// Push 10% inwards for title safe area
|
||||
p.translate(0, frame->video_params().height() - doc_height -
|
||||
frame->video_params().height() / 10);
|
||||
@@ -169,7 +169,7 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
text_doc.documentLayout()->draw(&p, ctx);
|
||||
|
||||
// Transplant alpha channel to frame
|
||||
Color rgb = job.Get(kColorInput).toColor();
|
||||
Color rgb = job.get(k_color_input).to_color();
|
||||
for (int x = 0; x < frame->width(); x++) {
|
||||
for (int y = 0; y < frame->height(); y++) {
|
||||
uchar src_alpha = img.bits()[img.bytesPerLine() * y + x];
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTGENERATORV1_H
|
||||
#define TEXTGENERATORV1_H
|
||||
#ifndef OAK_TEXTGENERATORV1_H
|
||||
#define OAK_TEXTGENERATORV1_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,27 +34,27 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TextGeneratorV1)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
static const QString kTextInput;
|
||||
static const QString kHtmlInput;
|
||||
static const QString kColorInput;
|
||||
static const QString kVAlignInput;
|
||||
static const QString kFontInput;
|
||||
static const QString kFontSizeInput;
|
||||
static const QString k_text_input;
|
||||
static const QString k_html_input;
|
||||
static const QString k_color_input;
|
||||
static const QString k_v_align_input;
|
||||
static const QString k_font_input;
|
||||
static const QString k_font_size_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TEXTGENERATORV1_H
|
||||
#endif // OAK_TEXTGENERATORV1_H
|
||||
|
||||
@@ -32,36 +32,36 @@ namespace olive
|
||||
#define super ShapeNodeBase
|
||||
|
||||
enum TextVerticalAlign {
|
||||
kVerticalAlignTop,
|
||||
kVerticalAlignCenter,
|
||||
kVerticalAlignBottom,
|
||||
k_vertical_align_top,
|
||||
k_vertical_align_center,
|
||||
k_vertical_align_bottom,
|
||||
};
|
||||
|
||||
const QString TextGeneratorV2::kTextInput = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV2::kHtmlInput = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV2::kVAlignInput = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV2::kFontInput = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV2::kFontSizeInput = QStringLiteral("font_size_in");
|
||||
const QString TextGeneratorV2::k_text_input = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV2::k_html_input = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV2::k_v_align_input = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV2::k_font_input = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV2::k_font_size_input = QStringLiteral("font_size_in");
|
||||
|
||||
TextGeneratorV2::TextGeneratorV2()
|
||||
{
|
||||
AddInput(kTextInput, NodeValue::kText, tr("Sample Text"));
|
||||
add_input(k_text_input, NodeValue::k_text, tr("Sample Text"));
|
||||
|
||||
AddInput(kHtmlInput, NodeValue::kBoolean, false);
|
||||
add_input(k_html_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kVAlignInput, NodeValue::kCombo, kVerticalAlignTop);
|
||||
add_input(k_v_align_input, NodeValue::k_combo, k_vertical_align_top);
|
||||
|
||||
AddInput(kFontInput, NodeValue::kFont);
|
||||
add_input(k_font_input, NodeValue::k_font);
|
||||
|
||||
AddInput(kFontSizeInput, NodeValue::kFloat, 72.0f);
|
||||
add_input(k_font_size_input, NodeValue::k_float, 72.0f);
|
||||
|
||||
SetStandardValue(kColorInput, QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
SetStandardValue(kSizeInput, QVector2D(400, 300));
|
||||
set_standard_value(k_color_input, QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
set_standard_value(k_size_input, QVector2D(400, 300));
|
||||
|
||||
SetFlag(kDontShowInCreateMenu);
|
||||
set_flag(k_dont_show_in_create_menu);
|
||||
}
|
||||
|
||||
QString TextGeneratorV2::Name() const
|
||||
QString TextGeneratorV2::name() const
|
||||
{
|
||||
return tr("Text (Legacy)");
|
||||
}
|
||||
@@ -71,41 +71,41 @@ QString TextGeneratorV2::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.text2");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TextGeneratorV2::Category() const
|
||||
QVector<Node::CategoryID> TextGeneratorV2::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString TextGeneratorV2::Description() const
|
||||
QString TextGeneratorV2::description() const
|
||||
{
|
||||
return tr("Generate rich text.");
|
||||
}
|
||||
|
||||
void TextGeneratorV2::Retranslate()
|
||||
void TextGeneratorV2::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextInput, tr("Text"));
|
||||
SetInputName(kHtmlInput, tr("Enable HTML"));
|
||||
SetInputName(kFontInput, tr("Font"));
|
||||
SetInputName(kFontSizeInput, tr("Font Size"));
|
||||
SetInputName(kVAlignInput, tr("Vertical Align"));
|
||||
SetComboBoxStrings(kVAlignInput, { tr("Top"), tr("Center"), tr("Bottom") });
|
||||
set_input_name(k_text_input, tr("Text"));
|
||||
set_input_name(k_html_input, tr("Enable HTML"));
|
||||
set_input_name(k_font_input, tr("Font"));
|
||||
set_input_name(k_font_size_input, tr("Font Size"));
|
||||
set_input_name(k_v_align_input, tr("Vertical Align"));
|
||||
set_combo_box_strings(k_v_align_input, { tr("Top"), tr("Center"), tr("Bottom") });
|
||||
}
|
||||
|
||||
void TextGeneratorV2::Value(const NodeValueRow &value,
|
||||
void TextGeneratorV2::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (!value[kTextInput].toString().isEmpty()) {
|
||||
if (!value[k_text_input].to_string().isEmpty()) {
|
||||
GenerateJob job(value);
|
||||
auto text_params = globals.vparams();
|
||||
text_params.set_format(PixelFormat::F32);
|
||||
table->Push(NodeValue::kTexture, Texture::Job(text_params, job), this);
|
||||
text_params.set_format(PixelFormat::f32);
|
||||
table->push(NodeValue::k_texture, Texture::job(text_params, job), this);
|
||||
}
|
||||
}
|
||||
|
||||
void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
void TextGeneratorV2::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
// This could probably be more optimized, but for now we use Qt to draw to a QImage.
|
||||
@@ -125,19 +125,19 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
|
||||
// Set default font
|
||||
QFont default_font;
|
||||
default_font.setFamily(job.Get(kFontInput).toString());
|
||||
default_font.setPointSizeF(job.Get(kFontSizeInput).toDouble());
|
||||
default_font.setFamily(job.get(k_font_input).to_string());
|
||||
default_font.setPointSizeF(job.get(k_font_size_input).to_double());
|
||||
text_doc.setDefaultFont(default_font);
|
||||
|
||||
QString html = job.Get(kTextInput).toString();
|
||||
if (job.Get(kHtmlInput).toBool()) {
|
||||
QString html = job.get(k_text_input).to_string();
|
||||
if (job.get(k_html_input).to_bool()) {
|
||||
html.replace('\n', QStringLiteral("<br>"));
|
||||
text_doc.setHtml(html);
|
||||
} else {
|
||||
text_doc.setPlainText(html);
|
||||
}
|
||||
|
||||
QVector2D size = job.Get(kSizeInput).toVec2();
|
||||
QVector2D size = job.get(k_size_input).to_vec2();
|
||||
text_doc.setTextWidth(size.x());
|
||||
|
||||
// Draw rich text onto image
|
||||
@@ -145,25 +145,25 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
p.scale(1.0 / frame->video_params().divider(),
|
||||
1.0 / frame->video_params().divider());
|
||||
|
||||
QVector2D pos = job.Get(kPositionInput).toVec2();
|
||||
QVector2D pos = job.get(k_position_input).to_vec2();
|
||||
p.translate(pos.x() - size.x() / 2, pos.y() - size.y() / 2);
|
||||
p.translate(frame->video_params().width() / 2,
|
||||
frame->video_params().height() / 2);
|
||||
p.setClipRect(0, 0, size.x(), size.y());
|
||||
|
||||
TextVerticalAlign valign =
|
||||
static_cast<TextVerticalAlign>(job.Get(kVAlignInput).toInt());
|
||||
static_cast<TextVerticalAlign>(job.get(k_v_align_input).to_int());
|
||||
int doc_height = text_doc.size().height();
|
||||
|
||||
switch (valign) {
|
||||
case kVerticalAlignTop:
|
||||
case k_vertical_align_top:
|
||||
// Do nothing
|
||||
break;
|
||||
case kVerticalAlignCenter:
|
||||
case k_vertical_align_center:
|
||||
// Center align
|
||||
p.translate(0, size.y() / 2 - doc_height / 2);
|
||||
break;
|
||||
case kVerticalAlignBottom:
|
||||
case k_vertical_align_bottom:
|
||||
p.translate(0, size.y() - doc_height);
|
||||
break;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
text_doc.documentLayout()->draw(&p, ctx);
|
||||
|
||||
// Transplant alpha channel to frame
|
||||
Color rgba = job.Get(kColorInput).toColor();
|
||||
Color rgba = job.get(k_color_input).to_color();
|
||||
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
|
||||
__m128 sse_color = _mm_loadu_ps(rgba.data());
|
||||
#endif
|
||||
@@ -183,11 +183,11 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
for (int y = 0; y < frame->height(); y++) {
|
||||
uchar *src_y = img.bits() + img.bytesPerLine() * y;
|
||||
float *dst_y = frame_dst + y * frame->linesize_pixels() *
|
||||
VideoParams::kRGBAChannelCount;
|
||||
VideoParams::k_rgba_channel_count;
|
||||
|
||||
for (int x = 0; x < frame->width(); x++) {
|
||||
float alpha = float(src_y[x]) / 255.0f;
|
||||
float *dst = dst_y + x * VideoParams::kRGBAChannelCount;
|
||||
float *dst = dst_y + x * VideoParams::k_rgba_channel_count;
|
||||
|
||||
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
|
||||
__m128 sse_alpha = _mm_load1_ps(&alpha);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTGENERATORV2_H
|
||||
#define TEXTGENERATORV2_H
|
||||
#ifndef OAK_TEXTGENERATORV2_H
|
||||
#define OAK_TEXTGENERATORV2_H
|
||||
|
||||
#include "node/generator/shape/shapenodebase.h"
|
||||
|
||||
@@ -34,26 +34,26 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TextGeneratorV2)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
static const QString kTextInput;
|
||||
static const QString kHtmlInput;
|
||||
static const QString kVAlignInput;
|
||||
static const QString kFontInput;
|
||||
static const QString kFontSizeInput;
|
||||
static const QString k_text_input;
|
||||
static const QString k_html_input;
|
||||
static const QString k_v_align_input;
|
||||
static const QString k_font_input;
|
||||
static const QString k_font_size_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TEXTGENERATORV2_H
|
||||
#endif // OAK_TEXTGENERATORV2_H
|
||||
|
||||
@@ -36,46 +36,46 @@ namespace olive
|
||||
#define super ShapeNodeBase
|
||||
|
||||
enum TextVerticalAlign {
|
||||
kVerticalAlignTop,
|
||||
kVerticalAlignCenter,
|
||||
kVerticalAlignBottom,
|
||||
k_vertical_align_top,
|
||||
k_vertical_align_center,
|
||||
k_vertical_align_bottom,
|
||||
};
|
||||
|
||||
const QString TextGeneratorV3::kTextInput = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV3::kVerticalAlignmentInput =
|
||||
const QString TextGeneratorV3::k_text_input = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV3::k_vertical_alignment_input =
|
||||
QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV3::kUseArgsInput = QStringLiteral("use_args_in");
|
||||
const QString TextGeneratorV3::kArgsInput = QStringLiteral("args_in");
|
||||
const QString TextGeneratorV3::k_use_args_input = QStringLiteral("use_args_in");
|
||||
const QString TextGeneratorV3::k_args_input = QStringLiteral("args_in");
|
||||
|
||||
TextGeneratorV3::TextGeneratorV3()
|
||||
: ShapeNodeBase(false)
|
||||
, dont_emit_valign_(false)
|
||||
{
|
||||
AddInput(kTextInput, NodeValue::kText,
|
||||
add_input(k_text_input, NodeValue::k_text,
|
||||
QStringLiteral("<p style='font-size: 72pt; color: white;'>%1</p>")
|
||||
.arg(tr("Sample Text")));
|
||||
SetInputProperty(kTextInput, QStringLiteral("vieweronly"), true);
|
||||
set_input_property(k_text_input, QStringLiteral("vieweronly"), true);
|
||||
|
||||
SetStandardValue(kSizeInput, QVector2D(400, 300));
|
||||
set_standard_value(k_size_input, QVector2D(400, 300));
|
||||
|
||||
AddInput(kVerticalAlignmentInput, NodeValue::kCombo,
|
||||
InputFlags(kInputFlagHidden | kInputFlagStatic));
|
||||
add_input(k_vertical_alignment_input, NodeValue::k_combo,
|
||||
InputFlags(k_input_flag_hidden | k_input_flag_static));
|
||||
|
||||
AddInput(kUseArgsInput, NodeValue::kBoolean, true,
|
||||
InputFlags(kInputFlagHidden | kInputFlagStatic));
|
||||
add_input(k_use_args_input, NodeValue::k_boolean, true,
|
||||
InputFlags(k_input_flag_hidden | k_input_flag_static));
|
||||
|
||||
AddInput(kArgsInput, NodeValue::kText, InputFlags(kInputFlagArray));
|
||||
SetInputProperty(kArgsInput, QStringLiteral("arraystart"), 1);
|
||||
add_input(k_args_input, NodeValue::k_text, InputFlags(k_input_flag_array));
|
||||
set_input_property(k_args_input, QStringLiteral("arraystart"), 1);
|
||||
|
||||
text_gizmo_ = new TextGizmo(this);
|
||||
text_gizmo_->SetInput(NodeInput(this, kTextInput));
|
||||
connect(text_gizmo_, &TextGizmo::Activated, this,
|
||||
&TextGeneratorV3::GizmoActivated);
|
||||
connect(text_gizmo_, &TextGizmo::Deactivated, this,
|
||||
&TextGeneratorV3::GizmoDeactivated);
|
||||
text_gizmo_->set_input(NodeInput(this, k_text_input));
|
||||
connect(text_gizmo_, &TextGizmo::activated, this,
|
||||
&TextGeneratorV3::gizmo_activated);
|
||||
connect(text_gizmo_, &TextGizmo::deactivated, this,
|
||||
&TextGeneratorV3::gizmo_deactivated);
|
||||
}
|
||||
|
||||
QString TextGeneratorV3::Name() const
|
||||
QString TextGeneratorV3::name() const
|
||||
{
|
||||
return tr("Text");
|
||||
}
|
||||
@@ -85,64 +85,64 @@ QString TextGeneratorV3::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.text3");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TextGeneratorV3::Category() const
|
||||
QVector<Node::CategoryID> TextGeneratorV3::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString TextGeneratorV3::Description() const
|
||||
QString TextGeneratorV3::description() const
|
||||
{
|
||||
return tr("Generate rich text.");
|
||||
}
|
||||
|
||||
void TextGeneratorV3::Retranslate()
|
||||
void TextGeneratorV3::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextInput, tr("Text"));
|
||||
SetInputName(kVerticalAlignmentInput, tr("Vertical Alignment"));
|
||||
SetComboBoxStrings(kVerticalAlignmentInput,
|
||||
set_input_name(k_text_input, tr("Text"));
|
||||
set_input_name(k_vertical_alignment_input, tr("Vertical Alignment"));
|
||||
set_combo_box_strings(k_vertical_alignment_input,
|
||||
{ tr("Top"), tr("Middle"), tr("Bottom") });
|
||||
SetInputName(kArgsInput, tr("Arguments"));
|
||||
set_input_name(k_args_input, tr("Arguments"));
|
||||
}
|
||||
|
||||
void TextGeneratorV3::Value(const NodeValueRow &value,
|
||||
void TextGeneratorV3::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
QString text = value[kTextInput].toString();
|
||||
QString text = value[k_text_input].to_string();
|
||||
|
||||
if (value[kUseArgsInput].toBool()) {
|
||||
auto args = value[kArgsInput].toArray();
|
||||
if (value[k_use_args_input].to_bool()) {
|
||||
auto args = value[k_args_input].to_array();
|
||||
if (!args.empty()) {
|
||||
QStringList list;
|
||||
list.reserve(args.size());
|
||||
for (size_t i = 0; i < args.size(); i++) {
|
||||
list.append(args[i].toString());
|
||||
list.append(args[i].to_string());
|
||||
}
|
||||
|
||||
text = FormatString(text, list);
|
||||
text = format_string(text, list);
|
||||
}
|
||||
}
|
||||
|
||||
if (!text.isEmpty()) {
|
||||
TexturePtr base = value[kTextInput].toTexture();
|
||||
TexturePtr base = value[k_text_input].to_texture();
|
||||
|
||||
VideoParams text_params = base ? base->params() : globals.vparams();
|
||||
text_params.set_format(PixelFormat::U8);
|
||||
text_params.set_format(PixelFormat::u8);
|
||||
text_params.set_colorspace(
|
||||
project()->color_manager()->GetDefaultInputColorSpace());
|
||||
project()->color_manager()->get_default_input_color_space());
|
||||
|
||||
GenerateJob job(value);
|
||||
job.Insert(kTextInput, NodeValue(NodeValue::kText, text));
|
||||
job.insert(k_text_input, NodeValue(NodeValue::k_text, text));
|
||||
|
||||
PushMergableJob(value, Texture::Job(text_params, job), table);
|
||||
} else if (value[kBaseInput].toTexture()) {
|
||||
table->Push(value[kBaseInput]);
|
||||
push_mergable_job(value, Texture::job(text_params, job), table);
|
||||
} else if (value[k_base_input].to_texture()) {
|
||||
table->push(value[k_base_input]);
|
||||
}
|
||||
}
|
||||
|
||||
void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
void TextGeneratorV3::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
QImage img(reinterpret_cast<uchar *>(frame->data()), frame->width(),
|
||||
@@ -158,10 +158,10 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
QTextDocument text_doc;
|
||||
text_doc.documentLayout()->setPaintDevice(&img);
|
||||
|
||||
QString html = job.Get(kTextInput).toString();
|
||||
Html::HtmlToDoc(&text_doc, html);
|
||||
QString html = job.get(k_text_input).to_string();
|
||||
Html::html_to_doc(&text_doc, html);
|
||||
|
||||
QVector2D size = job.Get(kSizeInput).toVec2();
|
||||
QVector2D size = job.get(k_size_input).to_vec2();
|
||||
text_doc.setTextWidth(size.x());
|
||||
|
||||
// Draw rich text onto image
|
||||
@@ -169,21 +169,21 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
p.scale(1.0 / frame->video_params().divider(),
|
||||
1.0 / frame->video_params().divider());
|
||||
|
||||
QVector2D pos = job.Get(kPositionInput).toVec2();
|
||||
QVector2D pos = job.get(k_position_input).to_vec2();
|
||||
p.translate(pos.x() - size.x() / 2, pos.y() - size.y() / 2);
|
||||
p.translate(frame->video_params().width() / 2,
|
||||
frame->video_params().height() / 2);
|
||||
p.setClipRect(0, 0, size.x(), size.y());
|
||||
|
||||
switch (static_cast<VerticalAlignment>(
|
||||
job.Get(kVerticalAlignmentInput).toInt())) {
|
||||
case kVAlignTop:
|
||||
job.get(k_vertical_alignment_input).to_int())) {
|
||||
case k_v_align_top:
|
||||
// Do nothing
|
||||
break;
|
||||
case kVAlignMiddle:
|
||||
case k_v_align_middle:
|
||||
p.translate(0, size.y() / 2 - text_doc.size().height() / 2);
|
||||
break;
|
||||
case kVAlignBottom:
|
||||
case k_v_align_bottom:
|
||||
p.translate(0, size.y() - text_doc.size().height());
|
||||
break;
|
||||
}
|
||||
@@ -195,45 +195,45 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
text_doc.documentLayout()->draw(&p, ctx);
|
||||
}
|
||||
|
||||
void TextGeneratorV3::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void TextGeneratorV3::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
super::UpdateGizmoPositions(row, globals);
|
||||
super::update_gizmo_positions(row, globals);
|
||||
|
||||
QRectF rect = poly_gizmo()->GetPolygon().boundingRect();
|
||||
text_gizmo_->SetRect(rect);
|
||||
text_gizmo_->SetHtml(row[kTextInput].toString());
|
||||
QRectF rect = poly_gizmo()->get_polygon().boundingRect();
|
||||
text_gizmo_->set_rect(rect);
|
||||
text_gizmo_->set_html(row[k_text_input].to_string());
|
||||
}
|
||||
|
||||
Qt::Alignment TextGeneratorV3::GetQtAlignmentFromOurs(VerticalAlignment v)
|
||||
Qt::Alignment TextGeneratorV3::get_qt_alignment_from_ours(VerticalAlignment v)
|
||||
{
|
||||
switch (v) {
|
||||
case kVAlignTop:
|
||||
case k_v_align_top:
|
||||
return Qt::AlignTop;
|
||||
case kVAlignMiddle:
|
||||
case k_v_align_middle:
|
||||
return Qt::AlignVCenter;
|
||||
case kVAlignBottom:
|
||||
case k_v_align_bottom:
|
||||
return Qt::AlignBottom;
|
||||
}
|
||||
return Qt::Alignment();
|
||||
}
|
||||
|
||||
TextGeneratorV3::VerticalAlignment
|
||||
TextGeneratorV3::GetOurAlignmentFromQts(Qt::Alignment v)
|
||||
TextGeneratorV3::get_our_alignment_from_qts(Qt::Alignment v)
|
||||
{
|
||||
switch (v) {
|
||||
case Qt::AlignTop:
|
||||
return kVAlignTop;
|
||||
return k_v_align_top;
|
||||
case Qt::AlignVCenter:
|
||||
return kVAlignMiddle;
|
||||
return k_v_align_middle;
|
||||
case Qt::AlignBottom:
|
||||
return kVAlignBottom;
|
||||
return k_v_align_bottom;
|
||||
}
|
||||
|
||||
return kVAlignTop;
|
||||
return k_v_align_top;
|
||||
}
|
||||
|
||||
QString TextGeneratorV3::FormatString(const QString &input,
|
||||
QString TextGeneratorV3::format_string(const QString &input,
|
||||
const QStringList &args)
|
||||
{
|
||||
QString output;
|
||||
@@ -274,36 +274,36 @@ QString TextGeneratorV3::FormatString(const QString &input,
|
||||
|
||||
void TextGeneratorV3::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
if (input == kVerticalAlignmentInput && !dont_emit_valign_) {
|
||||
text_gizmo_->SetVerticalAlignment(
|
||||
GetQtAlignmentFromOurs(GetVerticalAlignment()));
|
||||
if (input == k_vertical_alignment_input && !dont_emit_valign_) {
|
||||
text_gizmo_->set_vertical_alignment(
|
||||
get_qt_alignment_from_ours(get_vertical_alignment()));
|
||||
}
|
||||
|
||||
super::InputValueChangedEvent(input, element);
|
||||
}
|
||||
|
||||
void TextGeneratorV3::GizmoActivated()
|
||||
void TextGeneratorV3::gizmo_activated()
|
||||
{
|
||||
SetStandardValue(kUseArgsInput, false);
|
||||
connect(text_gizmo_, &TextGizmo::VerticalAlignmentChanged, this,
|
||||
&TextGeneratorV3::SetVerticalAlignmentUndoable);
|
||||
set_standard_value(k_use_args_input, false);
|
||||
connect(text_gizmo_, &TextGizmo::vertical_alignment_changed, this,
|
||||
&TextGeneratorV3::set_vertical_alignment_undoable);
|
||||
dont_emit_valign_ = true;
|
||||
}
|
||||
|
||||
void TextGeneratorV3::GizmoDeactivated()
|
||||
void TextGeneratorV3::gizmo_deactivated()
|
||||
{
|
||||
SetStandardValue(kUseArgsInput, true);
|
||||
disconnect(text_gizmo_, &TextGizmo::VerticalAlignmentChanged, this,
|
||||
&TextGeneratorV3::SetVerticalAlignmentUndoable);
|
||||
set_standard_value(k_use_args_input, true);
|
||||
disconnect(text_gizmo_, &TextGizmo::vertical_alignment_changed, this,
|
||||
&TextGeneratorV3::set_vertical_alignment_undoable);
|
||||
dont_emit_valign_ = true;
|
||||
}
|
||||
|
||||
void TextGeneratorV3::SetVerticalAlignmentUndoable(Qt::Alignment a)
|
||||
void TextGeneratorV3::set_vertical_alignment_undoable(Qt::Alignment a)
|
||||
{
|
||||
Core::instance()->undo_stack()->push(
|
||||
new NodeParamSetStandardValueCommand(NodeInput(this,
|
||||
kVerticalAlignmentInput),
|
||||
GetOurAlignmentFromQts(a)),
|
||||
k_vertical_alignment_input),
|
||||
get_our_alignment_from_qts(a)),
|
||||
tr("Set Text Vertical Alignment"));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTGENERATORV3_H
|
||||
#define TEXTGENERATORV3_H
|
||||
#ifndef OAK_TEXTGENERATORV3_H
|
||||
#define OAK_TEXTGENERATORV3_H
|
||||
|
||||
#include "node/generator/shape/shapenodebase.h"
|
||||
#include "node/gizmo/text.h"
|
||||
@@ -35,39 +35,39 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TextGeneratorV3)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
enum VerticalAlignment { kVAlignTop, kVAlignMiddle, kVAlignBottom };
|
||||
enum VerticalAlignment { k_v_align_top, k_v_align_middle, k_v_align_bottom };
|
||||
|
||||
VerticalAlignment GetVerticalAlignment() const
|
||||
VerticalAlignment get_vertical_alignment() const
|
||||
{
|
||||
return static_cast<VerticalAlignment>(
|
||||
GetStandardValue(kVerticalAlignmentInput).toInt());
|
||||
get_standard_value(k_vertical_alignment_input).toInt());
|
||||
}
|
||||
|
||||
static Qt::Alignment GetQtAlignmentFromOurs(VerticalAlignment v);
|
||||
static VerticalAlignment GetOurAlignmentFromQts(Qt::Alignment v);
|
||||
static Qt::Alignment get_qt_alignment_from_ours(VerticalAlignment v);
|
||||
static VerticalAlignment get_our_alignment_from_qts(Qt::Alignment v);
|
||||
|
||||
static const QString kTextInput;
|
||||
static const QString kVerticalAlignmentInput;
|
||||
static const QString kUseArgsInput;
|
||||
static const QString kArgsInput;
|
||||
static const QString k_text_input;
|
||||
static const QString k_vertical_alignment_input;
|
||||
static const QString k_use_args_input;
|
||||
static const QString k_args_input;
|
||||
|
||||
static QString FormatString(const QString &input, const QStringList &args);
|
||||
static QString format_string(const QString &input, const QStringList &args);
|
||||
|
||||
protected:
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
@@ -79,11 +79,11 @@ private:
|
||||
bool dont_emit_valign_;
|
||||
|
||||
private slots:
|
||||
void GizmoActivated();
|
||||
void GizmoDeactivated();
|
||||
void SetVerticalAlignmentUndoable(Qt::Alignment a);
|
||||
void gizmo_activated();
|
||||
void gizmo_deactivated();
|
||||
void set_vertical_alignment_undoable(Qt::Alignment a);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TEXTGENERATORV3_H
|
||||
#endif // OAK_TEXTGENERATORV3_H
|
||||
|
||||
@@ -26,30 +26,30 @@ namespace olive
|
||||
|
||||
DraggableGizmo::DraggableGizmo(QObject *parent)
|
||||
: NodeGizmo{ parent }
|
||||
, drag_value_behavior_(kAbsolute)
|
||||
, drag_value_behavior_(k_absolute)
|
||||
{
|
||||
}
|
||||
|
||||
void DraggableGizmo::DragStart(const NodeValueRow &row, double abs_x,
|
||||
double abs_y, const rational &time)
|
||||
void DraggableGizmo::drag_start(const NodeValueRow &row, double abs_x,
|
||||
double abs_y, const Rational &time)
|
||||
{
|
||||
for (int i = 0; i < draggers_.size(); i++) {
|
||||
draggers_[i].Start(inputs_[i], time);
|
||||
draggers_[i].start(inputs_[i], time);
|
||||
}
|
||||
|
||||
emit HandleStart(row, abs_x, abs_y, time);
|
||||
emit handle_start(row, abs_x, abs_y, time);
|
||||
}
|
||||
|
||||
void DraggableGizmo::DragMove(double x, double y,
|
||||
void DraggableGizmo::drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
emit HandleMovement(x, y, modifiers);
|
||||
emit handle_movement(x, y, modifiers);
|
||||
}
|
||||
|
||||
void DraggableGizmo::DragEnd(MultiUndoCommand *command)
|
||||
void DraggableGizmo::drag_end(MultiUndoCommand *command)
|
||||
{
|
||||
for (int i = 0; i < draggers_.size(); i++) {
|
||||
draggers_[i].End(command);
|
||||
draggers_[i].end(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-17
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DRAGGABLEGIZMO_H
|
||||
#define DRAGGABLEGIZMO_H
|
||||
#ifndef OAK_DRAGGABLEGIZMO_H
|
||||
#define OAK_DRAGGABLEGIZMO_H
|
||||
|
||||
#include "gizmo.h"
|
||||
#include "node/inputdragger.h"
|
||||
@@ -35,49 +35,49 @@ public:
|
||||
/// Changes what the X/Y coordinates emitted from HandleMovement specify
|
||||
enum DragValueBehavior {
|
||||
/// X/Y will be the exact mouse coordinates (in sequence pixels)
|
||||
kAbsolute,
|
||||
k_absolute,
|
||||
|
||||
/// X/Y will be the movement since the last time HandleMovement was called
|
||||
kDeltaFromPrevious,
|
||||
k_delta_from_previous,
|
||||
|
||||
/// X/Y will be the movement from the start of the drag
|
||||
kDeltaFromStart
|
||||
k_delta_from_start
|
||||
};
|
||||
|
||||
explicit DraggableGizmo(QObject *parent = nullptr);
|
||||
|
||||
void DragStart(const NodeValueRow &row, double abs_x, double abs_y,
|
||||
const olive::core::rational &time);
|
||||
void drag_start(const NodeValueRow &row, double abs_x, double abs_y,
|
||||
const olive::core::Rational &time);
|
||||
|
||||
void DragMove(double x, double y, const Qt::KeyboardModifiers &modifiers);
|
||||
void drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers);
|
||||
|
||||
void DragEnd(olive::MultiUndoCommand *command);
|
||||
void drag_end(olive::MultiUndoCommand *command);
|
||||
|
||||
void AddInput(const NodeKeyframeTrackReference &input)
|
||||
void add_input(const NodeKeyframeTrackReference &input)
|
||||
{
|
||||
inputs_.append(input);
|
||||
draggers_.append(NodeInputDragger());
|
||||
}
|
||||
|
||||
QVector<NodeInputDragger> &GetDraggers()
|
||||
QVector<NodeInputDragger> &get_draggers()
|
||||
{
|
||||
return draggers_;
|
||||
}
|
||||
|
||||
DragValueBehavior GetDragValueBehavior() const
|
||||
DragValueBehavior get_drag_value_behavior() const
|
||||
{
|
||||
return drag_value_behavior_;
|
||||
}
|
||||
void SetDragValueBehavior(DragValueBehavior d)
|
||||
void set_drag_value_behavior(DragValueBehavior d)
|
||||
{
|
||||
drag_value_behavior_ = d;
|
||||
}
|
||||
|
||||
signals:
|
||||
void HandleStart(const olive::NodeValueRow &row, double x, double y,
|
||||
const olive::core::rational &time);
|
||||
void handle_start(const olive::NodeValueRow &row, double x, double y,
|
||||
const olive::core::Rational &time);
|
||||
|
||||
void HandleMovement(double x, double y,
|
||||
void handle_movement(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers);
|
||||
|
||||
private:
|
||||
@@ -90,4 +90,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // DRAGGABLEGIZMO_H
|
||||
#endif // OAK_DRAGGABLEGIZMO_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEGIZMO_H
|
||||
#define NODEGIZMO_H
|
||||
#ifndef OAK_NODEGIZMO_H
|
||||
#define OAK_NODEGIZMO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPainter>
|
||||
@@ -36,24 +36,24 @@ public:
|
||||
explicit NodeGizmo(QObject *parent = nullptr);
|
||||
virtual ~NodeGizmo() override;
|
||||
|
||||
virtual void Draw(QPainter *p) const
|
||||
virtual void draw(QPainter *p) const
|
||||
{
|
||||
}
|
||||
|
||||
const NodeGlobals &GetGlobals() const
|
||||
const NodeGlobals &get_globals() const
|
||||
{
|
||||
return globals_;
|
||||
}
|
||||
void SetGlobals(const NodeGlobals &globals)
|
||||
void set_globals(const NodeGlobals &globals)
|
||||
{
|
||||
globals_ = globals;
|
||||
}
|
||||
|
||||
bool IsVisible() const
|
||||
bool is_visible() const
|
||||
{
|
||||
return visible_;
|
||||
}
|
||||
void SetVisible(bool e)
|
||||
void set_visible(bool e)
|
||||
{
|
||||
visible_ = e;
|
||||
}
|
||||
@@ -68,4 +68,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEGIZMO_H
|
||||
#endif // OAK_NODEGIZMO_H
|
||||
|
||||
@@ -29,7 +29,7 @@ LineGizmo::LineGizmo(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void LineGizmo::Draw(QPainter *p) const
|
||||
void LineGizmo::draw(QPainter *p) const
|
||||
{
|
||||
// Draw transposed black
|
||||
QLineF transposed = p->transform().map(line_);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef LINEGIZMO_H
|
||||
#define LINEGIZMO_H
|
||||
#ifndef OAK_LINEGIZMO_H
|
||||
#define OAK_LINEGIZMO_H
|
||||
|
||||
#include <QLineF>
|
||||
|
||||
@@ -34,16 +34,16 @@ class LineGizmo : public NodeGizmo {
|
||||
public:
|
||||
LineGizmo(QObject *parent = nullptr);
|
||||
|
||||
const QLineF &GetLine() const
|
||||
const QLineF &get_line() const
|
||||
{
|
||||
return line_;
|
||||
}
|
||||
void SetLine(const QLineF &line)
|
||||
void set_line(const QLineF &line)
|
||||
{
|
||||
line_ = line;
|
||||
}
|
||||
|
||||
virtual void Draw(QPainter *p) const override;
|
||||
virtual void draw(QPainter *p) const override;
|
||||
|
||||
private:
|
||||
QLineF line_;
|
||||
@@ -51,4 +51,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // LINEGIZMO_H
|
||||
#endif // OAK_LINEGIZMO_H
|
||||
|
||||
@@ -29,7 +29,7 @@ PathGizmo::PathGizmo(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PathGizmo::Draw(QPainter *p) const
|
||||
void PathGizmo::draw(QPainter *p) const
|
||||
{
|
||||
// Draw transposed black
|
||||
QPainterPath transposed = p->transform().map(path_);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PATHGIZMO_H
|
||||
#define PATHGIZMO_H
|
||||
#ifndef OAK_PATHGIZMO_H
|
||||
#define OAK_PATHGIZMO_H
|
||||
|
||||
#include <QPainterPath>
|
||||
|
||||
@@ -34,16 +34,16 @@ class PathGizmo : public DraggableGizmo {
|
||||
public:
|
||||
explicit PathGizmo(QObject *parent = nullptr);
|
||||
|
||||
const QPainterPath &GetPath() const
|
||||
const QPainterPath &get_path() const
|
||||
{
|
||||
return path_;
|
||||
}
|
||||
void SetPath(const QPainterPath &path)
|
||||
void set_path(const QPainterPath &path)
|
||||
{
|
||||
path_ = path;
|
||||
}
|
||||
|
||||
virtual void Draw(QPainter *p) const override;
|
||||
virtual void draw(QPainter *p) const override;
|
||||
|
||||
private:
|
||||
QPainterPath path_;
|
||||
@@ -51,4 +51,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // PATHGIZMO_H
|
||||
#endif // OAK_PATHGIZMO_H
|
||||
|
||||
+12
-12
@@ -39,27 +39,27 @@ PointGizmo::PointGizmo(const Shape &shape, QObject *parent)
|
||||
}
|
||||
|
||||
PointGizmo::PointGizmo(QObject *parent)
|
||||
: PointGizmo(kSquare, parent)
|
||||
: PointGizmo(k_square, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PointGizmo::Draw(QPainter *p) const
|
||||
void PointGizmo::draw(QPainter *p) const
|
||||
{
|
||||
QRectF rect = GetDrawingRect(p->transform(), GetStandardRadius());
|
||||
QRectF rect = get_drawing_rect(p->transform(), get_standard_radius());
|
||||
|
||||
if (shape_ != kAnchorPoint) {
|
||||
if (shape_ != k_anchor_point) {
|
||||
p->setPen(QPen(Qt::black, 0));
|
||||
p->setBrush(Qt::white);
|
||||
}
|
||||
|
||||
switch (shape_) {
|
||||
case kSquare:
|
||||
case k_square:
|
||||
p->drawRect(rect);
|
||||
break;
|
||||
case kCircle:
|
||||
case k_circle:
|
||||
p->drawEllipse(rect);
|
||||
break;
|
||||
case kAnchorPoint:
|
||||
case k_anchor_point:
|
||||
p->setPen(QPen(Qt::white, 0));
|
||||
p->setBrush(Qt::NoBrush);
|
||||
|
||||
@@ -72,17 +72,17 @@ void PointGizmo::Draw(QPainter *p) const
|
||||
}
|
||||
}
|
||||
|
||||
QRectF PointGizmo::GetClickingRect(const QTransform &t) const
|
||||
QRectF PointGizmo::get_clicking_rect(const QTransform &t) const
|
||||
{
|
||||
return GetDrawingRect(t, GetStandardRadius());
|
||||
return get_drawing_rect(t, get_standard_radius());
|
||||
}
|
||||
|
||||
double PointGizmo::GetStandardRadius()
|
||||
double PointGizmo::get_standard_radius()
|
||||
{
|
||||
return QFontMetrics(qApp->font()).height() * 0.25;
|
||||
}
|
||||
|
||||
QRectF PointGizmo::GetDrawingRect(const QTransform &transform,
|
||||
QRectF PointGizmo::get_drawing_rect(const QTransform &transform,
|
||||
double radius) const
|
||||
{
|
||||
QRectF r(0, 0, radius, radius);
|
||||
@@ -92,7 +92,7 @@ QRectF PointGizmo::GetDrawingRect(const QTransform &transform,
|
||||
double width = r.width();
|
||||
double height = r.height();
|
||||
|
||||
if (shape_ == kAnchorPoint) {
|
||||
if (shape_ == k_anchor_point) {
|
||||
width *= 2;
|
||||
height *= 2;
|
||||
}
|
||||
|
||||
+14
-14
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef POINTGIZMO_H
|
||||
#define POINTGIZMO_H
|
||||
#ifndef OAK_POINTGIZMO_H
|
||||
#define OAK_POINTGIZMO_H
|
||||
|
||||
#include <QPointF>
|
||||
|
||||
@@ -32,48 +32,48 @@ namespace olive
|
||||
class PointGizmo : public DraggableGizmo {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Shape { kSquare, kCircle, kAnchorPoint };
|
||||
enum Shape { k_square, k_circle, k_anchor_point };
|
||||
|
||||
explicit PointGizmo(const Shape &shape, bool smaller,
|
||||
QObject *parent = nullptr);
|
||||
explicit PointGizmo(const Shape &shape, QObject *parent = nullptr);
|
||||
explicit PointGizmo(QObject *parent = nullptr);
|
||||
|
||||
const Shape &GetShape() const
|
||||
const Shape &get_shape() const
|
||||
{
|
||||
return shape_;
|
||||
}
|
||||
void SetShape(const Shape &s)
|
||||
void set_shape(const Shape &s)
|
||||
{
|
||||
shape_ = s;
|
||||
}
|
||||
|
||||
const QPointF &GetPoint() const
|
||||
const QPointF &get_point() const
|
||||
{
|
||||
return point_;
|
||||
}
|
||||
void SetPoint(const QPointF &pt)
|
||||
void set_point(const QPointF &pt)
|
||||
{
|
||||
point_ = pt;
|
||||
}
|
||||
|
||||
bool GetSmaller() const
|
||||
bool get_smaller() const
|
||||
{
|
||||
return smaller_;
|
||||
}
|
||||
void SetSmaller(bool e)
|
||||
void set_smaller(bool e)
|
||||
{
|
||||
smaller_ = e;
|
||||
}
|
||||
|
||||
virtual void Draw(QPainter *p) const override;
|
||||
virtual void draw(QPainter *p) const override;
|
||||
|
||||
QRectF GetClickingRect(const QTransform &t) const;
|
||||
QRectF get_clicking_rect(const QTransform &t) const;
|
||||
|
||||
private:
|
||||
static double GetStandardRadius();
|
||||
static double get_standard_radius();
|
||||
|
||||
QRectF GetDrawingRect(const QTransform &transform, double radius) const;
|
||||
QRectF get_drawing_rect(const QTransform &transform, double radius) const;
|
||||
|
||||
Shape shape_;
|
||||
|
||||
@@ -84,4 +84,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // POINTGIZMO_H
|
||||
#endif // OAK_POINTGIZMO_H
|
||||
|
||||
@@ -29,7 +29,7 @@ PolygonGizmo::PolygonGizmo(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PolygonGizmo::Draw(QPainter *p) const
|
||||
void PolygonGizmo::draw(QPainter *p) const
|
||||
{
|
||||
// Draw transposed black
|
||||
QPolygonF transposed = p->transform().map(polygon_);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef POLYGONGIZMO_H
|
||||
#define POLYGONGIZMO_H
|
||||
#ifndef OAK_POLYGONGIZMO_H
|
||||
#define OAK_POLYGONGIZMO_H
|
||||
|
||||
#include <QPolygonF>
|
||||
|
||||
@@ -34,16 +34,16 @@ class PolygonGizmo : public DraggableGizmo {
|
||||
public:
|
||||
explicit PolygonGizmo(QObject *parent = nullptr);
|
||||
|
||||
const QPolygonF &GetPolygon() const
|
||||
const QPolygonF &get_polygon() const
|
||||
{
|
||||
return polygon_;
|
||||
}
|
||||
void SetPolygon(const QPolygonF &polygon)
|
||||
void set_polygon(const QPolygonF &polygon)
|
||||
{
|
||||
polygon_ = polygon;
|
||||
}
|
||||
|
||||
virtual void Draw(QPainter *p) const override;
|
||||
virtual void draw(QPainter *p) const override;
|
||||
|
||||
private:
|
||||
QPolygonF polygon_;
|
||||
@@ -51,4 +51,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // POLYGONGIZMO_H
|
||||
#endif // OAK_POLYGONGIZMO_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SCREENGIZMO_H
|
||||
#define SCREENGIZMO_H
|
||||
#ifndef OAK_SCREENGIZMO_H
|
||||
#define OAK_SCREENGIZMO_H
|
||||
|
||||
#include "draggable.h"
|
||||
|
||||
@@ -35,4 +35,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // SCREENGIZMO_H
|
||||
#endif // OAK_SCREENGIZMO_H
|
||||
|
||||
@@ -33,26 +33,26 @@ TextGizmo::TextGizmo(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void TextGizmo::SetRect(const QRectF &r)
|
||||
void TextGizmo::set_rect(const QRectF &r)
|
||||
{
|
||||
rect_ = r;
|
||||
emit RectChanged(rect_);
|
||||
emit rect_changed(rect_);
|
||||
}
|
||||
|
||||
void TextGizmo::UpdateInputHtml(const QString &s, const rational &time)
|
||||
void TextGizmo::update_input_html(const QString &s, const Rational &time)
|
||||
{
|
||||
if (input_.IsValid()) {
|
||||
if (input_.is_valid()) {
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
Node::SetValueAtTime(input_.input(), time, s, input_.track(), command,
|
||||
Node::set_value_at_time(input_.input(), time, s, input_.track(), command,
|
||||
true);
|
||||
Core::instance()->undo_stack()->push(command, tr("Edit Text"));
|
||||
}
|
||||
}
|
||||
|
||||
void TextGizmo::SetVerticalAlignment(Qt::Alignment va)
|
||||
void TextGizmo::set_vertical_alignment(Qt::Alignment va)
|
||||
{
|
||||
valign_ = va;
|
||||
emit VerticalAlignmentChanged(valign_);
|
||||
emit vertical_alignment_changed(valign_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-15
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTGIZMO_H
|
||||
#define TEXTGIZMO_H
|
||||
#ifndef OAK_TEXTGIZMO_H
|
||||
#define OAK_TEXTGIZMO_H
|
||||
|
||||
#include "gizmo.h"
|
||||
#include "node/param.h"
|
||||
@@ -33,39 +33,39 @@ class TextGizmo : public NodeGizmo {
|
||||
public:
|
||||
explicit TextGizmo(QObject *parent = nullptr);
|
||||
|
||||
const QRectF &GetRect() const
|
||||
const QRectF &get_rect() const
|
||||
{
|
||||
return rect_;
|
||||
}
|
||||
void SetRect(const QRectF &r);
|
||||
void set_rect(const QRectF &r);
|
||||
|
||||
const QString &GetHtml() const
|
||||
const QString &get_html() const
|
||||
{
|
||||
return text_;
|
||||
}
|
||||
void SetHtml(const QString &t)
|
||||
void set_html(const QString &t)
|
||||
{
|
||||
text_ = t;
|
||||
}
|
||||
|
||||
void SetInput(const NodeKeyframeTrackReference &input)
|
||||
void set_input(const NodeKeyframeTrackReference &input)
|
||||
{
|
||||
input_ = input;
|
||||
}
|
||||
|
||||
void UpdateInputHtml(const QString &s, const rational &time);
|
||||
void update_input_html(const QString &s, const Rational &time);
|
||||
|
||||
Qt::Alignment GetVerticalAlignment() const
|
||||
Qt::Alignment get_vertical_alignment() const
|
||||
{
|
||||
return valign_;
|
||||
}
|
||||
void SetVerticalAlignment(Qt::Alignment va);
|
||||
void set_vertical_alignment(Qt::Alignment va);
|
||||
|
||||
signals:
|
||||
void Activated();
|
||||
void Deactivated();
|
||||
void VerticalAlignmentChanged(Qt::Alignment va);
|
||||
void RectChanged(const QRectF &r);
|
||||
void activated();
|
||||
void deactivated();
|
||||
void vertical_alignment_changed(Qt::Alignment va);
|
||||
void rect_changed(const QRectF &r);
|
||||
|
||||
private:
|
||||
QRectF rect_;
|
||||
@@ -79,4 +79,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TEXTGIZMO_H
|
||||
#endif // OAK_TEXTGIZMO_H
|
||||
|
||||
+4
-4
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEGLOBALS_H
|
||||
#define NODEGLOBALS_H
|
||||
#ifndef OAK_NODEGLOBALS_H
|
||||
#define OAK_NODEGLOBALS_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
}
|
||||
|
||||
NodeGlobals(const VideoParams &vparam, const AudioParams &aparam,
|
||||
const rational &time, LoopMode loop_mode)
|
||||
const Rational &time, LoopMode loop_mode)
|
||||
: NodeGlobals(vparam, aparam,
|
||||
TimeRange(time, time + vparam.frame_rate_as_time_base()),
|
||||
loop_mode)
|
||||
@@ -87,4 +87,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEGLOBALS_H
|
||||
#endif // OAK_NODEGLOBALS_H
|
||||
|
||||
+63
-63
@@ -31,10 +31,10 @@ namespace olive
|
||||
NodeGroup::NodeGroup()
|
||||
: output_passthrough_(nullptr)
|
||||
{
|
||||
SetFlag(kDontShowInCreateMenu);
|
||||
set_flag(k_dont_show_in_create_menu);
|
||||
}
|
||||
|
||||
QString NodeGroup::Name() const
|
||||
QString NodeGroup::name() const
|
||||
{
|
||||
return tr("Group");
|
||||
}
|
||||
@@ -44,37 +44,37 @@ QString NodeGroup::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.group");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> NodeGroup::Category() const
|
||||
QVector<Node::CategoryID> NodeGroup::category() const
|
||||
{
|
||||
return { kCategoryUnknown };
|
||||
return { k_category_unknown };
|
||||
}
|
||||
|
||||
QString NodeGroup::Description() const
|
||||
QString NodeGroup::description() const
|
||||
{
|
||||
return tr("A group of nodes that is represented as a single node.");
|
||||
}
|
||||
|
||||
void NodeGroup::Retranslate()
|
||||
void NodeGroup::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
for (auto it = GetContextPositions().cbegin();
|
||||
it != GetContextPositions().cend(); it++) {
|
||||
it.key()->Retranslate();
|
||||
for (auto it = get_context_positions().cbegin();
|
||||
it != get_context_positions().cend(); it++) {
|
||||
it.key()->retranslate();
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeGroup::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
bool NodeGroup::load_custom(QXmlStreamReader *reader, SerializedData *data)
|
||||
{
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("inputpassthroughs")) {
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("inputpassthrough")) {
|
||||
SerializedData::GroupLink link;
|
||||
|
||||
link.group = this;
|
||||
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("node")) {
|
||||
link.input_node =
|
||||
reader->readElementText().toULongLong();
|
||||
@@ -92,22 +92,22 @@ bool NodeGroup::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
link.custom_flags = InputFlags(
|
||||
reader->readElementText().toULongLong());
|
||||
} else if (reader->name() == QStringLiteral("type")) {
|
||||
link.data_type = NodeValue::GetDataTypeFromName(
|
||||
link.data_type = NodeValue::get_data_type_from_name(
|
||||
reader->readElementText());
|
||||
} else if (reader->name() ==
|
||||
QStringLiteral("default")) {
|
||||
link.default_val = NodeValue::StringToValue(
|
||||
link.default_val = NodeValue::string_to_value(
|
||||
link.data_type, reader->readElementText(),
|
||||
false);
|
||||
} else if (reader->name() ==
|
||||
QStringLiteral("properties")) {
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() ==
|
||||
QStringLiteral("property")) {
|
||||
QString key;
|
||||
QString value;
|
||||
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() ==
|
||||
QStringLiteral("key")) {
|
||||
key = reader->readElementText();
|
||||
@@ -148,12 +148,12 @@ bool NodeGroup::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void NodeGroup::SaveCustom(QXmlStreamWriter *writer) const
|
||||
void NodeGroup::save_custom(QXmlStreamWriter *writer) const
|
||||
{
|
||||
writer->writeStartElement(QStringLiteral("inputpassthroughs"));
|
||||
|
||||
foreach (const NodeGroup::InputPassthrough &ip,
|
||||
this->GetInputPassthroughs()) {
|
||||
this->get_input_passthroughs()) {
|
||||
writer->writeStartElement(QStringLiteral("inputpassthrough"));
|
||||
|
||||
// Reference to inner input
|
||||
@@ -170,23 +170,23 @@ void NodeGroup::SaveCustom(QXmlStreamWriter *writer) const
|
||||
// Passthrough-specific details
|
||||
const QString &input = ip.first;
|
||||
writer->writeTextElement(QStringLiteral("name"),
|
||||
this->Node::GetInputName(input));
|
||||
this->Node::get_input_name(input));
|
||||
|
||||
writer->writeTextElement(
|
||||
QStringLiteral("flags"),
|
||||
QString::number(
|
||||
(GetInputFlags(input) & ~ip.second.GetFlags()).value()));
|
||||
(get_input_flags(input) & ~ip.second.get_flags()).value()));
|
||||
|
||||
NodeValue::Type data_type = GetInputDataType(input);
|
||||
NodeValue::Type data_type = get_input_data_type(input);
|
||||
writer->writeTextElement(QStringLiteral("type"),
|
||||
NodeValue::GetDataTypeName(data_type));
|
||||
NodeValue::get_data_type_name(data_type));
|
||||
|
||||
writer->writeTextElement(
|
||||
QStringLiteral("default"),
|
||||
NodeValue::ValueToString(data_type, GetDefaultValue(input), false));
|
||||
NodeValue::value_to_string(data_type, get_default_value(input), false));
|
||||
|
||||
writer->writeStartElement(QStringLiteral("properties"));
|
||||
auto p = GetInputProperties(input);
|
||||
auto p = get_input_properties(input);
|
||||
for (auto it = p.cbegin(); it != p.cend(); it++) {
|
||||
writer->writeStartElement(QStringLiteral("property"));
|
||||
writer->writeTextElement(QStringLiteral("key"), it.key());
|
||||
@@ -203,7 +203,7 @@ void NodeGroup::SaveCustom(QXmlStreamWriter *writer) const
|
||||
|
||||
writer->writeTextElement(QStringLiteral("outputpassthrough"),
|
||||
QString::number(reinterpret_cast<quintptr>(
|
||||
this->GetOutputPassthrough())));
|
||||
this->get_output_passthrough())));
|
||||
}
|
||||
|
||||
void NodeGroup::PostLoadEvent(SerializedData *data)
|
||||
@@ -214,22 +214,22 @@ void NodeGroup::PostLoadEvent(SerializedData *data)
|
||||
if (Node *input_node = data->node_ptrs.value(l.input_node)) {
|
||||
NodeInput resolved(input_node, l.input_id, l.input_element);
|
||||
|
||||
l.group->AddInputPassthrough(resolved, l.passthrough_id);
|
||||
l.group->add_input_passthrough(resolved, l.passthrough_id);
|
||||
|
||||
l.group->SetInputFlag(l.passthrough_id,
|
||||
l.group->set_input_flag(l.passthrough_id,
|
||||
InputFlag(l.custom_flags.value()));
|
||||
|
||||
if (!l.custom_name.isEmpty()) {
|
||||
l.group->SetInputName(l.passthrough_id, l.custom_name);
|
||||
l.group->set_input_name(l.passthrough_id, l.custom_name);
|
||||
}
|
||||
|
||||
l.group->SetInputDataType(l.passthrough_id, l.data_type);
|
||||
l.group->set_input_data_type(l.passthrough_id, l.data_type);
|
||||
|
||||
l.group->SetDefaultValue(l.passthrough_id, l.default_val);
|
||||
l.group->set_default_value(l.passthrough_id, l.default_val);
|
||||
|
||||
for (auto it = l.custom_properties.cbegin();
|
||||
it != l.custom_properties.cend(); it++) {
|
||||
l.group->SetInputProperty(l.passthrough_id, it.key(),
|
||||
l.group->set_input_property(l.passthrough_id, it.key(),
|
||||
it.value());
|
||||
}
|
||||
}
|
||||
@@ -238,15 +238,15 @@ void NodeGroup::PostLoadEvent(SerializedData *data)
|
||||
for (auto it = data->group_output_links.cbegin();
|
||||
it != data->group_output_links.cend(); it++) {
|
||||
if (Node *output_node = data->node_ptrs.value(it.value())) {
|
||||
it.key()->SetOutputPassthrough(output_node);
|
||||
it.key()->set_output_passthrough(output_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString NodeGroup::AddInputPassthrough(const NodeInput &input,
|
||||
QString NodeGroup::add_input_passthrough(const NodeInput &input,
|
||||
const QString &force_id)
|
||||
{
|
||||
Q_ASSERT(ContextContainsNode(input.node()));
|
||||
Q_ASSERT(context_contains_node(input.node()));
|
||||
|
||||
for (auto it = input_passthroughs_.cbegin();
|
||||
it != input_passthroughs_.cend(); it++) {
|
||||
@@ -261,7 +261,7 @@ QString NodeGroup::AddInputPassthrough(const NodeInput &input,
|
||||
if (force_id.isEmpty()) {
|
||||
id = input.input();
|
||||
int i = 2;
|
||||
while (HasInputWithID(id)) {
|
||||
while (has_input_with_id(id)) {
|
||||
id = QStringLiteral("%1_%2").arg(input.input(), QString::number(i));
|
||||
i++;
|
||||
}
|
||||
@@ -280,39 +280,39 @@ QString NodeGroup::AddInputPassthrough(const NodeInput &input,
|
||||
Q_ASSERT(!already_exists);
|
||||
}
|
||||
|
||||
AddInput(id, input.GetDataType(), input.GetDefaultValue(),
|
||||
input.GetFlags());
|
||||
add_input(id, input.get_data_type(), input.get_default_value(),
|
||||
input.get_flags());
|
||||
|
||||
input_passthroughs_.append({ id, input });
|
||||
|
||||
emit InputPassthroughAdded(this, input);
|
||||
emit input_passthrough_added(this, input);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void NodeGroup::RemoveInputPassthrough(const NodeInput &input)
|
||||
void NodeGroup::remove_input_passthrough(const NodeInput &input)
|
||||
{
|
||||
for (auto it = input_passthroughs_.begin(); it != input_passthroughs_.end();
|
||||
it++) {
|
||||
if (it->second == input) {
|
||||
RemoveInput(it->first);
|
||||
emit InputPassthroughRemoved(this, it->second);
|
||||
remove_input(it->first);
|
||||
emit input_passthrough_removed(this, it->second);
|
||||
input_passthroughs_.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeGroup::SetOutputPassthrough(Node *node)
|
||||
void NodeGroup::set_output_passthrough(Node *node)
|
||||
{
|
||||
Q_ASSERT(!node || ContextContainsNode(node));
|
||||
Q_ASSERT(!node || context_contains_node(node));
|
||||
|
||||
output_passthrough_ = node;
|
||||
|
||||
emit OutputPassthroughChanged(this, output_passthrough_);
|
||||
emit output_passthrough_changed(this, output_passthrough_);
|
||||
}
|
||||
|
||||
bool NodeGroup::ContainsInputPassthrough(const NodeInput &input) const
|
||||
bool NodeGroup::contains_input_passthrough(const NodeInput &input) const
|
||||
{
|
||||
for (auto it = input_passthroughs_.cbegin();
|
||||
it != input_passthroughs_.cend(); it++) {
|
||||
@@ -324,35 +324,35 @@ bool NodeGroup::ContainsInputPassthrough(const NodeInput &input) const
|
||||
return false;
|
||||
}
|
||||
|
||||
QString NodeGroup::GetInputName(const QString &id) const
|
||||
QString NodeGroup::get_input_name(const QString &id) const
|
||||
{
|
||||
// If an override name was set, use that
|
||||
QString override = super::GetInputName(id);
|
||||
QString override = super::get_input_name(id);
|
||||
if (!override.isEmpty()) {
|
||||
return override;
|
||||
}
|
||||
|
||||
// Call GetInputName of passed through node, which may be another group
|
||||
NodeInput pass = GetInputFromID(id);
|
||||
if (!pass.IsValid()) {
|
||||
NodeInput pass = get_input_from_id(id);
|
||||
if (!pass.is_valid()) {
|
||||
return QString();
|
||||
}
|
||||
return pass.node()->GetInputName(pass.input());
|
||||
return pass.node()->get_input_name(pass.input());
|
||||
}
|
||||
|
||||
NodeInput NodeGroup::ResolveInput(NodeInput input)
|
||||
NodeInput NodeGroup::resolve_input(NodeInput input)
|
||||
{
|
||||
while (GetInner(&input)) {
|
||||
while (get_inner(&input)) {
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
bool NodeGroup::GetInner(NodeInput *input)
|
||||
bool NodeGroup::get_inner(NodeInput *input)
|
||||
{
|
||||
if (NodeGroup *g = dynamic_cast<NodeGroup *>(input->node())) {
|
||||
const NodeInput &passthrough = g->GetInputFromID(input->input());
|
||||
if (!passthrough.IsValid()) {
|
||||
const NodeInput &passthrough = g->get_input_from_id(input->input());
|
||||
if (!passthrough.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -366,8 +366,8 @@ bool NodeGroup::GetInner(NodeInput *input)
|
||||
|
||||
void NodeGroupAddInputPassthrough::redo()
|
||||
{
|
||||
if (!group_->ContainsInputPassthrough(input_)) {
|
||||
group_->AddInputPassthrough(input_, force_id_);
|
||||
if (!group_->contains_input_passthrough(input_)) {
|
||||
group_->add_input_passthrough(input_, force_id_);
|
||||
actually_added_ = true;
|
||||
} else {
|
||||
actually_added_ = false;
|
||||
@@ -377,19 +377,19 @@ void NodeGroupAddInputPassthrough::redo()
|
||||
void NodeGroupAddInputPassthrough::undo()
|
||||
{
|
||||
if (actually_added_) {
|
||||
group_->RemoveInputPassthrough(input_);
|
||||
group_->remove_input_passthrough(input_);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeGroupSetOutputPassthrough::redo()
|
||||
{
|
||||
old_output_ = group_->GetOutputPassthrough();
|
||||
group_->SetOutputPassthrough(new_output_);
|
||||
old_output_ = group_->get_output_passthrough();
|
||||
group_->set_output_passthrough(new_output_);
|
||||
}
|
||||
|
||||
void NodeGroupSetOutputPassthrough::undo()
|
||||
{
|
||||
group_->SetOutputPassthrough(old_output_);
|
||||
group_->set_output_passthrough(old_output_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-25
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEGROUP_H
|
||||
#define NODEGROUP_H
|
||||
#ifndef OAK_NODEGROUP_H
|
||||
#define OAK_NODEGROUP_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,45 +34,45 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(NodeGroup)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual bool LoadCustom(QXmlStreamReader *reader,
|
||||
virtual bool load_custom(QXmlStreamReader *reader,
|
||||
SerializedData *data) override;
|
||||
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
|
||||
virtual void save_custom(QXmlStreamWriter *writer) const override;
|
||||
virtual void PostLoadEvent(SerializedData *data) override;
|
||||
|
||||
QString AddInputPassthrough(const NodeInput &input,
|
||||
QString add_input_passthrough(const NodeInput &input,
|
||||
const QString &force_id = QString());
|
||||
|
||||
void RemoveInputPassthrough(const NodeInput &input);
|
||||
void remove_input_passthrough(const NodeInput &input);
|
||||
|
||||
Node *GetOutputPassthrough() const
|
||||
Node *get_output_passthrough() const
|
||||
{
|
||||
return output_passthrough_;
|
||||
}
|
||||
|
||||
void SetOutputPassthrough(Node *node);
|
||||
void set_output_passthrough(Node *node);
|
||||
|
||||
using InputPassthrough = QPair<QString, NodeInput>;
|
||||
using InputPassthroughs = QVector<InputPassthrough>;
|
||||
const InputPassthroughs &GetInputPassthroughs() const
|
||||
const InputPassthroughs &get_input_passthroughs() const
|
||||
{
|
||||
return input_passthroughs_;
|
||||
}
|
||||
|
||||
bool ContainsInputPassthrough(const NodeInput &input) const;
|
||||
bool contains_input_passthrough(const NodeInput &input) const;
|
||||
|
||||
virtual QString GetInputName(const QString &id) const override;
|
||||
virtual QString get_input_name(const QString &id) const override;
|
||||
|
||||
static NodeInput ResolveInput(NodeInput input);
|
||||
static bool GetInner(NodeInput *input);
|
||||
static NodeInput resolve_input(NodeInput input);
|
||||
static bool get_inner(NodeInput *input);
|
||||
|
||||
QString GetIDOfPassthrough(const NodeInput &input) const
|
||||
QString get_id_of_passthrough(const NodeInput &input) const
|
||||
{
|
||||
for (auto it = input_passthroughs_.cbegin();
|
||||
it != input_passthroughs_.cend(); it++) {
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
return QString();
|
||||
}
|
||||
|
||||
NodeInput GetInputFromID(const QString &id) const
|
||||
NodeInput get_input_from_id(const QString &id) const
|
||||
{
|
||||
for (auto it = input_passthroughs_.cbegin();
|
||||
it != input_passthroughs_.cend(); it++) {
|
||||
@@ -95,13 +95,13 @@ public:
|
||||
}
|
||||
|
||||
signals:
|
||||
void InputPassthroughAdded(olive::NodeGroup *group,
|
||||
void input_passthrough_added(olive::NodeGroup *group,
|
||||
const olive::NodeInput &input);
|
||||
|
||||
void InputPassthroughRemoved(olive::NodeGroup *group,
|
||||
void input_passthrough_removed(olive::NodeGroup *group,
|
||||
const olive::NodeInput &input);
|
||||
|
||||
void OutputPassthroughChanged(olive::NodeGroup *group, olive::Node *output);
|
||||
void output_passthrough_changed(olive::NodeGroup *group, olive::Node *output);
|
||||
|
||||
private:
|
||||
InputPassthroughs input_passthroughs_;
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return group_->project();
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return group_->project();
|
||||
}
|
||||
@@ -166,4 +166,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEGROUP_H
|
||||
#endif // OAK_NODEGROUP_H
|
||||
|
||||
@@ -25,29 +25,29 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString MultiCamNode::kCurrentInput = QStringLiteral("current_in");
|
||||
const QString MultiCamNode::kSourcesInput = QStringLiteral("sources_in");
|
||||
const QString MultiCamNode::kSequenceInput = QStringLiteral("sequence_in");
|
||||
const QString MultiCamNode::kSequenceTypeInput =
|
||||
const QString MultiCamNode::k_current_input = QStringLiteral("current_in");
|
||||
const QString MultiCamNode::k_sources_input = QStringLiteral("sources_in");
|
||||
const QString MultiCamNode::k_sequence_input = QStringLiteral("sequence_in");
|
||||
const QString MultiCamNode::k_sequence_type_input =
|
||||
QStringLiteral("sequence_type_in");
|
||||
|
||||
MultiCamNode::MultiCamNode()
|
||||
{
|
||||
AddInput(kCurrentInput, NodeValue::kCombo, InputFlags(kInputFlagStatic));
|
||||
add_input(k_current_input, NodeValue::k_combo, InputFlags(k_input_flag_static));
|
||||
|
||||
AddInput(kSourcesInput, NodeValue::kNone,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagArray));
|
||||
SetInputProperty(kSourcesInput, QStringLiteral("arraystart"), 1);
|
||||
add_input(k_sources_input, NodeValue::k_none,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_array));
|
||||
set_input_property(k_sources_input, QStringLiteral("arraystart"), 1);
|
||||
|
||||
AddInput(kSequenceInput, NodeValue::kNone,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kSequenceTypeInput, NodeValue::kCombo,
|
||||
InputFlags(kInputFlagStatic | kInputFlagHidden));
|
||||
add_input(k_sequence_input, NodeValue::k_none,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
add_input(k_sequence_type_input, NodeValue::k_combo,
|
||||
InputFlags(k_input_flag_static | k_input_flag_hidden));
|
||||
|
||||
sequence_ = nullptr;
|
||||
}
|
||||
|
||||
QString MultiCamNode::Name() const
|
||||
QString MultiCamNode::name() const
|
||||
{
|
||||
return tr("Multi-Cam");
|
||||
}
|
||||
@@ -57,44 +57,44 @@ QString MultiCamNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.multicam");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> MultiCamNode::Category() const
|
||||
QVector<Node::CategoryID> MultiCamNode::category() const
|
||||
{
|
||||
return { kCategoryTimeline };
|
||||
return { k_category_timeline };
|
||||
}
|
||||
|
||||
QString MultiCamNode::Description() const
|
||||
QString MultiCamNode::description() const
|
||||
{
|
||||
return tr("Allows easy switching between multiple sources.");
|
||||
}
|
||||
|
||||
Node::ActiveElements
|
||||
MultiCamNode::GetActiveElementsAtTime(const QString &input,
|
||||
MultiCamNode::get_active_elements_at_time(const QString &input,
|
||||
const TimeRange &r) const
|
||||
{
|
||||
if (input == kSourcesInput) {
|
||||
int src = GetCurrentSource();
|
||||
if (src >= 0 && src < GetSourceCount()) {
|
||||
if (input == k_sources_input) {
|
||||
int src = get_current_source();
|
||||
if (src >= 0 && src < get_source_count()) {
|
||||
Node::ActiveElements a;
|
||||
a.add(src);
|
||||
return a;
|
||||
} else {
|
||||
return ActiveElements::kNoElements;
|
||||
return ActiveElements::k_no_elements;
|
||||
}
|
||||
} else {
|
||||
return super::GetActiveElementsAtTime(input, r);
|
||||
return super::get_active_elements_at_time(input, r);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCamNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void MultiCamNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
NodeValueArray arr = value[kSourcesInput].toArray();
|
||||
NodeValueArray arr = value[k_sources_input].to_array();
|
||||
if (!arr.empty()) {
|
||||
table->Push(arr.begin()->second);
|
||||
table->push(arr.begin()->second);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCamNode::IndexToRowCols(int index, int total_rows, int total_cols,
|
||||
void MultiCamNode::index_to_row_cols(int index, int total_rows, int total_cols,
|
||||
int *row, int *col)
|
||||
{
|
||||
Q_UNUSED(total_rows)
|
||||
@@ -103,39 +103,39 @@ void MultiCamNode::IndexToRowCols(int index, int total_rows, int total_cols,
|
||||
*row = index / total_cols;
|
||||
}
|
||||
|
||||
Node *MultiCamNode::GetConnectedRenderOutput(const QString &input,
|
||||
Node *MultiCamNode::get_connected_render_output(const QString &input,
|
||||
int element) const
|
||||
{
|
||||
if (sequence_ && input == kSourcesInput && element >= 0 &&
|
||||
element < GetSourceCount()) {
|
||||
return GetTrackList()->GetTrackAt(element);
|
||||
if (sequence_ && input == k_sources_input && element >= 0 &&
|
||||
element < get_source_count()) {
|
||||
return get_track_list()->get_track_at(element);
|
||||
} else {
|
||||
return Node::GetConnectedRenderOutput(input, element);
|
||||
return Node::get_connected_render_output(input, element);
|
||||
}
|
||||
}
|
||||
|
||||
bool MultiCamNode::IsInputConnectedForRender(const QString &input,
|
||||
bool MultiCamNode::is_input_connected_for_render(const QString &input,
|
||||
int element) const
|
||||
{
|
||||
if (sequence_ && input == kSourcesInput && element >= 0 &&
|
||||
element < GetSourceCount()) {
|
||||
if (sequence_ && input == k_sources_input && element >= 0 &&
|
||||
element < get_source_count()) {
|
||||
return true;
|
||||
} else {
|
||||
return Node::IsInputConnectedForRender(input, element);
|
||||
return Node::is_input_connected_for_render(input, element);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QString> MultiCamNode::IgnoreInputsForRendering() const
|
||||
QVector<QString> MultiCamNode::ignore_inputs_for_rendering() const
|
||||
{
|
||||
return { kSequenceInput };
|
||||
return { k_sequence_input };
|
||||
}
|
||||
|
||||
void MultiCamNode::InputConnectedEvent(const QString &input, int element,
|
||||
Node *output)
|
||||
{
|
||||
if (input == kSequenceInput) {
|
||||
if (input == k_sequence_input) {
|
||||
if (Sequence *s = dynamic_cast<Sequence *>(output)) {
|
||||
SetInputFlag(kSequenceTypeInput, kInputFlagHidden, false);
|
||||
set_input_flag(k_sequence_type_input, k_input_flag_hidden, false);
|
||||
sequence_ = s;
|
||||
}
|
||||
}
|
||||
@@ -144,51 +144,51 @@ void MultiCamNode::InputConnectedEvent(const QString &input, int element,
|
||||
void MultiCamNode::InputDisconnectedEvent(const QString &input, int element,
|
||||
Node *output)
|
||||
{
|
||||
if (input == kSequenceInput) {
|
||||
SetInputFlag(kSequenceTypeInput, kInputFlagHidden, true);
|
||||
if (input == k_sequence_input) {
|
||||
set_input_flag(k_sequence_type_input, k_input_flag_hidden, true);
|
||||
sequence_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
TrackList *MultiCamNode::GetTrackList() const
|
||||
TrackList *MultiCamNode::get_track_list() const
|
||||
{
|
||||
return sequence_->track_list(
|
||||
static_cast<Track::Type>(GetStandardValue(kSequenceTypeInput).toInt()));
|
||||
static_cast<Track::Type>(get_standard_value(k_sequence_type_input).toInt()));
|
||||
}
|
||||
|
||||
void MultiCamNode::Retranslate()
|
||||
void MultiCamNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kCurrentInput, tr("Current"));
|
||||
SetInputName(kSourcesInput, tr("Sources"));
|
||||
SetInputName(kSequenceInput, tr("Sequence"));
|
||||
SetInputName(kSequenceTypeInput, tr("Sequence Type"));
|
||||
SetComboBoxStrings(kSequenceTypeInput, { tr("Video"), tr("Audio") });
|
||||
set_input_name(k_current_input, tr("Current"));
|
||||
set_input_name(k_sources_input, tr("Sources"));
|
||||
set_input_name(k_sequence_input, tr("Sequence"));
|
||||
set_input_name(k_sequence_type_input, tr("Sequence Type"));
|
||||
set_combo_box_strings(k_sequence_type_input, { tr("Video"), tr("Audio") });
|
||||
|
||||
QStringList names;
|
||||
int name_count = GetSourceCount();
|
||||
int name_count = get_source_count();
|
||||
names.reserve(name_count);
|
||||
for (int i = 0; i < name_count; i++) {
|
||||
QString src_name;
|
||||
if (Node *n = GetConnectedRenderOutput(kSourcesInput, i)) {
|
||||
src_name = n->Name();
|
||||
if (Node *n = get_connected_render_output(k_sources_input, i)) {
|
||||
src_name = n->name();
|
||||
}
|
||||
names.append(tr("%1: %2").arg(QString::number(i + 1), src_name));
|
||||
}
|
||||
SetComboBoxStrings(kCurrentInput, names);
|
||||
set_combo_box_strings(k_current_input, names);
|
||||
}
|
||||
|
||||
int MultiCamNode::GetSourceCount() const
|
||||
int MultiCamNode::get_source_count() const
|
||||
{
|
||||
if (sequence_) {
|
||||
return GetTrackList()->GetTrackCount();
|
||||
return get_track_list()->get_track_count();
|
||||
} else {
|
||||
return InputArraySize(kSourcesInput);
|
||||
return input_array_size(k_sources_input);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCamNode::GetRowsAndColumns(int sources, int *rows_in, int *cols_in)
|
||||
void MultiCamNode::get_rows_and_columns(int sources, int *rows_in, int *cols_in)
|
||||
{
|
||||
int &rows = *rows_in;
|
||||
int &cols = *cols_in;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MULTICAMNODE_H
|
||||
#define MULTICAMNODE_H
|
||||
#ifndef OAK_MULTICAMNODE_H
|
||||
#define OAK_MULTICAMNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "node/output/track/tracklist.h"
|
||||
@@ -34,57 +34,57 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MultiCamNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual ActiveElements
|
||||
GetActiveElementsAtTime(const QString &input,
|
||||
get_active_elements_at_time(const QString &input,
|
||||
const TimeRange &r) const override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
static const QString kCurrentInput;
|
||||
static const QString kSourcesInput;
|
||||
static const QString kSequenceInput;
|
||||
static const QString kSequenceTypeInput;
|
||||
static const QString k_current_input;
|
||||
static const QString k_sources_input;
|
||||
static const QString k_sequence_input;
|
||||
static const QString k_sequence_type_input;
|
||||
|
||||
int GetCurrentSource() const
|
||||
int get_current_source() const
|
||||
{
|
||||
return GetStandardValue(kCurrentInput).toInt();
|
||||
return get_standard_value(k_current_input).toInt();
|
||||
}
|
||||
|
||||
int GetSourceCount() const;
|
||||
int get_source_count() const;
|
||||
|
||||
static void GetRowsAndColumns(int sources, int *rows, int *cols);
|
||||
void GetRowsAndColumns(int *rows, int *cols) const
|
||||
static void get_rows_and_columns(int sources, int *rows, int *cols);
|
||||
void get_rows_and_columns(int *rows, int *cols) const
|
||||
{
|
||||
return GetRowsAndColumns(GetSourceCount(), rows, cols);
|
||||
return get_rows_and_columns(get_source_count(), rows, cols);
|
||||
}
|
||||
|
||||
void SetSequenceType(Track::Type t)
|
||||
void set_sequence_type(Track::Type t)
|
||||
{
|
||||
SetStandardValue(kSequenceTypeInput, t);
|
||||
set_standard_value(k_sequence_type_input, t);
|
||||
}
|
||||
|
||||
static void IndexToRowCols(int index, int total_rows, int total_cols,
|
||||
static void index_to_row_cols(int index, int total_rows, int total_cols,
|
||||
int *row, int *col);
|
||||
|
||||
static int RowsColsToIndex(int row, int col, int total_rows, int total_cols)
|
||||
static int rows_cols_to_index(int row, int col, int total_rows, int total_cols)
|
||||
{
|
||||
return col + row * total_cols;
|
||||
}
|
||||
|
||||
virtual Node *GetConnectedRenderOutput(const QString &input,
|
||||
virtual Node *get_connected_render_output(const QString &input,
|
||||
int element = -1) const override;
|
||||
virtual bool IsInputConnectedForRender(const QString &input,
|
||||
virtual bool is_input_connected_for_render(const QString &input,
|
||||
int element = -1) const override;
|
||||
|
||||
virtual QVector<QString> IgnoreInputsForRendering() const override;
|
||||
virtual QVector<QString> ignore_inputs_for_rendering() const override;
|
||||
|
||||
protected:
|
||||
virtual void InputConnectedEvent(const QString &input, int element,
|
||||
@@ -93,11 +93,11 @@ protected:
|
||||
Node *output) override;
|
||||
|
||||
private:
|
||||
TrackList *GetTrackList() const;
|
||||
TrackList *get_track_list() const;
|
||||
|
||||
Sequence *sequence_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MULTICAMNODE_H
|
||||
#endif // OAK_MULTICAMNODE_H
|
||||
|
||||
@@ -30,7 +30,7 @@ TimeInput::TimeInput()
|
||||
{
|
||||
}
|
||||
|
||||
QString TimeInput::Name() const
|
||||
QString TimeInput::name() const
|
||||
{
|
||||
return tr("Time");
|
||||
}
|
||||
@@ -40,20 +40,20 @@ QString TimeInput::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.time");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TimeInput::Category() const
|
||||
QVector<Node::CategoryID> TimeInput::category() const
|
||||
{
|
||||
return { kCategoryTime };
|
||||
return { k_category_time };
|
||||
}
|
||||
|
||||
QString TimeInput::Description() const
|
||||
QString TimeInput::description() const
|
||||
{
|
||||
return tr("Generates the time (in seconds) at this frame.");
|
||||
}
|
||||
|
||||
void TimeInput::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void TimeInput::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
table->Push(NodeValue::kFloat, globals.time().in().toDouble(), this, false,
|
||||
table->push(NodeValue::k_float, globals.time().in().to_double(), this, false,
|
||||
QStringLiteral("time"));
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user