style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -29,39 +29,39 @@
|
||||
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 =
|
||||
const QString MatrixGenerator::k_position_input = QStringLiteral("pos_in");
|
||||
const QString MatrixGenerator::k_rotation_input = QStringLiteral("rot_in");
|
||||
const QString MatrixGenerator::k_scale_input = QStringLiteral("scale_in");
|
||||
const QString MatrixGenerator::k_uniform_scale_input =
|
||||
QStringLiteral("uniform_scale_in");
|
||||
const QString MatrixGenerator::kAnchorInput = QStringLiteral("anchor_in");
|
||||
const QString MatrixGenerator::k_anchor_input = QStringLiteral("anchor_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
MatrixGenerator::MatrixGenerator()
|
||||
{
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
|
||||
AddInput(kRotationInput, NodeValue::kFloat, 0.0);
|
||||
add_input(k_rotation_input, NodeValue::k_float, 0.0);
|
||||
|
||||
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("disable1"), true);
|
||||
add_input(k_scale_input, NodeValue::k_vec2, QVector2D(1.0f, 1.0f));
|
||||
set_input_property(k_scale_input, QStringLiteral("min"), QVector2D(0, 0));
|
||||
set_input_property(k_scale_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_scale_input, QStringLiteral("disable1"), true);
|
||||
|
||||
AddInput(kUniformScaleInput, NodeValue::kBoolean, true,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_uniform_scale_input, NodeValue::k_boolean, true,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kAnchorInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
add_input(k_anchor_input, NodeValue::k_vec2, QVector2D(0.0, 0.0));
|
||||
}
|
||||
|
||||
QString MatrixGenerator::Name() const
|
||||
QString MatrixGenerator::name() const
|
||||
{
|
||||
return tr("Orthographic Matrix");
|
||||
}
|
||||
|
||||
QString MatrixGenerator::ShortName() const
|
||||
QString MatrixGenerator::short_name() const
|
||||
{
|
||||
return tr("Ortho");
|
||||
}
|
||||
@@ -71,38 +71,38 @@ QString MatrixGenerator::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ortho");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> MatrixGenerator::Category() const
|
||||
QVector<Node::CategoryID> MatrixGenerator::category() const
|
||||
{
|
||||
return { kCategoryGenerator, kCategoryMath };
|
||||
return { k_category_generator, k_category_math };
|
||||
}
|
||||
|
||||
QString MatrixGenerator::Description() const
|
||||
QString MatrixGenerator::description() const
|
||||
{
|
||||
return tr(
|
||||
"Generate an orthographic matrix using position, rotation, and scale.");
|
||||
}
|
||||
|
||||
void MatrixGenerator::Retranslate()
|
||||
void MatrixGenerator::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kRotationInput, tr("Rotation"));
|
||||
SetInputName(kScaleInput, tr("Scale"));
|
||||
SetInputName(kUniformScaleInput, tr("Uniform Scale"));
|
||||
SetInputName(kAnchorInput, tr("Anchor Point"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_rotation_input, tr("Rotation"));
|
||||
set_input_name(k_scale_input, tr("Scale"));
|
||||
set_input_name(k_uniform_scale_input, tr("Uniform Scale"));
|
||||
set_input_name(k_anchor_input, tr("Anchor Point"));
|
||||
}
|
||||
|
||||
void MatrixGenerator::Value(const NodeValueRow &value,
|
||||
void MatrixGenerator::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Push matrix output
|
||||
QMatrix4x4 mat = GenerateMatrix(value, false, false, false, QMatrix4x4());
|
||||
table->Push(NodeValue::kMatrix, mat, this);
|
||||
QMatrix4x4 mat = generate_matrix(value, false, false, false, QMatrix4x4());
|
||||
table->push(NodeValue::k_matrix, mat, this);
|
||||
}
|
||||
|
||||
QMatrix4x4 MatrixGenerator::GenerateMatrix(const NodeValueRow &value,
|
||||
QMatrix4x4 MatrixGenerator::generate_matrix(const NodeValueRow &value,
|
||||
bool ignore_anchor,
|
||||
bool ignore_position,
|
||||
bool ignore_scale,
|
||||
@@ -113,23 +113,23 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(const NodeValueRow &value,
|
||||
QVector2D scale;
|
||||
|
||||
if (!ignore_anchor) {
|
||||
anchor = value[kAnchorInput].toVec2();
|
||||
anchor = value[k_anchor_input].to_vec2();
|
||||
}
|
||||
|
||||
if (!ignore_scale) {
|
||||
scale = value[kScaleInput].toVec2();
|
||||
scale = value[k_scale_input].to_vec2();
|
||||
}
|
||||
|
||||
if (!ignore_position) {
|
||||
position = value[kPositionInput].toVec2();
|
||||
position = value[k_position_input].to_vec2();
|
||||
}
|
||||
|
||||
return GenerateMatrix(position, value[kRotationInput].toDouble(), scale,
|
||||
value[kUniformScaleInput].toBool(), anchor, mat);
|
||||
return generate_matrix(position, value[k_rotation_input].to_double(), scale,
|
||||
value[k_uniform_scale_input].to_bool(), anchor, mat);
|
||||
}
|
||||
|
||||
QMatrix4x4
|
||||
MatrixGenerator::GenerateMatrix(const QVector2D &pos, const float &rot,
|
||||
MatrixGenerator::generate_matrix(const QVector2D &pos, const float &rot,
|
||||
const QVector2D &scale, bool uniform_scale,
|
||||
const QVector2D &anchor, QMatrix4x4 mat)
|
||||
{
|
||||
@@ -158,9 +158,9 @@ void MatrixGenerator::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kUniformScaleInput) {
|
||||
SetInputProperty(kScaleInput, QStringLiteral("disable1"),
|
||||
GetStandardValue(kUniformScaleInput).toBool());
|
||||
if (input == k_uniform_scale_input) {
|
||||
set_input_property(k_scale_input, QStringLiteral("disable1"),
|
||||
get_standard_value(k_uniform_scale_input).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MATRIXGENERATOR_H
|
||||
#define MATRIXGENERATOR_H
|
||||
#ifndef OAK_MATRIXGENERATOR_H
|
||||
#define OAK_MATRIXGENERATOR_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
@@ -37,28 +37,28 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(MatrixGenerator)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString ShortName() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString short_name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kPositionInput;
|
||||
static const QString kRotationInput;
|
||||
static const QString kScaleInput;
|
||||
static const QString kUniformScaleInput;
|
||||
static const QString kAnchorInput;
|
||||
static const QString k_position_input;
|
||||
static const QString k_rotation_input;
|
||||
static const QString k_scale_input;
|
||||
static const QString k_uniform_scale_input;
|
||||
static const QString k_anchor_input;
|
||||
|
||||
protected:
|
||||
QMatrix4x4 GenerateMatrix(const NodeValueRow &value, bool ignore_anchor,
|
||||
QMatrix4x4 generate_matrix(const NodeValueRow &value, bool ignore_anchor,
|
||||
bool ignore_position, bool ignore_scale,
|
||||
const QMatrix4x4 &mat) const;
|
||||
static QMatrix4x4 GenerateMatrix(const QVector2D &pos, const float &rot,
|
||||
static QMatrix4x4 generate_matrix(const QVector2D &pos, const float &rot,
|
||||
const QVector2D &scale, bool uniform_scale,
|
||||
const QVector2D &anchor, QMatrix4x4 mat);
|
||||
|
||||
|
||||
@@ -26,30 +26,30 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString NoiseGeneratorNode::kBaseIn = QStringLiteral("base_in");
|
||||
const QString NoiseGeneratorNode::kColorInput = QStringLiteral("color_in");
|
||||
const QString NoiseGeneratorNode::kStrengthInput =
|
||||
const QString NoiseGeneratorNode::k_base_in = QStringLiteral("base_in");
|
||||
const QString NoiseGeneratorNode::k_color_input = QStringLiteral("color_in");
|
||||
const QString NoiseGeneratorNode::k_strength_input =
|
||||
QStringLiteral("strength_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
NoiseGeneratorNode::NoiseGeneratorNode()
|
||||
{
|
||||
AddInput(kBaseIn, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_base_in, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kStrengthInput, NodeValue::kFloat, 0.2);
|
||||
SetInputProperty(kStrengthInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kStrengthInput, QStringLiteral("min"), 0);
|
||||
add_input(k_strength_input, NodeValue::k_float, 0.2);
|
||||
set_input_property(k_strength_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_strength_input, QStringLiteral("min"), 0);
|
||||
|
||||
AddInput(kColorInput, NodeValue::kBoolean, false);
|
||||
add_input(k_color_input, NodeValue::k_boolean, false);
|
||||
|
||||
SetEffectInput(kBaseIn);
|
||||
SetFlag(kVideoEffect);
|
||||
set_effect_input(k_base_in);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
QString NoiseGeneratorNode::Name() const
|
||||
QString NoiseGeneratorNode::name() const
|
||||
{
|
||||
return tr("Noise");
|
||||
}
|
||||
@@ -59,45 +59,45 @@ QString NoiseGeneratorNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.noise");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> NoiseGeneratorNode::Category() const
|
||||
QVector<Node::CategoryID> NoiseGeneratorNode::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString NoiseGeneratorNode::Description() const
|
||||
QString NoiseGeneratorNode::description() const
|
||||
{
|
||||
return tr("Generates noise patterns");
|
||||
}
|
||||
|
||||
void NoiseGeneratorNode::Retranslate()
|
||||
void NoiseGeneratorNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBaseIn, tr("Base"));
|
||||
SetInputName(kStrengthInput, tr("Strength"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_base_in, tr("Base"));
|
||||
set_input_name(k_strength_input, tr("Strength"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
ShaderCode NoiseGeneratorNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode NoiseGeneratorNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/noise.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/noise.frag"));
|
||||
}
|
||||
|
||||
void NoiseGeneratorNode::Value(const NodeValueRow &value,
|
||||
void NoiseGeneratorNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job(value);
|
||||
|
||||
job.Insert(value);
|
||||
job.Insert(QStringLiteral("time_in"),
|
||||
NodeValue(NodeValue::kFloat, globals.time().in().toDouble(),
|
||||
job.insert(value);
|
||||
job.insert(QStringLiteral("time_in"),
|
||||
NodeValue(NodeValue::k_float, globals.time().in().to_double(),
|
||||
this));
|
||||
|
||||
TexturePtr base = value[kBaseIn].toTexture();
|
||||
TexturePtr base = value[k_base_in].to_texture();
|
||||
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(base ? base->params() : globals.vparams(), job),
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(base ? base->params() : globals.vparams(), job),
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NOISEGENERATORNODE_H
|
||||
#define NOISEGENERATORNODE_H
|
||||
#ifndef OAK_NOISEGENERATORNODE_H
|
||||
#define OAK_NOISEGENERATORNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,23 +34,23 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(NoiseGeneratorNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kBaseIn;
|
||||
static const QString kColorInput;
|
||||
static const QString kStrengthInput;
|
||||
static const QString k_base_in;
|
||||
static const QString k_color_input;
|
||||
static const QString k_strength_input;
|
||||
};
|
||||
|
||||
} // namespace olive
|
||||
|
||||
#endif // NOISEGENERATORNODE_H
|
||||
#endif // OAK_NOISEGENERATORNODE_H
|
||||
|
||||
@@ -27,43 +27,43 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString PolygonGenerator::kPointsInput = QStringLiteral("points_in");
|
||||
const QString PolygonGenerator::kColorInput = QStringLiteral("color_in");
|
||||
const QString PolygonGenerator::k_points_input = QStringLiteral("points_in");
|
||||
const QString PolygonGenerator::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
#define super GeneratorWithMerge
|
||||
|
||||
PolygonGenerator::PolygonGenerator()
|
||||
{
|
||||
AddInput(kPointsInput, NodeValue::kBezier, QVector2D(0, 0),
|
||||
InputFlags(kInputFlagArray));
|
||||
add_input(k_points_input, NodeValue::k_bezier, QVector2D(0, 0),
|
||||
InputFlags(k_input_flag_array));
|
||||
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0, 1.0, 1.0)));
|
||||
|
||||
const int kMiddleX = 135;
|
||||
const int kMiddleY = 45;
|
||||
const int kBottomX = 90;
|
||||
const int kBottomY = 120;
|
||||
const int kTopY = 135;
|
||||
const int k_middle_x = 135;
|
||||
const int k_middle_y = 45;
|
||||
const int k_bottom_x = 90;
|
||||
const int k_bottom_y = 120;
|
||||
const int k_top_y = 135;
|
||||
|
||||
// The Default Pentagon(tm)
|
||||
InputArrayResize(kPointsInput, 5);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, 0, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kTopY, 0);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, kMiddleX, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 1);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, kBottomX, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 2);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, -kBottomX, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 3);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 0, -kMiddleX, 4);
|
||||
SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 4);
|
||||
input_array_resize(k_points_input, 5);
|
||||
set_split_standard_value_on_track(k_points_input, 0, 0, 0);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_top_y, 0);
|
||||
set_split_standard_value_on_track(k_points_input, 0, k_middle_x, 1);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 1);
|
||||
set_split_standard_value_on_track(k_points_input, 0, k_bottom_x, 2);
|
||||
set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 2);
|
||||
set_split_standard_value_on_track(k_points_input, 0, -k_bottom_x, 3);
|
||||
set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 3);
|
||||
set_split_standard_value_on_track(k_points_input, 0, -k_middle_x, 4);
|
||||
set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 4);
|
||||
|
||||
// Initiate gizmos
|
||||
poly_gizmo_ = new PathGizmo(this);
|
||||
}
|
||||
|
||||
QString PolygonGenerator::Name() const
|
||||
QString PolygonGenerator::name() const
|
||||
{
|
||||
return tr("Polygon");
|
||||
}
|
||||
@@ -73,52 +73,52 @@ QString PolygonGenerator::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.polygon");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> PolygonGenerator::Category() const
|
||||
QVector<Node::CategoryID> PolygonGenerator::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString PolygonGenerator::Description() const
|
||||
QString PolygonGenerator::description() const
|
||||
{
|
||||
return tr("Generate a 2D polygon of any amount of points.");
|
||||
}
|
||||
|
||||
void PolygonGenerator::Retranslate()
|
||||
void PolygonGenerator::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kPointsInput, tr("Points"));
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_points_input, tr("Points"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
ShaderJob PolygonGenerator::GetGenerateJob(const NodeValueRow &value,
|
||||
ShaderJob PolygonGenerator::get_generate_job(const NodeValueRow &value,
|
||||
const VideoParams ¶ms) const
|
||||
{
|
||||
VideoParams p = params;
|
||||
p.set_format(PixelFormat::U8);
|
||||
auto job = Texture::Job(p, GenerateJob(value));
|
||||
p.set_format(PixelFormat::u8);
|
||||
auto job = Texture::job(p, GenerateJob(value));
|
||||
|
||||
// Conversion to RGB
|
||||
ShaderJob rgb;
|
||||
rgb.SetShaderID(QStringLiteral("rgb"));
|
||||
rgb.Insert(QStringLiteral("texture_in"),
|
||||
NodeValue(NodeValue::kTexture, job, this));
|
||||
rgb.Insert(QStringLiteral("color_in"), value[kColorInput]);
|
||||
rgb.set_shader_id(QStringLiteral("rgb"));
|
||||
rgb.insert(QStringLiteral("texture_in"),
|
||||
NodeValue(NodeValue::k_texture, job, this));
|
||||
rgb.insert(QStringLiteral("color_in"), value[k_color_input]);
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
void PolygonGenerator::Value(const NodeValueRow &value,
|
||||
void PolygonGenerator::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
PushMergableJob(value,
|
||||
Texture::Job(globals.vparams(),
|
||||
GetGenerateJob(value, globals.vparams())),
|
||||
push_mergable_job(value,
|
||||
Texture::job(globals.vparams(),
|
||||
get_generate_job(value, globals.vparams())),
|
||||
table);
|
||||
}
|
||||
|
||||
void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
void PolygonGenerator::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
// This could probably be more optimized, but for now we use Qt to draw to a QImage.
|
||||
@@ -129,12 +129,12 @@ void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
frame->linesize_bytes(), QImage::Format_RGBA8888_Premultiplied);
|
||||
img.fill(Qt::transparent);
|
||||
|
||||
auto points = job.Get(kPointsInput).toArray();
|
||||
auto points = job.get(k_points_input).to_array();
|
||||
|
||||
QPainterPath path = GeneratePath(points, InputArraySize(kPointsInput));
|
||||
QPainterPath path = generate_path(points, input_array_size(k_points_input));
|
||||
|
||||
QPainter p(&img);
|
||||
double par = frame->video_params().pixel_aspect_ratio().toDouble();
|
||||
double par = frame->video_params().pixel_aspect_ratio().to_double();
|
||||
p.scale(1.0 / frame->video_params().divider() / par,
|
||||
1.0 / frame->video_params().divider());
|
||||
p.translate(frame->video_params().width() / 2 * par,
|
||||
@@ -145,18 +145,18 @@ void PolygonGenerator::GenerateFrame(FramePtr frame,
|
||||
p.drawPath(path);
|
||||
}
|
||||
|
||||
template <typename T> NodeGizmo *PolygonGenerator::CreateAppropriateGizmo()
|
||||
template <typename T> NodeGizmo *PolygonGenerator::create_appropriate_gizmo()
|
||||
{
|
||||
return new T(this);
|
||||
}
|
||||
|
||||
template <> NodeGizmo *PolygonGenerator::CreateAppropriateGizmo<PointGizmo>()
|
||||
template <> NodeGizmo *PolygonGenerator::create_appropriate_gizmo<PointGizmo>()
|
||||
{
|
||||
return AddDraggableGizmo<PointGizmo>();
|
||||
return add_draggable_gizmo<PointGizmo>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void PolygonGenerator::ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz)
|
||||
void PolygonGenerator::validate_gizmo_vector_size(QVector<T *> &vec, int new_sz)
|
||||
{
|
||||
int old_sz = vec.size();
|
||||
|
||||
@@ -171,17 +171,17 @@ void PolygonGenerator::ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz)
|
||||
|
||||
if (old_sz < new_sz) {
|
||||
for (int i = old_sz; i < new_sz; i++) {
|
||||
vec[i] = static_cast<T *>(CreateAppropriateGizmo<T>());
|
||||
vec[i] = static_cast<T *>(create_appropriate_gizmo<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void PolygonGenerator::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
QVector2D res;
|
||||
if (TexturePtr tex = row[kBaseInput].toTexture()) {
|
||||
if (TexturePtr tex = row[k_base_input].to_texture()) {
|
||||
res = tex->virtual_resolution();
|
||||
} else {
|
||||
res = globals.square_resolution();
|
||||
@@ -189,72 +189,72 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
|
||||
Imath::V2d half_res(res.x() / 2, res.y() / 2);
|
||||
|
||||
auto points = row[kPointsInput].toArray();
|
||||
auto points = row[k_points_input].to_array();
|
||||
|
||||
int current_pos_sz = gizmo_position_handles_.size();
|
||||
|
||||
ValidateGizmoVectorSize(gizmo_position_handles_, points.size());
|
||||
ValidateGizmoVectorSize(gizmo_bezier_handles_, points.size() * 2);
|
||||
ValidateGizmoVectorSize(gizmo_bezier_lines_, points.size() * 2);
|
||||
validate_gizmo_vector_size(gizmo_position_handles_, points.size());
|
||||
validate_gizmo_vector_size(gizmo_bezier_handles_, points.size() * 2);
|
||||
validate_gizmo_vector_size(gizmo_bezier_lines_, points.size() * 2);
|
||||
|
||||
for (int i = current_pos_sz; i < gizmo_position_handles_.size(); i++) {
|
||||
gizmo_position_handles_.at(i)->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 0));
|
||||
gizmo_position_handles_.at(i)->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 1));
|
||||
gizmo_position_handles_.at(i)->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 0));
|
||||
gizmo_position_handles_.at(i)->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 1));
|
||||
|
||||
PointGizmo *bez_gizmo1 = gizmo_bezier_handles_.at(i * 2 + 0);
|
||||
bez_gizmo1->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 2));
|
||||
bez_gizmo1->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 3));
|
||||
bez_gizmo1->SetShape(PointGizmo::kCircle);
|
||||
bez_gizmo1->SetSmaller(true);
|
||||
bez_gizmo1->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 2));
|
||||
bez_gizmo1->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 3));
|
||||
bez_gizmo1->set_shape(PointGizmo::k_circle);
|
||||
bez_gizmo1->set_smaller(true);
|
||||
|
||||
PointGizmo *bez_gizmo2 = gizmo_bezier_handles_.at(i * 2 + 1);
|
||||
bez_gizmo2->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 4));
|
||||
bez_gizmo2->AddInput(
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 5));
|
||||
bez_gizmo2->SetShape(PointGizmo::kCircle);
|
||||
bez_gizmo2->SetSmaller(true);
|
||||
bez_gizmo2->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 4));
|
||||
bez_gizmo2->add_input(
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 5));
|
||||
bez_gizmo2->set_shape(PointGizmo::k_circle);
|
||||
bez_gizmo2->set_smaller(true);
|
||||
}
|
||||
|
||||
int pts_sz = InputArraySize(kPointsInput);
|
||||
int pts_sz = input_array_size(k_points_input);
|
||||
if (!points.empty()) {
|
||||
for (int i = 0; i < pts_sz; i++) {
|
||||
const Bezier &pt = points.at(i).toBezier();
|
||||
const Bezier &pt = points.at(i).to_bezier();
|
||||
|
||||
Imath::V2d main = pt.to_vec() + half_res;
|
||||
Imath::V2d cp1 = main + pt.control_point_1_to_vec();
|
||||
Imath::V2d cp2 = main + pt.control_point_2_to_vec();
|
||||
|
||||
gizmo_position_handles_[i]->SetPoint(QPointF(main.x, main.y));
|
||||
gizmo_position_handles_[i]->set_point(QPointF(main.x, main.y));
|
||||
|
||||
gizmo_bezier_handles_[i * 2]->SetPoint(QPointF(cp1.x, cp1.y));
|
||||
gizmo_bezier_lines_[i * 2]->SetLine(
|
||||
gizmo_bezier_handles_[i * 2]->set_point(QPointF(cp1.x, cp1.y));
|
||||
gizmo_bezier_lines_[i * 2]->set_line(
|
||||
QLineF(QPointF(main.x, main.y), QPointF(cp1.x, cp1.y)));
|
||||
gizmo_bezier_handles_[i * 2 + 1]->SetPoint(QPointF(cp2.x, cp2.y));
|
||||
gizmo_bezier_lines_[i * 2 + 1]->SetLine(
|
||||
gizmo_bezier_handles_[i * 2 + 1]->set_point(QPointF(cp2.x, cp2.y));
|
||||
gizmo_bezier_lines_[i * 2 + 1]->set_line(
|
||||
QLineF(QPointF(main.x, main.y), QPointF(cp2.x, cp2.y)));
|
||||
}
|
||||
}
|
||||
|
||||
poly_gizmo_->SetPath(GeneratePath(points, pts_sz)
|
||||
poly_gizmo_->set_path(generate_path(points, pts_sz)
|
||||
.translated(QPointF(half_res.x, half_res.y)));
|
||||
}
|
||||
|
||||
ShaderCode PolygonGenerator::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode PolygonGenerator::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("rgb")) {
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/rgb.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/rgb.frag"));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::GizmoDragMove(double x, double y,
|
||||
void PolygonGenerator::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
@@ -262,14 +262,14 @@ void PolygonGenerator::GizmoDragMove(double x, double y,
|
||||
if (gizmo == poly_gizmo_) {
|
||||
// FIXME: Drag all points
|
||||
} else {
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
void PolygonGenerator::add_point_to_path(QPainterPath *path, const Bezier &before,
|
||||
const Bezier &after)
|
||||
{
|
||||
Imath::V2d a = before.to_vec() + before.control_point_2_to_vec();
|
||||
@@ -279,22 +279,22 @@ void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
path->cubicTo(QPointF(a.x, a.y), QPointF(b.x, b.y), QPointF(c.x, c.y));
|
||||
}
|
||||
|
||||
QPainterPath PolygonGenerator::GeneratePath(const NodeValueArray &points,
|
||||
QPainterPath PolygonGenerator::generate_path(const NodeValueArray &points,
|
||||
int size)
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
if (!points.empty()) {
|
||||
const Bezier &first_pt = points.at(0).toBezier();
|
||||
const Bezier &first_pt = points.at(0).to_bezier();
|
||||
Imath::V2d v = first_pt.to_vec();
|
||||
path.moveTo(QPointF(v.x, v.y));
|
||||
|
||||
for (int i = 1; i < size; i++) {
|
||||
AddPointToPath(&path, points.at(i - 1).toBezier(),
|
||||
points.at(i).toBezier());
|
||||
add_point_to_path(&path, points.at(i - 1).to_bezier(),
|
||||
points.at(i).to_bezier());
|
||||
}
|
||||
|
||||
AddPointToPath(&path, points.at(size - 1).toBezier(), first_pt);
|
||||
add_point_to_path(&path, points.at(size - 1).to_bezier(), first_pt);
|
||||
}
|
||||
|
||||
return path;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef POLYGONGENERATOR_H
|
||||
#define POLYGONGENERATOR_H
|
||||
#ifndef OAK_POLYGONGENERATOR_H
|
||||
#define OAK_POLYGONGENERATOR_H
|
||||
|
||||
#include <QPainterPath>
|
||||
|
||||
@@ -41,46 +41,46 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(PolygonGenerator)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kPointsInput;
|
||||
static const QString kColorInput;
|
||||
static const QString k_points_input;
|
||||
static const QString k_color_input;
|
||||
|
||||
protected:
|
||||
ShaderJob GetGenerateJob(const NodeValueRow &value,
|
||||
ShaderJob get_generate_job(const NodeValueRow &value,
|
||||
const VideoParams ¶ms) const;
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
static void AddPointToPath(QPainterPath *path, const Bezier &before,
|
||||
static void add_point_to_path(QPainterPath *path, const Bezier &before,
|
||||
const Bezier &after);
|
||||
|
||||
static QPainterPath GeneratePath(const NodeValueArray &points, int size);
|
||||
static QPainterPath generate_path(const NodeValueArray &points, int size);
|
||||
|
||||
template <typename T>
|
||||
void ValidateGizmoVectorSize(QVector<T *> &vec, int new_sz);
|
||||
void validate_gizmo_vector_size(QVector<T *> &vec, int new_sz);
|
||||
|
||||
template <typename T> NodeGizmo *CreateAppropriateGizmo();
|
||||
template <typename T> NodeGizmo *create_appropriate_gizmo();
|
||||
|
||||
PathGizmo *poly_gizmo_;
|
||||
QVector<PointGizmo *> gizmo_position_handles_;
|
||||
@@ -90,4 +90,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // POLYGONGENERATOR_H
|
||||
#endif // OAK_POLYGONGENERATOR_H
|
||||
|
||||
@@ -28,50 +28,50 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString GeneratorWithMerge::kBaseInput = QStringLiteral("base_in");
|
||||
const QString GeneratorWithMerge::k_base_input = QStringLiteral("base_in");
|
||||
|
||||
GeneratorWithMerge::GeneratorWithMerge()
|
||||
{
|
||||
AddInput(kBaseInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
SetEffectInput(kBaseInput);
|
||||
SetFlag(kVideoEffect);
|
||||
add_input(k_base_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
set_effect_input(k_base_input);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
void GeneratorWithMerge::Retranslate()
|
||||
void GeneratorWithMerge::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBaseInput, tr("Base"));
|
||||
set_input_name(k_base_input, tr("Base"));
|
||||
}
|
||||
|
||||
ShaderCode GeneratorWithMerge::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode GeneratorWithMerge::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("mrg")) {
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/alphaover.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/alphaover.frag"));
|
||||
}
|
||||
|
||||
return ShaderCode();
|
||||
}
|
||||
|
||||
void GeneratorWithMerge::PushMergableJob(const NodeValueRow &value,
|
||||
void GeneratorWithMerge::push_mergable_job(const NodeValueRow &value,
|
||||
TexturePtr job,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr base = value[kBaseInput].toTexture()) {
|
||||
if (TexturePtr base = value[k_base_input].to_texture()) {
|
||||
// Push as merge node
|
||||
ShaderJob merge;
|
||||
|
||||
merge.SetShaderID(QStringLiteral("mrg"));
|
||||
merge.Insert(MergeNode::kBaseIn, value[kBaseInput]);
|
||||
merge.Insert(MergeNode::kBlendIn,
|
||||
NodeValue(NodeValue::kTexture, job, this));
|
||||
merge.set_shader_id(QStringLiteral("mrg"));
|
||||
merge.insert(MergeNode::k_base_in, value[k_base_input]);
|
||||
merge.insert(MergeNode::k_blend_in,
|
||||
NodeValue(NodeValue::k_texture, job, this));
|
||||
|
||||
table->Push(NodeValue::kTexture, base->toJob(merge), this);
|
||||
table->push(NodeValue::k_texture, base->to_job(merge), this);
|
||||
} else {
|
||||
// Just push generate job
|
||||
table->Push(NodeValue::kTexture, job, this);
|
||||
table->push(NodeValue::k_texture, job, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef GENERATORWITHMERGE_H
|
||||
#define GENERATORWITHMERGE_H
|
||||
#ifndef OAK_GENERATORWITHMERGE_H
|
||||
#define OAK_GENERATORWITHMERGE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -32,18 +32,18 @@ class GeneratorWithMerge : public Node {
|
||||
public:
|
||||
GeneratorWithMerge();
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kBaseInput;
|
||||
static const QString k_base_input;
|
||||
|
||||
protected:
|
||||
void PushMergableJob(const NodeValueRow &value, TexturePtr job,
|
||||
void push_mergable_job(const NodeValueRow &value, TexturePtr job,
|
||||
NodeValueTable *table) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GENERATORWITHMERGE_H
|
||||
#endif // OAK_GENERATORWITHMERGE_H
|
||||
|
||||
@@ -26,18 +26,18 @@ namespace olive
|
||||
|
||||
#define super ShapeNodeBase
|
||||
|
||||
QString ShapeNode::kTypeInput = QStringLiteral("type_in");
|
||||
QString ShapeNode::kRadiusInput = QStringLiteral("radius_in");
|
||||
QString ShapeNode::k_type_input = QStringLiteral("type_in");
|
||||
QString ShapeNode::k_radius_input = QStringLiteral("radius_in");
|
||||
|
||||
ShapeNode::ShapeNode()
|
||||
{
|
||||
PrependInput(kTypeInput, NodeValue::kCombo);
|
||||
prepend_input(k_type_input, NodeValue::k_combo);
|
||||
|
||||
AddInput(kRadiusInput, NodeValue::kFloat, 20.0);
|
||||
SetInputProperty(kRadiusInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_radius_input, NodeValue::k_float, 20.0);
|
||||
set_input_property(k_radius_input, QStringLiteral("min"), 0.0);
|
||||
}
|
||||
|
||||
QString ShapeNode::Name() const
|
||||
QString ShapeNode::name() const
|
||||
{
|
||||
return tr("Shape");
|
||||
}
|
||||
@@ -47,63 +47,63 @@ QString ShapeNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.shape");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> ShapeNode::Category() const
|
||||
QVector<Node::CategoryID> ShapeNode::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString ShapeNode::Description() const
|
||||
QString ShapeNode::description() const
|
||||
{
|
||||
return tr("Generate a 2D primitive shape.");
|
||||
}
|
||||
|
||||
void ShapeNode::Retranslate()
|
||||
void ShapeNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTypeInput, tr("Type"));
|
||||
SetInputName(kRadiusInput, tr("Radius"));
|
||||
set_input_name(k_type_input, tr("Type"));
|
||||
set_input_name(k_radius_input, tr("Radius"));
|
||||
|
||||
// Coordinate with Type enum
|
||||
SetComboBoxStrings(kTypeInput, { tr("Rectangle"), tr("Ellipse"),
|
||||
set_combo_box_strings(k_type_input, { tr("Rectangle"), tr("Ellipse"),
|
||||
tr("Rounded Rectangle") });
|
||||
}
|
||||
|
||||
ShaderCode ShapeNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode ShapeNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
if (request.id == QStringLiteral("shape")) {
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(
|
||||
return ShaderCode(FileFunctions::read_file_as_string(
|
||||
QStringLiteral(":/shaders/shape.frag")));
|
||||
} else {
|
||||
return super::GetShaderCode(request);
|
||||
return super::get_shader_code(request);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void ShapeNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
TexturePtr base = value[kBaseInput].toTexture();
|
||||
TexturePtr base = value[k_base_input].to_texture();
|
||||
|
||||
ShaderJob job(value);
|
||||
|
||||
job.Insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::kVec2,
|
||||
job.insert(QStringLiteral("resolution_in"),
|
||||
NodeValue(NodeValue::k_vec2,
|
||||
base ? base->virtual_resolution() :
|
||||
globals.square_resolution(),
|
||||
this));
|
||||
job.SetShaderID(QStringLiteral("shape"));
|
||||
job.set_shader_id(QStringLiteral("shape"));
|
||||
|
||||
PushMergableJob(
|
||||
value, Texture::Job(base ? base->params() : globals.vparams(), job),
|
||||
push_mergable_job(
|
||||
value, Texture::job(base ? base->params() : globals.vparams(), job),
|
||||
table);
|
||||
}
|
||||
|
||||
void ShapeNode::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
if (input == kTypeInput) {
|
||||
SetInputFlag(kRadiusInput, kInputFlagHidden,
|
||||
(GetStandardValue(kTypeInput).toInt() !=
|
||||
kRoundedRectangle));
|
||||
if (input == k_type_input) {
|
||||
set_input_flag(k_radius_input, k_input_flag_hidden,
|
||||
(get_standard_value(k_type_input).toInt() !=
|
||||
k_rounded_rectangle));
|
||||
}
|
||||
super::InputValueChangedEvent(input, element);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SHAPENODE_H
|
||||
#define SHAPENODE_H
|
||||
#ifndef OAK_SHAPENODE_H
|
||||
#define OAK_SHAPENODE_H
|
||||
|
||||
#include "shapenodebase.h"
|
||||
|
||||
@@ -32,24 +32,24 @@ class ShapeNode : public ShapeNodeBase {
|
||||
public:
|
||||
ShapeNode();
|
||||
|
||||
enum Type { kRectangle, kEllipse, kRoundedRectangle };
|
||||
enum Type { k_rectangle, k_ellipse, k_rounded_rectangle };
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(ShapeNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static QString kTypeInput;
|
||||
static QString kRadiusInput;
|
||||
static QString k_type_input;
|
||||
static QString k_radius_input;
|
||||
|
||||
protected:
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
@@ -58,4 +58,4 @@ protected:
|
||||
|
||||
}
|
||||
|
||||
#endif // SHAPENODE_H
|
||||
#endif // OAK_SHAPENODE_H
|
||||
|
||||
@@ -33,60 +33,60 @@ namespace olive
|
||||
|
||||
#define super GeneratorWithMerge
|
||||
|
||||
const QString ShapeNodeBase::kPositionInput = QStringLiteral("pos_in");
|
||||
const QString ShapeNodeBase::kSizeInput = QStringLiteral("size_in");
|
||||
const QString ShapeNodeBase::kColorInput = QStringLiteral("color_in");
|
||||
const QString ShapeNodeBase::k_position_input = QStringLiteral("pos_in");
|
||||
const QString ShapeNodeBase::k_size_input = QStringLiteral("size_in");
|
||||
const QString ShapeNodeBase::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
ShapeNodeBase::ShapeNodeBase(bool create_color_input)
|
||||
{
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
AddInput(kSizeInput, NodeValue::kVec2, QVector2D(100, 100));
|
||||
SetInputProperty(kSizeInput, QStringLiteral("min"), QVector2D(0, 0));
|
||||
add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0));
|
||||
add_input(k_size_input, NodeValue::k_vec2, QVector2D(100, 100));
|
||||
set_input_property(k_size_input, QStringLiteral("min"), QVector2D(0, 0));
|
||||
|
||||
if (create_color_input) {
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0, 0.0, 0.0, 1.0)));
|
||||
}
|
||||
|
||||
// Initiate gizmos
|
||||
QVector<NodeKeyframeTrackReference> pos_n_sz = {
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 1)
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_size_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_size_input), 1)
|
||||
};
|
||||
poly_gizmo_ = AddDraggableGizmo<PolygonGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1),
|
||||
poly_gizmo_ = add_draggable_gizmo<PolygonGizmo>({
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0),
|
||||
NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1),
|
||||
});
|
||||
for (int i = 0; i < kGizmoScaleCount; i++) {
|
||||
for (int i = 0; i < k_gizmo_scale_count; i++) {
|
||||
point_gizmo_[i] =
|
||||
AddDraggableGizmo<PointGizmo>(pos_n_sz, PointGizmo::kAbsolute);
|
||||
add_draggable_gizmo<PointGizmo>(pos_n_sz, PointGizmo::k_absolute);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNodeBase::Retranslate()
|
||||
void ShapeNodeBase::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kPositionInput, tr("Position"));
|
||||
SetInputName(kSizeInput, tr("Size"));
|
||||
set_input_name(k_position_input, tr("Position"));
|
||||
set_input_name(k_size_input, tr("Size"));
|
||||
|
||||
if (HasInputWithID(kColorInput)) {
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
if (has_input_with_id(k_color_input)) {
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void ShapeNodeBase::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
QVector2D center_pt = globals.square_resolution() * 0.5;
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"), center_pt);
|
||||
set_input_property(k_position_input, QStringLiteral("offset"), center_pt);
|
||||
|
||||
QVector2D pos = row[kPositionInput].toVec2();
|
||||
QVector2D sz = row[kSizeInput].toVec2();
|
||||
QVector2D pos = row[k_position_input].to_vec2();
|
||||
QVector2D sz = row[k_size_input].to_vec2();
|
||||
QVector2D half_sz = sz * 0.5;
|
||||
|
||||
double left_pt = pos.x() + center_pt.x() - half_sz.x();
|
||||
@@ -96,32 +96,32 @@ void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
double center_x_pt = mid(left_pt, right_pt);
|
||||
double center_y_pt = mid(top_pt, bottom_pt);
|
||||
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_top_left]->set_point(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_center]->set_point(QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_top_right]->set_point(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_left]->set_point(QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[k_gizmo_scale_bottom_center]->set_point(
|
||||
QPointF(center_x_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_bottom_right]->set_point(
|
||||
QPointF(right_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_left]->set_point(
|
||||
QPointF(left_pt, center_y_pt));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(
|
||||
point_gizmo_[k_gizmo_scale_center_right]->set_point(
|
||||
QPointF(right_pt, center_y_pt));
|
||||
|
||||
poly_gizmo_->SetPolygon(
|
||||
poly_gizmo_->set_polygon(
|
||||
QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt));
|
||||
}
|
||||
|
||||
void ShapeNodeBase::SetRect(QRectF rect, const VideoParams &sequence_res,
|
||||
void ShapeNodeBase::set_rect(QRectF rect, const VideoParams &sequence_res,
|
||||
MultiUndoCommand *command)
|
||||
{
|
||||
// Normalize around center of sequence
|
||||
rect.translate(-sequence_res.width() * 0.5, -sequence_res.height() * 0.5);
|
||||
rect.translate(rect.width() * 0.5, rect.height() * 0.5);
|
||||
|
||||
NodeInput pos(this, ShapeNodeBase::kPositionInput);
|
||||
NodeInput sz(this, ShapeNodeBase::kSizeInput);
|
||||
NodeInput pos(this, ShapeNodeBase::k_position_input);
|
||||
NodeInput sz(this, ShapeNodeBase::k_size_input);
|
||||
|
||||
command->add_child(new NodeParamSetStandardValueCommand(
|
||||
NodeKeyframeTrackReference(sz, 0), rect.width()));
|
||||
@@ -133,40 +133,40 @@ void ShapeNodeBase::SetRect(QRectF rect, const VideoParams &sequence_res,
|
||||
NodeKeyframeTrackReference(pos, 1), rect.y()));
|
||||
}
|
||||
|
||||
void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
void ShapeNodeBase::gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo *>(sender());
|
||||
|
||||
NodeInputDragger &x_drag = gizmo->GetDraggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->GetDraggers()[1];
|
||||
NodeInputDragger &x_drag = gizmo->get_draggers()[0];
|
||||
NodeInputDragger &y_drag = gizmo->get_draggers()[1];
|
||||
|
||||
if (gizmo == poly_gizmo_) {
|
||||
x_drag.Drag(x_drag.GetStartValue().toDouble() + x);
|
||||
y_drag.Drag(y_drag.GetStartValue().toDouble() + y);
|
||||
x_drag.drag(x_drag.get_start_value().toDouble() + x);
|
||||
y_drag.drag(y_drag.get_start_value().toDouble() + y);
|
||||
} else {
|
||||
bool from_center = modifiers & Qt::AltModifier;
|
||||
bool keep_ratio = modifiers & Qt::ShiftModifier;
|
||||
|
||||
NodeInputDragger &w_drag = gizmo->GetDraggers()[2];
|
||||
NodeInputDragger &h_drag = gizmo->GetDraggers()[3];
|
||||
NodeInputDragger &w_drag = gizmo->get_draggers()[2];
|
||||
NodeInputDragger &h_drag = gizmo->get_draggers()[3];
|
||||
|
||||
QVector2D gizmo_sz_start(w_drag.GetStartValue().toDouble(),
|
||||
h_drag.GetStartValue().toDouble());
|
||||
QVector2D gizmo_pos_start(x_drag.GetStartValue().toDouble(),
|
||||
y_drag.GetStartValue().toDouble());
|
||||
QVector2D gizmo_half_res = gizmo->GetGlobals().square_resolution() / 2;
|
||||
QVector2D gizmo_sz_start(w_drag.get_start_value().toDouble(),
|
||||
h_drag.get_start_value().toDouble());
|
||||
QVector2D gizmo_pos_start(x_drag.get_start_value().toDouble(),
|
||||
y_drag.get_start_value().toDouble());
|
||||
QVector2D gizmo_half_res = gizmo->get_globals().square_resolution() / 2;
|
||||
QVector2D adjusted_pt(x, y);
|
||||
QVector2D new_size;
|
||||
QVector2D new_pos;
|
||||
QVector2D anchor;
|
||||
static const int kXYCount = 2;
|
||||
bool negative[kXYCount] = { false };
|
||||
static const int k_xy_count = 2;
|
||||
bool negative[k_xy_count] = { false };
|
||||
|
||||
double original_ratio;
|
||||
if (keep_ratio) {
|
||||
original_ratio = w_drag.GetStartValue().toDouble() /
|
||||
h_drag.GetStartValue().toDouble();
|
||||
original_ratio = w_drag.get_start_value().toDouble() /
|
||||
h_drag.get_start_value().toDouble();
|
||||
}
|
||||
|
||||
// Calculate new size
|
||||
@@ -174,11 +174,11 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
// Calculate new size by using distance from center and doubling it
|
||||
new_size = (adjusted_pt - gizmo_half_res - gizmo_pos_start) * 2;
|
||||
|
||||
if (IsGizmoTop(gizmo)) {
|
||||
if (is_gizmo_top(gizmo)) {
|
||||
new_size.setY(-new_size.y());
|
||||
}
|
||||
|
||||
if (IsGizmoLeft(gizmo)) {
|
||||
if (is_gizmo_left(gizmo)) {
|
||||
new_size.setX(-new_size.x());
|
||||
}
|
||||
} else {
|
||||
@@ -186,7 +186,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
// from the gizmo being dragged
|
||||
adjusted_pt -= gizmo_half_res;
|
||||
|
||||
anchor = GenerateGizmoAnchor(gizmo_pos_start, gizmo_sz_start, gizmo,
|
||||
anchor = generate_gizmo_anchor(gizmo_pos_start, gizmo_sz_start, gizmo,
|
||||
&adjusted_pt) +
|
||||
gizmo_half_res;
|
||||
|
||||
@@ -196,7 +196,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
new_size = adjusted_pt - anchor;
|
||||
|
||||
// Abs size so neither coord is negative
|
||||
for (int i = 0; i < kXYCount; i++) {
|
||||
for (int i = 0; i < k_xy_count; i++) {
|
||||
if (new_size[i] < 0) {
|
||||
negative[i] = true;
|
||||
new_size[i] = -new_size[i];
|
||||
@@ -205,7 +205,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
}
|
||||
|
||||
// Restrict sizes by constraints
|
||||
if (IsGizmoVerticalCenter(gizmo)) {
|
||||
if (is_gizmo_vertical_center(gizmo)) {
|
||||
if (keep_ratio) {
|
||||
// Calculate width from new height
|
||||
new_size.setX(new_size.y() * original_ratio);
|
||||
@@ -215,7 +215,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoHorizontalCenter(gizmo)) {
|
||||
if (is_gizmo_horizontal_center(gizmo)) {
|
||||
if (keep_ratio) {
|
||||
// Calculate height from new width
|
||||
new_size.setY(new_size.x() / original_ratio);
|
||||
@@ -225,7 +225,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoCorner(gizmo)) {
|
||||
if (is_gizmo_corner(gizmo)) {
|
||||
if (keep_ratio) {
|
||||
float hypot = std::hypot(new_size.x(), new_size.y());
|
||||
|
||||
@@ -245,34 +245,34 @@ void ShapeNodeBase::GizmoDragMove(double x, double y,
|
||||
QVector2D using_size = new_size;
|
||||
|
||||
// Un-abs size
|
||||
for (int i = 0; i < kXYCount; i++) {
|
||||
for (int i = 0; i < k_xy_count; i++) {
|
||||
if (negative[i]) {
|
||||
using_size[i] = -using_size[i];
|
||||
}
|
||||
}
|
||||
|
||||
// I'm pretty sure there's an algorithmic way of doing this, but I'm tired and this works
|
||||
if (IsGizmoHorizontalCenter(gizmo)) {
|
||||
if (is_gizmo_horizontal_center(gizmo)) {
|
||||
using_size.setY(0);
|
||||
}
|
||||
|
||||
if (IsGizmoVerticalCenter(gizmo)) {
|
||||
if (is_gizmo_vertical_center(gizmo)) {
|
||||
using_size.setX(0);
|
||||
}
|
||||
|
||||
new_pos =
|
||||
GenerateGizmoAnchor(gizmo_pos_start, gizmo_sz_start, gizmo) +
|
||||
generate_gizmo_anchor(gizmo_pos_start, gizmo_sz_start, gizmo) +
|
||||
using_size / 2;
|
||||
}
|
||||
|
||||
x_drag.Drag(new_pos.x());
|
||||
y_drag.Drag(new_pos.y());
|
||||
w_drag.Drag(new_size.x());
|
||||
h_drag.Drag(new_size.y());
|
||||
x_drag.drag(new_pos.x());
|
||||
y_drag.drag(new_pos.y());
|
||||
w_drag.drag(new_size.x());
|
||||
h_drag.drag(new_size.y());
|
||||
}
|
||||
}
|
||||
|
||||
QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos,
|
||||
QVector2D ShapeNodeBase::generate_gizmo_anchor(const QVector2D &pos,
|
||||
const QVector2D &size,
|
||||
NodeGizmo *gizmo,
|
||||
QVector2D *pt) const
|
||||
@@ -280,28 +280,28 @@ QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos,
|
||||
QVector2D anchor = pos;
|
||||
QVector2D half_sz = size / 2;
|
||||
|
||||
if (IsGizmoLeft(gizmo)) {
|
||||
if (is_gizmo_left(gizmo)) {
|
||||
anchor.setX(anchor.x() + half_sz.x());
|
||||
if (pt && pt->x() > anchor.x()) {
|
||||
pt->setX(anchor.x());
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoRight(gizmo)) {
|
||||
if (is_gizmo_right(gizmo)) {
|
||||
anchor.setX(anchor.x() - half_sz.x());
|
||||
if (pt && pt->x() < anchor.x()) {
|
||||
pt->setX(anchor.x());
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoTop(gizmo)) {
|
||||
if (is_gizmo_top(gizmo)) {
|
||||
anchor.setY(anchor.y() + half_sz.y());
|
||||
if (pt && pt->y() > anchor.y()) {
|
||||
pt->setY(anchor.y());
|
||||
}
|
||||
}
|
||||
|
||||
if (IsGizmoBottom(gizmo)) {
|
||||
if (is_gizmo_bottom(gizmo)) {
|
||||
anchor.setY(anchor.y() - half_sz.y());
|
||||
if (pt && pt->y() < anchor.y()) {
|
||||
pt->setY(anchor.y());
|
||||
@@ -311,52 +311,52 @@ QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos,
|
||||
return anchor;
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoTop(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_top(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopCenter] ||
|
||||
g == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleTopRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_center] ||
|
||||
g == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_top_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoBottom(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_bottom(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleBottomCenter] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_bottom_center] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoLeft(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_left(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleCenterLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomLeft];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_center_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_left];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoRight(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_right(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
g == point_gizmo_[kGizmoScaleCenterRight] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_center_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoHorizontalCenter(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_horizontal_center(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleCenterLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleCenterRight];
|
||||
return g == point_gizmo_[k_gizmo_scale_center_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_center_right];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoVerticalCenter(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_vertical_center(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopCenter] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomCenter];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_center] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_center];
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::IsGizmoCorner(NodeGizmo *g) const
|
||||
bool ShapeNodeBase::is_gizmo_corner(NodeGizmo *g) const
|
||||
{
|
||||
return g == point_gizmo_[kGizmoScaleTopLeft] ||
|
||||
g == point_gizmo_[kGizmoScaleTopRight] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomRight] ||
|
||||
g == point_gizmo_[kGizmoScaleBottomLeft];
|
||||
return g == point_gizmo_[k_gizmo_scale_top_left] ||
|
||||
g == point_gizmo_[k_gizmo_scale_top_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_right] ||
|
||||
g == point_gizmo_[k_gizmo_scale_bottom_left];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SHAPENODEBASE_H
|
||||
#define SHAPENODEBASE_H
|
||||
#ifndef OAK_SHAPENODEBASE_H
|
||||
#define OAK_SHAPENODEBASE_H
|
||||
|
||||
#include "generatorwithmerge.h"
|
||||
#include "node/gizmo/point.h"
|
||||
@@ -36,17 +36,17 @@ class ShapeNodeBase : public GeneratorWithMerge {
|
||||
public:
|
||||
ShapeNodeBase(bool create_color_input = true);
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
void SetRect(QRectF rect, const VideoParams &sequence_res,
|
||||
void set_rect(QRectF rect, const VideoParams &sequence_res,
|
||||
MultiUndoCommand *command);
|
||||
|
||||
static const QString kPositionInput;
|
||||
static const QString kSizeInput;
|
||||
static const QString kColorInput;
|
||||
static const QString k_position_input;
|
||||
static const QString k_size_input;
|
||||
static const QString k_color_input;
|
||||
|
||||
protected:
|
||||
PolygonGizmo *poly_gizmo() const
|
||||
@@ -55,28 +55,28 @@ protected:
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void GizmoDragMove(double x, double y,
|
||||
virtual void gizmo_drag_move(double x, double y,
|
||||
const Qt::KeyboardModifiers &modifiers) override;
|
||||
|
||||
private:
|
||||
QVector2D GenerateGizmoAnchor(const QVector2D &pos, const QVector2D &size,
|
||||
QVector2D generate_gizmo_anchor(const QVector2D &pos, const QVector2D &size,
|
||||
NodeGizmo *gizmo,
|
||||
QVector2D *pt = nullptr) const;
|
||||
|
||||
bool IsGizmoTop(NodeGizmo *g) const;
|
||||
bool IsGizmoBottom(NodeGizmo *g) const;
|
||||
bool IsGizmoLeft(NodeGizmo *g) const;
|
||||
bool IsGizmoRight(NodeGizmo *g) const;
|
||||
bool IsGizmoHorizontalCenter(NodeGizmo *g) const;
|
||||
bool IsGizmoVerticalCenter(NodeGizmo *g) const;
|
||||
bool IsGizmoCorner(NodeGizmo *g) const;
|
||||
bool is_gizmo_top(NodeGizmo *g) const;
|
||||
bool is_gizmo_bottom(NodeGizmo *g) const;
|
||||
bool is_gizmo_left(NodeGizmo *g) const;
|
||||
bool is_gizmo_right(NodeGizmo *g) const;
|
||||
bool is_gizmo_horizontal_center(NodeGizmo *g) const;
|
||||
bool is_gizmo_vertical_center(NodeGizmo *g) const;
|
||||
bool is_gizmo_corner(NodeGizmo *g) const;
|
||||
|
||||
// Gizmo variables
|
||||
static const int kGizmoWholeRect = kGizmoScaleCount;
|
||||
PointGizmo *point_gizmo_[kGizmoScaleCount];
|
||||
static const int k_gizmo_whole_rect = k_gizmo_scale_count;
|
||||
PointGizmo *point_gizmo_[k_gizmo_scale_count];
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SHAPENODEBASE_H
|
||||
#endif // OAK_SHAPENODEBASE_H
|
||||
|
||||
@@ -24,18 +24,18 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString SolidGenerator::kColorInput = QStringLiteral("color_in");
|
||||
const QString SolidGenerator::k_color_input = QStringLiteral("color_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
SolidGenerator::SolidGenerator()
|
||||
{
|
||||
// Default to a color that isn't black
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||
}
|
||||
|
||||
QString SolidGenerator::Name() const
|
||||
QString SolidGenerator::name() const
|
||||
{
|
||||
return tr("Solid");
|
||||
}
|
||||
@@ -45,36 +45,36 @@ QString SolidGenerator::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.solidgenerator");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> SolidGenerator::Category() const
|
||||
QVector<Node::CategoryID> SolidGenerator::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString SolidGenerator::Description() const
|
||||
QString SolidGenerator::description() const
|
||||
{
|
||||
return tr("Generate a solid color.");
|
||||
}
|
||||
|
||||
void SolidGenerator::Retranslate()
|
||||
void SolidGenerator::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
}
|
||||
|
||||
void SolidGenerator::Value(const NodeValueRow &value,
|
||||
void SolidGenerator::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(globals.vparams(), ShaderJob(value)), this);
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(globals.vparams(), ShaderJob(value)), this);
|
||||
}
|
||||
|
||||
ShaderCode SolidGenerator::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode SolidGenerator::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
|
||||
return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/solid.frag"));
|
||||
return ShaderCode(FileFunctions::read_file_as_string(":/shaders/solid.frag"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SOLIDGENERATOR_H
|
||||
#define SOLIDGENERATOR_H
|
||||
#ifndef OAK_SOLIDGENERATOR_H
|
||||
#define OAK_SOLIDGENERATOR_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,21 +34,21 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(SolidGenerator)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
static const QString kColorInput;
|
||||
static const QString k_color_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SOLIDGENERATOR_H
|
||||
#endif // OAK_SOLIDGENERATOR_H
|
||||
|
||||
@@ -28,39 +28,39 @@ namespace olive
|
||||
{
|
||||
|
||||
enum TextVerticalAlign {
|
||||
kVerticalAlignTop,
|
||||
kVerticalAlignCenter,
|
||||
kVerticalAlignBottom,
|
||||
k_vertical_align_top,
|
||||
k_vertical_align_center,
|
||||
k_vertical_align_bottom,
|
||||
};
|
||||
|
||||
const QString TextGeneratorV1::kTextInput = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV1::kHtmlInput = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV1::kColorInput = QStringLiteral("color_in");
|
||||
const QString TextGeneratorV1::kVAlignInput = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV1::kFontInput = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV1::kFontSizeInput = QStringLiteral("font_size_in");
|
||||
const QString TextGeneratorV1::k_text_input = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV1::k_html_input = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV1::k_color_input = QStringLiteral("color_in");
|
||||
const QString TextGeneratorV1::k_v_align_input = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV1::k_font_input = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV1::k_font_size_input = QStringLiteral("font_size_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
TextGeneratorV1::TextGeneratorV1()
|
||||
{
|
||||
AddInput(kTextInput, NodeValue::kText, tr("Sample Text"));
|
||||
add_input(k_text_input, NodeValue::k_text, tr("Sample Text"));
|
||||
|
||||
AddInput(kHtmlInput, NodeValue::kBoolean, false);
|
||||
add_input(k_html_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kColorInput, NodeValue::kColor,
|
||||
add_input(k_color_input, NodeValue::k_color,
|
||||
QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
|
||||
AddInput(kVAlignInput, NodeValue::kCombo, 1);
|
||||
add_input(k_v_align_input, NodeValue::k_combo, 1);
|
||||
|
||||
AddInput(kFontInput, NodeValue::kFont);
|
||||
add_input(k_font_input, NodeValue::k_font);
|
||||
|
||||
AddInput(kFontSizeInput, NodeValue::kFloat, 72.0f);
|
||||
add_input(k_font_size_input, NodeValue::k_float, 72.0f);
|
||||
|
||||
SetFlag(kDontShowInCreateMenu);
|
||||
set_flag(k_dont_show_in_create_menu);
|
||||
}
|
||||
|
||||
QString TextGeneratorV1::Name() const
|
||||
QString TextGeneratorV1::name() const
|
||||
{
|
||||
return tr("Text (Legacy)");
|
||||
}
|
||||
@@ -70,40 +70,40 @@ QString TextGeneratorV1::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.textgenerator");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TextGeneratorV1::Category() const
|
||||
QVector<Node::CategoryID> TextGeneratorV1::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString TextGeneratorV1::Description() const
|
||||
QString TextGeneratorV1::description() const
|
||||
{
|
||||
return tr("Generate rich text.");
|
||||
}
|
||||
|
||||
void TextGeneratorV1::Retranslate()
|
||||
void TextGeneratorV1::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextInput, tr("Text"));
|
||||
SetInputName(kHtmlInput, tr("Enable HTML"));
|
||||
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") });
|
||||
set_input_name(k_text_input, tr("Text"));
|
||||
set_input_name(k_html_input, tr("Enable HTML"));
|
||||
set_input_name(k_font_input, tr("Font"));
|
||||
set_input_name(k_font_size_input, tr("Font Size"));
|
||||
set_input_name(k_color_input, tr("Color"));
|
||||
set_input_name(k_v_align_input, tr("Vertical Align"));
|
||||
set_combo_box_strings(k_v_align_input, { tr("Top"), tr("Center"), tr("Bottom") });
|
||||
}
|
||||
|
||||
void TextGeneratorV1::Value(const NodeValueRow &value,
|
||||
void TextGeneratorV1::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (!value[kTextInput].toString().isEmpty()) {
|
||||
table->Push(NodeValue::kTexture,
|
||||
Texture::Job(globals.vparams(), GenerateJob(value)), this);
|
||||
if (!value[k_text_input].to_string().isEmpty()) {
|
||||
table->push(NodeValue::k_texture,
|
||||
Texture::job(globals.vparams(), GenerateJob(value)), this);
|
||||
}
|
||||
}
|
||||
|
||||
void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
void TextGeneratorV1::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
// This could probably be more optimized, but for now we use Qt to draw to a QImage.
|
||||
@@ -117,15 +117,15 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
|
||||
// Set default font
|
||||
QFont default_font;
|
||||
default_font.setFamily(job.Get(kFontInput).toString());
|
||||
default_font.setPointSizeF(job.Get(kFontSizeInput).toDouble());
|
||||
default_font.setFamily(job.get(k_font_input).to_string());
|
||||
default_font.setPointSizeF(job.get(k_font_size_input).to_double());
|
||||
text_doc.setDefaultFont(default_font);
|
||||
|
||||
// Center by default
|
||||
text_doc.setDefaultTextOption(QTextOption(Qt::AlignCenter));
|
||||
|
||||
QString html = job.Get(kTextInput).toString();
|
||||
if (job.Get(kHtmlInput).toBool()) {
|
||||
QString html = job.get(k_text_input).to_string();
|
||||
if (job.get(k_html_input).to_bool()) {
|
||||
html.replace('\n', QStringLiteral("<br>"));
|
||||
text_doc.setHtml(html);
|
||||
} else {
|
||||
@@ -145,19 +145,19 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
p.translate(tenth_of_width, 0);
|
||||
|
||||
TextVerticalAlign valign =
|
||||
static_cast<TextVerticalAlign>(job.Get(kVAlignInput).toInt());
|
||||
static_cast<TextVerticalAlign>(job.get(k_v_align_input).to_int());
|
||||
int doc_height = text_doc.size().height();
|
||||
|
||||
switch (valign) {
|
||||
case kVerticalAlignTop:
|
||||
case k_vertical_align_top:
|
||||
// Push 10% inwards for title safe area
|
||||
p.translate(0, frame->video_params().height() / 10);
|
||||
break;
|
||||
case kVerticalAlignCenter:
|
||||
case k_vertical_align_center:
|
||||
// Center align
|
||||
p.translate(0, frame->video_params().height() / 2 - doc_height / 2);
|
||||
break;
|
||||
case kVerticalAlignBottom:
|
||||
case k_vertical_align_bottom:
|
||||
// Push 10% inwards for title safe area
|
||||
p.translate(0, frame->video_params().height() - doc_height -
|
||||
frame->video_params().height() / 10);
|
||||
@@ -169,7 +169,7 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame,
|
||||
text_doc.documentLayout()->draw(&p, ctx);
|
||||
|
||||
// Transplant alpha channel to frame
|
||||
Color rgb = job.Get(kColorInput).toColor();
|
||||
Color rgb = job.get(k_color_input).to_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];
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTGENERATORV1_H
|
||||
#define TEXTGENERATORV1_H
|
||||
#ifndef OAK_TEXTGENERATORV1_H
|
||||
#define OAK_TEXTGENERATORV1_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,27 +34,27 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TextGeneratorV1)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
static const QString kTextInput;
|
||||
static const QString kHtmlInput;
|
||||
static const QString kColorInput;
|
||||
static const QString kVAlignInput;
|
||||
static const QString kFontInput;
|
||||
static const QString kFontSizeInput;
|
||||
static const QString k_text_input;
|
||||
static const QString k_html_input;
|
||||
static const QString k_color_input;
|
||||
static const QString k_v_align_input;
|
||||
static const QString k_font_input;
|
||||
static const QString k_font_size_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TEXTGENERATORV1_H
|
||||
#endif // OAK_TEXTGENERATORV1_H
|
||||
|
||||
@@ -32,36 +32,36 @@ namespace olive
|
||||
#define super ShapeNodeBase
|
||||
|
||||
enum TextVerticalAlign {
|
||||
kVerticalAlignTop,
|
||||
kVerticalAlignCenter,
|
||||
kVerticalAlignBottom,
|
||||
k_vertical_align_top,
|
||||
k_vertical_align_center,
|
||||
k_vertical_align_bottom,
|
||||
};
|
||||
|
||||
const QString TextGeneratorV2::kTextInput = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV2::kHtmlInput = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV2::kVAlignInput = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV2::kFontInput = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV2::kFontSizeInput = QStringLiteral("font_size_in");
|
||||
const QString TextGeneratorV2::k_text_input = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV2::k_html_input = QStringLiteral("html_in");
|
||||
const QString TextGeneratorV2::k_v_align_input = QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV2::k_font_input = QStringLiteral("font_in");
|
||||
const QString TextGeneratorV2::k_font_size_input = QStringLiteral("font_size_in");
|
||||
|
||||
TextGeneratorV2::TextGeneratorV2()
|
||||
{
|
||||
AddInput(kTextInput, NodeValue::kText, tr("Sample Text"));
|
||||
add_input(k_text_input, NodeValue::k_text, tr("Sample Text"));
|
||||
|
||||
AddInput(kHtmlInput, NodeValue::kBoolean, false);
|
||||
add_input(k_html_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kVAlignInput, NodeValue::kCombo, kVerticalAlignTop);
|
||||
add_input(k_v_align_input, NodeValue::k_combo, k_vertical_align_top);
|
||||
|
||||
AddInput(kFontInput, NodeValue::kFont);
|
||||
add_input(k_font_input, NodeValue::k_font);
|
||||
|
||||
AddInput(kFontSizeInput, NodeValue::kFloat, 72.0f);
|
||||
add_input(k_font_size_input, NodeValue::k_float, 72.0f);
|
||||
|
||||
SetStandardValue(kColorInput, QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
SetStandardValue(kSizeInput, QVector2D(400, 300));
|
||||
set_standard_value(k_color_input, QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
|
||||
set_standard_value(k_size_input, QVector2D(400, 300));
|
||||
|
||||
SetFlag(kDontShowInCreateMenu);
|
||||
set_flag(k_dont_show_in_create_menu);
|
||||
}
|
||||
|
||||
QString TextGeneratorV2::Name() const
|
||||
QString TextGeneratorV2::name() const
|
||||
{
|
||||
return tr("Text (Legacy)");
|
||||
}
|
||||
@@ -71,41 +71,41 @@ QString TextGeneratorV2::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.text2");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TextGeneratorV2::Category() const
|
||||
QVector<Node::CategoryID> TextGeneratorV2::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString TextGeneratorV2::Description() const
|
||||
QString TextGeneratorV2::description() const
|
||||
{
|
||||
return tr("Generate rich text.");
|
||||
}
|
||||
|
||||
void TextGeneratorV2::Retranslate()
|
||||
void TextGeneratorV2::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextInput, tr("Text"));
|
||||
SetInputName(kHtmlInput, tr("Enable HTML"));
|
||||
SetInputName(kFontInput, tr("Font"));
|
||||
SetInputName(kFontSizeInput, tr("Font Size"));
|
||||
SetInputName(kVAlignInput, tr("Vertical Align"));
|
||||
SetComboBoxStrings(kVAlignInput, { tr("Top"), tr("Center"), tr("Bottom") });
|
||||
set_input_name(k_text_input, tr("Text"));
|
||||
set_input_name(k_html_input, tr("Enable HTML"));
|
||||
set_input_name(k_font_input, tr("Font"));
|
||||
set_input_name(k_font_size_input, tr("Font Size"));
|
||||
set_input_name(k_v_align_input, tr("Vertical Align"));
|
||||
set_combo_box_strings(k_v_align_input, { tr("Top"), tr("Center"), tr("Bottom") });
|
||||
}
|
||||
|
||||
void TextGeneratorV2::Value(const NodeValueRow &value,
|
||||
void TextGeneratorV2::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (!value[kTextInput].toString().isEmpty()) {
|
||||
if (!value[k_text_input].to_string().isEmpty()) {
|
||||
GenerateJob job(value);
|
||||
auto text_params = globals.vparams();
|
||||
text_params.set_format(PixelFormat::F32);
|
||||
table->Push(NodeValue::kTexture, Texture::Job(text_params, job), this);
|
||||
text_params.set_format(PixelFormat::f32);
|
||||
table->push(NodeValue::k_texture, Texture::job(text_params, job), this);
|
||||
}
|
||||
}
|
||||
|
||||
void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
void TextGeneratorV2::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
// This could probably be more optimized, but for now we use Qt to draw to a QImage.
|
||||
@@ -125,19 +125,19 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
|
||||
// Set default font
|
||||
QFont default_font;
|
||||
default_font.setFamily(job.Get(kFontInput).toString());
|
||||
default_font.setPointSizeF(job.Get(kFontSizeInput).toDouble());
|
||||
default_font.setFamily(job.get(k_font_input).to_string());
|
||||
default_font.setPointSizeF(job.get(k_font_size_input).to_double());
|
||||
text_doc.setDefaultFont(default_font);
|
||||
|
||||
QString html = job.Get(kTextInput).toString();
|
||||
if (job.Get(kHtmlInput).toBool()) {
|
||||
QString html = job.get(k_text_input).to_string();
|
||||
if (job.get(k_html_input).to_bool()) {
|
||||
html.replace('\n', QStringLiteral("<br>"));
|
||||
text_doc.setHtml(html);
|
||||
} else {
|
||||
text_doc.setPlainText(html);
|
||||
}
|
||||
|
||||
QVector2D size = job.Get(kSizeInput).toVec2();
|
||||
QVector2D size = job.get(k_size_input).to_vec2();
|
||||
text_doc.setTextWidth(size.x());
|
||||
|
||||
// Draw rich text onto image
|
||||
@@ -145,25 +145,25 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
p.scale(1.0 / frame->video_params().divider(),
|
||||
1.0 / frame->video_params().divider());
|
||||
|
||||
QVector2D pos = job.Get(kPositionInput).toVec2();
|
||||
QVector2D pos = job.get(k_position_input).to_vec2();
|
||||
p.translate(pos.x() - size.x() / 2, pos.y() - size.y() / 2);
|
||||
p.translate(frame->video_params().width() / 2,
|
||||
frame->video_params().height() / 2);
|
||||
p.setClipRect(0, 0, size.x(), size.y());
|
||||
|
||||
TextVerticalAlign valign =
|
||||
static_cast<TextVerticalAlign>(job.Get(kVAlignInput).toInt());
|
||||
static_cast<TextVerticalAlign>(job.get(k_v_align_input).to_int());
|
||||
int doc_height = text_doc.size().height();
|
||||
|
||||
switch (valign) {
|
||||
case kVerticalAlignTop:
|
||||
case k_vertical_align_top:
|
||||
// Do nothing
|
||||
break;
|
||||
case kVerticalAlignCenter:
|
||||
case k_vertical_align_center:
|
||||
// Center align
|
||||
p.translate(0, size.y() / 2 - doc_height / 2);
|
||||
break;
|
||||
case kVerticalAlignBottom:
|
||||
case k_vertical_align_bottom:
|
||||
p.translate(0, size.y() - doc_height);
|
||||
break;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
text_doc.documentLayout()->draw(&p, ctx);
|
||||
|
||||
// Transplant alpha channel to frame
|
||||
Color rgba = job.Get(kColorInput).toColor();
|
||||
Color rgba = job.get(k_color_input).to_color();
|
||||
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
|
||||
__m128 sse_color = _mm_loadu_ps(rgba.data());
|
||||
#endif
|
||||
@@ -183,11 +183,11 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame,
|
||||
for (int y = 0; y < frame->height(); y++) {
|
||||
uchar *src_y = img.bits() + img.bytesPerLine() * y;
|
||||
float *dst_y = frame_dst + y * frame->linesize_pixels() *
|
||||
VideoParams::kRGBAChannelCount;
|
||||
VideoParams::k_rgba_channel_count;
|
||||
|
||||
for (int x = 0; x < frame->width(); x++) {
|
||||
float alpha = float(src_y[x]) / 255.0f;
|
||||
float *dst = dst_y + x * VideoParams::kRGBAChannelCount;
|
||||
float *dst = dst_y + x * VideoParams::k_rgba_channel_count;
|
||||
|
||||
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
|
||||
__m128 sse_alpha = _mm_load1_ps(&alpha);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTGENERATORV2_H
|
||||
#define TEXTGENERATORV2_H
|
||||
#ifndef OAK_TEXTGENERATORV2_H
|
||||
#define OAK_TEXTGENERATORV2_H
|
||||
|
||||
#include "node/generator/shape/shapenodebase.h"
|
||||
|
||||
@@ -34,26 +34,26 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TextGeneratorV2)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
static const QString kTextInput;
|
||||
static const QString kHtmlInput;
|
||||
static const QString kVAlignInput;
|
||||
static const QString kFontInput;
|
||||
static const QString kFontSizeInput;
|
||||
static const QString k_text_input;
|
||||
static const QString k_html_input;
|
||||
static const QString k_v_align_input;
|
||||
static const QString k_font_input;
|
||||
static const QString k_font_size_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TEXTGENERATORV2_H
|
||||
#endif // OAK_TEXTGENERATORV2_H
|
||||
|
||||
@@ -36,46 +36,46 @@ namespace olive
|
||||
#define super ShapeNodeBase
|
||||
|
||||
enum TextVerticalAlign {
|
||||
kVerticalAlignTop,
|
||||
kVerticalAlignCenter,
|
||||
kVerticalAlignBottom,
|
||||
k_vertical_align_top,
|
||||
k_vertical_align_center,
|
||||
k_vertical_align_bottom,
|
||||
};
|
||||
|
||||
const QString TextGeneratorV3::kTextInput = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV3::kVerticalAlignmentInput =
|
||||
const QString TextGeneratorV3::k_text_input = QStringLiteral("text_in");
|
||||
const QString TextGeneratorV3::k_vertical_alignment_input =
|
||||
QStringLiteral("valign_in");
|
||||
const QString TextGeneratorV3::kUseArgsInput = QStringLiteral("use_args_in");
|
||||
const QString TextGeneratorV3::kArgsInput = QStringLiteral("args_in");
|
||||
const QString TextGeneratorV3::k_use_args_input = QStringLiteral("use_args_in");
|
||||
const QString TextGeneratorV3::k_args_input = QStringLiteral("args_in");
|
||||
|
||||
TextGeneratorV3::TextGeneratorV3()
|
||||
: ShapeNodeBase(false)
|
||||
, dont_emit_valign_(false)
|
||||
{
|
||||
AddInput(kTextInput, NodeValue::kText,
|
||||
add_input(k_text_input, NodeValue::k_text,
|
||||
QStringLiteral("<p style='font-size: 72pt; color: white;'>%1</p>")
|
||||
.arg(tr("Sample Text")));
|
||||
SetInputProperty(kTextInput, QStringLiteral("vieweronly"), true);
|
||||
set_input_property(k_text_input, QStringLiteral("vieweronly"), true);
|
||||
|
||||
SetStandardValue(kSizeInput, QVector2D(400, 300));
|
||||
set_standard_value(k_size_input, QVector2D(400, 300));
|
||||
|
||||
AddInput(kVerticalAlignmentInput, NodeValue::kCombo,
|
||||
InputFlags(kInputFlagHidden | kInputFlagStatic));
|
||||
add_input(k_vertical_alignment_input, NodeValue::k_combo,
|
||||
InputFlags(k_input_flag_hidden | k_input_flag_static));
|
||||
|
||||
AddInput(kUseArgsInput, NodeValue::kBoolean, true,
|
||||
InputFlags(kInputFlagHidden | kInputFlagStatic));
|
||||
add_input(k_use_args_input, NodeValue::k_boolean, true,
|
||||
InputFlags(k_input_flag_hidden | k_input_flag_static));
|
||||
|
||||
AddInput(kArgsInput, NodeValue::kText, InputFlags(kInputFlagArray));
|
||||
SetInputProperty(kArgsInput, QStringLiteral("arraystart"), 1);
|
||||
add_input(k_args_input, NodeValue::k_text, InputFlags(k_input_flag_array));
|
||||
set_input_property(k_args_input, QStringLiteral("arraystart"), 1);
|
||||
|
||||
text_gizmo_ = new TextGizmo(this);
|
||||
text_gizmo_->SetInput(NodeInput(this, kTextInput));
|
||||
connect(text_gizmo_, &TextGizmo::Activated, this,
|
||||
&TextGeneratorV3::GizmoActivated);
|
||||
connect(text_gizmo_, &TextGizmo::Deactivated, this,
|
||||
&TextGeneratorV3::GizmoDeactivated);
|
||||
text_gizmo_->set_input(NodeInput(this, k_text_input));
|
||||
connect(text_gizmo_, &TextGizmo::activated, this,
|
||||
&TextGeneratorV3::gizmo_activated);
|
||||
connect(text_gizmo_, &TextGizmo::deactivated, this,
|
||||
&TextGeneratorV3::gizmo_deactivated);
|
||||
}
|
||||
|
||||
QString TextGeneratorV3::Name() const
|
||||
QString TextGeneratorV3::name() const
|
||||
{
|
||||
return tr("Text");
|
||||
}
|
||||
@@ -85,64 +85,64 @@ QString TextGeneratorV3::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.text3");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> TextGeneratorV3::Category() const
|
||||
QVector<Node::CategoryID> TextGeneratorV3::category() const
|
||||
{
|
||||
return { kCategoryGenerator };
|
||||
return { k_category_generator };
|
||||
}
|
||||
|
||||
QString TextGeneratorV3::Description() const
|
||||
QString TextGeneratorV3::description() const
|
||||
{
|
||||
return tr("Generate rich text.");
|
||||
}
|
||||
|
||||
void TextGeneratorV3::Retranslate()
|
||||
void TextGeneratorV3::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextInput, tr("Text"));
|
||||
SetInputName(kVerticalAlignmentInput, tr("Vertical Alignment"));
|
||||
SetComboBoxStrings(kVerticalAlignmentInput,
|
||||
set_input_name(k_text_input, tr("Text"));
|
||||
set_input_name(k_vertical_alignment_input, tr("Vertical Alignment"));
|
||||
set_combo_box_strings(k_vertical_alignment_input,
|
||||
{ tr("Top"), tr("Middle"), tr("Bottom") });
|
||||
SetInputName(kArgsInput, tr("Arguments"));
|
||||
set_input_name(k_args_input, tr("Arguments"));
|
||||
}
|
||||
|
||||
void TextGeneratorV3::Value(const NodeValueRow &value,
|
||||
void TextGeneratorV3::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
QString text = value[kTextInput].toString();
|
||||
QString text = value[k_text_input].to_string();
|
||||
|
||||
if (value[kUseArgsInput].toBool()) {
|
||||
auto args = value[kArgsInput].toArray();
|
||||
if (value[k_use_args_input].to_bool()) {
|
||||
auto args = value[k_args_input].to_array();
|
||||
if (!args.empty()) {
|
||||
QStringList list;
|
||||
list.reserve(args.size());
|
||||
for (size_t i = 0; i < args.size(); i++) {
|
||||
list.append(args[i].toString());
|
||||
list.append(args[i].to_string());
|
||||
}
|
||||
|
||||
text = FormatString(text, list);
|
||||
text = format_string(text, list);
|
||||
}
|
||||
}
|
||||
|
||||
if (!text.isEmpty()) {
|
||||
TexturePtr base = value[kTextInput].toTexture();
|
||||
TexturePtr base = value[k_text_input].to_texture();
|
||||
|
||||
VideoParams text_params = base ? base->params() : globals.vparams();
|
||||
text_params.set_format(PixelFormat::U8);
|
||||
text_params.set_format(PixelFormat::u8);
|
||||
text_params.set_colorspace(
|
||||
project()->color_manager()->GetDefaultInputColorSpace());
|
||||
project()->color_manager()->get_default_input_color_space());
|
||||
|
||||
GenerateJob job(value);
|
||||
job.Insert(kTextInput, NodeValue(NodeValue::kText, text));
|
||||
job.insert(k_text_input, NodeValue(NodeValue::k_text, text));
|
||||
|
||||
PushMergableJob(value, Texture::Job(text_params, job), table);
|
||||
} else if (value[kBaseInput].toTexture()) {
|
||||
table->Push(value[kBaseInput]);
|
||||
push_mergable_job(value, Texture::job(text_params, job), table);
|
||||
} else if (value[k_base_input].to_texture()) {
|
||||
table->push(value[k_base_input]);
|
||||
}
|
||||
}
|
||||
|
||||
void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
void TextGeneratorV3::generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const
|
||||
{
|
||||
QImage img(reinterpret_cast<uchar *>(frame->data()), frame->width(),
|
||||
@@ -158,10 +158,10 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
QTextDocument text_doc;
|
||||
text_doc.documentLayout()->setPaintDevice(&img);
|
||||
|
||||
QString html = job.Get(kTextInput).toString();
|
||||
Html::HtmlToDoc(&text_doc, html);
|
||||
QString html = job.get(k_text_input).to_string();
|
||||
Html::html_to_doc(&text_doc, html);
|
||||
|
||||
QVector2D size = job.Get(kSizeInput).toVec2();
|
||||
QVector2D size = job.get(k_size_input).to_vec2();
|
||||
text_doc.setTextWidth(size.x());
|
||||
|
||||
// Draw rich text onto image
|
||||
@@ -169,21 +169,21 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
p.scale(1.0 / frame->video_params().divider(),
|
||||
1.0 / frame->video_params().divider());
|
||||
|
||||
QVector2D pos = job.Get(kPositionInput).toVec2();
|
||||
QVector2D pos = job.get(k_position_input).to_vec2();
|
||||
p.translate(pos.x() - size.x() / 2, pos.y() - size.y() / 2);
|
||||
p.translate(frame->video_params().width() / 2,
|
||||
frame->video_params().height() / 2);
|
||||
p.setClipRect(0, 0, size.x(), size.y());
|
||||
|
||||
switch (static_cast<VerticalAlignment>(
|
||||
job.Get(kVerticalAlignmentInput).toInt())) {
|
||||
case kVAlignTop:
|
||||
job.get(k_vertical_alignment_input).to_int())) {
|
||||
case k_v_align_top:
|
||||
// Do nothing
|
||||
break;
|
||||
case kVAlignMiddle:
|
||||
case k_v_align_middle:
|
||||
p.translate(0, size.y() / 2 - text_doc.size().height() / 2);
|
||||
break;
|
||||
case kVAlignBottom:
|
||||
case k_v_align_bottom:
|
||||
p.translate(0, size.y() - text_doc.size().height());
|
||||
break;
|
||||
}
|
||||
@@ -195,45 +195,45 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame,
|
||||
text_doc.documentLayout()->draw(&p, ctx);
|
||||
}
|
||||
|
||||
void TextGeneratorV3::UpdateGizmoPositions(const NodeValueRow &row,
|
||||
void TextGeneratorV3::update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals)
|
||||
{
|
||||
super::UpdateGizmoPositions(row, globals);
|
||||
super::update_gizmo_positions(row, globals);
|
||||
|
||||
QRectF rect = poly_gizmo()->GetPolygon().boundingRect();
|
||||
text_gizmo_->SetRect(rect);
|
||||
text_gizmo_->SetHtml(row[kTextInput].toString());
|
||||
QRectF rect = poly_gizmo()->get_polygon().boundingRect();
|
||||
text_gizmo_->set_rect(rect);
|
||||
text_gizmo_->set_html(row[k_text_input].to_string());
|
||||
}
|
||||
|
||||
Qt::Alignment TextGeneratorV3::GetQtAlignmentFromOurs(VerticalAlignment v)
|
||||
Qt::Alignment TextGeneratorV3::get_qt_alignment_from_ours(VerticalAlignment v)
|
||||
{
|
||||
switch (v) {
|
||||
case kVAlignTop:
|
||||
case k_v_align_top:
|
||||
return Qt::AlignTop;
|
||||
case kVAlignMiddle:
|
||||
case k_v_align_middle:
|
||||
return Qt::AlignVCenter;
|
||||
case kVAlignBottom:
|
||||
case k_v_align_bottom:
|
||||
return Qt::AlignBottom;
|
||||
}
|
||||
return Qt::Alignment();
|
||||
}
|
||||
|
||||
TextGeneratorV3::VerticalAlignment
|
||||
TextGeneratorV3::GetOurAlignmentFromQts(Qt::Alignment v)
|
||||
TextGeneratorV3::get_our_alignment_from_qts(Qt::Alignment v)
|
||||
{
|
||||
switch (v) {
|
||||
case Qt::AlignTop:
|
||||
return kVAlignTop;
|
||||
return k_v_align_top;
|
||||
case Qt::AlignVCenter:
|
||||
return kVAlignMiddle;
|
||||
return k_v_align_middle;
|
||||
case Qt::AlignBottom:
|
||||
return kVAlignBottom;
|
||||
return k_v_align_bottom;
|
||||
}
|
||||
|
||||
return kVAlignTop;
|
||||
return k_v_align_top;
|
||||
}
|
||||
|
||||
QString TextGeneratorV3::FormatString(const QString &input,
|
||||
QString TextGeneratorV3::format_string(const QString &input,
|
||||
const QStringList &args)
|
||||
{
|
||||
QString output;
|
||||
@@ -274,36 +274,36 @@ QString TextGeneratorV3::FormatString(const QString &input,
|
||||
|
||||
void TextGeneratorV3::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
if (input == kVerticalAlignmentInput && !dont_emit_valign_) {
|
||||
text_gizmo_->SetVerticalAlignment(
|
||||
GetQtAlignmentFromOurs(GetVerticalAlignment()));
|
||||
if (input == k_vertical_alignment_input && !dont_emit_valign_) {
|
||||
text_gizmo_->set_vertical_alignment(
|
||||
get_qt_alignment_from_ours(get_vertical_alignment()));
|
||||
}
|
||||
|
||||
super::InputValueChangedEvent(input, element);
|
||||
}
|
||||
|
||||
void TextGeneratorV3::GizmoActivated()
|
||||
void TextGeneratorV3::gizmo_activated()
|
||||
{
|
||||
SetStandardValue(kUseArgsInput, false);
|
||||
connect(text_gizmo_, &TextGizmo::VerticalAlignmentChanged, this,
|
||||
&TextGeneratorV3::SetVerticalAlignmentUndoable);
|
||||
set_standard_value(k_use_args_input, false);
|
||||
connect(text_gizmo_, &TextGizmo::vertical_alignment_changed, this,
|
||||
&TextGeneratorV3::set_vertical_alignment_undoable);
|
||||
dont_emit_valign_ = true;
|
||||
}
|
||||
|
||||
void TextGeneratorV3::GizmoDeactivated()
|
||||
void TextGeneratorV3::gizmo_deactivated()
|
||||
{
|
||||
SetStandardValue(kUseArgsInput, true);
|
||||
disconnect(text_gizmo_, &TextGizmo::VerticalAlignmentChanged, this,
|
||||
&TextGeneratorV3::SetVerticalAlignmentUndoable);
|
||||
set_standard_value(k_use_args_input, true);
|
||||
disconnect(text_gizmo_, &TextGizmo::vertical_alignment_changed, this,
|
||||
&TextGeneratorV3::set_vertical_alignment_undoable);
|
||||
dont_emit_valign_ = true;
|
||||
}
|
||||
|
||||
void TextGeneratorV3::SetVerticalAlignmentUndoable(Qt::Alignment a)
|
||||
void TextGeneratorV3::set_vertical_alignment_undoable(Qt::Alignment a)
|
||||
{
|
||||
Core::instance()->undo_stack()->push(
|
||||
new NodeParamSetStandardValueCommand(NodeInput(this,
|
||||
kVerticalAlignmentInput),
|
||||
GetOurAlignmentFromQts(a)),
|
||||
k_vertical_alignment_input),
|
||||
get_our_alignment_from_qts(a)),
|
||||
tr("Set Text Vertical Alignment"));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTGENERATORV3_H
|
||||
#define TEXTGENERATORV3_H
|
||||
#ifndef OAK_TEXTGENERATORV3_H
|
||||
#define OAK_TEXTGENERATORV3_H
|
||||
|
||||
#include "node/generator/shape/shapenodebase.h"
|
||||
#include "node/gizmo/text.h"
|
||||
@@ -35,39 +35,39 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(TextGeneratorV3)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void GenerateFrame(FramePtr frame,
|
||||
virtual void generate_frame(FramePtr frame,
|
||||
const GenerateJob &job) const override;
|
||||
|
||||
virtual void UpdateGizmoPositions(const NodeValueRow &row,
|
||||
virtual void update_gizmo_positions(const NodeValueRow &row,
|
||||
const NodeGlobals &globals) override;
|
||||
|
||||
enum VerticalAlignment { kVAlignTop, kVAlignMiddle, kVAlignBottom };
|
||||
enum VerticalAlignment { k_v_align_top, k_v_align_middle, k_v_align_bottom };
|
||||
|
||||
VerticalAlignment GetVerticalAlignment() const
|
||||
VerticalAlignment get_vertical_alignment() const
|
||||
{
|
||||
return static_cast<VerticalAlignment>(
|
||||
GetStandardValue(kVerticalAlignmentInput).toInt());
|
||||
get_standard_value(k_vertical_alignment_input).toInt());
|
||||
}
|
||||
|
||||
static Qt::Alignment GetQtAlignmentFromOurs(VerticalAlignment v);
|
||||
static VerticalAlignment GetOurAlignmentFromQts(Qt::Alignment v);
|
||||
static Qt::Alignment get_qt_alignment_from_ours(VerticalAlignment v);
|
||||
static VerticalAlignment get_our_alignment_from_qts(Qt::Alignment v);
|
||||
|
||||
static const QString kTextInput;
|
||||
static const QString kVerticalAlignmentInput;
|
||||
static const QString kUseArgsInput;
|
||||
static const QString kArgsInput;
|
||||
static const QString k_text_input;
|
||||
static const QString k_vertical_alignment_input;
|
||||
static const QString k_use_args_input;
|
||||
static const QString k_args_input;
|
||||
|
||||
static QString FormatString(const QString &input, const QStringList &args);
|
||||
static QString format_string(const QString &input, const QStringList &args);
|
||||
|
||||
protected:
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
@@ -79,11 +79,11 @@ private:
|
||||
bool dont_emit_valign_;
|
||||
|
||||
private slots:
|
||||
void GizmoActivated();
|
||||
void GizmoDeactivated();
|
||||
void SetVerticalAlignmentUndoable(Qt::Alignment a);
|
||||
void gizmo_activated();
|
||||
void gizmo_deactivated();
|
||||
void set_vertical_alignment_undoable(Qt::Alignment a);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TEXTGENERATORV3_H
|
||||
#endif // OAK_TEXTGENERATORV3_H
|
||||
|
||||
Reference in New Issue
Block a user