created enum for more node data types
This commit is contained in:
+18
-30
@@ -159,21 +159,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
const QXmlStreamAttribute& attr = attributes.at(i);
|
||||
if (attr.name() == "type") {
|
||||
QString comp = attr.value().toString().toUpper();
|
||||
if (comp == "DOUBLE") {
|
||||
type = EffectField::EFFECT_FIELD_DOUBLE;
|
||||
} else if (comp == "BOOL") {
|
||||
type = EffectField::EFFECT_FIELD_BOOL;
|
||||
} else if (comp == "COLOR") {
|
||||
type = EffectField::EFFECT_FIELD_COLOR;
|
||||
} else if (comp == "COMBO") {
|
||||
type = EffectField::EFFECT_FIELD_COMBO;
|
||||
} else if (comp == "FONT") {
|
||||
type = EffectField::EFFECT_FIELD_FONT;
|
||||
} else if (comp == "STRING") {
|
||||
type = EffectField::EFFECT_FIELD_STRING;
|
||||
} else if (comp == "FILE") {
|
||||
type = EffectField::EFFECT_FIELD_FILE;
|
||||
}
|
||||
type = olive::nodes::StringToDataType(comp);
|
||||
} else if (attr.name() == "id") {
|
||||
id = attr.value().toString();
|
||||
}
|
||||
@@ -181,11 +167,13 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
|
||||
if (id.isEmpty()) {
|
||||
qCritical() << "Couldn't load field from" << em->filename << "- ID cannot be empty.";
|
||||
} else if (type == olive::nodes::kInvalid) {
|
||||
qWarning() << "Invalid field type found";
|
||||
} else {
|
||||
EffectField* field = nullptr;
|
||||
|
||||
switch (type) {
|
||||
case EffectField::EFFECT_FIELD_DOUBLE:
|
||||
case olive::nodes::kFloat:
|
||||
{
|
||||
|
||||
DoubleField* double_field = new DoubleField(row, id);
|
||||
@@ -204,7 +192,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
field = double_field;
|
||||
}
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_COLOR:
|
||||
case olive::nodes::kColor:
|
||||
{
|
||||
QColor color;
|
||||
|
||||
@@ -232,7 +220,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
field->SetValueAt(0, color);
|
||||
}
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_STRING:
|
||||
case olive::nodes::kString:
|
||||
field = new StringField(row, id);
|
||||
for (int i=0;i<attributes.size();i++) {
|
||||
const QXmlStreamAttribute& attr = attributes.at(i);
|
||||
@@ -241,7 +229,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_BOOL:
|
||||
case olive::nodes::kBoolean:
|
||||
field = new BoolField(row, id);
|
||||
for (int i=0;i<attributes.size();i++) {
|
||||
const QXmlStreamAttribute& attr = attributes.at(i);
|
||||
@@ -250,7 +238,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_COMBO:
|
||||
case olive::nodes::kCombo:
|
||||
{
|
||||
ComboField* combo_field = new ComboField(row, id);
|
||||
int combo_default_index = 0;
|
||||
@@ -274,7 +262,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
field = combo_field;
|
||||
}
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_FONT:
|
||||
case olive::nodes::kFont:
|
||||
field = new FontField(row, id);
|
||||
for (int i=0;i<attributes.size();i++) {
|
||||
const QXmlStreamAttribute& attr = attributes.at(i);
|
||||
@@ -283,7 +271,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_FILE:
|
||||
case olive::nodes::kFile:
|
||||
field = new FileField(row, id);
|
||||
for (int i=0;i<attributes.size();i++) {
|
||||
const QXmlStreamAttribute& attr = attributes.at(i);
|
||||
@@ -864,14 +852,14 @@ void Effect::process_shader(double timecode, GLTextureCoords&, int iteration) {
|
||||
EffectField* field = row->Field(j);
|
||||
if (!field->id().isEmpty()) {
|
||||
switch (field->type()) {
|
||||
case EffectField::EFFECT_FIELD_DOUBLE:
|
||||
case olive::nodes::kFloat:
|
||||
{
|
||||
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:
|
||||
case olive::nodes::kColor:
|
||||
{
|
||||
ColorField* color_field = static_cast<ColorField*>(field);
|
||||
shader_program_->setUniformValue(
|
||||
@@ -882,18 +870,18 @@ void Effect::process_shader(double timecode, GLTextureCoords&, int iteration) {
|
||||
);
|
||||
}
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_BOOL:
|
||||
case olive::nodes::kBoolean:
|
||||
shader_program_->setUniformValue(field->id().toUtf8().constData(), field->GetValueAt(timecode).toBool());
|
||||
break;
|
||||
case EffectField::EFFECT_FIELD_COMBO:
|
||||
case olive::nodes::kCombo:
|
||||
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:
|
||||
case olive::nodes::kString:
|
||||
case olive::nodes::kFont:
|
||||
case olive::nodes::kFile:
|
||||
case olive::nodes::kUI:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -34,7 +34,7 @@
|
||||
#include "global/math.h"
|
||||
#include "global/debug.h"
|
||||
|
||||
EffectField::EffectField(EffectRow* parent, const QString &i, EffectFieldType t) :
|
||||
EffectField::EffectField(EffectRow* parent, const QString &i, olive::nodes::DataType t) :
|
||||
QObject(parent),
|
||||
type_(t),
|
||||
id_(i),
|
||||
@@ -43,7 +43,7 @@ EffectField::EffectField(EffectRow* parent, const QString &i, EffectFieldType t)
|
||||
{
|
||||
// EffectField MUST be created with a parent.
|
||||
Q_ASSERT(parent != nullptr);
|
||||
Q_ASSERT(!i.isEmpty() || t == EFFECT_FIELD_UI);
|
||||
Q_ASSERT(!i.isEmpty() || t == olive::nodes::kUI);
|
||||
|
||||
// Add this field to the parent row specified
|
||||
parent->AddField(this);
|
||||
@@ -93,7 +93,7 @@ QVariant EffectField::GetValueAt(double timecode)
|
||||
|
||||
const QVariant& before_data = keyframes.at(before_keyframe).data;
|
||||
switch (type_) {
|
||||
case EFFECT_FIELD_DOUBLE:
|
||||
case olive::nodes::kFloat:
|
||||
{
|
||||
double value;
|
||||
if (before_keyframe == after_keyframe) {
|
||||
@@ -163,7 +163,7 @@ QVariant EffectField::GetValueAt(double timecode)
|
||||
persistent_data_ = value;
|
||||
break;
|
||||
}
|
||||
case EFFECT_FIELD_COLOR:
|
||||
case olive::nodes::kColor:
|
||||
{
|
||||
QColor value;
|
||||
if (before_keyframe == after_keyframe) {
|
||||
@@ -178,11 +178,11 @@ QVariant EffectField::GetValueAt(double timecode)
|
||||
persistent_data_ = value;
|
||||
break;
|
||||
}
|
||||
case EFFECT_FIELD_STRING:
|
||||
case EFFECT_FIELD_BOOL:
|
||||
case EFFECT_FIELD_COMBO:
|
||||
case EFFECT_FIELD_FONT:
|
||||
case EFFECT_FIELD_FILE:
|
||||
case olive::nodes::kString:
|
||||
case olive::nodes::kBoolean:
|
||||
case olive::nodes::kCombo:
|
||||
case olive::nodes::kFont:
|
||||
case olive::nodes::kFile:
|
||||
persistent_data_ = before_data;
|
||||
break;
|
||||
default:
|
||||
@@ -274,7 +274,7 @@ void EffectField::PrepareDataForKeyframing(bool enabled, ComboAction *ca)
|
||||
}
|
||||
}
|
||||
|
||||
const EffectField::EffectFieldType &EffectField::type()
|
||||
const olive::nodes::DataType &EffectField::type()
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ void EffectField::GetKeyframeData(double timecode, int &before, int &after, doub
|
||||
}
|
||||
}
|
||||
|
||||
if ((type_ == EFFECT_FIELD_DOUBLE || type_ == EFFECT_FIELD_COLOR)
|
||||
if ((type_ == olive::nodes::kFloat || type_ == olive::nodes::kColor)
|
||||
&& (before_keyframe_index > -1 && after_keyframe_index > -1)) {
|
||||
// interpolate
|
||||
before = before_keyframe_index;
|
||||
|
||||
+5
-37
@@ -28,6 +28,7 @@
|
||||
#include "effects/keyframe.h"
|
||||
#include "undo/undo.h"
|
||||
#include "undo/undostack.h"
|
||||
#include "nodes/nodedatatypes.h"
|
||||
|
||||
class EffectRow;
|
||||
class ComboAction;
|
||||
@@ -56,39 +57,6 @@ class ComboAction;
|
||||
class EffectField : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief The EffectFieldType enum
|
||||
*
|
||||
* Predetermined types of fields. Used throughout Olive to identify what kind of data to expect from GetValueAt().
|
||||
*
|
||||
* This enum is also currently used to match an external XML effect's fields with the correct derived class (e.g.
|
||||
* EFFECT_FIELD_DOUBLE matches to DoubleField).
|
||||
*/
|
||||
enum EffectFieldType {
|
||||
/** Values are doubles. Also corresponds to DoubleField. */
|
||||
EFFECT_FIELD_DOUBLE,
|
||||
|
||||
/** Values are colors. Also corresponds to ColorField. */
|
||||
EFFECT_FIELD_COLOR,
|
||||
|
||||
/** Values are strings. Also corresponds to StringField. */
|
||||
EFFECT_FIELD_STRING,
|
||||
|
||||
/** Values are booleans. Also corresponds to BoolField. */
|
||||
EFFECT_FIELD_BOOL,
|
||||
|
||||
/** Values are arbitrary data. Also corresponds to ComboField. */
|
||||
EFFECT_FIELD_COMBO,
|
||||
|
||||
/** Values are font family names (in string). Also corresponds to FontField. */
|
||||
EFFECT_FIELD_FONT,
|
||||
|
||||
/** Values are filenames (in string). Also corresponds to FileField. */
|
||||
EFFECT_FIELD_FILE,
|
||||
|
||||
/** Values is a UI object with no data. Corresponds to nothing. */
|
||||
EFFECT_FIELD_UI
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief EffectField Constructor
|
||||
@@ -112,7 +80,7 @@ public:
|
||||
*
|
||||
* The type of data contained within this field. This is expected to be filled by a derived class.
|
||||
*/
|
||||
EffectField(EffectRow* parent, const QString& i, EffectFieldType t);
|
||||
EffectField(EffectRow* parent, const QString& i, olive::nodes::DataType t);
|
||||
|
||||
/**
|
||||
* @brief Get the EffectRow that this field is a member of.
|
||||
@@ -130,9 +98,9 @@ public:
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* A member of the EffectFieldType enum.
|
||||
* A member of the olive::nodes::DataType enum.
|
||||
*/
|
||||
const EffectFieldType& type();
|
||||
const olive::nodes::DataType& type();
|
||||
|
||||
/**
|
||||
* @brief Get the unique identifier of this field set in the constructor
|
||||
@@ -430,7 +398,7 @@ private:
|
||||
/**
|
||||
* @brief Internal type variable set in the constructor. Access with type().
|
||||
*/
|
||||
EffectFieldType type_;
|
||||
olive::nodes::DataType type_;
|
||||
|
||||
/**
|
||||
* @brief Internal unique identifier for this field set in the constructor. Access with id().
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <QCheckBox>
|
||||
|
||||
BoolField::BoolField(EffectRow *parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_BOOL)
|
||||
EffectField(parent, id, olive::nodes::kBoolean)
|
||||
{}
|
||||
|
||||
bool BoolField::GetBoolAt(double timecode)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <QPushButton>
|
||||
|
||||
ButtonField::ButtonField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI),
|
||||
EffectField(parent, nullptr, olive::nodes::kUI),
|
||||
button_text_(string)
|
||||
{}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "ui/colorbutton.h"
|
||||
|
||||
ColorField::ColorField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_COLOR)
|
||||
EffectField(parent, id, olive::nodes::kColor)
|
||||
{}
|
||||
|
||||
QColor ColorField::GetColorAt(double timecode)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "ui/comboboxex.h"
|
||||
|
||||
ComboField::ComboField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_COMBO)
|
||||
EffectField(parent, id, olive::nodes::kCombo)
|
||||
{}
|
||||
|
||||
void ComboField::AddItem(const QString &text, const QVariant &data)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "effects/effectrow.h"
|
||||
|
||||
DoubleField::DoubleField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_DOUBLE),
|
||||
EffectField(parent, id, olive::nodes::kFloat),
|
||||
min_(qSNaN()),
|
||||
max_(qSNaN()),
|
||||
default_(0),
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "ui/embeddedfilechooser.h"
|
||||
|
||||
FileField::FileField(EffectRow* parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_FILE)
|
||||
EffectField(parent, id, olive::nodes::kFile)
|
||||
{
|
||||
// Set default value to an empty string
|
||||
SetValueAt(0, "");
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// NOTE/TODO: This shares a lot of similarity with ComboField, and could probably be a derived class of it
|
||||
|
||||
FontField::FontField(EffectRow* parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_FONT)
|
||||
EffectField(parent, id, olive::nodes::kFont)
|
||||
{
|
||||
font_list = QFontDatabase().families();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <QLabel>
|
||||
|
||||
LabelField::LabelField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI),
|
||||
EffectField(parent, nullptr, olive::nodes::kUI),
|
||||
label_text_(string)
|
||||
{}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "global/config.h"
|
||||
|
||||
StringField::StringField(EffectRow* parent, const QString& id, bool rich_text) :
|
||||
EffectField(parent, id, EFFECT_FIELD_STRING),
|
||||
EffectField(parent, id, olive::nodes::kString),
|
||||
rich_text_(rich_text)
|
||||
{
|
||||
// Set default value to an empty string
|
||||
|
||||
Reference in New Issue
Block a user