finished moving field data retrieving to row

This commit is contained in:
itsmattkc
2019-04-11 00:02:50 +10:00
parent 14ae903000
commit d3bc1d4f06
78 changed files with 1189 additions and 676 deletions
+15
View File
@@ -0,0 +1,15 @@
#ifndef INPUTS_H
#define INPUTS_H
#include "inputs/vecinput.h"
#include "inputs/boolinput.h"
#include "inputs/comboinput.h"
#include "inputs/colorinput.h"
#include "inputs/stringinput.h"
#include "inputs/fileinput.h"
#include "inputs/fontinput.h"
#include "widgets/labelwidget.h"
#include "widgets/buttonwidget.h"
#endif // INPUTS_H
+14
View File
@@ -0,0 +1,14 @@
#include "boolinput.h"
BoolInput::BoolInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
BoolField* bool_field = new BoolField(this);
connect(bool_field, SIGNAL(Toggled(bool)), this, SIGNAL(Toggled(bool)));
AddField(bool_field);
}
bool BoolInput::GetBoolAt(double timecode)
{
return static_cast<BoolField*>(Field(0))->GetBoolAt(timecode);
}
+36
View File
@@ -0,0 +1,36 @@
#ifndef BOOLINPUT_H
#define BOOLINPUT_H
#include "effects/effectrow.h"
class BoolInput : public EffectRow
{
Q_OBJECT
public:
BoolInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the boolean value at a given timecode
*
* A wrapper for BoolField::GetBoolAt().
*
* @param timecode
*
* The timecode to retrieve the value at
*
* @return
*
* The boolean value at this timecode
*/
bool GetBoolAt(double timecode);
signals:
/**
* @brief Emitted whenever the UI widget's boolean value has changed
*
* Wrapper for BoolField::Toggled().
*/
void Toggled(bool);
};
#endif // BOOLINPUT_H
+12
View File
@@ -0,0 +1,12 @@
#include "colorinput.h"
ColorInput::ColorInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new ColorField(this));
}
QColor ColorInput::GetColorAt(double timecode)
{
static_cast<ColorField*>(Field(0))->GetColorAt(timecode);
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef COLORINPUT_H
#define COLORINPUT_H
#include "effects/effectrow.h"
class ColorInput : public EffectRow
{
Q_OBJECT
public:
ColorInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the color value at a given timecode
*
* Wrapper for ColorField::GetColorAt().
*
* @param timecode
*
* The timecode to retrieve the color at
*
* @return
*
* The color value at this timecode
*/
QColor GetColorAt(double timecode);
};
#endif // COLORINPUT_H
+14
View File
@@ -0,0 +1,14 @@
#include "comboinput.h"
ComboInput::ComboInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
ComboField* combo_field = new ComboField(this);
connect(combo_field, SIGNAL(DataChanged(const QVariant&)), this, SIGNAL(DataChanged(const QVariant&)));
AddField(combo_field);
}
void ComboInput::AddItem(const QString &text, const QVariant &data)
{
static_cast<ComboField*>(Field(0))->AddItem(text, data);
}
+36
View File
@@ -0,0 +1,36 @@
#ifndef COMBOINPUT_H
#define COMBOINPUT_H
#include "effects/effectrow.h"
class ComboInput : public EffectRow
{
Q_OBJECT
public:
ComboInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Add an item to this ComboInput
*
* Wrapper for ComboField::AddItem.
*
* @param text
*
* The text to show at this index.
*
* @param data
*
* The data to be retrieved at this index.
*/
void AddItem(const QString& text, const QVariant& data);
signals:
/**
* @brief Signal emitted whenever a connected widget's data gets changed
*
* Wrapper for ComboField::DataChanged.
*/
void DataChanged(const QVariant&);
};
#endif // COMBOINPUT_H
-6
View File
@@ -1,6 +0,0 @@
#include "doubleinput.h"
DoubleInput::DoubleInput()
{
}
-12
View File
@@ -1,12 +0,0 @@
#ifndef DOUBLEINPUT_H
#define DOUBLEINPUT_H
#include "effects/effectrow.h"
class DoubleInput : public EffectRow
{
public:
DoubleInput();
};
#endif // DOUBLEINPUT_H
+12
View File
@@ -0,0 +1,12 @@
#include "fileinput.h"
FileInput::FileInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new FileField(this));
}
QString FileInput::GetFileAt(double timecode)
{
return static_cast<FileField*>(Field(0))->GetFileAt(timecode);
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef FILEINPUT_H
#define FILEINPUT_H
#include "effects/effectrow.h"
class FileInput : public EffectRow
{
Q_OBJECT
public:
FileInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the filename at the given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toString()
*
* @param timecode
*
* The timecode to retrieve the filename at
*
* @return
*
* The filename at this timecode
*/
QString GetFileAt(double timecode);
};
#endif // FILEINPUT_H
+12
View File
@@ -0,0 +1,12 @@
#include "fontinput.h"
FontInput::FontInput(Effect* parent, const QString& id, const QString& name, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new FontField(this));
}
QString FontInput::GetFontAt(double timecode)
{
return static_cast<FontField*>(Field(0))->GetFontAt(timecode);
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef FONTINPUT_H
#define FONTINPUT_H
#include "effects/effectrow.h"
class FontInput : public EffectRow
{
Q_OBJECT
public:
FontInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
/**
* @brief Get the font family name at the given timecode
*
* Wrapper for FontField::GetFontAt().
*
* @param timecode
*
* The timecode to retrieve the font family name at
*
* @return
*
* The font family name at this timecode
*/
QString GetFontAt(double timecode);
};
#endif // FONTINPUT_H
+12
View File
@@ -0,0 +1,12 @@
#include "stringinput.h"
StringInput::StringInput(Effect* parent, const QString& id, const QString& name, bool rich_text, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable)
{
AddField(new StringField(this, rich_text));
}
QString StringInput::GetStringAt(double timecode)
{
return static_cast<StringField*>(Field(0))->GetStringAt(timecode);
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef STRINGINPUT_H
#define STRINGINPUT_H
#include "effects/effectrow.h"
class StringInput : public EffectRow
{
Q_OBJECT
public:
StringInput(Effect* parent,
const QString& id,
const QString& name,
bool rich_text = true,
bool savable = true,
bool keyframable = true);
/**
* @brief Get the string at the given timecode
*
* Wrappre for StringField::GetStringAt().
*
* @param timecode
*
* The timecode to retrieve the string at
*
* @return
*
* The string at this timecode
*/
QString GetStringAt(double timecode);
};
#endif // STRINGINPUT_H
+186
View File
@@ -0,0 +1,186 @@
#include "vecinput.h"
#include <QVector3D>
#include <QVector4D>
#include <QDebug>
VecInput::VecInput(Effect* parent, const QString& id, const QString& name, int values, bool savable, bool keyframable) :
EffectRow(parent, id, name, savable, keyframable),
single_value_mode_(false),
values_(values)
{
Q_ASSERT(values_ >= 1 && values_ <= 4);
for (int i=0;i<values_;i++) {
AddField(new DoubleField(this));
}
}
void VecInput::SetMinimum(double minimum)
{
for (int i=0;i<values_;i++) {
static_cast<DoubleField*>(Field(i))->SetMinimum(minimum);
}
}
void VecInput::SetMaximum(double maximum)
{
for (int i=0;i<values_;i++) {
static_cast<DoubleField*>(Field(i))->SetMaximum(maximum);
}
}
void VecInput::SetDefault(double def)
{
for (int i=0;i<values_;i++) {
static_cast<DoubleField*>(Field(i))->SetDefault(def);
}
}
void VecInput::SetDefault(const QVector<double> &def)
{
for (int i=0;i<values_;i++) {
static_cast<DoubleField*>(Field(i))->SetDefault(def.at(i));
}
}
void VecInput::SetDisplayType(LabelSlider::DisplayType type)
{
for (int i=0;i<FieldCount();i++) {
static_cast<DoubleField*>(Field(i))->SetDisplayType(type);
}
}
void VecInput::SetFrameRate(const double &rate)
{
for (int i=0;i<FieldCount();i++) {
static_cast<DoubleField*>(Field(i))->SetFrameRate(rate);
}
}
void VecInput::SetSingleValueMode(bool on)
{
qDebug() << "i'm here";
single_value_mode_ = on;
// Disable all fields except the first
for (int i=1;i<FieldCount();i++) {
Field(i)->SetEnabled(!single_value_mode_);
}
}
DoubleInput::DoubleInput(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 1, savable, keyframable)
{
}
double DoubleInput::GetDoubleAt(double timecode)
{
return static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode);
}
Vec2Input::Vec2Input(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 2, savable, keyframable)
{
}
QVector2D Vec2Input::GetVector2DAt(double timecode)
{
return GetValueAt(timecode).value<QVector2D>();
}
QVariant Vec2Input::GetValueAt(double timecode)
{
QVector2D vec2;
vec2.setX(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
if (single_value_mode_) {
vec2.setY(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
} else {
vec2.setY(static_cast<DoubleField*>(Field(1))->GetDoubleAt(timecode));
}
return vec2;
}
void Vec2Input::SetValueAt(double timecode, const QVariant &value)
{
QVector2D vec2 = value.value<QVector2D>();
static_cast<DoubleField*>(Field(0))->SetValueAt(timecode, vec2.x());
static_cast<DoubleField*>(Field(1))->SetValueAt(timecode, vec2.y());
}
Vec3Input::Vec3Input(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 3, savable, keyframable)
{
}
QVector3D Vec3Input::GetVector3DAt(double timecode)
{
return GetValueAt(timecode).value<QVector3D>();
}
QVariant Vec3Input::GetValueAt(double timecode)
{
QVector3D vec3;
vec3.setX(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
if (single_value_mode_) {
vec3.setY(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
vec3.setZ(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
} else {
vec3.setY(static_cast<DoubleField*>(Field(1))->GetDoubleAt(timecode));
vec3.setZ(static_cast<DoubleField*>(Field(2))->GetDoubleAt(timecode));
}
return vec3;
}
void Vec3Input::SetValueAt(double timecode, const QVariant &value)
{
QVector3D vec3 = value.value<QVector3D>();
static_cast<DoubleField*>(Field(0))->SetValueAt(timecode, vec3.x());
static_cast<DoubleField*>(Field(1))->SetValueAt(timecode, vec3.y());
static_cast<DoubleField*>(Field(2))->SetValueAt(timecode, vec3.z());
}
Vec4Input::Vec4Input(Effect *parent, const QString &id, const QString &name, bool savable, bool keyframable) :
VecInput(parent, id, name, 4, savable, keyframable)
{
}
QVector4D Vec4Input::GetVector4DAt(double timecode)
{
return GetValueAt(timecode).value<QVector4D>();
}
QVariant Vec4Input::GetValueAt(double timecode)
{
QVector4D vec4;
vec4.setX(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
if (single_value_mode_) {
vec4.setY(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
vec4.setZ(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
vec4.setZ(static_cast<DoubleField*>(Field(0))->GetDoubleAt(timecode));
} else {
vec4.setY(static_cast<DoubleField*>(Field(1))->GetDoubleAt(timecode));
vec4.setZ(static_cast<DoubleField*>(Field(2))->GetDoubleAt(timecode));
vec4.setW(static_cast<DoubleField*>(Field(3))->GetDoubleAt(timecode));
}
return vec4;
}
void Vec4Input::SetValueAt(double timecode, const QVariant &value)
{
QVector4D vec4 = value.value<QVector4D>();
static_cast<DoubleField*>(Field(0))->SetValueAt(timecode, vec4.x());
static_cast<DoubleField*>(Field(1))->SetValueAt(timecode, vec4.y());
static_cast<DoubleField*>(Field(2))->SetValueAt(timecode, vec4.z());
static_cast<DoubleField*>(Field(3))->SetValueAt(timecode, vec4.w());
}
+78
View File
@@ -0,0 +1,78 @@
#ifndef VEC2INPUT_H
#define VEC2INPUT_H
#include <QVector2D>
#include "effects/effectrow.h"
class VecInput : public EffectRow
{
Q_OBJECT
public:
VecInput(Effect* parent, const QString& id, const QString& name, int values, bool savable = true, bool keyframable = true);
void SetMinimum(double minimum);
void SetMaximum(double maximum);
void SetDefault(double def);
void SetDefault(const QVector<double> &def);
/**
* @brief Sets the UI display type to a member of LabelSlider::DisplayType.
*/
void SetDisplayType(LabelSlider::DisplayType type);
/**
* @brief For a timecode-based display type, sets the frame rate to be used for the displayed timecode
*
* \see SetDisplayType() and LabelSlider::SetFrameRate().
*/
void SetFrameRate(const double& rate);
protected:
bool single_value_mode_;
public slots:
void SetSingleValueMode(bool on);
private:
int values_;
};
class DoubleInput : public VecInput
{
public:
DoubleInput(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
double GetDoubleAt(double timecode);
};
class Vec2Input : public VecInput {
public:
Vec2Input(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
QVector2D GetVector2DAt(double timecode);
virtual QVariant GetValueAt(double timecode) override;
virtual void SetValueAt(double timecode, const QVariant &value) override;
};
class Vec3Input : public VecInput {
public:
Vec3Input(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
QVector3D GetVector3DAt(double timecode);
virtual QVariant GetValueAt(double timecode) override;
virtual void SetValueAt(double timecode, const QVariant &value) override;
};
class Vec4Input : public VecInput {
public:
Vec4Input(Effect* parent, const QString& id, const QString& name, bool savable = true, bool keyframable = true);
QVector4D GetVector4DAt(double timecode);
virtual QVariant GetValueAt(double timecode) override;
virtual void SetValueAt(double timecode, const QVariant &value) override;
};
#endif // VEC2INPUT_H
+8 -8
View File
@@ -12,13 +12,13 @@ namespace nodes {
* 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).
* EFFECT_FIELD_DOUBLE matches to DoubleInput).
*/
enum DataType {
/** Invalid data type. Used only for error handling. */
kInvalid,
/** Values are doubles. Also corresponds to DoubleField. */
/** Values are doubles. Also corresponds to DoubleInput. */
kFloat,
/** Value is an 2-component vector of floats. */
@@ -33,22 +33,22 @@ enum DataType {
/** Value is an array of floats. This cannot be an input field, and can only be passed between nodes. */
kArray,
/** Values are colors. Equivalent to kVec4 but represents as a color. Corresponds to ColorField. */
/** Values are colors. Equivalent to kVec4 but represents as a color. Corresponds to ColorInput. */
kColor,
/** Values are strings. Also corresponds to StringField. */
/** Values are strings. Also corresponds to StringInput. */
kString,
/** Values are booleans. Also corresponds to BoolField. */
/** Values are booleans. Also corresponds to BoolInput. */
kBoolean,
/** Values are arbitrary data. Also corresponds to ComboField. */
/** Values are arbitrary data. Also corresponds to ComboInput. */
kCombo,
/** Values are font family names (in string). Also corresponds to FontField. */
/** Values are font family names (in string). Also corresponds to FontInput. */
kFont,
/** Values are filenames (in string). Also corresponds to FileField. */
/** Values are filenames (in string). Also corresponds to FileInput. */
kFile,
/** Values are integers. */
+23
View File
@@ -0,0 +1,23 @@
#include "buttonwidget.h"
ButtonWidget::ButtonWidget(Effect* parent, const QString& name, const QString& text) :
EffectRow(parent, nullptr, name, false, false)
{
ButtonField* button_field = new ButtonField(this, text);
connect(button_field, SIGNAL(CheckedChanged(bool)), this, SIGNAL(CheckedChanged(bool)));
connect(button_field, SIGNAL(Toggled(bool)), this, SIGNAL(Toggled(bool)));
connect(this, SLOT(SetChecked(bool)), button_field, SLOT(SetChecked(bool)));
AddField(button_field);
}
void ButtonWidget::SetCheckable(bool c)
{
static_cast<ButtonField*>(Field(0))->SetCheckable(c);
}
void ButtonWidget::SetChecked(bool c)
{
static_cast<ButtonField*>(Field(0))->SetChecked(c);
}
+35
View File
@@ -0,0 +1,35 @@
#ifndef BUTTONWIDGET_H
#define BUTTONWIDGET_H
#include "effects/effectrow.h"
class ButtonWidget : public EffectRow
{
public:
ButtonWidget(Effect* parent, const QString& name, const QString& text);
/**
* @brief Wrapper for ButtonField::SetCheckable.
*/
void SetCheckable(bool c);
public slots:
/**
* @brief Wrapper for ButtonField::SetChecked()
*/
void SetChecked(bool c);
signals:
/**
* @brief Wrapper for ButtonField::CheckedChanged()
*/
void CheckedChanged(bool);
/**
* @brief Wrapper for ButtonField::Toggled()
*/
void Toggled(bool);
};
#endif // BUTTONWIDGET_H
+7
View File
@@ -0,0 +1,7 @@
#include "labelwidget.h"
LabelWidget::LabelWidget(Effect *parent, const QString &name, const QString &text) :
EffectRow(parent, nullptr, name, false, false)
{
AddField(new LabelField(this, text));
}
+12
View File
@@ -0,0 +1,12 @@
#ifndef LABELWIDGET_H
#define LABELWIDGET_H
#include "effects/effectrow.h"
class LabelWidget : public EffectRow
{
public:
LabelWidget(Effect* parent, const QString& name, const QString& text);
};
#endif // LABELWIDGET_H