making it work

This commit is contained in:
itsmattkc
2019-01-25 16:46:39 +11:00
parent 4cabe1571b
commit 9c57219ba9
4 changed files with 107 additions and 21 deletions
+39 -20
View File
@@ -23,19 +23,14 @@
#include "panels/viewer.h"
#include "ui/viewerwidget.h"
#define BLEND_MODE_NORMAL 0
#define BLEND_MODE_SCREEN 1
#define BLEND_MODE_MULTIPLY 2
#define BLEND_MODE_OVERLAY 3
TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) {
enable_coords = true;
EffectRow* position_row = add_row(tr("Position"));
EffectRow* position_row = add_row(tr("Position"));
position_x = position_row->add_field(EFFECT_FIELD_DOUBLE, "posx"); // position X
position_y = position_row->add_field(EFFECT_FIELD_DOUBLE, "posy"); // position Y
EffectRow* scale_row = add_row(tr("Scale"));
EffectRow* scale_row = add_row(tr("Scale"));
scale_x = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scalex"); // scale X (and Y is uniform scale is selected)
scale_x->set_double_minimum_value(0);
scale_x->set_double_maximum_value(3000);
@@ -43,27 +38,49 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em)
scale_y->set_double_minimum_value(0);
scale_y->set_double_maximum_value(3000);
EffectRow* uniform_scale_row = add_row(tr("Uniform Scale"));
EffectRow* uniform_scale_row = add_row(tr("Uniform Scale"));
uniform_scale_field = uniform_scale_row->add_field(EFFECT_FIELD_BOOL, "uniformscale"); // uniform scale option
EffectRow* rotation_row = add_row(tr("Rotation"));
EffectRow* rotation_row = add_row(tr("Rotation"));
rotation = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation");
EffectRow* anchor_point_row = add_row(tr("Anchor Point"));
EffectRow* anchor_point_row = add_row(tr("Anchor Point"));
anchor_x_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchorx"); // anchor point X
anchor_y_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchory"); // anchor point Y
EffectRow* opacity_row = add_row(tr("Opacity"));
EffectRow* opacity_row = add_row(tr("Opacity"));
opacity = opacity_row->add_field(EFFECT_FIELD_DOUBLE, "opacity"); // opacity
opacity->set_double_minimum_value(0);
opacity->set_double_maximum_value(100);
EffectRow* blend_mode_row = add_row(tr("Blend Mode"));
EffectRow* blend_mode_row = add_row(tr("Blend Mode"));
blend_mode_box = blend_mode_row->add_field(EFFECT_FIELD_COMBO, "blendmode"); // blend mode
blend_mode_box->add_combo_item(tr("Normal"), BLEND_MODE_NORMAL);
blend_mode_box->add_combo_item(tr("Overlay"), BLEND_MODE_OVERLAY);
blend_mode_box->add_combo_item(tr("Screen"), BLEND_MODE_SCREEN);
blend_mode_box->add_combo_item(tr("Multiply"), BLEND_MODE_MULTIPLY);
blend_mode_box->add_combo_item(tr("Normal"), BLEND_MODE_NORMAL);
blend_mode_box->add_combo_item(tr("Darken"), BLEND_MODE_DARKEN);
blend_mode_box->add_combo_item(tr("Multiply"), BLEND_MODE_MULTIPLY);
blend_mode_box->add_combo_item(tr("Color Burn"), BLEND_MODE_COLORBURN);
blend_mode_box->add_combo_item(tr("Linear Burn"), BLEND_MODE_LINEARBURN);
blend_mode_box->add_combo_item(tr("Lighten"), BLEND_MODE_LIGHTEN);
blend_mode_box->add_combo_item(tr("Screen"), BLEND_MODE_SCREEN);
blend_mode_box->add_combo_item(tr("Color Dodge"), BLEND_MODE_COLORDODGE);
blend_mode_box->add_combo_item(tr("Linear Dodge"), BLEND_MODE_LINEARDODGE);
blend_mode_box->add_combo_item(tr("Overlay"), BLEND_MODE_OVERLAY);
blend_mode_box->add_combo_item(tr("Soft Light"), BLEND_MODE_SOFTLIGHT);
blend_mode_box->add_combo_item(tr("Hard Light"), BLEND_MODE_HARDLIGHT);
blend_mode_box->add_combo_item(tr("Vivid Light"), BLEND_MODE_VIVIDLIGHT);
blend_mode_box->add_combo_item(tr("Linear Light"), BLEND_MODE_LINEARLIGHT);
blend_mode_box->add_combo_item(tr("Pin Light"), BLEND_MODE_PINLIGHT);
blend_mode_box->add_combo_item(tr("Hard Mix"), BLEND_MODE_HARDMIX);
blend_mode_box->add_combo_item(tr("Difference"), BLEND_MODE_DIFFERENCE);
blend_mode_box->add_combo_item(tr("Exclusion"), BLEND_MODE_EXCLUSION);
blend_mode_box->add_combo_item(tr("Reflect"), BLEND_MODE_REFLECT);
blend_mode_box->add_combo_item(tr("Subtract"), BLEND_MODE_SUBTRACT);
blend_mode_box->add_combo_item(tr("Substract"), BLEND_MODE_SUBSTRACT);
blend_mode_box->add_combo_item(tr("Add"), BLEND_MODE_ADD);
blend_mode_box->add_combo_item(tr("Average"), BLEND_MODE_AVERAGE);
blend_mode_box->add_combo_item(tr("Glow"), BLEND_MODE_GLOW);
blend_mode_box->add_combo_item(tr("Negation"), BLEND_MODE_NEGATION);
blend_mode_box->add_combo_item(tr("Phoenix"), BLEND_MODE_PHOENIX);
// set up gizmos
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
@@ -211,7 +228,8 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i
glScalef(sx, sy, 1);
// blend mode
switch (blend_mode_box->get_combo_data(timecode).toInt()) {
coords.blendmode = blend_mode_box->get_combo_data(timecode).toInt();
/*switch (blend_mode_box->get_combo_data(timecode).toInt()) {
case BLEND_MODE_NORMAL:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
@@ -226,12 +244,13 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i
break;
default:
qCritical() << "Invalid blend mode. This is a bug - please contact developers";
}
}*/
// opacity
float color[4];
coords.opacity *= opacity->get_double_value(timecode)*0.01;
/*float color[4];
glGetFloatv(GL_CURRENT_COLOR, color);
glColor4f(1.0, 1.0, 1.0, color[3]*(opacity->get_double_value(timecode)*0.01));
glColor4f(1.0, 1.0, 1.0, color[3]*(opacity->get_double_value(timecode)*0.01));*/
}
void TransformEffect::gizmo_draw(double, GLTextureCoords& coords) {