ported functions to new node type

This commit is contained in:
itsmattkc
2019-05-13 12:00:15 +10:00
parent f796c2b379
commit 49feb12999
53 changed files with 296 additions and 269 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
#include "boolinput.h"
BoolInput::BoolInput(OldEffectNode* 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) :
NodeIO(parent, id, name, savable, keyframable)
{
BoolField* bool_field = new BoolField(this);
+1 -1
View File
@@ -7,7 +7,7 @@ class BoolInput : public NodeIO
{
Q_OBJECT
public:
BoolInput(OldEffectNode* 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
+1 -1
View File
@@ -1,6 +1,6 @@
#include "colorinput.h"
ColorInput::ColorInput(OldEffectNode* 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) :
NodeIO(parent, id, name, savable, keyframable)
{
AddField(new ColorField(this));
+1 -1
View File
@@ -7,7 +7,7 @@ class ColorInput : public NodeIO
{
Q_OBJECT
public:
ColorInput(OldEffectNode* 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(OldEffectNode* 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) :
NodeIO(parent, id, name, savable, keyframable)
{
ComboField* combo_field = new ComboField(this);
+1 -1
View File
@@ -7,7 +7,7 @@ class ComboInput : public NodeIO
{
Q_OBJECT
public:
ComboInput(OldEffectNode* 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(OldEffectNode* 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) :
NodeIO(parent, id, name, savable, keyframable)
{
AddField(new FileField(this));
+1 -1
View File
@@ -7,7 +7,7 @@ class FileInput : public NodeIO
{
Q_OBJECT
public:
FileInput(OldEffectNode* 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(OldEffectNode* 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) :
NodeIO(parent, id, name, savable, keyframable)
{
AddField(new FontField(this));
+1 -1
View File
@@ -7,7 +7,7 @@ class FontInput : public NodeIO
{
Q_OBJECT
public:
FontInput(OldEffectNode* 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(OldEffectNode* 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) :
NodeIO(parent, id, name, savable, keyframable)
{
AddField(new StringField(this, rich_text));
+1 -1
View File
@@ -7,7 +7,7 @@ class StringInput : public NodeIO
{
Q_OBJECT
public:
StringInput(OldEffectNode* 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(OldEffectNode* 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) :
NodeIO(parent, id, name, savable, keyframable),
single_value_mode_(false),
values_(values)
@@ -79,7 +79,7 @@ void VecInput::SetSingleValueMode(bool on)
}
}
DoubleInput::DoubleInput(OldEffectNode *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(OldEffectNode *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(OldEffectNode *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(OldEffectNode *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 NodeIO
{
Q_OBJECT
public:
VecInput(OldEffectNode* 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(OldEffectNode* 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(OldEffectNode* 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(OldEffectNode* 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(OldEffectNode* 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;
+25
View File
@@ -7,6 +7,11 @@ Node::Node(NodeGraph *graph) :
{
}
QString Node::name()
{
return tr("Node");
}
void Node::AddParameter(NodeIO *param)
{
param->setParent(this);
@@ -27,3 +32,23 @@ int Node::ParameterCount()
{
return parameters_.size();
}
NodeGraph *Node::ParentGraph()
{
return static_cast<NodeGraph*>(parent());
}
double Node::Time()
{
return ParentGraph()->Time();
}
const QPointF &Node::pos()
{
return pos_;
}
void Node::SetPos(const QPointF &pos)
{
pos_ = pos;
}
+11
View File
@@ -13,13 +13,24 @@ class Node : public QObject
public:
Node(NodeGraph* parent);
virtual QString name();
void AddParameter(NodeIO* row);
int IndexOfParameter(NodeIO* row);
NodeIO* Parameter(int i);
int ParameterCount();
NodeGraph* ParentGraph();
double Time();
const QPointF& pos();
public slots:
void SetPos(const QPointF& pos);
private:
QVector<NodeIO*> parameters_;
QPointF pos_;
};
#endif // NODE_H
+4 -4
View File
@@ -30,8 +30,8 @@ QString olive::nodes::DataTypeToString(DataType type) {
return "TEXTURE";
case kMatrix:
return "MATRIX";
case kUI:
return "UI";
case kClip:
return "CLIP";
default:
return QString();
}
@@ -67,8 +67,8 @@ olive::nodes::DataType olive::nodes::StringToDataType(const QString &s)
return kTexture;
} else if (s == "MATRIX") {
return kMatrix;
} else if (s == "UI") {
return kUI;
} else if (s == "CLIP") {
return kClip;
}
return kInvalid;
}
+2 -2
View File
@@ -60,8 +60,8 @@ enum DataType {
/** Value is a 4x4 matrix. This cannot be an input field, and can only be passed between nodes. */
kMatrix,
/** Values is a UI object with no data. Corresponds to nothing. */
kUI,
/** Value is a Clip node */
kClip,
/** Total count of valid node data types. Never use this as an actual data type. */
kDataTypeCount
+11
View File
@@ -24,3 +24,14 @@ Node *NodeGraph::OutputNode()
{
return output_node_;
}
double NodeGraph::Time()
{
return time_;
}
void NodeGraph::SetTime(double d)
{
time_ = d;
emit TimeChanged();
}
+6
View File
@@ -41,14 +41,20 @@ public:
*/
Node* OutputNode();
double Time();
void SetTime(double d);
signals:
void NodeGraphChanged();
void TimeChanged();
protected:
virtual void childEvent(QChildEvent *event) override;
private:
Node* output_node_;
double time_;
};
#endif // NODEGRAPH_H
+15 -8
View File
@@ -37,7 +37,7 @@
#include "ui/keyframenavigator.h"
#include "ui/clickablelabel.h"
NodeIO::NodeIO(OldEffectNode *parent,
NodeIO::NodeIO(Node *parent,
const QString &id,
const QString &name,
bool savable,
@@ -52,7 +52,7 @@ NodeIO::NodeIO(OldEffectNode *parent,
{
Q_ASSERT(parent != nullptr);
parent->AddRow(this);
parent->AddParameter(this);
}
void NodeIO::AddField(EffectField *field)
@@ -118,10 +118,12 @@ bool NodeIO::IsKeyframing() {
}
void NodeIO::SetKeyframingInternal(bool b) {
/* FIXME
if (GetParentEffect()->type() != EFFECT_TYPE_TRANSITION) {
keyframing_ = b;
emit KeyframingSetChanged(keyframing_);
}
*/
}
bool NodeIO::IsSavable()
@@ -239,6 +241,7 @@ void NodeIO::SetKeyframingEnabled(bool enabled) {
}
void NodeIO::GoToPreviousKeyframe() {
/* FIXME
long key = LONG_MIN;
Clip* c = GetParentEffect()->parent_clip;
long sequence_playhead = c->track()->sequence()->playhead;
@@ -264,9 +267,11 @@ void NodeIO::GoToPreviousKeyframe() {
// If we found a keyframe less than the playhead, jump to it
if (key != LONG_MIN) panel_sequence_viewer->seek(key);
*/
}
void NodeIO::ToggleKeyframe() {
/* FIXME
Clip* c = GetParentEffect()->parent_clip;
long sequence_playhead = c->track()->sequence()->playhead;
@@ -334,9 +339,11 @@ void NodeIO::ToggleKeyframe() {
olive::undo_stack.push(ca);
update_ui(false);
*/
}
void NodeIO::GoToNextKeyframe() {
/* FIXME
long key = LONG_MAX;
Clip* c = GetParentEffect()->parent_clip;
for (int i=0;i<FieldCount();i++) {
@@ -349,19 +356,24 @@ void NodeIO::GoToNextKeyframe() {
}
}
if (key != LONG_MAX) panel_sequence_viewer->seek(key);
*/
}
void NodeIO::FocusRow() {
panel_graph_editor->set_row(this);
}
Node* NodeIO::ParentNode() {
return static_cast<Node*>(parent());
}
void NodeIO::SetKeyframeOnAllFields(ComboAction* ca) {
for (int i=0;i<FieldCount();i++) {
EffectField* field = Field(i);
KeyframeDataChange* kdc = new KeyframeDataChange(field);
field->SetValueAt(GetParentEffect()->Now(), field->GetValueAt(GetParentEffect()->Now()));
field->SetValueAt(ParentNode()->Time(), field->GetValueAt(ParentNode()->Time()));
kdc->SetNewKeyframes();
ca->append(kdc);
@@ -370,11 +382,6 @@ void NodeIO::SetKeyframeOnAllFields(ComboAction* ca) {
panel_effect_controls->update_keyframes();
}
OldEffectNode *NodeIO::GetParentEffect()
{
return static_cast<OldEffectNode*>(parent());
}
const QString &NodeIO::name() {
return name_;
}
+3 -3
View File
@@ -24,7 +24,7 @@
#include <QObject>
#include <QVector>
class OldEffectNode;
class Node;
class QGridLayout;
class EffectField;
class QLabel;
@@ -84,7 +84,7 @@ public:
* Whether keyframing can be enabled on this row or not. This is true by default. Some values you may want to prevent
* the user from keyframing (e.g. the filename of a VST plugin), which can be done by setting this to false.
*/
NodeIO(OldEffectNode* parent,
NodeIO(Node* parent,
const QString& id,
const QString& name,
bool savable = true,
@@ -127,7 +127,7 @@ public:
*
* @return The parent Effect object that this row is attached to.
*/
OldEffectNode* GetParentEffect();
Node* ParentNode();
/**
* @brief Return the row's name
+15 -43
View File
@@ -60,7 +60,8 @@
QVector<OldEffectNodePtr> olive::node_library;
OldEffectNode::OldEffectNode(Clip* c) :
OldEffectNode::OldEffectNode(Clip *c) :
Node(nullptr),
parent_clip(c),
flags_(0),
shader_program_(nullptr),
@@ -83,8 +84,8 @@ OldEffectNode::~OldEffectNode() {
// 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()) {
for (int i=0;i<ParameterCount();i++) {
if (Parameter(i) == panel_graph_editor->get_row()) {
panel_graph_editor->set_row(nullptr);
break;
}
@@ -107,21 +108,10 @@ bool OldEffectNode::IsCreatable()
return true;
}
void OldEffectNode::AddRow(NodeIO *row)
{
row->setParent(this);
rows.append(row);
}
int OldEffectNode::IndexOfRow(NodeIO *row)
{
return rows.indexOf(row);
}
void OldEffectNode::copy_field_keyframes(OldEffectNodePtr e) {
for (int i=0;i<rows.size();i++) {
NodeIO* row = rows.at(i);
NodeIO* copy_row = e->rows.at(i);
for (int i=0;i<ParameterCount();i++) {
NodeIO* row = Parameter(i);
NodeIO* copy_row = e->Parameter(i);
copy_row->SetKeyframingInternal(row->IsKeyframing());
for (int j=0;j<row->FieldCount();j++) {
// Get field from this (the source) effect
@@ -139,14 +129,6 @@ void OldEffectNode::copy_field_keyframes(OldEffectNodePtr e) {
}
}
NodeIO* OldEffectNode::row(int i) {
return rows.at(i);
}
int OldEffectNode::row_count() {
return rows.size();
}
EffectGizmo *OldEffectNode::add_gizmo(int type) {
EffectGizmo* gizmo = new EffectGizmo(this, type);
gizmos.append(gizmo);
@@ -165,8 +147,8 @@ QVector<NodeEdgePtr> OldEffectNode::GetAllEdges()
{
QVector<NodeEdgePtr> edges;
for (int i=0;i<row_count();i++) {
edges.append(row(i)->edges());
for (int i=0;i<ParameterCount();i++) {
edges.append(Parameter(i)->edges());
}
return edges;
@@ -291,11 +273,6 @@ void OldEffectNode::SetExpanded(bool e)
expanded_ = e;
}
void OldEffectNode::SetPos(const QPointF &pos)
{
pos_ = pos;
}
void OldEffectNode::SetEnabled(bool b) {
enabled_ = b;
emit EnabledChanged(b);
@@ -434,8 +411,8 @@ void OldEffectNode::save(QXmlStreamWriter& stream) {
void OldEffectNode::load_from_string(const QByteArray &s) {
// clear existing keyframe data
for (int i=0;i<rows.size();i++) {
NodeIO* row = rows.at(i);
for (int i=0;i<ParameterCount();i++) {
NodeIO* row = Parameter(i);
row->SetKeyframingInternal(false);
for (int j=0;j<row->FieldCount();j++) {
EffectField* field = row->Field(j);
@@ -601,11 +578,6 @@ void OldEffectNode::setIterations(int i) {
iterations = i;
}
const QPointF &OldEffectNode::pos()
{
return pos_;
}
void OldEffectNode::process_image(double, uint8_t *, uint8_t *, int){}
OldEffectNodePtr OldEffectNode::copy(Clip *c) {
@@ -881,8 +853,8 @@ void OldEffectNode::redraw(double) {
bool OldEffectNode::valueHasChanged(double timecode) {
if (cachedValues.isEmpty()) {
for (int i=0;i<row_count();i++) {
NodeIO* crow = row(i);
for (int i=0;i<ParameterCount();i++) {
NodeIO* crow = Parameter(i);
for (int j=0;j<crow->FieldCount();j++) {
cachedValues.append(crow->Field(j)->GetValueAt(timecode));
}
@@ -893,8 +865,8 @@ bool OldEffectNode::valueHasChanged(double timecode) {
bool changed = false;
int index = 0;
for (int i=0;i<row_count();i++) {
NodeIO* crow = row(i);
for (int i=0;i<ParameterCount();i++) {
NodeIO* crow = Parameter(i);
for (int j=0;j<crow->FieldCount();j++) {
EffectField* field = crow->Field(j);
if (cachedValues.at(index) != field->GetValueAt(timecode)) {
+5 -10
View File
@@ -44,6 +44,7 @@
#include "rendering/qopenglshaderprogramptr.h"
#include "inputs.h"
#include "effects/effectgizmo.h"
#include "node.h"
class EffectGizmo;
class KeyframeDataChange;
@@ -109,7 +110,7 @@ struct GLTextureCoords {
float opacity;
};
class OldEffectNode : public QObject {
class OldEffectNode : public Node {
Q_OBJECT
public:
OldEffectNode(Clip *c);
@@ -126,11 +127,6 @@ public:
virtual bool IsCreatable();
virtual OldEffectNodePtr Create(Clip *c) = 0;
void AddRow(NodeIO* row);
int IndexOfRow(NodeIO* row);
NodeIO* row(int i);
int row_count();
EffectGizmo* add_gizmo(int type);
EffectGizmo* gizmo(int i);
int gizmo_count();
@@ -170,7 +166,7 @@ public:
int getIterations();
void setIterations(int i);
const QPointF& pos();
virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
virtual void process_shader(double timecode, GLTextureCoords&, int iteration);
@@ -229,7 +225,7 @@ public slots:
void FieldChanged();
void SetEnabled(bool b);
void SetExpanded(bool e);
void SetPos(const QPointF& pos);
signals:
void EnabledChanged(bool);
private slots:
@@ -257,7 +253,6 @@ protected:
private:
bool isOpen;
QVector<NodeIO*> rows;
QVector<EffectGizmo*> gizmos;
bool bound;
int iterations;
@@ -269,7 +264,7 @@ private:
QVector<KeyframeDataChange*> gizmo_dragging_actions_;
QPointF pos_;
// superimpose functions
virtual void redraw(double timecode);
+1 -1
View File
@@ -1,6 +1,6 @@
#include "buttonwidget.h"
ButtonWidget::ButtonWidget(OldEffectNode* parent, const QString& name, const QString& text) :
ButtonWidget::ButtonWidget(Node* parent, const QString& name, const QString& text) :
NodeIO(parent, nullptr, name, false, false)
{
ButtonField* button_field = new ButtonField(this, text);
+1 -1
View File
@@ -6,7 +6,7 @@
class ButtonWidget : public NodeIO
{
public:
ButtonWidget(OldEffectNode* 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(OldEffectNode *parent, const QString &name, const QString &text) :
LabelWidget::LabelWidget(Node *parent, const QString &name, const QString &text) :
NodeIO(parent, nullptr, name, false, false)
{
AddField(new LabelField(this, text));
+1 -1
View File
@@ -6,7 +6,7 @@
class LabelWidget : public NodeIO
{
public:
LabelWidget(OldEffectNode* parent, const QString& name, const QString& text);
LabelWidget(Node* parent, const QString& name, const QString& text);
};
#endif // LABELWIDGET_H