This commit is contained in:
itsmattkc
2019-05-13 13:37:42 +10:00
58 changed files with 474 additions and 362 deletions
+24 -35
View File
@@ -22,6 +22,7 @@
#include <QDateTime>
#include <QtMath>
#include <cfloat>
#include "rendering/renderfunctions.h"
#include "global/config.h"
@@ -46,7 +47,7 @@ EffectField::EffectField(NodeIO* parent, EffectFieldType t) :
SetValueAt(0, 0);
// Connect this field to the effect's changed function
connect(this, SIGNAL(Changed()), parent->GetParentEffect(), SLOT(FieldChanged()));
connect(this, SIGNAL(Changed()), parent->ParentNode(), SLOT(FieldChanged()));
}
NodeIO *EffectField::GetParentRow()
@@ -99,40 +100,40 @@ QVariant EffectField::GetValueAt(double timecode)
if (before_key.type == EFFECT_KEYFRAME_BEZIER && after_key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier
double t = cubic_t_from_x(SecondsToFrame(timecode),
double t = cubic_t_from_x(timecode,
before_key.time,
before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true),
after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false),
after_key.time);
value = cubic_from_t(before_dbl,
before_dbl+before_key.post_handle_y,
after_dbl+after_key.pre_handle_y,
before_dbl+before_key.post_handle.y(),
after_dbl+after_key.pre_handle.y(),
after_dbl,
t);
} else if (after_key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one
double t = quad_t_from_x(SecondsToFrame(timecode),
double t = quad_t_from_x(timecode,
before_key.time,
before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true),
after_key.time);
value = quad_from_t(before_dbl,
before_dbl+before_key.post_handle_y,
before_dbl+before_key.post_handle.y(),
after_dbl,
t);
} else {
// this keyframe is the bezier one
double t = quad_t_from_x(SecondsToFrame(timecode),
double t = quad_t_from_x(timecode,
before_key.time,
after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false),
after_key.time);
value = quad_from_t(before_dbl,
after_dbl+after_key.pre_handle_y,
after_dbl+after_key.pre_handle.y(),
after_dbl,
t);
}
@@ -182,13 +183,10 @@ void EffectField::SetValueAt(double time, const QVariant &value)
// Create keyframe here
// Convert seconds timecode to frame
long frame_timecode = SecondsToFrame(time);
// Check array if a keyframe at this time already exists
int keyframe_index = -1;
for (int i=0;i<keyframes.size();i++) {
if (keyframes.at(i).time == frame_timecode) {
if (qFuzzyCompare(keyframes.at(i).time, time)) {
keyframe_index = i;
break;
}
@@ -197,7 +195,7 @@ void EffectField::SetValueAt(double time, const QVariant &value)
// If keyframe doesn't exist, make it
if (keyframe_index == -1) {
EffectKeyframe key;
key.time = frame_timecode;
key.time = time;
key.data = value;
key.type = (keyframes.isEmpty()) ? EFFECT_KEYFRAME_LINEAR : keyframes.last().type;
keyframes.append(key);
@@ -222,7 +220,7 @@ void EffectField::PrepareDataForKeyframing(bool enabled, ComboAction *ca)
// Create keyframe from perpetual data
EffectKeyframe key;
key.time = GetParentRow()->GetParentEffect()->NowInFrames();
key.time = GetParentRow()->ParentNode()->ParentGraph()->Time();
key.data = persistent_data_;
key.type = EFFECT_KEYFRAME_LINEAR;
@@ -235,7 +233,7 @@ void EffectField::PrepareDataForKeyframing(bool enabled, ComboAction *ca)
// Convert keyframes to one "perpetual" keyframe
// Set first keyframe to whatever the data is now
ca->append(new SetQVariant(&persistent_data_, persistent_data_, GetValueAt(GetParentRow()->GetParentEffect()->Now())));
ca->append(new SetQVariant(&persistent_data_, persistent_data_, GetValueAt(GetParentRow()->ParentNode()->ParentGraph()->Time())));
// Delete all keyframes
for (int i=0;i<keyframes.size();i++) {
@@ -264,7 +262,7 @@ double EffectField::GetValidKeyframeHandlePosition(int key, bool post) {
}
}
double adjusted_key = post ? keyframes.at(key).post_handle_x : keyframes.at(key).pre_handle_x;
double adjusted_key = post ? keyframes.at(key).post_handle.x() : keyframes.at(key).pre_handle.x();
// if this is the earliest/latest keyframe, no validation is required
if (comp_key == -1) {
@@ -275,10 +273,10 @@ double EffectField::GetValidKeyframeHandlePosition(int key, bool post) {
// if comp keyframe is bezier, validate with its accompanying handle
if (keyframes.at(comp_key).type == EFFECT_KEYFRAME_BEZIER) {
double relative_comp_handle = comp + (post ? keyframes.at(comp_key).pre_handle_x : keyframes.at(comp_key).post_handle_x);
double relative_comp_handle = comp + (post ? keyframes.at(comp_key).pre_handle.x() : keyframes.at(comp_key).post_handle.x());
// return an average
if ((post && keyframes.at(key).post_handle_x > relative_comp_handle)
|| (!post && keyframes.at(key).pre_handle_x < relative_comp_handle)) {
if ((post && keyframes.at(key).post_handle.x() > relative_comp_handle)
|| (!post && keyframes.at(key).pre_handle.x() < relative_comp_handle)) {
adjusted_key = (adjusted_key + relative_comp_handle)*0.5;
}
}
@@ -296,31 +294,22 @@ double EffectField::GetValidKeyframeHandlePosition(int key, bool post) {
return adjusted_key;
}
double EffectField::FrameToSeconds(long frame) {
return (double(frame) / GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate());
}
long EffectField::SecondsToFrame(double seconds) {
return qRound(seconds * GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate());
}
void EffectField::GetKeyframeData(double timecode, int &before, int &after, double &progress) {
int before_keyframe_index = -1;
int after_keyframe_index = -1;
long before_keyframe_time = LONG_MIN;
long after_keyframe_time = LONG_MAX;
long frame = SecondsToFrame(timecode);
double before_keyframe_time = DBL_MIN;
double after_keyframe_time = DBL_MAX;
for (int i=0;i<keyframes.size();i++) {
long eval_keyframe_time = keyframes.at(i).time;
if (eval_keyframe_time == frame) {
double eval_keyframe_time = keyframes.at(i).time;
if (qFuzzyCompare(eval_keyframe_time, timecode)) {
before = i;
after = i;
return;
} else if (eval_keyframe_time < frame && eval_keyframe_time > before_keyframe_time) {
} else if (eval_keyframe_time < timecode && eval_keyframe_time > before_keyframe_time) {
before_keyframe_index = i;
before_keyframe_time = eval_keyframe_time;
} else if (eval_keyframe_time > frame && eval_keyframe_time < after_keyframe_time) {
} else if (eval_keyframe_time > timecode && eval_keyframe_time < after_keyframe_time) {
after_keyframe_index = i;
after_keyframe_time = eval_keyframe_time;
}
@@ -331,7 +320,7 @@ void EffectField::GetKeyframeData(double timecode, int &before, int &after, doub
// interpolate
before = before_keyframe_index;
after = after_keyframe_index;
progress = (timecode-FrameToSeconds(before_keyframe_time))/(FrameToSeconds(after_keyframe_time)-FrameToSeconds(before_keyframe_time));
progress = (timecode-before_keyframe_time)/(after_keyframe_time-before_keyframe_time);
} else if (before_keyframe_index > -1) {
before = before_keyframe_index;
after = before_keyframe_index;
-26
View File
@@ -389,32 +389,6 @@ private:
*/
bool HasKeyframes();
/**
* @brief Convert clip time in frames to clip time in seconds
*
* @param frame
*
* Clip time in frames
*
* @return
*
* Clip time in seconds
*/
double FrameToSeconds(long frame);
/**
* @brief Convert clip time in seconds to clip time in frames
*
* @param seconds
*
* Clip time in seconds
*
* @return
*
* Clip time in frames
*/
long SecondsToFrame(double seconds);
/**
* @brief Internal function for determining where we are between the available keyframes
*
+2 -2
View File
@@ -22,7 +22,7 @@
#include <QCheckBox>
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "undo/undo.h"
BoolField::BoolField(NodeIO *parent) :
@@ -92,7 +92,7 @@ void BoolField::UpdateFromWidget(bool b)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->GetParentEffect()->Now(), b);
SetValueAt(GetParentRow()->ParentNode()->Time(), b);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
+2 -2
View File
@@ -23,7 +23,7 @@
#include <QColor>
#include "ui/colorbutton.h"
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "undo/undo.h"
ColorField::ColorField(NodeIO* parent) :
@@ -66,7 +66,7 @@ void ColorField::UpdateFromWidget(const QColor& c)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->GetParentEffect()->Now(), c);
SetValueAt(GetParentRow()->ParentNode()->Time(), c);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
+2 -2
View File
@@ -22,7 +22,7 @@
#include <QDebug>
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "ui/comboboxex.h"
#include "undo/undo.h"
@@ -86,7 +86,7 @@ void ComboField::UpdateFromWidget(int index)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->GetParentEffect()->Now(), items_.at(index).data);
SetValueAt(GetParentRow()->ParentNode()->Time(), items_.at(index).data);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
+2 -2
View File
@@ -20,7 +20,7 @@
#include "doublefield.h"
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "undo/undo.h"
DoubleField::DoubleField(NodeIO* parent) :
@@ -139,7 +139,7 @@ void DoubleField::UpdateFromWidget(double d)
kdc_ = new KeyframeDataChange(this);
}
SetValueAt(GetParentRow()->GetParentEffect()->Now(), d);
SetValueAt(GetParentRow()->ParentNode()->Time(), d);
if (!ls->IsDragging() && kdc_ != nullptr) {
kdc_->SetNewKeyframes();
+2 -2
View File
@@ -23,7 +23,7 @@
#include <QDebug>
#include "ui/embeddedfilechooser.h"
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "undo/undo.h"
FileField::FileField(NodeIO* parent) :
@@ -61,7 +61,7 @@ void FileField::UpdateFromWidget(const QString &s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->GetParentEffect()->Now(), s);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
+2 -2
View File
@@ -24,7 +24,7 @@
#include <QDebug>
#include "ui/comboboxex.h"
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "undo/undo.h"
// NOTE/TODO: This shares a lot of similarity with ComboInput, and could probably be a derived class of it
@@ -88,7 +88,7 @@ void FontField::UpdateFromWidget(const QString& s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->GetParentEffect()->Now(), s);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
+2 -2
View File
@@ -23,7 +23,7 @@
#include <QtMath>
#include <QDebug>
#include "nodes/oldeffectnode.h"
#include "nodes/node.h"
#include "ui/texteditex.h"
#include "global/config.h"
#include "undo/undo.h"
@@ -94,7 +94,7 @@ void StringField::UpdateFromWidget(const QString &s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->GetParentEffect()->Now(), s);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
+2 -4
View File
@@ -29,10 +29,8 @@
EffectKeyframe::EffectKeyframe()
{
pre_handle_x = -40;
pre_handle_y = 0;
post_handle_x = 40;
post_handle_y = 0;
pre_handle = QPointF(-40, 0);
post_handle = QPointF(40, 0);
}
void delete_keyframes(QVector<EffectField *>& selected_key_fields, QVector<int> &selected_keys) {
+4 -5
View File
@@ -22,6 +22,7 @@
#define KEYFRAME_H
#include <QVariant>
#include <QPointF>
class EffectField;
@@ -30,14 +31,12 @@ public:
EffectKeyframe();
int type;
long time;
double time;
QVariant data;
// only for bezier type
double pre_handle_x;
double pre_handle_y;
double post_handle_x;
double post_handle_y;
QPointF pre_handle;
QPointF post_handle;
};
void delete_keyframes(QVector<EffectField *> &selected_key_fields, QVector<int> &selected_keys);
+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;
+50 -2
View File
@@ -1,6 +1,54 @@
#include "node.h"
Node::Node(NodeGraph *graph)
{
#include "nodegraph.h"
Node::Node(NodeGraph *graph) :
QObject(graph)
{
}
QString Node::name()
{
return tr("Node");
}
void Node::AddParameter(NodeIO *param)
{
param->setParent(this);
parameters_.append(param);
}
int Node::IndexOfParameter(NodeIO *param)
{
return parameters_.indexOf(param);
}
NodeIO *Node::Parameter(int i)
{
return parameters_.at(i);
}
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;
}
+21 -5
View File
@@ -3,18 +3,34 @@
#include <memory>
#include "nodes/nodeio.h"
class NodeGraph;
class Node;
using NodePtr = std::shared_ptr<Node>;
class Node
class Node : public QObject
{
Q_OBJECT
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:
NodeGraph* parent_;
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
+23 -6
View File
@@ -1,20 +1,37 @@
#include "nodegraph.h"
#include <QChildEvent>
#include <QDebug>
NodeGraph::NodeGraph() :
output_node_(nullptr)
NodeGraph::NodeGraph()
{
}
void NodeGraph::AddNode(NodePtr node)
void NodeGraph::childEvent(QChildEvent *event)
{
nodes_.append(node);
emit NodeGraphChanged();
if (event->type() == QEvent::ChildAdded || event->type() == QEvent::ChildRemoved) {
emit NodeGraphChanged();
}
}
void NodeGraph::SetOutputNode(Node *node)
{
output_node_ = node;
}
Node *NodeGraph::OutputNode()
{
return output_node_.get();
return output_node_;
}
double NodeGraph::Time()
{
return time_;
}
void NodeGraph::SetTime(double d)
{
time_ = d;
emit TimeChanged();
}
+10 -12
View File
@@ -12,15 +12,6 @@ class NodeGraph : public QObject
public:
NodeGraph();
/**
* @brief Add a node to this graph
*
* The graph takes ownership of the node.
*
* @param node
*/
void AddNode(NodePtr node);
/**
* @brief Process the graph
*
@@ -43,20 +34,27 @@ public:
*
* The node to set as the output node. The graph takes ownership of the node and the user cannot delete it.
*/
void SetOutputNode(NodePtr node);
void SetOutputNode(Node* node);
/**
* @brief Returns the currently set output node
*/
Node* OutputNode();
double Time();
void SetTime(double d);
signals:
void NodeGraphChanged();
void TimeChanged();
protected:
virtual void childEvent(QChildEvent *event) override;
private:
NodePtr output_node_;
Node* output_node_;
QVector<NodePtr> nodes_;
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
+2 -2
View File
@@ -120,8 +120,8 @@ void EffectsPanel::Load() {
// Check if one of the open effects contains the row currently active in the graph editor. If not, we'll have
// to clear the graph editor later.
if (!graph_editor_row_is_still_active) {
for (int k=0;k<effects_to_open.at(j)->row_count();k++) {
NodeIO* row = effects_to_open.at(j)->row(k);
for (int k=0;k<effects_to_open.at(j)->ParameterCount();k++) {
NodeIO* row = effects_to_open.at(j)->Parameter(k);
if (row == panel_graph_editor->get_row()) {
graph_editor_row_is_still_active = true;
break;
+5 -3
View File
@@ -150,7 +150,7 @@ void GraphEditor::update_panel() {
for (int i=0;i<row->FieldCount();i++) {
EffectField* field = row->Field(i);
if (field->type() == EffectField::EFFECT_FIELD_DOUBLE) {
field->UpdateWidgetValue(field_sliders_.at(slider_index), row->GetParentEffect()->Now());
field->UpdateWidgetValue(field_sliders_.at(slider_index), row->ParentNode()->Time());
slider_index++;
}
}
@@ -209,10 +209,12 @@ void GraphEditor::set_row(NodeIO *r) {
if (found_vals) {
row = r;
current_row_desc->setText(row->GetParentEffect()->parent_clip->name()
/* FIXME
current_row_desc->setText(row->ParentNode()->parent_clip->name()
+ " :: " + row->GetParentEffect()->name()
+ " :: " + row->name());
header->set_visible_in(r->GetParentEffect()->parent_clip->timeline_in());
header->set_visible_in(r->ParentNode()->parent_clip->timeline_in());
*/
connect(keyframe_nav, SIGNAL(goto_previous_key()), row, SLOT(GoToPreviousKeyframe()));
connect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(ToggleKeyframe()));
+2 -2
View File
@@ -125,8 +125,8 @@ void NodeEditor::LoadEdges()
if (n->parent_clip == first_clip) {
// Connect all rows to this
for (int j=0;j<n->row_count();j++) {
ConnectRow(n->row(j));
for (int j=0;j<n->ParameterCount();j++) {
ConnectRow(n->Parameter(j));
}
// Get node edges
+3 -3
View File
@@ -518,12 +518,12 @@ void Clip::refactor_frame_rate(ComboAction* ca, double multiplier, bool change_t
// move keyframes
for (int i=0;i<effects.size();i++) {
OldEffectNodePtr e = effects.at(i);
for (int j=0;j<e->row_count();j++) {
NodeIO* r = e->row(j);
for (int j=0;j<e->ParameterCount();j++) {
NodeIO* r = e->Parameter(j);
for (int l=0;l<r->FieldCount();l++) {
EffectField* f = r->Field(l);
for (int k=0;k<f->keyframes.size();k++) {
ca->append(new SetLong(&f->keyframes[k].time, f->keyframes[k].time, qRound(f->keyframes[k].time * multiplier)));
ca->append(new SetDouble(&f->keyframes[k].time, f->keyframes[k].time, qRound(f->keyframes[k].time * multiplier)));
}
}
}
+113 -54
View File
@@ -169,8 +169,11 @@ void Sequence::set_audio_layout(const int& l)
long Sequence::GetEndFrame() {
long end_frame = 0;
for (int i=0;i<tracks_.size();i++) {
end_frame = qMax(tracks_.at(i)->GetEndFrame(), end_frame);
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
Track* t = static_cast<Track*>(all_tracks.at(i));
end_frame = qMax(t->GetEndFrame(), end_frame);
}
return end_frame;
@@ -180,9 +183,11 @@ QVector<Clip *> Sequence::GetAllClips()
{
QVector<Clip*> all_clips;
for (int j=0;j<tracks_.size();j++) {
const QObjectList& tracks = children();
all_clips.append(tracks_.at(j)->GetAllClips());
for (int j=0;j<tracks.size();j++) {
all_clips.append(static_cast<Track*>(tracks.at(j))->GetAllClips());
}
@@ -193,9 +198,12 @@ QVector<Track *> Sequence::GetTrackList(olive::TrackType type)
{
QVector<Track*> tracks;
for (int i=0;i<tracks_.size();i++) {
if (tracks_.at(i)->type() == type) {
tracks.append(tracks_.at(i));
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
Track* t = static_cast<Track*>(all_tracks.at(i));
if (t->type() == type) {
tracks.append(t);
}
}
@@ -230,8 +238,10 @@ QVector<Clip *> Sequence::SelectedClips(bool containing)
{
QVector<Clip*> selected_clips;
for (int j=0;j<tracks_.size();j++) {
Track* t = tracks_.at(j);
const QObjectList& all_tracks = children();
for (int j=0;j<all_tracks.size();j++) {
Track* t = static_cast<Track*>(all_tracks.at(j));
selected_clips.append(t->GetSelectedClips(containing));
}
@@ -388,6 +398,8 @@ void Sequence::EditToPoint(bool in, bool ripple)
bool push_undo = true;
long seek = playhead;
const QObjectList& all_tracks = children();
if ((in && (playhead_falls_on_out || (playhead_falls_on_in && playhead == 0)))
|| (!in && (playhead_falls_on_in || (playhead_falls_on_out && playhead == sequence_end)))) { // one frame mode
if (ripple) {
@@ -400,8 +412,9 @@ void Sequence::EditToPoint(bool in, bool ripple)
if (in_point >= 0) {
for (int j=0;j<tracks_.size();j++) {
areas.append(Selection(in_point, in_point+1, tracks_.at(j)));
for (int j=0;j<all_tracks.size();j++) {
Track* t = static_cast<Track*>(all_tracks.at(j));
areas.append(Selection(in_point, in_point+1, t));
}
// trim and move clips around the in point
@@ -436,8 +449,9 @@ void Sequence::EditToPoint(bool in, bool ripple)
} else {
for (int j=0;j<tracks_.size();j++) {
areas.append(Selection(area_in, area_out, tracks_.at(j)));
for (int j=0;j<all_tracks.size();j++) {
Track* t = static_cast<Track*>(all_tracks.at(j));
areas.append(Selection(area_in, area_out, t));
}
// trim and move clips around the in point
@@ -522,8 +536,11 @@ void Sequence::DeleteInToOut(bool ripple)
QVector<Selection> areas_to_delete;
for (int j=0;j<tracks_.size();j++) {
areas_to_delete.append(Selection(workarea_in, workarea_out, tracks_.at(j)));
const QObjectList& all_tracks = children();
for (int j=0;j<all_tracks.size();j++) {
Track* t = static_cast<Track*>(all_tracks.at(j));
areas_to_delete.append(Selection(workarea_in, workarea_out, t));
}
ComboAction* ca = new ComboAction();
@@ -576,8 +593,10 @@ void Sequence::Ripple(ComboAction *ca, long point, long length, const QVector<Cl
void Sequence::ChangeTrackHeightsRelatively(int diff)
{
for (int j=0;j<tracks_.size();j++) {
Track* t = tracks_.at(j);
const QObjectList& all_tracks = children();
for (int j=0;j<all_tracks.size();j++) {
Track* t = static_cast<Track*>(all_tracks.at(j));
t->set_height(t->height() + diff);
}
@@ -649,9 +668,12 @@ void Sequence::Split()
// If we weren't able to split any selected clips above, see if there are arbitrary selections to split
if (!split_occurred) {
Track* track;
const QObjectList& all_tracks = children();
QObject* obj;
foreach (track, tracks_) {
foreach (obj, all_tracks) {
Track* track = static_cast<Track*>(obj);
QVector<Selection> track_selections = track->Selections();
QVector<long> split_positions;
@@ -894,8 +916,10 @@ void Sequence::RippleDeleteEmptySpace(ComboAction* ca, Track* track, long point)
void Sequence::RippleDeleteArea(ComboAction* ca, long ripple_point, long ripple_length) {
for (int j=0;j<tracks_.size();j++) {
Track* t = tracks_.at(j);
const QObjectList& all_tracks = children();
for (int j=0;j<all_tracks.size();j++) {
Track* t = static_cast<Track*>(all_tracks.at(j));
// We've already tested `track`, so we don't need to test it again
long first_in_point_after_point = LONG_MAX;
@@ -982,22 +1006,25 @@ OldEffectNode *Sequence::GetSelectedGizmo()
void Sequence::SelectAll()
{
for (int i=0;i<tracks_.size();i++) {
tracks_.at(i)->SelectAll();
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
static_cast<Track*>(all_tracks.at(i))->SelectAll();
}
}
void Sequence::SelectAtPlayhead()
{
for (int i=0;i<tracks_.size();i++) {
tracks_.at(i)->SelectAtPoint(playhead);
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
static_cast<Track*>(all_tracks.at(i))->SelectAtPoint(playhead);
}
}
void Sequence::ClearSelections()
{
for (int i=0;i<tracks_.size();i++) {
tracks_.at(i)->ClearSelections();
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
static_cast<Track*>(all_tracks.at(i))->ClearSelections();
}
}
@@ -1078,8 +1105,10 @@ QVector<Selection> Sequence::Selections()
{
QVector<Selection> selections;
for (int i=0;i<tracks_.size();i++) {
selections.append(tracks_.at(i)->Selections());
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
selections.append(static_cast<Track*>(all_tracks.at(i))->Selections());
}
return selections;
@@ -1108,12 +1137,15 @@ Track *Sequence::PreviousTrack(Track *t)
Track* previous_track = nullptr;
// Loop through tracks
for (int i=0;i<tracks_.size();i++) {
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
if (tracks_.at(i) == t) {
Track* comp_track = static_cast<Track*>(all_tracks.at(i));
if (comp_track == t) {
// If this is the track, we'll know the previous track by now
break;
} else if (tracks_.at(i)->type() == t->type()) {
} else if (comp_track->type() == t->type()) {
// Otherwise, we'll keep "track" of it
previous_track = t;
}
@@ -1132,14 +1164,18 @@ Track *Sequence::NextTrack(Track *t)
Track* next_track = nullptr;
for (int i=tracks_.size()-1;i>=0;i--) {
const QObjectList& all_tracks = children();
if (tracks_.at(i) == t) {
for (int i=all_tracks.size()-1;i>=0;i--) {
Track* track = static_cast<Track*>(all_tracks.at(i));
if (track == t) {
break;
}
if (tracks_.at(i)->type() == t->type()) {
next_track = tracks_.at(i);
if (track->type() == t->type()) {
next_track = track;
}
}
@@ -1161,13 +1197,17 @@ int Sequence::IndexOfTrack(Track *t)
{
int counter = -1;
for (int i=0;i<tracks_.size();i++) {
const QObjectList& all_tracks = children();
if (tracks_.at(i)->type() == t->type()) {
for (int i=0;i<all_tracks.size();i++) {
Track* track = static_cast<Track*>(all_tracks.at(i));
if (track->type() == t->type()) {
counter++;
}
if (tracks_.at(i) == t) {
if (track == t) {
return counter;
}
}
@@ -1177,9 +1217,14 @@ int Sequence::IndexOfTrack(Track *t)
Track *Sequence::FirstTrack(olive::TrackType type)
{
for (int i=0;i<tracks_.size();i++) {
if (tracks_.at(i)->type() == type) {
return tracks_.at(i);
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
Track* track = static_cast<Track*>(all_tracks.at(i));
if (track->type() == type) {
return track;
}
}
return nullptr;
@@ -1187,9 +1232,14 @@ Track *Sequence::FirstTrack(olive::TrackType type)
Track *Sequence::LastTrack(olive::TrackType type)
{
for (int i=tracks_.size()-1;i>=0;i--) {
if (tracks_.at(i)->type() == type) {
return tracks_.at(i);
const QObjectList& all_tracks = children();
for (int i=all_tracks.size()-1;i>=0;i--) {
Track* track = static_cast<Track*>(all_tracks.at(i));
if (track->type() == type) {
return track;
}
}
return nullptr;
@@ -1199,13 +1249,18 @@ Track *Sequence::TrackAt(olive::TrackType type, int index)
{
int counter = -1;
for (int i=0;i<tracks_.size();i++) {
if (tracks_.at(i)->type() == type) {
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
Track* track = static_cast<Track*>(all_tracks.at(i));
if (track->type() == type) {
counter++;
}
if (counter == index) {
return tracks_.at(i);
return track;
}
}
@@ -1223,8 +1278,13 @@ int Sequence::TrackCount(olive::TrackType type)
{
int counter = 0;
for (int i=0;i<tracks_.size();i++) {
if (tracks_.at(i)->type() == type) {
const QObjectList& all_tracks = children();
for (int i=0;i<all_tracks.size();i++) {
Track* track = static_cast<Track*>(all_tracks.at(i));
if (track->type() == type) {
counter++;
}
}
@@ -1234,10 +1294,9 @@ int Sequence::TrackCount(olive::TrackType type)
Track* Sequence::AddTrack(olive::TrackType type)
{
Track* track = new Track(this, type);
tracks_.append(track);
emit TrackCountChanged();
return track;
Track* t = new Track(nullptr, type);
t->setParent(this);
return t;
}
ClipPtr Sequence::SplitClip(ComboAction *ca, bool transitions, Clip* pre, long frame)
+3 -3
View File
@@ -28,8 +28,9 @@
#include "marker.h"
#include "selection.h"
#include "ghost.h"
#include "nodes/nodegraph.h"
class Sequence : public QObject {
class Sequence : public NodeGraph {
Q_OBJECT
public:
Sequence();
@@ -142,11 +143,10 @@ public:
QVector<Marker> markers;
signals:
void SequenceParametersChanged();
void TrackCountChanged();
private:
Track *AddTrack(olive::TrackType type);
QVector<Track*> tracks_;
//QVector<Track*> tracks_;
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame);
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame, long post_in);
+7 -7
View File
@@ -9,7 +9,7 @@ int olive::timeline::kTrackMinHeight = 30;
int olive::timeline::kTrackHeightIncrement = 10;
Track::Track(Sequence* parent, olive::TrackType type) :
parent_(parent),
Node(parent),
type_(type),
muted_(false),
soloed_(false),
@@ -35,7 +35,7 @@ Track *Track::copy(Sequence *parent)
Sequence *Track::sequence()
{
return parent_;
return static_cast<Sequence*>(parent());
}
void Track::Save(QXmlStreamWriter &stream)
@@ -204,22 +204,22 @@ bool Track::ContainsClip(Clip *c)
Track *Track::Previous()
{
return parent_->PreviousTrack(this);
return sequence()->PreviousTrack(this);
}
Track *Track::Next()
{
return parent_->NextTrack(this);
return sequence()->NextTrack(this);
}
Track *Track::Sibling(int diff)
{
return parent_->SiblingTrack(this, diff);
return sequence()->SiblingTrack(this, diff);
}
int Track::Index()
{
return parent_->IndexOfTrack(this);
return sequence()->IndexOfTrack(this);
}
bool Track::IsClipSelected(int clip_index, bool containing)
@@ -378,7 +378,7 @@ bool Track::IsEffectivelyMuted()
// Check if any tracks are soloed
bool a_track_is_soloed = false;
QVector<Track*> siblings = parent_->GetTrackList(type_);
QVector<Track*> siblings = sequence()->GetTrackList(type_);
for (int i=0;i<siblings.size();i++) {
if (siblings.at(i)->IsSoloed()) {
a_track_is_soloed = true;
+2 -2
View File
@@ -8,6 +8,7 @@
#include "tracktypes.h"
#include "undo/comboaction.h"
#include "timeline/selection.h"
#include "nodes/node.h"
class Sequence;
class Transition;
@@ -37,7 +38,7 @@ namespace olive {
class Sequence;
class Track : public QObject
class Track : public Node
{
Q_OBJECT
public:
@@ -107,7 +108,6 @@ signals:
private:
void ResizeClipArray(int new_size);
Sequence* parent_;
olive::TrackType type_;
int height_;
QVector<ClipPtr> clips_;
+12 -12
View File
@@ -103,11 +103,11 @@ EffectUI::EffectUI(OldEffectNode* e) :
this,
SLOT(show_context_menu(const QPoint&)));
widgets_.resize(e->row_count());
keyframe_navigators_.resize(e->row_count());
widgets_.resize(e->ParameterCount());
keyframe_navigators_.resize(e->ParameterCount());
for (int i=0;i<e->row_count();i++) {
NodeIO* row = e->row(i);
for (int i=0;i<e->ParameterCount();i++) {
NodeIO* row = e->Parameter(i);
ClickableLabel* row_label = new ClickableLabel(row->name());
connect(row_label, SIGNAL(clicked()), row, SLOT(FocusRow()));
@@ -181,17 +181,17 @@ void EffectUI::AddAdditionalEffect(OldEffectNode *e)
additional_effects_.append(e);
// Attach this UI's widgets to the additional effect
for (int i=0;i<effect_->row_count();i++) {
for (int i=0;i<effect_->ParameterCount();i++) {
NodeIO* row = effect_->row(i);
NodeIO* row = effect_->Parameter(i);
// Attach existing keyframe navigator to this effect's row
AttachKeyframeNavigationToRow(e->row(i), keyframe_navigators_.at(i));
AttachKeyframeNavigationToRow(e->Parameter(i), keyframe_navigators_.at(i));
for (int j=0;j<row->FieldCount();j++) {
// Attach existing field widget to this effect's field
e->row(i)->Field(j)->CreateWidget(Widget(i, j));
e->Parameter(i)->Field(j)->CreateWidget(Widget(i, j));
}
@@ -229,9 +229,9 @@ void EffectUI::UpdateFromEffect()
{
OldEffectNode* effect = GetEffect();
for (int j=0;j<effect->row_count();j++) {
for (int j=0;j<effect->ParameterCount();j++) {
NodeIO* row = effect->row(j);
NodeIO* row = effect->Parameter(j);
for (int k=0;k<row->FieldCount();k++) {
EffectField* field = row->Field(k);
@@ -246,8 +246,8 @@ void EffectUI::UpdateFromEffect()
bool same_value = true;
for (int i=0;i<additional_effects_.size();i++) {
EffectField* previous_field = i > 0 ? additional_effects_.at(i-1)->row(j)->Field(k) : field;
EffectField* additional_field = additional_effects_.at(i)->row(j)->Field(k);
EffectField* previous_field = i > 0 ? additional_effects_.at(i-1)->Parameter(j)->Field(k) : field;
EffectField* additional_field = additional_effects_.at(i)->Parameter(j)->Field(k);
if (additional_field->GetValueAt(additional_effects_.at(i)->Now())
!= previous_field->GetValueAt(additional_effects_.at(i)->Now())) {
+40 -37
View File
@@ -114,8 +114,8 @@ void GraphView::reset_view() {
void GraphView::set_view_to_selection() {
if (row != nullptr && selected_keys.size() > 0) {
long min_time = LONG_MAX;
long max_time = LONG_MIN;
double min_time = DBL_MAX;
double max_time = DBL_MIN;
double min_dbl = DBL_MAX;
double max_dbl = DBL_MIN;
for (int i=0;i<selected_keys.size();i++) {
@@ -126,8 +126,10 @@ void GraphView::set_view_to_selection() {
max_dbl = qMax(key.data.toDouble(), max_dbl);
}
/* FIXME
min_time -= row->GetParentEffect()->parent_clip->clip_in();
max_time -= row->GetParentEffect()->parent_clip->clip_in();
*/
set_view_to_rect(min_time, min_dbl, max_time, max_dbl);
}
@@ -137,8 +139,8 @@ void GraphView::set_view_to_all() {
if (row != nullptr) {
bool can_set = false;
long min_time = LONG_MAX;
long max_time = LONG_MIN;
double min_time = DBL_MAX;
double max_time = DBL_MIN;
double min_dbl = DBL_MAX;
double max_dbl = DBL_MIN;
for (int i=0;i<row->FieldCount();i++) {
@@ -152,15 +154,17 @@ void GraphView::set_view_to_all() {
}
}
if (can_set) {
/* FIXME
min_time -= row->GetParentEffect()->parent_clip->clip_in();
max_time -= row->GetParentEffect()->parent_clip->clip_in();
*/
set_view_to_rect(min_time, min_dbl, max_time, max_dbl);
}
}
}
void GraphView::set_view_to_rect(int x1, double y1, int x2, double y2) {
void GraphView::set_view_to_rect(double x1, double y1, double x2, double y2) {
double padding = 1.5;
double x_diff = double(x2 - x1);
double y_diff = (y2 - y1);
@@ -278,20 +282,20 @@ void GraphView::paintEvent(QPaintEvent *) {
if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier
bezier_path.cubicTo(
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one
bezier_path.quadTo(
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else {
// this keyframe is the bezier one
bezier_path.quadTo(
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
}
@@ -317,12 +321,12 @@ void GraphView::paintEvent(QPaintEvent *) {
p.setPen(Qt::gray);
// pre handle line
QPointF pre_point(key_x + key.pre_handle_x*x_zoom, key_y - key.pre_handle_y*y_zoom);
QPointF pre_point(key_x + key.pre_handle.x()*x_zoom, key_y - key.pre_handle.y()*y_zoom);
p.drawLine(pre_point, QPointF(key_x, key_y));
p.drawEllipse(pre_point, kBezierHandleSize, kBezierHandleSize);
// post handle line
QPointF post_point(key_x + key.post_handle_x*x_zoom, key_y - key.post_handle_y*y_zoom);
QPointF post_point(key_x + key.post_handle.x()*x_zoom, key_y - key.post_handle.y()*y_zoom);
p.drawLine(post_point, QPointF(key_x, key_y));
p.drawEllipse(post_point, kBezierHandleSize, kBezierHandleSize);
}
@@ -400,8 +404,8 @@ void GraphView::mousePressEvent(QMouseEvent *event) {
break;
} else {
// selecting a handle
QPointF pre_point(key_x + key.pre_handle_x*x_zoom, key_y - key.pre_handle_y*y_zoom);
QPointF post_point(key_x + key.post_handle_x*x_zoom, key_y - key.post_handle_y*y_zoom);
QPointF pre_point(key_x + key.pre_handle.x()*x_zoom, key_y - key.pre_handle.y()*y_zoom);
QPointF post_point(key_x + key.post_handle.x()*x_zoom, key_y - key.post_handle.y()*y_zoom);
if (event->pos().x() > pre_point.x()-kBezierHandleSize
&& event->pos().x() < pre_point.x()+kBezierHandleSize
&& event->pos().y() > pre_point.y()-kBezierHandleSize
@@ -419,10 +423,10 @@ void GraphView::mousePressEvent(QMouseEvent *event) {
sel_key_field = i;
handle_index = j;
handle_field = i;
old_pre_handle_x = key.pre_handle_x;
old_pre_handle_y = key.pre_handle_y;
old_post_handle_x = key.post_handle_x;
old_post_handle_y = key.post_handle_y;
old_pre_handle_x = key.pre_handle.x();
old_pre_handle_y = key.pre_handle.y();
old_post_handle_x = key.post_handle.x();
old_post_handle_y = key.post_handle.y();
break;
}
}
@@ -551,10 +555,8 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) {
}
EffectKeyframe& key = row->Field(handle_field)->keyframes[handle_index];
key.pre_handle_x = qMin(0.0, new_pre_handle_x);
key.pre_handle_y = new_pre_handle_y;
key.post_handle_x = qMax(0.0, new_post_handle_x);
key.post_handle_y = new_post_handle_y;
key.pre_handle = QPointF(qMin(0.0, new_pre_handle_x), new_pre_handle_y);
key.post_handle = QPointF(qMax(0.0, new_post_handle_x), new_post_handle_y);
moved_keys = true;
update_ui(false);
@@ -580,14 +582,14 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) {
KEYFRAME_SIZE+KEYFRAME_SIZE
);
QRect pre_rect(
qRound(key_x + key.pre_handle_x*x_zoom - kBezierHandleSize),
qRound(key_y + key.pre_handle_y*y_zoom - kBezierHandleSize),
qRound(key_x + key.pre_handle.x()*x_zoom - kBezierHandleSize),
qRound(key_y + key.pre_handle.y()*y_zoom - kBezierHandleSize),
kBezierHandleSize+kBezierHandleSize,
kBezierHandleSize+kBezierHandleSize
);
QRect post_rect(
qRound(key_x + key.post_handle_x*x_zoom - kBezierHandleSize),
qRound(key_y + key.post_handle_y*y_zoom - kBezierHandleSize),
qRound(key_x + key.post_handle.x()*x_zoom - kBezierHandleSize),
qRound(key_y + key.post_handle.y()*y_zoom - kBezierHandleSize),
kBezierHandleSize+kBezierHandleSize,
kBezierHandleSize+kBezierHandleSize
);
@@ -653,20 +655,20 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) {
if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier
bezier_path.cubicTo(
QPointF(last_key_x+last_key.post_handle_x*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(key_x+key.pre_handle_x*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(last_key_x+last_key.post_handle.x()*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x+key.pre_handle.x()*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one
bezier_path.quadTo(
QPointF(last_key_x+last_key.post_handle_x*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(last_key_x+last_key.post_handle.x()*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else {
// this keyframe is the bezier one
bezier_path.quadTo(
QPointF(key_x+key.pre_handle_x*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(key_x+key.pre_handle.x()*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
}
@@ -708,7 +710,7 @@ void GraphView::mouseReleaseEvent(QMouseEvent *) {
case kBezierHandleNone:
for (int i=0;i<selected_keys.size();i++) {
EffectKeyframe& key = row->Field(selected_keys_fields.at(i))->keyframes[selected_keys.at(i)];
ca->append(new SetLong(&key.time, selected_keys_old_vals.at(i), key.time));
ca->append(new SetDouble(&key.time, selected_keys_old_vals.at(i), key.time));
ca->append(new SetQVariant(&key.data, selected_keys_old_doubles.at(i), key.data));
}
break;
@@ -716,10 +718,8 @@ void GraphView::mouseReleaseEvent(QMouseEvent *) {
case kBezierHandlePost:
{
EffectKeyframe& key = row->Field(handle_field)->keyframes[handle_index];
ca->append(new SetDouble(&key.pre_handle_x, old_pre_handle_x, key.pre_handle_x));
ca->append(new SetDouble(&key.pre_handle_y, old_pre_handle_y, key.pre_handle_y));
ca->append(new SetDouble(&key.post_handle_x, old_post_handle_x, key.post_handle_x));
ca->append(new SetDouble(&key.post_handle_y, old_post_handle_y, key.post_handle_y));
ca->append(new SetPointF(&key.pre_handle, QPointF(old_pre_handle_x, old_pre_handle_y), key.pre_handle));
ca->append(new SetPointF(&key.post_handle, QPointF(old_post_handle_x, old_post_handle_y), key.post_handle));
}
break;
}
@@ -834,7 +834,8 @@ void GraphView::set_row(NodeIO *r) {
for (int i=0;i<row->FieldCount();i++) {
field_visibility[i] = row->Field(i)->IsEnabled();
}
visible_in = row->GetParentEffect()->parent_clip->timeline_in();
// FIXME
//visible_in = row->ParentNode()->parent_clip->timeline_in();
set_view_to_all();
} else {
update();
@@ -902,7 +903,8 @@ void GraphView::set_zoom(double xz, double yz) {
int GraphView::get_screen_x(double d) {
if (row != nullptr) {
d -= row->GetParentEffect()->parent_clip->clip_in();
// FIXME
//d -= row->GetParentEffect()->parent_clip->clip_in();
}
return qRound((d*x_zoom) - x_scroll);
}
@@ -914,7 +916,8 @@ int GraphView::get_screen_y(double d) {
long GraphView::get_value_x(int i) {
long frame = qRound((i + x_scroll)/x_zoom);
if (row != nullptr) {
frame += row->GetParentEffect()->parent_clip->clip_in();
// FIXME
//frame += row->GetParentEffect()->parent_clip->clip_in();
}
return frame;
}
+2 -2
View File
@@ -77,7 +77,7 @@ private:
QVector<int> selected_keys;
QVector<int> selected_keys_fields;
QVector<long> selected_keys_old_vals;
QVector<double> selected_keys_old_vals;
QVector<double> selected_keys_old_doubles;
double old_pre_handle_x;
@@ -116,7 +116,7 @@ private slots:
void reset_view();
void set_view_to_selection();
void set_view_to_all();
void set_view_to_rect(int x1, double y1, int x2, double y2);
void set_view_to_rect(double x1, double y1, double x2, double y2);
};
#endif // GRAPHVIEW_H
+3
View File
@@ -55,7 +55,10 @@ void draw_keyframe(QPainter &p, int type, int x, int y, bool darker, int r, int
// adjusts keyframe's internal time (in clip time) to timeline time
long adjust_row_keyframe(NodeIO* row, long time, long visible_in) {
return 0;
/* FIXME
return time
- row->GetParentEffect()->parent_clip->clip_in()
+ (row->GetParentEffect()->parent_clip->timeline_in() - visible_in);
*/
}
+7 -3
View File
@@ -123,8 +123,8 @@ void KeyframeView::paintEvent(QPaintEvent*) {
OldEffectNode* e = container->GetEffect();
if (container->IsExpanded()) {
for (int j=0;j<e->row_count();j++) {
NodeIO* row = e->row(j);
for (int j=0;j<e->ParameterCount();j++) {
NodeIO* row = e->Parameter(j);
int keyframe_y = container->GetRowY(j, this);
@@ -261,6 +261,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) {
for (int k=0;k<row->FieldCount();k++) {
EffectField* f = row->Field(k);
for (int j=0;j<f->keyframes.size();j++) {
/* FIXME
long eval_keyframe_time = f->keyframes.at(j).time-row->GetParentEffect()->parent_clip->clip_in()+(row->GetParentEffect()->parent_clip->timeline_in()-visible_in);
if (eval_keyframe_time >= frame_min && eval_keyframe_time <= frame_max) {
long eval_frame_diff = qAbs(eval_keyframe_time - drag_frame_start);
@@ -271,6 +272,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) {
frame_diff = eval_frame_diff;
}
}
*/
}
}
break;
@@ -381,6 +383,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent* event) {
olive::timeline::snapped = false;
if (olive::timeline::snapping) {
for (int i=0;i<selected_keyframes.size();i++) {
/* FIXME
EffectField* field = selected_fields.at(i);
Clip* c = field->GetParentRow()->GetParentEffect()->parent_clip;
long key_time = old_key_vals.at(i) + frame_diff - c->clip_in() + c->timeline_in();
@@ -389,6 +392,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent* event) {
frame_diff += (key_eval - key_time);
break;
}
*/
}
}
@@ -428,7 +432,7 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent*) {
if (dragging) {
ComboAction* ca = new ComboAction();
for (int i=0;i<selected_fields.size();i++) {
ca->append(new SetLong(
ca->append(new SetDouble(
&selected_fields.at(i)->keyframes[selected_keyframes.at(i)].time,
old_key_vals.at(i),
selected_fields.at(i)->keyframes.at(selected_keyframes.at(i)).time
+2 -2
View File
@@ -26,7 +26,7 @@ void NodeEdgeUI::adjust()
if (node != nullptr) {
// Check if this node has the output row
int row_index = node->GetNode()->IndexOfRow(edge_->output());
int row_index = node->GetNode()->IndexOfParameter(edge_->output());
if (row_index > -1) {
output_node_ = node;
@@ -34,7 +34,7 @@ void NodeEdgeUI::adjust()
}
// Check if this node has the input row
row_index = node->GetNode()->IndexOfRow(edge_->input());
row_index = node->GetNode()->IndexOfParameter(edge_->input());
if (row_index > -1) {
input_node_ = node;
+18 -18
View File
@@ -32,14 +32,14 @@ void NodeUI::AddToScene(QGraphicsScene *scene)
scene->addItem(this);
}
void NodeUI::SetNode(OldEffectNode *n)
void NodeUI::SetNode(Node *n)
{
node_ = n;
QRectF rectangle;
rectangle.setTopLeft(pos());
rectangle.setSize(QSizeF(200, GetRowY(node_->row_count())));
rectangle.setSize(QSizeF(200, GetRowY(node_->ParameterCount())));
QRectF inner_rect = rectangle;
inner_rect.setX(inner_rect.x() + kNodePlugSize/2);
@@ -51,7 +51,7 @@ void NodeUI::SetNode(OldEffectNode *n)
setRect(rectangle);
}
OldEffectNode *NodeUI::GetNode()
Node *NodeUI::GetNode()
{
return node_;
}
@@ -90,12 +90,12 @@ void NodeUI::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
node_->name());
// Draw node row names
for (int i=0;i<node_->row_count();i++) {
for (int i=0;i<node_->ParameterCount();i++) {
int text_x;
if (node_->row(i)->IsNodeOutput()) {
if (node_->Parameter(i)->IsNodeOutput()) {
// right alignment
text_x = rect().right() - kNodePlugSize/2 - qApp->fontMetrics().width(node_->row(i)->name()) - kTextPadding;
text_x = rect().right() - kNodePlugSize/2 - qApp->fontMetrics().width(node_->Parameter(i)->name()) - kTextPadding;
} else {
// left alignment
text_x = left_text_x;
@@ -103,7 +103,7 @@ void NodeUI::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
painter->drawText(text_x,
GetRowY(i) + qApp->fontMetrics().ascent(),
node_->row(i)->name());
node_->Parameter(i)->name());
}
// Draw title splitter line
@@ -128,8 +128,8 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (clicked_socket_ > -1) {
// See if this socket already has an edge connected
QVector<NodeEdgePtr> edges = node_->row(clicked_socket_)->edges();
if (!edges.isEmpty() && edges.last()->input()->GetParentEffect() == node_) {
QVector<NodeEdgePtr> edges = node_->Parameter(clicked_socket_)->edges();
if (!edges.isEmpty() && edges.last()->input()->ParentNode() == node_) {
NodeEdge* e = edges.last().get();
@@ -137,9 +137,9 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event)
NodeIO* other_row = e->output();
OldEffectNode* other_node = other_row->GetParentEffect();
Node* other_node = other_row->ParentNode();
int other_row_index = other_node->IndexOfRow(other_row);
int other_row_index = other_node->IndexOfParameter(other_row);
NodeUI* other_node_ui = FindUIFromNode(other_node);
@@ -158,7 +158,7 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event)
// Start a new edge here
drag_line_start_ = pos() + sockets.at(clicked_socket_).center();
drag_source_ = node_->row(clicked_socket_);
drag_source_ = node_->Parameter(clicked_socket_);
}
@@ -269,11 +269,11 @@ QVector<QRectF> NodeUI::GetNodeSocketRects()
QVector<QRectF> rects;
if (node_ != nullptr) {
OldEffectNode* e = node_;
Node* e = node_;
for (int i=0;i<e->row_count();i++) {
for (int i=0;i<e->ParameterCount();i++) {
NodeIO* row = e->row(i);
NodeIO* row = e->Parameter(i);
if (row->IsNodeInput() || row->IsNodeOutput()) {
qreal x = (row->IsNodeOutput()) ? rect().right() - kNodePlugSize : rect().x();
@@ -292,13 +292,13 @@ QVector<QRectF> NodeUI::GetNodeSocketRects()
NodeIO *NodeUI::GetRowFromIndex(int i)
{
if (node_ != nullptr && i < node_->row_count()) {
return node_->row(i);
if (node_ != nullptr && i < node_->ParameterCount()) {
return node_->Parameter(i);
}
return nullptr;
}
NodeUI *NodeUI::FindUIFromNode(OldEffectNode* n)
NodeUI *NodeUI::FindUIFromNode(Node* n)
{
QList<QGraphicsItem*> all_items = scene()->items();
+5 -5
View File
@@ -7,7 +7,7 @@
class EffectUI;
class NodeIO;
class NodeEdge;
class OldEffectNode;
class Node;
class NodeUI : public QGraphicsRectItem {
public:
@@ -15,8 +15,8 @@ public:
void AddToScene(QGraphicsScene* scene);
//void Resize(const QSize& s);
void SetNode(OldEffectNode* n);
OldEffectNode* GetNode();
void SetNode(Node* n);
Node* GetNode();
QVector<QRectF> GetNodeSocketRects();
@@ -29,10 +29,10 @@ protected:
private:
NodeIO *GetRowFromIndex(int i);
NodeUI* FindUIFromNode(OldEffectNode* n);
NodeUI* FindUIFromNode(Node *n);
int GetRowY(int index);
OldEffectNode* node_;
Node* node_;
QGraphicsPathItem* drag_line_;
QPointF drag_line_start_;
+2 -2
View File
@@ -52,7 +52,7 @@ TimelineArea::TimelineArea(Timeline* timeline, olive::timeline::Alignment alignm
void TimelineArea::SetTrackType(Sequence *sequence, olive::TrackType track_type)
{
if (sequence_ != nullptr) {
disconnect(sequence_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels()));
disconnect(sequence_, SIGNAL(NodeGraphChanged()), this, SLOT(RefreshLabels()));
}
sequence_ = sequence;
@@ -60,7 +60,7 @@ void TimelineArea::SetTrackType(Sequence *sequence, olive::TrackType track_type)
if (sequence_ != nullptr) {
connect(sequence_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels()));
connect(sequence_, SIGNAL(NodeGraphChanged()), this, SLOT(RefreshLabels()));
}
+17
View File
@@ -1207,3 +1207,20 @@ void KeyframeDataChange::doRedo()
done_ = true;
}
}
SetPointF::SetPointF(QPointF *pointer, const QPointF &old_val, const QPointF &new_val) :
pointer_(pointer),
old_val_(old_val),
new_val_(new_val)
{
}
void SetPointF::doUndo()
{
*pointer_ = old_val_;
}
void SetPointF::doRedo()
{
*pointer_ = new_val_;
}
+11
View File
@@ -489,6 +489,17 @@ private:
QString newval;
};
class SetPointF : public OliveAction {
public:
SetPointF(QPointF* pointer, const QPointF& old_val, const QPointF& new_val);
virtual void doUndo() override;
virtual void doRedo() override;
private:
QPointF* pointer_;
QPointF old_val_;
QPointF new_val_;
};
class CloseAllClipsCommand : public OliveAction {
public:
virtual void doUndo() override;