use strings to connect nodes
This makes the node system somewhat more high-level with the intent of making working with them far more flexible and stable. By making the architecture more abstracted, it becomes far less rigid which should allow us to do even more with it and make it much less crash prone.
This commit is contained in:
@@ -27,23 +27,26 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QString MatrixGenerator::kPositionInput = QStringLiteral("pos_in");
|
||||
const QString MatrixGenerator::kRotationInput = QStringLiteral("rot_in");
|
||||
const QString MatrixGenerator::kScaleInput = QStringLiteral("scale_in");
|
||||
const QString MatrixGenerator::kUniformScaleInput = QStringLiteral("uniform_scale_in");
|
||||
const QString MatrixGenerator::kAnchorInput = QStringLiteral("anchor_in");
|
||||
|
||||
MatrixGenerator::MatrixGenerator()
|
||||
{
|
||||
position_input_ = new NodeInput(this, QStringLiteral("pos_in"), NodeValue::kVec2, QVector2D());
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
|
||||
rotation_input_ = new NodeInput(this, QStringLiteral("rot_in"), NodeValue::kFloat, 0.0f);
|
||||
AddInput(kRotationInput, NodeValue::kFloat, 0.0);
|
||||
|
||||
scale_input_ = new NodeInput(this, QStringLiteral("scale_in"), NodeValue::kVec2, QVector2D(1.0f, 1.0f));
|
||||
scale_input_->setProperty("min", QVector2D(0, 0));
|
||||
scale_input_->setProperty("view", FloatSlider::kPercentage);
|
||||
scale_input_->setProperty("disabley", true);
|
||||
AddInput(kScaleInput, NodeValue::kVec2, QVector2D(1.0f, 1.0f));
|
||||
SetInputProperty(kScaleInput, QStringLiteral("min"), QVector2D(0, 0));
|
||||
SetInputProperty(kScaleInput, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
SetInputProperty(kScaleInput, QStringLiteral("disabley"), true);
|
||||
|
||||
uniform_scale_input_ = new NodeInput(this, QStringLiteral("uniform_scale_in"), NodeValue::kBoolean, true);
|
||||
uniform_scale_input_->SetKeyframable(false);
|
||||
uniform_scale_input_->SetConnectable(false);
|
||||
connect(uniform_scale_input_, &NodeInput::ValueChanged, this, &MatrixGenerator::UniformScaleChanged);
|
||||
AddInput(kUniformScaleInput, NodeValue::kBoolean, true, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
|
||||
anchor_input_ = new NodeInput(this, QStringLiteral("anchor_in"), NodeValue::kVec2, QVector2D());
|
||||
AddInput(kAnchorInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
}
|
||||
|
||||
Node *MatrixGenerator::copy() const
|
||||
@@ -78,20 +81,22 @@ QString MatrixGenerator::Description() const
|
||||
|
||||
void MatrixGenerator::Retranslate()
|
||||
{
|
||||
position_input_->set_name(tr("Position"));
|
||||
rotation_input_->set_name(tr("Rotation"));
|
||||
scale_input_->set_name(tr("Scale"));
|
||||
uniform_scale_input_->set_name(tr("Uniform Scale"));
|
||||
anchor_input_->set_name(tr("Anchor Point"));
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kRotationInput, tr("Rotation"));
|
||||
SetInputName(kScaleInput, tr("Scale"));
|
||||
SetInputName(kUniformScaleInput, tr("Uniform Scale"));
|
||||
SetInputName(kAnchorInput, tr("Anchor Point"));
|
||||
}
|
||||
|
||||
NodeValueTable MatrixGenerator::Value(NodeValueDatabase &value) const
|
||||
NodeValueTable MatrixGenerator::Value(const QString &output, NodeValueDatabase &value) const
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
// Push matrix output
|
||||
QMatrix4x4 mat = GenerateMatrix(value, true, false, false, false);
|
||||
NodeValueTable output = value.Merge();
|
||||
output.Push(NodeValue::kMatrix, mat, this);
|
||||
return output;
|
||||
NodeValueTable out = value.Merge();
|
||||
out.Push(NodeValue::kMatrix, mat, this);
|
||||
return out;
|
||||
}
|
||||
|
||||
QMatrix4x4 MatrixGenerator::GenerateMatrix(NodeValueDatabase &value, bool take, bool ignore_anchor, bool ignore_position, bool ignore_scale) const
|
||||
@@ -103,47 +108,47 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(NodeValueDatabase &value, bool take,
|
||||
if (!ignore_anchor) {
|
||||
if (take) {
|
||||
// Take and store
|
||||
anchor = value[anchor_input_].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
anchor = value[kAnchorInput].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
} else {
|
||||
// Get and store
|
||||
anchor = value[anchor_input_].Get(NodeValue::kVec2).value<QVector2D>();
|
||||
anchor = value[kAnchorInput].Get(NodeValue::kVec2).value<QVector2D>();
|
||||
}
|
||||
} else if (take) {
|
||||
// Just take
|
||||
value[anchor_input_].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
value[kAnchorInput].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
}
|
||||
|
||||
if (!ignore_scale) {
|
||||
if (take) {
|
||||
scale = value[scale_input_].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
scale = value[kScaleInput].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
} else {
|
||||
scale = value[scale_input_].Get(NodeValue::kVec2).value<QVector2D>();
|
||||
scale = value[kScaleInput].Get(NodeValue::kVec2).value<QVector2D>();
|
||||
}
|
||||
} else if (take) {
|
||||
value[scale_input_].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
value[kScaleInput].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
}
|
||||
|
||||
if (!ignore_position) {
|
||||
if (take) {
|
||||
position = value[position_input_].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
position = value[kPositionInput].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
} else {
|
||||
position = value[position_input_].Get(NodeValue::kVec2).value<QVector2D>();
|
||||
position = value[kPositionInput].Get(NodeValue::kVec2).value<QVector2D>();
|
||||
}
|
||||
} else if (take) {
|
||||
value[position_input_].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
value[kPositionInput].Take(NodeValue::kVec2).value<QVector2D>();
|
||||
}
|
||||
|
||||
if (take) {
|
||||
return GenerateMatrix(position,
|
||||
value[rotation_input_].Take(NodeValue::kFloat).toFloat(),
|
||||
value[kRotationInput].Take(NodeValue::kFloat).toFloat(),
|
||||
scale,
|
||||
value[uniform_scale_input_].Take(NodeValue::kBoolean).toBool(),
|
||||
value[kUniformScaleInput].Take(NodeValue::kBoolean).toBool(),
|
||||
anchor);
|
||||
} else {
|
||||
return GenerateMatrix(position,
|
||||
value[rotation_input_].Get(NodeValue::kFloat).toFloat(),
|
||||
value[kRotationInput].Get(NodeValue::kFloat).toFloat(),
|
||||
scale,
|
||||
value[uniform_scale_input_].Get(NodeValue::kBoolean).toBool(),
|
||||
value[kUniformScaleInput].Get(NodeValue::kBoolean).toBool(),
|
||||
anchor);
|
||||
|
||||
}
|
||||
@@ -178,9 +183,13 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(const QVector2D& pos,
|
||||
return mat;
|
||||
}
|
||||
|
||||
void MatrixGenerator::UniformScaleChanged()
|
||||
void MatrixGenerator::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
scale_input_->setProperty("disabley", uniform_scale_input_->GetStandardValue().toBool());
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kUniformScaleInput) {
|
||||
SetInputProperty(kScaleInput, QStringLiteral("disabley"), GetStandardValue(kUniformScaleInput).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,13 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase& value) const override;
|
||||
virtual NodeValueTable Value(const QString& output, NodeValueDatabase& value) const override;
|
||||
|
||||
static const QString kPositionInput;
|
||||
static const QString kRotationInput;
|
||||
static const QString kScaleInput;
|
||||
static const QString kUniformScaleInput;
|
||||
static const QString kAnchorInput;
|
||||
|
||||
protected:
|
||||
QMatrix4x4 GenerateMatrix(NodeValueDatabase &value, bool take, bool ignore_anchor, bool ignore_position, bool ignore_scale) const;
|
||||
@@ -54,44 +60,7 @@ protected:
|
||||
bool uniform_scale,
|
||||
const QVector2D &anchor);
|
||||
|
||||
NodeInput* position_input() const
|
||||
{
|
||||
return position_input_;
|
||||
}
|
||||
|
||||
NodeInput* rotation_input() const
|
||||
{
|
||||
return rotation_input_;
|
||||
}
|
||||
|
||||
NodeInput* scale_input() const
|
||||
{
|
||||
return scale_input_;
|
||||
}
|
||||
|
||||
NodeInput* uniform_scale_input() const
|
||||
{
|
||||
return uniform_scale_input_;
|
||||
}
|
||||
|
||||
NodeInput* anchor_input() const
|
||||
{
|
||||
return anchor_input_;
|
||||
}
|
||||
|
||||
private:
|
||||
NodeInput* position_input_;
|
||||
|
||||
NodeInput* rotation_input_;
|
||||
|
||||
NodeInput* scale_input_;
|
||||
|
||||
NodeInput* uniform_scale_input_;
|
||||
|
||||
NodeInput* anchor_input_;
|
||||
|
||||
private slots:
|
||||
void UniformScaleChanged();
|
||||
virtual void InputValueChangedEvent(const QString& input, int element) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -25,25 +25,27 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QString PolygonGenerator::kPointsInput = QStringLiteral("points_in");
|
||||
const QString PolygonGenerator::kColorInput = QStringLiteral("color_in");
|
||||
|
||||
PolygonGenerator::PolygonGenerator()
|
||||
{
|
||||
points_input_ = new NodeInput(this, QStringLiteral("points_in"), NodeValue::kVec2, QVector2D(0, 0));
|
||||
points_input_->SetIsArray(true);
|
||||
AddInput(kPointsInput, NodeValue::kVec2, QVector2D(0, 0), InputFlags(kInputFlagArray));
|
||||
|
||||
color_input_ = new NodeInput(this, QStringLiteral("color_in"), NodeValue::kColor, QVariant::fromValue(Color(1.0, 1.0, 1.0)));
|
||||
AddInput(kColorInput, NodeValue::kColor, QVariant::fromValue(Color(1.0, 1.0, 1.0)));
|
||||
|
||||
// The Default Pentagon(tm)
|
||||
points_input_->ArrayResize(5);
|
||||
points_input_->SetStandardValueOnTrack(960, 0, 0);
|
||||
points_input_->SetStandardValueOnTrack(240, 1, 0);
|
||||
points_input_->SetStandardValueOnTrack(640, 0, 1);
|
||||
points_input_->SetStandardValueOnTrack(480, 1, 1);
|
||||
points_input_->SetStandardValueOnTrack(760, 0, 2);
|
||||
points_input_->SetStandardValueOnTrack(800, 1, 2);
|
||||
points_input_->SetStandardValueOnTrack(1100, 0, 3);
|
||||
points_input_->SetStandardValueOnTrack(800, 1, 3);
|
||||
points_input_->SetStandardValueOnTrack(1280, 0, 4);
|
||||
points_input_->SetStandardValueOnTrack(480, 1, 4);
|
||||
InputArrayResize(kPointsInput, 5);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 960, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, 240, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 640, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, 480, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 760, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, 800, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 1100, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, 800, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 1200, 4);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, 480, 4);
|
||||
}
|
||||
|
||||
Node *PolygonGenerator::copy() const
|
||||
@@ -73,8 +75,8 @@ QString PolygonGenerator::Description() const
|
||||
|
||||
void PolygonGenerator::Retranslate()
|
||||
{
|
||||
points_input_->set_name(tr("Points"));
|
||||
color_input_->set_name(tr("Color"));
|
||||
SetInputName(kPointsInput, tr("Points"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
}
|
||||
|
||||
ShaderCode PolygonGenerator::GetShaderCode(const QString &shader_id) const
|
||||
@@ -84,12 +86,14 @@ ShaderCode PolygonGenerator::GetShaderCode(const QString &shader_id) const
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/polygon.frag")));
|
||||
}
|
||||
|
||||
NodeValueTable PolygonGenerator::Value(NodeValueDatabase &value) const
|
||||
NodeValueTable PolygonGenerator::Value(const QString &output, NodeValueDatabase &value) const
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
ShaderJob job;
|
||||
|
||||
job.InsertValue(points_input_, value);
|
||||
job.InsertValue(color_input_, value);
|
||||
job.InsertValue(this, kPointsInput, value);
|
||||
job.InsertValue(this, kColorInput, value);
|
||||
job.InsertValue(QStringLiteral("resolution_in"), value[QStringLiteral("global")].GetWithMeta(NodeValue::kVec2, QStringLiteral("resolution")));
|
||||
job.SetAlphaChannelRequired(true);
|
||||
|
||||
@@ -168,10 +172,10 @@ void PolygonGenerator::GizmoRelease()
|
||||
QVector<QPointF> PolygonGenerator::GetGizmoCoordinates(NodeValueDatabase &db, const QVector2D& scale) const
|
||||
{
|
||||
// FIXME: Should Get() use a `kArray` type instead of a `kVec2` type?
|
||||
QVector<NodeValueTable> array_tbl = db[points_input_].Get(NodeValue::kVec2).value< QVector<NodeValueTable> >();
|
||||
QVector<NodeValueTable> array_tbl = db[kPointsInput].Get(NodeValue::kVec2).value< QVector<NodeValueTable> >();
|
||||
QVector<QPointF> points(array_tbl.size());
|
||||
|
||||
for (int i=0;i<points_input_->ArraySize();i++) {
|
||||
for (int i=0;i<array_tbl.size();i++) {
|
||||
QVector2D v = array_tbl.at(i).Get(NodeValue::kVec2).value<QVector2D>();
|
||||
|
||||
v *= scale;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const QString& shader_id) const override;
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
virtual NodeValueTable Value(const QString& output, NodeValueDatabase &value) const override;
|
||||
|
||||
virtual bool HasGizmos() const override;
|
||||
//virtual void DrawGizmos(NodeValueDatabase& db, QPainter *p) const override;
|
||||
@@ -51,15 +51,14 @@ public:
|
||||
//virtual void GizmoMove(const QPointF &p, const QVector2D &scale, const rational &time) override;
|
||||
//virtual void GizmoRelease() override;
|
||||
|
||||
static const QString kPointsInput;
|
||||
static const QString kColorInput;
|
||||
|
||||
private:
|
||||
QVector<QPointF> GetGizmoCoordinates(NodeValueDatabase &db, const QVector2D &scale) const;
|
||||
|
||||
QVector<QRectF> GetGizmoRects(const QVector<QPointF>& points) const;
|
||||
|
||||
NodeInput* points_input_;
|
||||
|
||||
NodeInput* color_input_;
|
||||
|
||||
NodeInput* gizmo_drag_;
|
||||
QPointF gizmo_drag_start_;
|
||||
|
||||
|
||||
@@ -24,13 +24,12 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QString SolidGenerator::kColorInput = QStringLiteral("color_in");
|
||||
|
||||
SolidGenerator::SolidGenerator()
|
||||
{
|
||||
// Default to a color that isn't black
|
||||
color_input_ = new NodeInput(this,
|
||||
QStringLiteral("color_in"),
|
||||
NodeValue::kColor,
|
||||
QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||
AddInput(kColorInput, NodeValue::kColor, QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||
}
|
||||
|
||||
Node *SolidGenerator::copy() const
|
||||
@@ -60,13 +59,15 @@ QString SolidGenerator::Description() const
|
||||
|
||||
void SolidGenerator::Retranslate()
|
||||
{
|
||||
color_input_->set_name(tr("Color"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
}
|
||||
|
||||
NodeValueTable SolidGenerator::Value(NodeValueDatabase &value) const
|
||||
NodeValueTable SolidGenerator::Value(const QString &output, NodeValueDatabase &value) const
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
ShaderJob job;
|
||||
job.InsertValue(color_input_, value);
|
||||
job.InsertValue(this, kColorInput, value);
|
||||
|
||||
NodeValueTable table = value.Merge();
|
||||
table.Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
|
||||
|
||||
@@ -40,11 +40,10 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
virtual NodeValueTable Value(const QString& output, NodeValueDatabase &value) const override;
|
||||
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
|
||||
|
||||
private:
|
||||
NodeInput* color_input_;
|
||||
static const QString kColorInput;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -30,31 +30,23 @@ enum TextVerticalAlign {
|
||||
kVerticalAlignBottom,
|
||||
};
|
||||
|
||||
const QString TextGenerator::kTextInput = QStringLiteral("text_in");
|
||||
const QString TextGenerator::kColorInput = QStringLiteral("color_in");
|
||||
const QString TextGenerator::kVAlignInput = QStringLiteral("valign_in");
|
||||
const QString TextGenerator::kFontInput = QStringLiteral("font_in");
|
||||
const QString TextGenerator::kFontSizeInput = QStringLiteral("font_size_in");
|
||||
|
||||
TextGenerator::TextGenerator()
|
||||
{
|
||||
text_input_ = new NodeInput(this,
|
||||
QStringLiteral("text_in"),
|
||||
NodeValue::kText,
|
||||
tr("Sample Text"));
|
||||
AddInput(kTextInput, NodeValue::kText, tr("Sample Text"));
|
||||
|
||||
color_input_ = new NodeInput(this,
|
||||
QStringLiteral("color_in"),
|
||||
NodeValue::kColor,
|
||||
QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
AddInput(kColorInput, NodeValue::kColor, QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
|
||||
valign_input_ = new NodeInput(this,
|
||||
QStringLiteral("valign_in"),
|
||||
NodeValue::kCombo,
|
||||
1);
|
||||
AddInput(kVAlignInput, NodeValue::kCombo, 1);
|
||||
|
||||
font_input_ = new NodeInput(this,
|
||||
QStringLiteral("font_in"),
|
||||
NodeValue::kFont);
|
||||
AddInput(kFontInput, NodeValue::kFont);
|
||||
|
||||
font_size_input_ = new NodeInput(this,
|
||||
QStringLiteral("font_size_in"),
|
||||
NodeValue::kFloat,
|
||||
72.0f);
|
||||
AddInput(kFontSizeInput, NodeValue::kFloat, 72.0f);
|
||||
}
|
||||
|
||||
Node *TextGenerator::copy() const
|
||||
@@ -84,27 +76,29 @@ QString TextGenerator::Description() const
|
||||
|
||||
void TextGenerator::Retranslate()
|
||||
{
|
||||
text_input_->set_name(tr("Text"));
|
||||
font_input_->set_name(tr("Font"));
|
||||
font_size_input_->set_name(tr("Font Size"));
|
||||
color_input_->set_name(tr("Color"));
|
||||
valign_input_->set_name(tr("Vertical Align"));
|
||||
valign_input_->set_combobox_strings({tr("Top"), tr("Center"), tr("Bottom")});
|
||||
SetInputName(kTextInput, tr("Text"));
|
||||
SetInputName(kFontInput, tr("Font"));
|
||||
SetInputName(kFontSizeInput, tr("Font Size"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
SetInputName(kVAlignInput, tr("Vertical Align"));
|
||||
SetComboBoxStrings(kVAlignInput, {tr("Top"), tr("Center"), tr("Bottom")});
|
||||
}
|
||||
|
||||
NodeValueTable TextGenerator::Value(NodeValueDatabase &value) const
|
||||
NodeValueTable TextGenerator::Value(const QString &output, NodeValueDatabase &value) const
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
GenerateJob job;
|
||||
job.InsertValue(text_input_, value);
|
||||
job.InsertValue(color_input_, value);
|
||||
job.InsertValue(valign_input_, value);
|
||||
job.InsertValue(font_input_, value);
|
||||
job.InsertValue(font_size_input_, value);
|
||||
job.InsertValue(this, kTextInput, value);
|
||||
job.InsertValue(this, kColorInput, value);
|
||||
job.InsertValue(this, kVAlignInput, value);
|
||||
job.InsertValue(this, kFontInput, value);
|
||||
job.InsertValue(this, kFontSizeInput, value);
|
||||
job.SetAlphaChannelRequired(true);
|
||||
|
||||
NodeValueTable table = value.Merge();
|
||||
|
||||
if (!job.GetValue(text_input_).data().toString().isEmpty()) {
|
||||
if (!job.GetValue(kTextInput).data().toString().isEmpty()) {
|
||||
table.Push(NodeValue::kGenerateJob, QVariant::fromValue(job), this);
|
||||
}
|
||||
|
||||
@@ -124,14 +118,14 @@ void TextGenerator::GenerateFrame(FramePtr frame, const GenerateJob& job) const
|
||||
|
||||
// Set default font
|
||||
QFont default_font;
|
||||
default_font.setFamily(job.GetValue(font_input_).data().toString());
|
||||
default_font.setPointSizeF(job.GetValue(font_size_input_).data().toFloat());
|
||||
default_font.setFamily(job.GetValue(kFontInput).data().toString());
|
||||
default_font.setPointSizeF(job.GetValue(kFontSizeInput).data().toFloat());
|
||||
text_doc.setDefaultFont(default_font);
|
||||
|
||||
// Center by default
|
||||
text_doc.setDefaultTextOption(QTextOption(Qt::AlignCenter));
|
||||
|
||||
text_doc.setHtml(job.GetValue(text_input_).data().toString());
|
||||
text_doc.setHtml(job.GetValue(kTextInput).data().toString());
|
||||
|
||||
// Align to 80% width because that's considered the "title safe" area
|
||||
int tenth_of_width = frame->video_params().width() / 10;
|
||||
@@ -144,7 +138,7 @@ void TextGenerator::GenerateFrame(FramePtr frame, const GenerateJob& job) const
|
||||
// Push 10% inwards to compensate for title safe area
|
||||
p.translate(tenth_of_width, 0);
|
||||
|
||||
TextVerticalAlign valign = static_cast<TextVerticalAlign>(job.GetValue(valign_input_).data().toInt());
|
||||
TextVerticalAlign valign = static_cast<TextVerticalAlign>(job.GetValue(kVAlignInput).data().toInt());
|
||||
int doc_height = text_doc.size().height();
|
||||
|
||||
switch (valign) {
|
||||
@@ -165,7 +159,7 @@ void TextGenerator::GenerateFrame(FramePtr frame, const GenerateJob& job) const
|
||||
text_doc.drawContents(&p);
|
||||
|
||||
// Transplant alpha channel to frame
|
||||
Color rgb = job.GetValue(color_input_).data().value<Color>();
|
||||
Color rgb = job.GetValue(kColorInput).data().value<Color>();
|
||||
for (int x=0; x<frame->width(); x++) {
|
||||
for (int y=0; y<frame->height(); y++) {
|
||||
uchar src_alpha = img.bits()[img.bytesPerLine() * y + x];
|
||||
|
||||
@@ -40,20 +40,15 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase& value) const override;
|
||||
virtual NodeValueTable Value(const QString& output, NodeValueDatabase& value) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame, const GenerateJob &job) const override;
|
||||
|
||||
private:
|
||||
NodeInput* text_input_;
|
||||
|
||||
NodeInput* color_input_;
|
||||
|
||||
NodeInput* valign_input_;
|
||||
|
||||
NodeInput* font_input_;
|
||||
|
||||
NodeInput* font_size_input_;
|
||||
static const QString kTextInput;
|
||||
static const QString kColorInput;
|
||||
static const QString kVAlignInput;
|
||||
static const QString kFontInput;
|
||||
static const QString kFontSizeInput;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user