merged effects into node structure

This commit is contained in:
itsmattkc
2019-04-12 21:50:52 +10:00
parent 4e4d2b1881
commit b21745f694
127 changed files with 1674 additions and 867 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
#include "boolinput.h"
BoolInput::BoolInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
BoolInput::BoolInput(Node* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
BoolField* bool_field = new BoolField(this);
+1 -1
View File
@@ -7,7 +7,7 @@ class BoolInput : public EffectRow
{
Q_OBJECT
public:
BoolInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
BoolInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the boolean value at a given timecode
+2 -2
View File
@@ -1,6 +1,6 @@
#include "colorinput.h"
ColorInput::ColorInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
ColorInput::ColorInput(Node* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new ColorField(this));
@@ -10,5 +10,5 @@ ColorInput::ColorInput(Effect* parent, const QString& id, const QString& name, b
QColor ColorInput::GetColorAt(double timecode)
{
static_cast<ColorField*>(Field(0))->GetColorAt(timecode);
return static_cast<ColorField*>(Field(0))->GetColorAt(timecode);
}
+1 -1
View File
@@ -7,7 +7,7 @@ class ColorInput : public EffectRow
{
Q_OBJECT
public:
ColorInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
ColorInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the color value at a given timecode
+1 -1
View File
@@ -1,6 +1,6 @@
#include "comboinput.h"
ComboInput::ComboInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
ComboInput::ComboInput(Node* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
ComboField* combo_field = new ComboField(this);
+1 -1
View File
@@ -7,7 +7,7 @@ class ComboInput : public EffectRow
{
Q_OBJECT
public:
ComboInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
ComboInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Add an item to this ComboInput
+1 -1
View File
@@ -1,6 +1,6 @@
#include "fileinput.h"
FileInput::FileInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
FileInput::FileInput(Node* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new FileField(this));
+1 -1
View File
@@ -7,7 +7,7 @@ class FileInput : public EffectRow
{
Q_OBJECT
public:
FileInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
FileInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the filename at the given timecode
+1 -1
View File
@@ -1,6 +1,6 @@
#include "fontinput.h"
FontInput::FontInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
FontInput::FontInput(Node* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new FontField(this));
+1 -1
View File
@@ -7,7 +7,7 @@ class FontInput : public EffectRow
{
Q_OBJECT
public:
FontInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
FontInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the font family name at the given timecode
+1 -1
View File
@@ -1,6 +1,6 @@
#include "stringinput.h"
StringInput::StringInput(Effect* parent, const QString& id, const QString& name, bool rich_text, bool savable, bool keyframable) :
StringInput::StringInput(Node* parent, const QString& id, const QString& name, bool rich_text, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new StringField(this, rich_text));
+1 -1
View File
@@ -7,7 +7,7 @@ class StringInput : public EffectRow
{
Q_OBJECT
public:
StringInput(Effect* parent,
StringInput(Node* parent,
const QString& id,
const QString& name,
bool rich_text = true,
+5 -5
View File
@@ -4,7 +4,7 @@
#include <QVector4D>
#include <QDebug>
VecInput::VecInput(Effect* parent, const QString& id, const QString& name, int values, bool savable, bool keyframable) :
VecInput::VecInput(Node* parent, const QString& id, const QString& name, int values, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable),
single_value_mode_(false),
values_(values)
@@ -79,7 +79,7 @@ void VecInput::SetSingleValueMode(bool on)
}
}
DoubleInput::DoubleInput(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
DoubleInput::DoubleInput(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 1, savable, keyframable)
{
}
@@ -89,7 +89,7 @@ double DoubleInput::GetDoubleAt(double timecode)
return static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode);
}
Vec2Input::Vec2Input(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
Vec2Input::Vec2Input(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 2, savable, keyframable)
{
}
@@ -121,7 +121,7 @@ void Vec2Input::SetValueAt(double timecode, const QVariant &value)
static_cast<DoubleField*>(Field(1))->SetValueAt(timecode, vec2.y());
}
Vec3Input::Vec3Input(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
Vec3Input::Vec3Input(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 3, savable, keyframable)
{
}
@@ -156,7 +156,7 @@ void Vec3Input::SetValueAt(double timecode, const QVariant &value)
static_cast<DoubleField*>(Field(2))->SetValueAt(timecode, vec3.z());
}
Vec4Input::Vec4Input(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
Vec4Input::Vec4Input(Node *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 4, savable, keyframable)
{
}
+5 -5
View File
@@ -9,7 +9,7 @@ class VecInput : public EffectRow
{
Q_OBJECT
public:
VecInput(Effect* parent, const QString& id, const QString& name, int values, bool savable = true, bool keyframable = true);
VecInput(Node* parent, const QString& id, const QString& name, int values, bool savable = true, bool keyframable = true);
void SetMinimum(double minimum);
void SetMaximum(double maximum);
@@ -43,14 +43,14 @@ private:
class DoubleInput : public VecInput
{
public:
DoubleInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
DoubleInput(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
double GetDoubleAt(double timecode);
};
class Vec2Input : public VecInput {
public:
Vec2Input(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
Vec2Input(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
QVector2D GetVector2DAt(double timecode);
virtual QVariant GetValueAt(double timecode) override;
@@ -59,7 +59,7 @@ public:
class Vec3Input : public VecInput {
public:
Vec3Input(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
Vec3Input(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
QVector3D GetVector3DAt(double timecode);
virtual QVariant GetValueAt(double timecode) override;
@@ -68,7 +68,7 @@ public:
class Vec4Input : public VecInput {
public:
Vec4Input(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
Vec4Input(Node* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
QVector4D GetVector4DAt(double timecode);
virtual QVariant GetValueAt(double timecode) override;
+957
View File
@@ -0,0 +1,957 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "node.h"
#include <QCheckBox>
#include <QGridLayout>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QMessageBox>
#include <QOpenGLContext>
#include <QDir>
#include <QPainter>
#include <QtMath>
#include <QMenu>
#include <QApplication>
#include <QFileDialog>
#include "panels/panels.h"
#include "panels/viewer.h"
#include "ui/viewerwidget.h"
#include "ui/collapsiblewidget.h"
#include "panels/project.h"
#include "undo/undo.h"
#include "timeline/sequence.h"
#include "timeline/clip.h"
#include "panels/timeline.h"
#include "panels/effectcontrols.h"
#include "panels/grapheditor.h"
#include "global/debug.h"
#include "global/path.h"
#include "ui/mainwindow.h"
#include "global/math.h"
#include "global/clipboard.h"
#include "global/config.h"
#include "effects/transition.h"
#include "undo/undostack.h"
#include "rendering/shadergenerators.h"
#include "global/timing.h"
#include "nodes/nodes.h"
QVector<NodePtr> olive::node_library;
/*
NodePtr Node::Create(Clip* c) {
// must be an internal effect
switch (em->internal) {
case kTransformEffect: return std::make_shared<TransformEffect>(c, em);
case kTextInput: return std::make_shared<TextEffect>(c, em);
case kTimecodeEffect: return std::make_shared<TimecodeEffect>(c, em);
case kSolidInput: return std::make_shared<SolidEffect>(c, em);
case kNoiseInput: return std::make_shared<AudioNoiseEffect>(c, em);
case kVolumeEffect: return std::make_shared<VolumeEffect>(c, em);
case kPanEffect: return std::make_shared<PanEffect>(c, em);
case kToneInput: return std::make_shared<ToneEffect>(c, em);
case kShakeEffect: return std::make_shared<ShakeEffect>(c, em);
case kCornerPinEffect: return std::make_shared<CornerPinEffect>(c, em);
case kFillLeftRightEffect: return std::make_shared<FillLeftRightEffect>(c, em);
case kVstEffect: return std::make_shared<VSTHost>(c, em);
case kRichTextInput: return std::make_shared<RichTextEffect>(c, em);
case kMediaInput: return std::make_shared<NodeMedia>(c, em);
case kShaderEffect: return std::make_shared<NodeShader>(c, em);
case kImageOutput: return std::make_shared<NodeImageOutput>(c, em);
default:
qCritical() << "Invalid effect data";
QMessageBox::critical(olive::MainWindow,
QCoreApplication::translate("Effect", "Invalid effect"),
QCoreApplication::translate("Effect", "No candidate for effect '%1'. This effect may be "
"corrupt. Try reinstalling it or Olive.").arg(em->name));
return nullptr;
}
}
*/
/*
const EffectMeta* Node::GetInternalMeta(int internal_id, int type) {
for (int i=0;i<olive::effects.size();i++) {
if (olive::effects.at(i).internal == internal_id && olive::effects.at(i).type == type) {
return &olive::effects.at(i);
}
}
return nullptr;
}
*/
Node::Node(Clip* c) :
parent_clip(c),
flags_(0),
shader_program_(nullptr),
texture(0),
tex_width_(0),
tex_height_(0),
isOpen(false),
bound(false),
iterations(1),
enabled_(true),
expanded_(true),
texture_ctx(nullptr)
{
}
Node::~Node() {
if (isOpen) {
close();
}
// Clear graph editor if it's using one of these rows
if (panel_graph_editor != nullptr) {
for (int i=0;i<row_count();i++) {
if (row(i) == panel_graph_editor->get_row()) {
panel_graph_editor->set_row(nullptr);
break;
}
}
}
}
QString Node::category()
{
return QString();
}
bool Node::IsCreatable()
{
return true;
}
void Node::AddRow(EffectRow *row)
{
row->setParent(this);
rows.append(row);
}
void Node::copy_field_keyframes(NodePtr e) {
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
EffectRow* copy_row = e->rows.at(i);
copy_row->SetKeyframingInternal(row->IsKeyframing());
for (int j=0;j<row->FieldCount();j++) {
// Get field from this (the source) effect
EffectField* field = row->Field(j);
// Get field from the destination effect
EffectField* copy_field = copy_row->Field(j);
// Copy keyframes between effects
copy_field->keyframes = field->keyframes;
// Copy persistet data between effects
copy_field->persistent_data_ = field->persistent_data_;
}
}
}
EffectRow* Node::row(int i) {
return rows.at(i);
}
int Node::row_count() {
return rows.size();
}
EffectGizmo *Node::add_gizmo(int type) {
EffectGizmo* gizmo = new EffectGizmo(this, type);
gizmos.append(gizmo);
return gizmo;
}
EffectGizmo *Node::gizmo(int i) {
return gizmos.at(i);
}
int Node::gizmo_count() {
return gizmos.size();
}
void Node::refresh() {}
void Node::FieldChanged() {
// Update the UI if a field has been modified, but don't both if this effect is inactive
if (parent_clip != nullptr) {
update_ui(false);
}
}
void Node::delete_self() {
olive::undo_stack.push(new EffectDeleteCommand(this));
update_ui(true);
}
void Node::move_up() {
int index_of_effect = parent_clip->IndexOfEffect(this);
if (index_of_effect == 0) {
return;
}
MoveEffectCommand* command = new MoveEffectCommand();
command->clip = parent_clip;
command->from = index_of_effect;
command->to = command->from - 1;
olive::undo_stack.push(command);
panel_effect_controls->Reload();
panel_sequence_viewer->viewer_widget()->frame_update();
}
void Node::move_down() {
int index_of_effect = parent_clip->IndexOfEffect(this);
if (index_of_effect == parent_clip->effects.size()-1) {
return;
}
MoveEffectCommand* command = new MoveEffectCommand();
command->clip = parent_clip;
command->from = index_of_effect;
command->to = command->from + 1;
olive::undo_stack.push(command);
panel_effect_controls->Reload();
panel_sequence_viewer->viewer_widget()->frame_update();
}
void Node::save_to_file() {
// save effect settings to file
QString file = QFileDialog::getSaveFileName(olive::MainWindow,
tr("Save Effect Settings"),
QString(),
tr("Effect XML Settings %1").arg("(*.xml)"));
// if the user picked a file
if (!file.isEmpty()) {
// ensure file ends with .xml extension
if (!file.endsWith(".xml", Qt::CaseInsensitive)) {
file.append(".xml");
}
QFile file_handle(file);
if (file_handle.open(QFile::WriteOnly)) {
file_handle.write(save_to_string());
file_handle.close();
} else {
QMessageBox::critical(olive::MainWindow,
tr("Save Settings Failed"),
tr("Failed to open \"%1\" for writing.").arg(file),
QMessageBox::Ok);
}
}
}
void Node::load_from_file() {
// load effect settings from file
QString file = QFileDialog::getOpenFileName(olive::MainWindow,
tr("Load Effect Settings"),
QString(),
tr("Effect XML Settings %1").arg("(*.xml)"));
// if the user picked a file
if (!file.isEmpty()) {
QFile file_handle(file);
if (file_handle.open(QFile::ReadOnly)) {
olive::undo_stack.push(new SetEffectData(this, file_handle.readAll()));
file_handle.close();
update_ui(false);
} else {
QMessageBox::critical(olive::MainWindow,
tr("Load Settings Failed"),
tr("Failed to open \"%1\" for reading.").arg(file),
QMessageBox::Ok);
}
}
}
bool Node::AlwaysUpdate()
{
return false;
}
bool Node::IsEnabled() {
return enabled_;
}
bool Node::IsExpanded()
{
return expanded_;
}
void Node::SetExpanded(bool e)
{
expanded_ = e;
}
void Node::SetEnabled(bool b) {
enabled_ = b;
emit EnabledChanged(b);
}
void Node::load(QXmlStreamReader& stream) {
/*
int row_count = 0;
QString tag = stream.name().toString();
while (!stream.atEnd() && !(stream.name() == tag && stream.isEndElement())) {
stream.readNext();
if (stream.name() == "row" && stream.isStartElement()) {
if (row_count < rows.size()) {
EffectRow* row = rows.at(row_count);
while (!stream.atEnd() && !(stream.name() == "row" && stream.isEndElement())) {
stream.readNext();
// read field
if (stream.name() == "field" && stream.isStartElement()) {
int field_number = -1;
// match field using ID
for (int k=0;k<stream.attributes().size();k++) {
const QXmlStreamAttribute& attr = stream.attributes().at(k);
if (attr.name() == "id") {
for (int l=0;l<row->FieldCount();l++) {
if (row->Field(l)->id() == attr.value()) {
field_number = l;
break;
}
}
break;
}
}
if (field_number > -1) {
EffectField* field = row->Field(field_number);
// get current field value
for (int k=0;k<stream.attributes().size();k++) {
const QXmlStreamAttribute& attr = stream.attributes().at(k);
if (attr.name() == "value") {
field->persistent_data_ = field->ConvertStringToValue(attr.value().toString());
break;
}
}
while (!stream.atEnd() && !(stream.name() == "field" && stream.isEndElement())) {
stream.readNext();
// read keyframes
if (stream.name() == "key" && stream.isStartElement()) {
row->SetKeyframingInternal(true);
EffectKeyframe key;
for (int k=0;k<stream.attributes().size();k++) {
const QXmlStreamAttribute& attr = stream.attributes().at(k);
if (attr.name() == "value") {
key.data = field->ConvertStringToValue(attr.value().toString());
} else if (attr.name() == "frame") {
key.time = attr.value().toLong();
} else if (attr.name() == "type") {
key.type = attr.value().toInt();
} else if (attr.name() == "prehx") {
key.pre_handle_x = attr.value().toDouble();
} else if (attr.name() == "prehy") {
key.pre_handle_y = attr.value().toDouble();
} else if (attr.name() == "posthx") {
key.post_handle_x = attr.value().toDouble();
} else if (attr.name() == "posthy") {
key.post_handle_y = attr.value().toDouble();
}
}
field->keyframes.append(key);
}
}
field->Changed();
}
}
}
} else {
qCritical() << "Too many rows for effect" << id << ". Project might be corrupt. (Got" << row_count << ", expected <" << rows.size()-1 << ")";
}
row_count++;
} else if (stream.isStartElement()) {
custom_load(stream);
}
}
*/
}
void Node::custom_load(QXmlStreamReader &) {}
void Node::save(QXmlStreamWriter& stream) {
/*
stream.writeAttribute("name", meta->category + "/" + meta->name);
stream.writeAttribute("enabled", QString::number(IsEnabled()));
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
if (row->IsSavable()) {
stream.writeStartElement("row"); // row
for (int j=0;j<row->FieldCount();j++) {
EffectField* field = row->Field(j);
if (!field->id().isEmpty()) {
stream.writeStartElement("field"); // field
stream.writeAttribute("id", field->id());
stream.writeAttribute("value", field->ConvertValueToString(field->persistent_data_));
for (int k=0;k<field->keyframes.size();k++) {
const EffectKeyframe& key = field->keyframes.at(k);
stream.writeStartElement("key");
stream.writeAttribute("value", field->ConvertValueToString(key.data));
stream.writeAttribute("frame", QString::number(key.time));
stream.writeAttribute("type", QString::number(key.type));
stream.writeAttribute("prehx", QString::number(key.pre_handle_x));
stream.writeAttribute("prehy", QString::number(key.pre_handle_y));
stream.writeAttribute("posthx", QString::number(key.post_handle_x));
stream.writeAttribute("posthy", QString::number(key.post_handle_y));
stream.writeEndElement(); // key
}
stream.writeEndElement(); // field
}
}
stream.writeEndElement(); // row
}
}
*/
}
void Node::load_from_string(const QByteArray &s) {
// clear existing keyframe data
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
row->SetKeyframingInternal(false);
for (int j=0;j<row->FieldCount();j++) {
EffectField* field = row->Field(j);
field->keyframes.clear();
}
}
// write settings with xml writer
QXmlStreamReader stream(s);
bool found_id = false;
while (!stream.atEnd()) {
stream.readNext();
// find the effect opening tag
if (stream.name() == "effect" && stream.isStartElement()) {
// check the name to see if it matches this effect
const QXmlStreamAttributes& attributes = stream.attributes();
for (int i=0;i<attributes.size();i++) {
const QXmlStreamAttribute& attr = attributes.at(i);
if (attr.name() == "id") {
load(stream);
found_id = true;
break;
}
}
// we've found what we're looking for
break;
}
}
if (!found_id) {
QMessageBox::critical(olive::MainWindow,
tr("Load Settings Failed"),
tr("This settings file doesn't match this effect."),
QMessageBox::Ok);
}
}
QByteArray Node::save_to_string() {
QByteArray save_data;
// write settings to string with xml writer
QXmlStreamWriter stream(&save_data);
stream.writeStartDocument();
stream.writeStartElement("effect");
// pass off to standard saving function
save(stream);
stream.writeEndElement(); // effect
stream.writeEndDocument();
return save_data;
}
bool Node::is_open() {
return isOpen;
}
void Node::validate_meta_path() {
/*
if (!meta->path.isEmpty() || (shader_vert_path_.isEmpty() && shader_frag_path_.isEmpty())) return;
QList<QString> effects_paths = get_effects_paths();
const QString& test_fn = shader_vert_path_.isEmpty() ? shader_frag_path_ : shader_vert_path_;
for (int i=0;i<effects_paths.size();i++) {
if (QFileInfo::exists(effects_paths.at(i) + "/" + test_fn)) {
for (int j=0;j<olive::effects.size();j++) {
if (&olive::effects.at(j) == meta) {
olive::effects[j].path = effects_paths.at(i);
return;
}
}
return;
}
}
*/
}
void Node::open() {
/*
if (isOpen) {
qWarning() << "Tried to open an effect that was already open";
close();
}
if (olive::runtime_config.shaders_are_enabled && (Flags() & ShaderFlag)) {
if (QOpenGLContext::currentContext() == nullptr) {
qWarning() << "No current context to create a shader program for - will retry next repaint";
} else {
validate_meta_path();
QString frag_shader_str;
QString frag_file_url = QDir(file).filePath(shader_frag_path_);
QFile frag_file(frag_file_url);
if (frag_file.open(QFile::ReadOnly)) {
frag_shader_str = frag_file.readAll();
frag_file.close();
} else {
qWarning() << "Failed to open" << frag_file_url;
}
if (!frag_shader_str.isEmpty()) {
QString shader_func;
if (!shader_function_name_.isEmpty()) {
shader_func = shader_function_name_;
} else {
shader_func = "process";
}
shader_program_ = olive::shader::GetPipeline(shader_func, frag_shader_str);
}
isOpen = true;
}
} else {
isOpen = true;
}
*/
isOpen = true;
}
void Node::close() {
if (!isOpen) {
qWarning() << "Tried to close an effect that was already closed";
}
delete_texture();
shader_program_ = nullptr;
isOpen = false;
}
bool Node::is_shader_linked() {
return shader_program_ != nullptr && shader_program_->isLinked();
}
QOpenGLShaderProgram *Node::GetShaderPipeline()
{
return shader_program_.get();
}
int Node::Flags()
{
return flags_;
}
void Node::SetFlags(int flags)
{
flags_ = flags;
}
int Node::getIterations() {
return iterations;
}
void Node::setIterations(int i) {
iterations = i;
}
void Node::process_image(double, uint8_t *, uint8_t *, int){}
NodePtr Node::copy(Clip *c) {
NodePtr copy = Create(c);
copy->SetEnabled(IsEnabled());
copy_field_keyframes(copy);
return copy;
}
void Node::process_shader(double timecode, GLTextureCoords&, int iteration) {
/*
shader_program_->bind();
shader_program_->setUniformValue("resolution", parent_clip->media_width(), parent_clip->media_height());
shader_program_->setUniformValue("time", GLfloat(timecode));
shader_program_->setUniformValue("iteration", iteration);
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
for (int j=0;j<row->FieldCount();j++) {
EffectField* field = row->Field(j);
if (!field->id().isEmpty()) {
switch (field->type()) {
case EffectField::EFFECT_FIELD_DOUBLE:
{
DoubleField* double_field = static_cast<DoubleField*>(field);
shader_program_->setUniformValue(double_field->id().toUtf8().constData(),
GLfloat(double_field->GetDoubleAt(timecode)));
}
break;
case EffectField::EFFECT_FIELD_COLOR:
{
ColorField* color_field = static_cast<ColorField *>(field);
shader_program_->setUniformValue(
color_field->id().toUtf8().constData(),
GLfloat(color_field->GetColorAt(timecode).redF()),
GLfloat(color_field->GetColorAt(timecode).greenF()),
GLfloat(color_field->GetColorAt(timecode).blueF())
);
}
break;
case EffectField::EFFECT_FIELD_BOOL:
shader_program_->setUniformValue(field->id().toUtf8().constData(), field->GetValueAt(timecode).toBool());
break;
case EffectField::EFFECT_FIELD_COMBO:
shader_program_->setUniformValue(field->id().toUtf8().constData(), field->GetValueAt(timecode).toInt());
break;
// can you even send a string to a uniform value?
case EffectField::EFFECT_FIELD_STRING:
case EffectField::EFFECT_FIELD_FONT:
case EffectField::EFFECT_FIELD_FILE:
case EffectField::EFFECT_FIELD_UI:
break;
}
}
}
}
shader_program_->release();
*/
}
void Node::process_coords(double, GLTextureCoords&, int) {}
GLuint Node::process_superimpose(QOpenGLContext* ctx, double timecode) {
bool dimensions_changed = false;
bool redrew_image = false;
int width = parent_clip->media_width();
int height = parent_clip->media_height();
if (width != img.width() || height != img.height()) {
img = QImage(width, height, QImage::Format_RGBA8888_Premultiplied);
dimensions_changed = true;
}
if (valueHasChanged(timecode) || dimensions_changed || AlwaysUpdate()) {
redraw(timecode);
redrew_image = true;
}
QOpenGLFunctions* f = ctx->functions();
if (texture == 0 || tex_width_ != img.width() || tex_height_ != img.height()) {
delete_texture();
tex_width_ = img.width();
tex_height_ = img.height();
// create texture object
f->glGenTextures(1, &texture);
f->glBindTexture(GL_TEXTURE_2D, texture);
// set texture filtering to bilinear
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
f->glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA8, tex_width_, tex_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.constBits()
);
f->glBindTexture(GL_TEXTURE_2D, 0);
redrew_image = false;
}
if (redrew_image) {
f->glBindTexture(GL_TEXTURE_2D, texture);
f->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tex_width_, tex_height_, GL_RGBA, GL_UNSIGNED_BYTE, img.constBits());
f->glBindTexture(GL_TEXTURE_2D, 0);
}
return texture;
}
void Node::process_audio(double, double, float **, int, int, int) {}
void Node::gizmo_draw(double, GLTextureCoords &) {}
void Node::gizmo_move(EffectGizmo* gizmo, int x_movement, int y_movement, double timecode, bool done) {
// Loop through each gizmo to find `gizmo`
for (int i=0;i<gizmos.size();i++) {
if (gizmos.at(i) == gizmo) {
// If (!done && gizmo_dragging_actions_.isEmpty()), that means the drag just started and we're going to save
// the current state of the attach fields' keyframes in KeyframeDataChange objects to make the changes undoable
// by the user later.
if (!done && gizmo_dragging_actions_.isEmpty()) {
if (gizmo->x_field1 != nullptr) {
gizmo_dragging_actions_.append(new KeyframeDataChange(gizmo->x_field1));
}
if (gizmo->y_field1 != nullptr) {
gizmo_dragging_actions_.append(new KeyframeDataChange(gizmo->y_field1));
}
if (gizmo->x_field2 != nullptr) {
gizmo_dragging_actions_.append(new KeyframeDataChange(gizmo->x_field2));
}
if (gizmo->y_field2 != nullptr) {
gizmo_dragging_actions_.append(new KeyframeDataChange(gizmo->y_field2));
}
}
// Update the field values
if (gizmo->x_field1 != nullptr) {
gizmo->x_field1->SetValueAt(timecode,
gizmo->x_field1->GetDoubleAt(timecode) + x_movement*gizmo->x_field_multi1);
}
if (gizmo->y_field1 != nullptr) {
gizmo->y_field1->SetValueAt(timecode,
gizmo->y_field1->GetDoubleAt(timecode) + y_movement*gizmo->y_field_multi1);
}
if (gizmo->x_field2 != nullptr) {
gizmo->x_field2->SetValueAt(timecode,
gizmo->x_field2->GetDoubleAt(timecode) + x_movement*gizmo->x_field_multi2);
}
if (gizmo->y_field2 != nullptr) {
gizmo->y_field2->SetValueAt(timecode,
gizmo->y_field2->GetDoubleAt(timecode) + y_movement*gizmo->y_field_multi2);
}
// If (done && !gizmo_dragging_actions_.isEmpty()), that means the drag just ended and we're going to save
// the new state of the attach fields' keyframes in KeyframeDataChange objects to make the changes undoable
// by the user later.
if (done && !gizmo_dragging_actions_.isEmpty()) {
// Store all the KeyframeDataChange objects into a ComboAction to send to the undo stack (makes them all
// undoable together rather than having to be undone individually).
ComboAction* ca = new ComboAction();
for (int j=0;j<gizmo_dragging_actions_.size();j++) {
// Set the current state of the keyframes as the "new" keyframes (the old values were set earlier when the
// KeyframeDataChange object was constructed).
gizmo_dragging_actions_.at(j)->SetNewKeyframes();
// Add this KeyframeDataChange object to the ComboAction
ca->append(gizmo_dragging_actions_.at(j));
}
olive::undo_stack.push(ca);
gizmo_dragging_actions_.clear();
}
break;
}
}
}
void Node::gizmo_world_to_screen(const QMatrix4x4& matrix, const QMatrix4x4& projection) {
for (int i=0;i<gizmos.size();i++) {
EffectGizmo* g = gizmos.at(i);
for (int j=0;j<g->get_point_count();j++) {
// Convert the world point from the gizmo into a screen point relative to the sequence's dimensions
QVector3D screen_pos = g->world_pos.at(j).project(matrix,
projection,
QRect(0,
0,
parent_clip->track()->sequence()->width,
parent_clip->track()->sequence()->height));
g->screen_pos[j] = QPoint(screen_pos.x(), parent_clip->track()->sequence()->height-screen_pos.y());
}
}
}
bool Node::are_gizmos_enabled() {
return (gizmos.size() > 0);
}
double Node::Now()
{
return playhead_to_clip_seconds(parent_clip, parent_clip->track()->sequence()->playhead);
}
long Node::NowInFrames()
{
return playhead_to_clip_frame(parent_clip, parent_clip->track()->sequence()->playhead);
}
void Node::redraw(double) {
/*
// run javascript
QPainter p(&img);
painter_wrapper.img = &img;
painter_wrapper.painter = &p;
jsEngine.globalObject().setProperty("painter", wrapper_obj);
jsEngine.globalObject().setProperty("width", parent_clip->media_width());
jsEngine.globalObject().setProperty("height", parent_clip->media_height());
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
for (int j=0;j<row->fieldCount();j++) {
EffectField* field = row->field(j);
if (!field->id.isEmpty()) {
switch (field->type) {
case EffectField::EFFECT_FIELD_DOUBLE:
jsEngine.globalObject().setProperty(field->id, field->get_double_value(timecode));
break;
case EffectField::EFFECT_FIELD_COLOR:
jsEngine.globalObject().setProperty(field->id, field->get_color_value(timecode).name());
break;
case EffectField::EFFECT_FIELD_STRING:
jsEngine.globalObject().setProperty(field->id, field->get_string_value(timecode));
break;
case EffectField::EFFECT_FIELD_BOOL:
jsEngine.globalObject().setProperty(field->id, field->get_bool_value(timecode));
break;
case EffectField::EFFECT_FIELD_COMBO:
jsEngine.globalObject().setProperty(field->id, field->get_combo_index(timecode));
break;
case EffectField::EFFECT_FIELD_FONT:
jsEngine.globalObject().setProperty(field->id, field->get_font_name(timecode));
break;
}
}
}
}
jsEngine.evaluate(script);
*/
}
bool Node::valueHasChanged(double timecode) {
if (cachedValues.isEmpty()) {
for (int i=0;i<row_count();i++) {
EffectRow* crow = row(i);
for (int j=0;j<crow->FieldCount();j++) {
cachedValues.append(crow->Field(j)->GetValueAt(timecode));
}
}
return true;
} else {
bool changed = false;
int index = 0;
for (int i=0;i<row_count();i++) {
EffectRow* crow = row(i);
for (int j=0;j<crow->FieldCount();j++) {
EffectField* field = crow->Field(j);
if (cachedValues.at(index) != field->GetValueAt(timecode)) {
changed = true;
}
cachedValues[index] = field->GetValueAt(timecode);
index++;
}
}
return changed;
}
}
void Node::delete_texture() {
if (texture_ctx != nullptr) {
texture_ctx->functions()->glDeleteTextures(1, &texture);
texture = 0;
texture_ctx = nullptr;
}
}
int GetNodeLibraryIndexFromId(const QString& id) {
for (int i=0;i<olive::node_library.size();i++) {
if (olive::node_library.at(i)->id() == id) {
return i;
}
}
return -1;
}
/*
const EffectMeta* Node::GetMetaFromName(const QString& input) {
int split_index = input.indexOf('/');
QString category;
if (split_index > -1) {
category = input.left(split_index);
}
QString name = input.mid(split_index + 1);
for (int j=0;j<olive::effects.size();j++) {
if (olive::effects.at(j).name == name
&& (olive::effects.at(j).category == category
|| category.isEmpty())) {
return &olive::effects.at(j);
}
}
return nullptr;
}
*/
+279
View File
@@ -0,0 +1,279 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef EFFECT_H
#define EFFECT_H
#include <memory>
#include <QObject>
#include <QString>
#include <QVector>
#include <QColor>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QMutex>
#include <QThread>
#include <QLabel>
#include <QWidget>
#include <QGridLayout>
#include <QPushButton>
#include <QMouseEvent>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <random>
#include "timeline/tracktypes.h"
#include "rendering/qopenglshaderprogramptr.h"
#include "inputs.h"
#include "effects/effectgizmo.h"
class EffectGizmo;
class KeyframeDataChange;
class Clip;
using ClipPtr = std::shared_ptr<Clip>;
class Node;
using NodePtr = std::shared_ptr<Node>;
enum NodeType {
kTransformEffect,
kTextInput,
kSolidInput,
kNoiseInput,
kVolumeEffect,
kPanEffect,
kToneInput,
kShakeEffect,
kTimecodeEffect,
kMaskEffect,
kFillLeftRightEffect,
kVstEffect,
kCornerPinEffect,
kRichTextInput,
kMediaInput,
kShaderEffect,
kImageOutput,
kCrossDissolveTransition,
kLinearFadeTransition,
kExponentialFadeTransition,
kLogarithmicFadeTransition,
kInvalidNode
};
double log_volume(double linear);
enum EffectType {
EFFECT_TYPE_INVALID,
EFFECT_TYPE_EFFECT,
EFFECT_TYPE_TRANSITION
};
enum EffectKeyframeType {
EFFECT_KEYFRAME_LINEAR,
EFFECT_KEYFRAME_BEZIER,
EFFECT_KEYFRAME_HOLD
};
struct GLTextureCoords {
QMatrix4x4 matrix;
QVector3D vertex_top_left;
QVector3D vertex_top_right;
QVector3D vertex_bottom_left;
QVector3D vertex_bottom_right;
QVector2D texture_top_left;
QVector2D texture_top_right;
QVector2D texture_bottom_left;
QVector2D texture_bottom_right;
float opacity;
};
class Node : public QObject {
Q_OBJECT
public:
Node(Clip *c);
~Node();
Clip* parent_clip;
virtual QString name() = 0;
virtual QString id() = 0;
virtual QString category();
virtual QString description() = 0;
virtual EffectType type() = 0;
virtual olive::TrackType subtype() = 0;
virtual bool IsCreatable();
virtual NodePtr Create(Clip *c) = 0;
void AddRow(EffectRow* row);
EffectRow* row(int i);
int row_count();
EffectGizmo* add_gizmo(int type);
EffectGizmo* gizmo(int i);
int gizmo_count();
bool IsEnabled();
bool IsExpanded();
virtual void refresh();
virtual NodePtr copy(Clip* c);
void copy_field_keyframes(NodePtr e);
virtual void load(QXmlStreamReader& stream);
virtual void custom_load(QXmlStreamReader& stream);
virtual void save(QXmlStreamWriter& stream);
void load_from_string(const QByteArray &s);
QByteArray save_to_string();
// glsl handling
bool is_open();
void open();
void close();
bool is_shader_linked();
QOpenGLShaderProgram* GetShaderPipeline();
enum VideoEffectFlags {
ShaderFlag = 0x1,
CoordsFlag = 0x2,
SuperimposeFlag = 0x4
};
int Flags();
void SetFlags(int flags);
int getIterations();
void setIterations(int i);
virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
virtual void process_shader(double timecode, GLTextureCoords&, int iteration);
virtual void process_coords(double timecode, GLTextureCoords& coords, int data);
virtual GLuint process_superimpose(QOpenGLContext *ctx, double timecode);
virtual void process_audio(double timecode_start, double timecode_end, float **samples, int nb_samples, int nb_channels, int type);
virtual void gizmo_draw(double timecode, GLTextureCoords& coords);
void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode, bool done);
void gizmo_world_to_screen(const QMatrix4x4 &matrix, const QMatrix4x4 &projection);
bool are_gizmos_enabled();
/**
* @brief Get the current clip/media time
*
* A convenience function that can be plugged into GetValueAt() to get the value wherever the appropriate Sequence's
* playhead it.
*
* @return
*
* Current clip/media time in seconds.
*/
double Now();
/**
* @brief Retrieve the current clip as a frame number
*
* Same as Now() but retrieves the value as a frame number (in the appropriate Sequence's frame rate) instead of
* seconds.
*
* @return
*
* The current clip time in frames
*/
long NowInFrames();
template <typename T>
T randomNumber()
{
static std::random_device device;
static std::mt19937 generator(device());
static std::uniform_int_distribution<> distribution(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
return distribution(generator);
}
template <typename T>
T randomFloat()
{
static std::random_device device;
static std::mt19937 generator(device());
static std::uniform_int_distribution<> distribution(-1.0, 1.0);
return distribution(generator);
}
public slots:
void FieldChanged();
void SetEnabled(bool b);
void SetExpanded(bool e);
signals:
void EnabledChanged(bool);
private slots:
void delete_self();
void move_up();
void move_down();
void save_to_file();
void load_from_file();
protected:
// glsl effect
QOpenGLShaderProgramPtr shader_program_;
QString shader_vert_path_;
QString shader_frag_path_;
QString shader_function_name_;
// superimpose effect
QImage img;
GLuint texture;
QOpenGLContext* texture_ctx;
int tex_width_;
int tex_height_;
// enable effect to update constantly
virtual bool AlwaysUpdate();
private:
bool isOpen;
QVector<EffectRow*> rows;
QVector<EffectGizmo*> gizmos;
bool bound;
int iterations;
bool enabled_;
bool expanded_;
int flags_;
QVector<KeyframeDataChange*> gizmo_dragging_actions_;
// superimpose functions
virtual void redraw(double timecode);
bool valueHasChanged(double timecode);
QVector<QVariant> cachedValues;
void delete_texture();
void validate_meta_path();
};
namespace olive {
extern QVector<NodePtr> node_library;
}
#endif // EFFECT_H
+1 -1
View File
@@ -8,7 +8,7 @@ NodeGraph::NodeGraph() :
}
Effect *NodeGraph::OutputNode()
Node *NodeGraph::OutputNode()
{
return output_node_.get();
}
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef NODEGRAPH_H
#define NODEGRAPH_H
#include "effects/effect.h"
#include "nodes/node.h"
class NodeGraph
{
@@ -15,7 +15,7 @@ public:
*
* @param node
*/
void AddNode(EffectPtr node);
void AddNode(NodePtr node);
/**
* @brief Process the graph
@@ -39,15 +39,15 @@ public:
*
* The node to set as the output node. The graph takes ownership of the node and the user cannot delete it.
*/
void SetOutputNode(EffectPtr node);
void SetOutputNode(NodePtr node);
/**
* @brief Returns the currently set output node
*/
Effect* OutputNode();
Node* OutputNode();
private:
EffectPtr output_node_;
NodePtr output_node_;
};
#endif // NODEGRAPH_H
+37 -1
View File
@@ -1,6 +1,42 @@
#include "nodeimageoutput.h"
NodeImageOutput::NodeImageOutput()
NodeImageOutput::NodeImageOutput(Clip *c) :
Node(c)
{
}
QString NodeImageOutput::name()
{
return tr("Image Output");
}
QString NodeImageOutput::id()
{
return "org.olivevideoeditor.Olive.imageoutput";
}
QString NodeImageOutput::category()
{
return tr("Outputs");
}
QString NodeImageOutput::description()
{
return tr("Used for outputting images outside of the node graph.");
}
EffectType NodeImageOutput::type()
{
return EFFECT_TYPE_EFFECT;
}
olive::TrackType NodeImageOutput::subtype()
{
return olive::kTypeVideo;
}
NodePtr NodeImageOutput::Create(Clip *c)
{
return std::make_shared<NodeImageOutput>(c);
}
+12 -3
View File
@@ -1,11 +1,20 @@
#ifndef NODEIMAGEOUTPUT_H
#define NODEIMAGEOUTPUT_H
#include "nodes/node.h"
class NodeImageOutput
class NodeImageOutput : public Node
{
public:
NodeImageOutput();
NodeImageOutput(Clip* c);
virtual QString name() override;
virtual QString id() override;
virtual QString category() override;
virtual QString description() override;
virtual EffectType type() override;
virtual olive::TrackType subtype() override;
virtual NodePtr Create(Clip *c) override;
};
#endif // NODEIMAGEOUTPUT_H
#endif // NODEIMAGEOUTPUT_H
+36 -1
View File
@@ -1,6 +1,41 @@
#include "nodemedia.h"
NodeMedia::NodeMedia()
NodeMedia::NodeMedia(Clip* c) :
Node(c)
{
}
QString NodeMedia::name()
{
return tr("Media");
}
QString NodeMedia::id()
{
return "org.olivevideoeditor.Olive.media";
}
QString NodeMedia::category()
{
return tr("Inputs");
}
QString NodeMedia::description()
{
return tr("Retrieve frames from a media source.");
}
EffectType NodeMedia::type()
{
return EFFECT_TYPE_EFFECT;
}
olive::TrackType NodeMedia::subtype()
{
return olive::kTypeVideo;
}
NodePtr NodeMedia::Create(Clip *c)
{
return std::make_shared<NodeMedia>(c);
}
+12 -2
View File
@@ -1,10 +1,20 @@
#ifndef MEDIANODE_H
#define MEDIANODE_H
class NodeMedia
#include "nodes/node.h"
class NodeMedia : public Node
{
public:
NodeMedia();
NodeMedia(Clip *c);
virtual QString name() override;
virtual QString id() override;
virtual QString category() override;
virtual QString description() override;
virtual EffectType type() override;
virtual olive::TrackType subtype() override;
virtual NodePtr Create(Clip *c) override;
};
#endif // MEDIANODE_H
+58 -23
View File
@@ -1,10 +1,18 @@
#include "nodeshader.h"
NodeShader::NodeShader(Clip* c, const EffectMeta *em) :
Effect(c, em)
NodeShader::NodeShader(Clip* c,
const QString &name,
const QString &id,
const QString &category,
const QString &filename) :
Node(c),
name_(name),
id_(id),
category_(category),
filename_(filename)
{
if (em != nullptr && !em->filename.isEmpty() && em->internal == -1) {
QFile effect_file(em->filename);
if (!filename_.isEmpty()) {
QFile effect_file(filename_);
if (effect_file.open(QFile::ReadOnly)) {
QXmlStreamReader reader(&effect_file);
@@ -29,7 +37,7 @@ NodeShader::NodeShader(Clip* c, const EffectMeta *em) :
}
if (id.isEmpty() || name.isEmpty() || type == olive::nodes::kInvalid) {
qCritical() << "Couldn't load field from" << em->filename << "- ID, type, and name cannot be empty.";
qCritical() << "Couldn't load field from" << filename_ << "- ID, type, and name cannot be empty.";
} else {
EffectRow* field = nullptr;
@@ -158,29 +166,56 @@ NodeShader::NodeShader(Clip* c, const EffectMeta *em) :
shader_function_name_ = attr.value().toString();
}
}
}/* else if (reader.name() == "superimpose" && reader.isStartElement()) {
enable_superimpose = true;
const QXmlStreamAttributes& attributes = reader.attributes();
for (int i=0;i<attributes.size();i++) {
const QXmlStreamAttribute& attr = attributes.at(i);
if (attr.name() == "script") {
QFile script_file(get_effects_dir() + "/" + attr.value().toString());
if (script_file.open(QFile::ReadOnly)) {
script = script_file.readAll();
} else {
qCritical() << "Failed to open superimpose script file for" << em->filename;
enable_superimpose = false;
}
break;
}
}
}*/
} else if (reader.name() == "description" && reader.isStartElement()) {
reader.readNext();
description_ = reader.text().toString();
}
reader.readNext();
}
effect_file.close();
} else {
qCritical() << "Failed to open effect file" << em->filename;
qCritical() << "Failed to open effect file" << filename;
}
}
}
QString NodeShader::name()
{
return name_;
}
QString NodeShader::id()
{
return id_;
}
QString NodeShader::category()
{
return category_;
}
QString NodeShader::description()
{
return description_;
}
EffectType NodeShader::type()
{
return EFFECT_TYPE_EFFECT;
}
olive::TrackType NodeShader::subtype()
{
return olive::kTypeVideo;
}
bool NodeShader::IsCreatable()
{
return !filename_.isEmpty();
}
NodePtr NodeShader::Create(Clip *)
{
Q_ASSERT(false);
}
+23 -3
View File
@@ -1,12 +1,32 @@
#ifndef NODESHADER_H
#define NODESHADER_H
#include "effects/effect.h"
#include "nodes/node.h"
class NodeShader : public Effect {
class NodeShader : public Node {
Q_OBJECT
public:
NodeShader(Clip *c, const EffectMeta *em);
NodeShader(Clip *c,
const QString& name,
const QString& id,
const QString& category,
const QString& filename);
virtual QString name() override;
virtual QString id() override;
virtual QString category() override;
virtual QString description() override;
virtual EffectType type() override;
virtual olive::TrackType subtype() override;
virtual bool IsCreatable() override;
virtual NodePtr Create(Clip *c) override;
private:
QString name_;
QString id_;
QString category_;
QString description_;
QString filename_;
};
#endif // NODESHADER_H
+1 -1
View File
@@ -1,6 +1,6 @@
#include "buttonwidget.h"
ButtonWidget::ButtonWidget(Effect* parent, const QString& name, const QString& text) :
ButtonWidget::ButtonWidget(Node* parent, const QString& name, const QString& text) :
EffectRow(parent, nullptr, name, false, false)
{
ButtonField* button_field = new ButtonField(this, text);
+1 -1
View File
@@ -6,7 +6,7 @@
class ButtonWidget : public EffectRow
{
public:
ButtonWidget(Effect* parent, const QString& name, const QString& text);
ButtonWidget(Node* parent, const QString& name, const QString& text);
/**
* @brief Wrapper for ButtonField::SetCheckable.
+1 -1
View File
@@ -1,6 +1,6 @@
#include "labelwidget.h"
LabelWidget::LabelWidget(Effect *parent, const QString &name, const QString &text) :
LabelWidget::LabelWidget(Node *parent, const QString &name, const QString &text) :
EffectRow(parent, nullptr, name, false, false)
{
AddField(new LabelField(this, text));
+1 -1
View File
@@ -6,7 +6,7 @@
class LabelWidget : public EffectRow
{
public:
LabelWidget(Effect* parent, const QString& name, const QString& text);
LabelWidget(Node* parent, const QString& name, const QString& text);
};
#endif // LABELWIDGET_H