Merge branch 'master' into new_timecode

This commit is contained in:
itsmattkc
2018-12-01 12:24:32 +11:00
committed by GitHub
53 changed files with 1874 additions and 954 deletions
+4 -9
View File
@@ -4,20 +4,15 @@
#include <QtMath>
AudioNoiseEffect::AudioNoiseEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
amount_val = add_row("Amount:")->add_field(EFFECT_FIELD_DOUBLE);
amount_val = add_row("Amount:")->add_field(EFFECT_FIELD_DOUBLE, "amount");
amount_val->set_double_minimum_value(0);
amount_val->set_double_maximum_value(100);
amount_val->set_double_default_value(20);
amount_val->id = "amount";
amount_val->set_double_default_value(20);
mix_val = add_row("Mix:")->add_field(EFFECT_FIELD_BOOL);
mix_val->id = "mix";
mix_val = add_row("Mix:")->add_field(EFFECT_FIELD_BOOL, "mix");
mix_val->set_bool_value(true);
srand(QDateTime::currentMSecsSinceEpoch());
connect(amount_val, SIGNAL(changed()), this, SLOT(field_changed()));
connect(mix_val, SIGNAL(changed()), this, SLOT(field_changed()));
srand(QDateTime::currentMSecsSinceEpoch());
}
void AudioNoiseEffect::process_audio(double timecode_start, double timecode_end, quint8 *samples, int nb_bytes, int) {
+38 -28
View File
@@ -9,41 +9,28 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em)
enable_shader = true;
EffectRow* top_left = add_row("Top Left:");
top_left_x = top_left->add_field(EFFECT_FIELD_DOUBLE);
top_left_x->id = "topleftx";
top_left_y = top_left->add_field(EFFECT_FIELD_DOUBLE);
top_left_y->id = "toplefty";
top_left_x = top_left->add_field(EFFECT_FIELD_DOUBLE, "topleftx");
top_left_y = top_left->add_field(EFFECT_FIELD_DOUBLE, "toplefty");
EffectRow* top_right = add_row("Top Right:");
top_right_x = top_right->add_field(EFFECT_FIELD_DOUBLE);
top_right_x->id = "toprightx";
top_right_y = top_right->add_field(EFFECT_FIELD_DOUBLE);
top_right_y->id = "toprighty";
top_right_x = top_right->add_field(EFFECT_FIELD_DOUBLE, "toprightx");
top_right_y = top_right->add_field(EFFECT_FIELD_DOUBLE, "toprighty");
EffectRow* bottom_left = add_row("Bottom Left:");
bottom_left_x = bottom_left->add_field(EFFECT_FIELD_DOUBLE);
bottom_left_x->id = "bottomleftx";
bottom_left_y = bottom_left->add_field(EFFECT_FIELD_DOUBLE);
bottom_left_y->id = "bottomlefty";
bottom_left_x = bottom_left->add_field(EFFECT_FIELD_DOUBLE, "bottomleftx");
bottom_left_y = bottom_left->add_field(EFFECT_FIELD_DOUBLE, "bottomlefty");
EffectRow* bottom_right = add_row("Bottom Right:");
bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE);
bottom_right_x->id = "bottomrightx";
bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE);
bottom_right_y->id = "bottomrighty";
bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE, "bottomrightx");
bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE, "bottomrighty");
perspective = add_row("Perspective:")->add_field(EFFECT_FIELD_BOOL);
perspective->set_bool_value(true);
perspective = add_row("Perspective:")->add_field(EFFECT_FIELD_BOOL, "perspective");
perspective->set_bool_value(true);
connect(top_left_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(top_left_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(top_right_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(top_right_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_left_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_left_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_right_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(bottom_right_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(perspective, SIGNAL(changed()), this, SLOT(field_changed()));
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
vertPath = "cornerpin.vert";
fragPath = "cornerpin.frag";
@@ -68,5 +55,28 @@ void CornerPinEffect::process_shader(double timecode, GLTextureCoords &coords) {
glslProgram->setUniformValue("p1", (GLfloat) coords.vertexBottomRightX, (GLfloat) coords.vertexBottomRightY);
glslProgram->setUniformValue("p2", (GLfloat) coords.vertexTopLeftX, (GLfloat) coords.vertexTopLeftY);
glslProgram->setUniformValue("p3", (GLfloat) coords.vertexTopRightX, (GLfloat) coords.vertexTopRightY);
glslProgram->setUniformValue("perspective", perspective->get_bool_value(timecode));
glslProgram->setUniformValue("perspective", perspective->get_bool_value(timecode));
}
void CornerPinEffect::gizmo_draw(double timecode, GLTextureCoords &coords) {
top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
bottom_left_gizmo->world_pos[0] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
}
void CornerPinEffect::gizmo_move(EffectGizmo *sender, int x_movement, int y_movement, double timecode) {
if (sender == bottom_right_gizmo) {
bottom_right_x->set_double_value(bottom_right_x->get_double_value(timecode) + x_movement);
bottom_right_y->set_double_value(bottom_right_y->get_double_value(timecode) + y_movement);
} else if (sender == top_left_gizmo) {
top_left_x->set_double_value(top_left_x->get_double_value(timecode) + x_movement);
top_left_y->set_double_value(top_left_y->get_double_value(timecode) + y_movement);
} else if (sender == bottom_left_gizmo) {
bottom_left_x->set_double_value(bottom_left_x->get_double_value(timecode) + x_movement);
bottom_left_y->set_double_value(bottom_left_y->get_double_value(timecode) + y_movement);
} else if (sender == top_right_gizmo) {
top_right_x->set_double_value(top_right_x->get_double_value(timecode) + x_movement);
top_right_y->set_double_value(top_right_y->get_double_value(timecode) + y_movement);
}
}
+7
View File
@@ -9,6 +9,8 @@ public:
CornerPinEffect(Clip* c, const EffectMeta* em);
void process_coords(double timecode, GLTextureCoords& coords, int data);
void process_shader(double timecode, GLTextureCoords& coords);
void gizmo_draw(double timecode, GLTextureCoords& coords);
void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode);
private:
EffectField* top_left_x;
EffectField* top_left_y;
@@ -19,6 +21,11 @@ private:
EffectField* bottom_right_x;
EffectField* bottom_right_y;
EffectField* perspective;
EffectGizmo* top_left_gizmo;
EffectGizmo* top_right_gizmo;
EffectGizmo* bottom_left_gizmo;
EffectGizmo* bottom_right_gizmo;
};
#endif // CORNERPINEFFECT_H
@@ -4,6 +4,8 @@
CrossDissolveTransition::CrossDissolveTransition(Clip* c, Clip* s, const EffectMeta* em) : Transition(c, s, em) {
enable_coords = true;
// add_row("Smooth")->add_field(EFFECT_FIELD_BOOL, "smooth");
}
void CrossDissolveTransition::process_coords(double progress, GLTextureCoords&, int data) {
+4 -2
View File
@@ -6,6 +6,8 @@ CubeTransition::CubeTransition(Clip* c, Clip* s, const EffectMeta* em) : Transit
enable_coords = true;
}
void CubeTransition::process_coords(double progress, GLTextureCoords&, int data) {
glTranslatef(-progress, 0, -progress);
void CubeTransition::process_coords(double progress, GLTextureCoords& coords, int data) {
coords.vertexTopLeftZ = 1;
coords.vertexBottomLeftZ = 1;
}
+4 -7
View File
@@ -9,16 +9,13 @@
#include "ui/collapsiblewidget.h"
PanEffect::PanEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* pan_row = add_row("Pan:");
pan_val = pan_row->add_field(EFFECT_FIELD_DOUBLE);
EffectRow* pan_row = add_row("Pan:");
pan_val = pan_row->add_field(EFFECT_FIELD_DOUBLE, "pan");
pan_val->set_double_minimum_value(-100);
pan_val->set_double_maximum_value(100);
pan_val->id = "pan";
pan_val->set_double_maximum_value(100);
// set defaults
pan_val->set_double_default_value(0);
connect(pan_val, SIGNAL(changed()), this, SLOT(field_changed()));
pan_val->set_double_default_value(0);
}
void PanEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
+3 -10
View File
@@ -17,18 +17,15 @@ ShakeEffect::ShakeEffect(Clip *c, const EffectMeta *em) : Effect(c, em) {
enable_coords = true;
EffectRow* intensity_row = add_row("Intensity:");
intensity_val = intensity_row->add_field(EFFECT_FIELD_DOUBLE);
intensity_val->id = "intensity";
intensity_val = intensity_row->add_field(EFFECT_FIELD_DOUBLE, "intensity");
intensity_val->set_double_minimum_value(0);
EffectRow* rotation_row = add_row("Rotation:");
rotation_val = rotation_row->add_field(EFFECT_FIELD_DOUBLE);
rotation_val->id = "rotation";
rotation_val = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation");
rotation_val->set_double_minimum_value(0);
EffectRow* frequency_row = add_row("Frequency:");
frequency_val = frequency_row->add_field(EFFECT_FIELD_DOUBLE);
frequency_val->id = "frequency";
frequency_val = frequency_row->add_field(EFFECT_FIELD_DOUBLE, "frequency");
frequency_val->set_double_minimum_value(0);
// set defaults
@@ -41,10 +38,6 @@ ShakeEffect::ShakeEffect(Clip *c, const EffectMeta *em) : Effect(c, em) {
for (int i=0;i<RANDOM_VAL_SIZE;i++) {
random_vals[i] = (double)rand()/RAND_MAX;
}
connect(intensity_val, SIGNAL(changed()), this, SLOT(field_changed()));
connect(rotation_val, SIGNAL(changed()), this, SLOT(field_changed()));
connect(frequency_val, SIGNAL(changed()), this, SLOT(field_changed()));
}
void ShakeEffect::process_coords(double timecode, GLTextureCoords& coords, int data) {
+6 -15
View File
@@ -21,31 +21,22 @@
SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) : Effect(c, em) {
enable_superimpose = true;
solid_type = add_row("Type:")->add_field(EFFECT_FIELD_COMBO);
solid_type = add_row("Type:")->add_field(EFFECT_FIELD_COMBO, "type");
solid_type->add_combo_item("Solid Color", SOLID_TYPE_COLOR);
solid_type->add_combo_item("SMPTE Bars", SOLID_TYPE_BARS);
solid_type->add_combo_item("Checkerboard", SOLID_TYPE_CHECKERBOARD);
solid_type->id = "type";
opacity_field = add_row("Opacity:")->add_field(EFFECT_FIELD_DOUBLE);
opacity_field = add_row("Opacity:")->add_field(EFFECT_FIELD_DOUBLE, "opacity");
opacity_field->set_double_minimum_value(0);
opacity_field->set_double_maximum_value(100);
opacity_field->set_double_default_value(100);
opacity_field->id = "opacity";
solid_color_field = add_row("Color:")->add_field(EFFECT_FIELD_COLOR);
solid_color_field->set_color_value(Qt::red);
solid_color_field->id = "color";
solid_color_field = add_row("Color:")->add_field(EFFECT_FIELD_COLOR, "color");
solid_color_field->set_color_value(Qt::red);
checkerboard_size_field = add_row("Checkerboard Size:")->add_field(EFFECT_FIELD_DOUBLE);
checkerboard_size_field = add_row("Checkerboard Size:")->add_field(EFFECT_FIELD_DOUBLE, "checker_size");
checkerboard_size_field->set_double_minimum_value(1);
checkerboard_size_field->set_double_default_value(10);
checkerboard_size_field->id = "checker_size";
connect(solid_type, SIGNAL(changed()), this, SLOT(field_changed()));
connect(solid_color_field, SIGNAL(changed()), this, SLOT(field_changed()));
connect(opacity_field, SIGNAL(changed()), this, SLOT(field_changed()));
connect(checkerboard_size_field, SIGNAL(changed()), this, SLOT(field_changed()));
// hacky but eh
QComboBox* solid_type_combo = static_cast<QComboBox*>(solid_type->get_ui_element());
@@ -59,7 +50,7 @@ SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) : Effect(c, em) {
void SolidEffect::redraw(double timecode) {
int w = img.width();
int h = img.height();
int alpha = (opacity_field->get_double_value(timecode)*2.55);
int alpha = qRound(opacity_field->get_double_value(timecode)*2.55);
switch (solid_type->get_combo_data(timecode).toInt()) {
case SOLID_TYPE_COLOR:
{
+19 -50
View File
@@ -24,56 +24,41 @@ TextEffect::TextEffect(Clip *c, const EffectMeta* em) :
{
enable_superimpose = true;
text_val = add_row("Text:")->add_field(EFFECT_FIELD_STRING, 2);
text_val->id = "text";
text_val = add_row("Text:")->add_field(EFFECT_FIELD_STRING, "text", 2);
set_font_combobox = add_row("Font:")->add_field(EFFECT_FIELD_FONT, 2);
set_font_combobox->id = "font";
set_font_combobox = add_row("Font:")->add_field(EFFECT_FIELD_FONT, "font", 2);
size_val = add_row("Size:")->add_field(EFFECT_FIELD_DOUBLE, 2);
size_val->set_double_minimum_value(0);
size_val->id = "size";
size_val = add_row("Size:")->add_field(EFFECT_FIELD_DOUBLE, "size", 2);
size_val->set_double_minimum_value(0);
set_color_button = add_row("Color:")->add_field(EFFECT_FIELD_COLOR, 2);
set_color_button->id = "color";
set_color_button = add_row("Color:")->add_field(EFFECT_FIELD_COLOR, "color", 2);
EffectRow* alignment_row = add_row("Alignment:");
halign_field = alignment_row->add_field(EFFECT_FIELD_COMBO);
halign_field = alignment_row->add_field(EFFECT_FIELD_COMBO, "halign");
halign_field->add_combo_item("Left", Qt::AlignLeft);
halign_field->add_combo_item("Center", Qt::AlignHCenter);
halign_field->add_combo_item("Right", Qt::AlignRight);
halign_field->add_combo_item("Justify", Qt::AlignJustify);
halign_field->id = "halign";
halign_field->add_combo_item("Justify", Qt::AlignJustify);
valign_field = alignment_row->add_field(EFFECT_FIELD_COMBO);
valign_field = alignment_row->add_field(EFFECT_FIELD_COMBO, "valign");
valign_field->add_combo_item("Top", Qt::AlignTop);
valign_field->add_combo_item("Center", Qt::AlignVCenter);
valign_field->add_combo_item("Bottom", Qt::AlignBottom);
valign_field->id = "valign";
valign_field->add_combo_item("Bottom", Qt::AlignBottom);
word_wrap_field = add_row("Word Wrap:")->add_field(EFFECT_FIELD_BOOL, 2);
word_wrap_field->id = "wordwrap";
word_wrap_field = add_row("Word Wrap:")->add_field(EFFECT_FIELD_BOOL, "wordwrap", 2);
outline_bool = add_row("Outline:")->add_field(EFFECT_FIELD_BOOL, 2);
outline_bool->id = "outline";
outline_color = add_row("Outline Color:")->add_field(EFFECT_FIELD_COLOR, 2);
outline_color->id = "outlinecolor";
outline_width = add_row("Outline Width:")->add_field(EFFECT_FIELD_DOUBLE, 2);
outline_width->id = "outlinewidth";
outline_bool = add_row("Outline:")->add_field(EFFECT_FIELD_BOOL, "outline", 2);
outline_color = add_row("Outline Color:")->add_field(EFFECT_FIELD_COLOR, "outlinecolor", 2);
outline_width = add_row("Outline Width:")->add_field(EFFECT_FIELD_DOUBLE, "outlinewidth", 2);
outline_width->set_double_minimum_value(0);
shadow_bool = add_row("Shadow:")->add_field(EFFECT_FIELD_BOOL, 2);
shadow_bool->id = "shadow";
shadow_color = add_row("Shadow Color:")->add_field(EFFECT_FIELD_COLOR, 2);
shadow_color->id = "shadowcolor";
shadow_distance = add_row("Shadow Distance:")->add_field(EFFECT_FIELD_DOUBLE, 2);
shadow_distance->id = "shadowdistance";
shadow_bool = add_row("Shadow:")->add_field(EFFECT_FIELD_BOOL, "shadow", 2);
shadow_color = add_row("Shadow Color:")->add_field(EFFECT_FIELD_COLOR, "shadowcolor", 2);
shadow_distance = add_row("Shadow Distance:")->add_field(EFFECT_FIELD_DOUBLE, "shadowdistance", 2);
shadow_distance->set_double_minimum_value(0);
shadow_softness = add_row("Shadow Softness:")->add_field(EFFECT_FIELD_DOUBLE, 2);
shadow_softness->id = "shadowsoftness";
shadow_softness = add_row("Shadow Softness:")->add_field(EFFECT_FIELD_DOUBLE, "shadowsoftness", 2);
shadow_softness->set_double_minimum_value(0);
shadow_opacity = add_row("Shadow Opacity:")->add_field(EFFECT_FIELD_DOUBLE, 2);
shadow_opacity->id = "shadowopacity";
shadow_opacity = add_row("Shadow Opacity:")->add_field(EFFECT_FIELD_DOUBLE, "shadowopacity", 2);
shadow_opacity->set_double_minimum_value(0);
shadow_opacity->set_double_maximum_value(100);
@@ -91,23 +76,7 @@ TextEffect::TextEffect(Clip *c, const EffectMeta* em) :
outline_width->set_double_default_value(20);
outline_enable(false);
shadow_enable(false);
connect(text_val, SIGNAL(changed()), this, SLOT(field_changed()));
connect(size_val, SIGNAL(changed()), this, SLOT(field_changed()));
connect(set_color_button, SIGNAL(changed()), this, SLOT(field_changed()));
connect(set_font_combobox, SIGNAL(changed()), this, SLOT(field_changed()));
connect(halign_field, SIGNAL(changed()), this, SLOT(field_changed()));
connect(valign_field, SIGNAL(changed()), this, SLOT(field_changed()));
connect(word_wrap_field, SIGNAL(changed()), this, SLOT(field_changed()));
connect(outline_bool, SIGNAL(changed()), this, SLOT(field_changed()));
connect(outline_color, SIGNAL(changed()), this, SLOT(field_changed()));
connect(outline_width, SIGNAL(changed()), this, SLOT(field_changed()));
connect(shadow_bool, SIGNAL(changed()), this, SLOT(field_changed()));
connect(shadow_color, SIGNAL(changed()), this, SLOT(field_changed()));
connect(shadow_distance, SIGNAL(changed()), this, SLOT(field_changed()));
connect(shadow_softness, SIGNAL(changed()), this, SLOT(field_changed()));
connect(shadow_opacity, SIGNAL(changed()), this, SLOT(field_changed()));
shadow_enable(false);
connect(shadow_bool, SIGNAL(toggled(bool)), this, SLOT(shadow_enable(bool)));
connect(outline_bool, SIGNAL(toggled(bool)), this, SLOT(outline_enable(bool)));
+5 -13
View File
@@ -9,29 +9,21 @@
#include "debug.h"
ToneEffect::ToneEffect(Clip* c, const EffectMeta *em) : Effect(c, em), sinX(INT_MIN) {
type_val = add_row("Type:")->add_field(EFFECT_FIELD_COMBO);
type_val->id = "type";
type_val = add_row("Type:")->add_field(EFFECT_FIELD_COMBO, "type");
type_val->add_combo_item("Sine", TONE_TYPE_SINE);
freq_val = add_row("Frequency:")->add_field(EFFECT_FIELD_DOUBLE);
freq_val->id = "frequency";
freq_val = add_row("Frequency:")->add_field(EFFECT_FIELD_DOUBLE, "frequency");
freq_val->set_double_minimum_value(20);
freq_val->set_double_maximum_value(20000);
freq_val->set_double_default_value(1000);
amount_val = add_row("Amount:")->add_field(EFFECT_FIELD_DOUBLE);
amount_val->id = "amount";
amount_val = add_row("Amount:")->add_field(EFFECT_FIELD_DOUBLE, "amount");
amount_val->set_double_minimum_value(0);
amount_val->set_double_maximum_value(100);
amount_val->set_double_default_value(25);
mix_val = add_row("Mix:")->add_field(EFFECT_FIELD_BOOL);
mix_val->id = "mix";
mix_val->set_bool_value(true);
connect(freq_val, SIGNAL(changed()), this, SLOT(field_changed()));
connect(amount_val, SIGNAL(changed()), this, SLOT(field_changed()));
connect(mix_val, SIGNAL(changed()), this, SLOT(field_changed()));
mix_val = add_row("Mix:")->add_field(EFFECT_FIELD_BOOL, "mix");
mix_val->set_bool_value(true);
}
void ToneEffect::process_audio(double timecode_start, double timecode_end, quint8 *samples, int nb_bytes, int) {
+103 -36
View File
@@ -1,4 +1,4 @@
#include "transformeffect.h"
#include "transformeffect.h"
#include <QWidget>
#include <QLabel>
@@ -7,89 +7,97 @@
#include <QCheckBox>
#include <QOpenGLFunctions>
#include <QComboBox>
#include <QMouseEvent>
#include "ui/collapsiblewidget.h"
#include "project/clip.h"
#include "project/sequence.h"
#include "io/media.h"
#include "io/math.h"
#include "ui/labelslider.h"
#include "ui/comboboxex.h"
#include "panels/project.h"
#include "debug.h"
#include "panels/panels.h"
#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;
TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) {
enable_coords = true;
EffectRow* position_row = add_row("Position:");
position_x = position_row->add_field(EFFECT_FIELD_DOUBLE); // position X
position_x->id = "posx";
position_y = position_row->add_field(EFFECT_FIELD_DOUBLE); // position Y
position_y->id = "posy";
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("Scale:");
scale_x = scale_row->add_field(EFFECT_FIELD_DOUBLE); // scale X (and Y is uniform scale is selected)
scale_x->id = "scalex";
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);
scale_y = scale_row->add_field(EFFECT_FIELD_DOUBLE); // scale Y (disabled if uniform scale is selected)
scale_y->id = "scaley";
scale_y = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scaley"); // scale Y (disabled if uniform scale is selected)
scale_y->set_double_minimum_value(0);
scale_y->set_double_maximum_value(3000);
EffectRow* uniform_scale_row = add_row("Uniform Scale:");
uniform_scale_field = uniform_scale_row->add_field(EFFECT_FIELD_BOOL); // uniform scale option
uniform_scale_field->id = "uniformscale";
uniform_scale_field = uniform_scale_row->add_field(EFFECT_FIELD_BOOL, "uniformscale"); // uniform scale option
EffectRow* rotation_row = add_row("Rotation:");
rotation = rotation_row->add_field(EFFECT_FIELD_DOUBLE);
rotation->id = "rotation";
rotation = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation");
EffectRow* anchor_point_row = add_row("Anchor Point:");
anchor_x_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE); // anchor point X
anchor_x_box->id = "anchorx";
anchor_y_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE); // anchor point Y
anchor_y_box->id = "anchory";
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("Opacity:");
opacity = opacity_row->add_field(EFFECT_FIELD_DOUBLE); // opacity
opacity->id = "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("Blend Mode:");
blend_mode_box = blend_mode_row->add_field(EFFECT_FIELD_COMBO); // blend mode
blend_mode_box->id = "blendmode";
blend_mode_box = blend_mode_row->add_field(EFFECT_FIELD_COMBO, "blendmode"); // blend mode
blend_mode_box->add_combo_item("Normal", BLEND_MODE_NORMAL);
blend_mode_box->add_combo_item("Overlay", BLEND_MODE_OVERLAY);
blend_mode_box->add_combo_item("Screen", BLEND_MODE_SCREEN);
blend_mode_box->add_combo_item("Multiply", BLEND_MODE_MULTIPLY);
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
left_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
right_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
rotate_gizmo = add_gizmo(GIZMO_TYPE_DOT);
rect_gizmo = add_gizmo(GIZMO_TYPE_POLY);
top_left_gizmo->set_cursor(Qt::SizeFDiagCursor);
top_center_gizmo->set_cursor(Qt::SizeVerCursor);
top_right_gizmo->set_cursor(Qt::SizeBDiagCursor);
bottom_left_gizmo->set_cursor(Qt::SizeBDiagCursor);
bottom_center_gizmo->set_cursor(Qt::SizeVerCursor);
bottom_right_gizmo->set_cursor(Qt::SizeFDiagCursor);
left_center_gizmo->set_cursor(Qt::SizeHorCursor);
right_center_gizmo->set_cursor(Qt::SizeHorCursor);
rotate_gizmo->color = Qt::green;
rotate_gizmo->set_cursor(Qt::SizeAllCursor);
// set defaults
scale_y->set_enabled(false);
uniform_scale_field->set_bool_value(true);
blend_mode_box->set_combo_index(0);
refresh();
connect(position_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(position_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(scale_x, SIGNAL(changed()), this, SLOT(field_changed()));
connect(scale_y, SIGNAL(changed()), this, SLOT(field_changed()));
connect(uniform_scale_field, SIGNAL(changed()), this, SLOT(field_changed()));
connect(rotation, SIGNAL(changed()), this, SLOT(field_changed()));
connect(anchor_x_box, SIGNAL(changed()), this, SLOT(field_changed()));
connect(anchor_y_box, SIGNAL(changed()), this, SLOT(field_changed()));
connect(opacity, SIGNAL(changed()), this, SLOT(field_changed()));
connect(blend_mode_box, SIGNAL(changed()), this, SLOT(field_changed()));
connect(uniform_scale_field, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
}
void TransformEffect::refresh() {
if (parent_clip->sequence != NULL) {
if (parent_clip != NULL && parent_clip->sequence != NULL) {
double default_pos_x = parent_clip->sequence->width/2;
double default_pos_y = parent_clip->sequence->height/2;
@@ -131,7 +139,7 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i
coords.vertexBottomRightY -= anchor_y_offset;
// rotation
glRotatef(rotation->get_double_value(timecode), 0, 0, 1);
glRotatef(rotation->get_double_value(timecode), 0, 0, 1);
// scale
float sx = scale_x->get_double_value(timecode)*0.01;
@@ -159,5 +167,64 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i
// opacity
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 timecode, GLTextureCoords& coords) {
top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
top_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopLeftX, coords.vertexTopRightX, 0.5), lerp(coords.vertexTopLeftY, coords.vertexTopRightY, 0.5));
top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
right_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopRightX, coords.vertexBottomRightX, 0.5), lerp(coords.vertexTopRightY, coords.vertexBottomRightY, 0.5));
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
bottom_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomRightX, coords.vertexBottomLeftX, 0.5), lerp(coords.vertexBottomRightY, coords.vertexBottomLeftY, 0.5));
bottom_left_gizmo->world_pos[0] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
left_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomLeftX, coords.vertexTopLeftX, 0.5), lerp(coords.vertexBottomLeftY, coords.vertexTopLeftY, 0.5));
rotate_gizmo->world_pos[0] = QPoint(lerp(top_center_gizmo->world_pos[0].x(), bottom_center_gizmo->world_pos[0].x(), -0.1), lerp(top_center_gizmo->world_pos[0].y(), bottom_center_gizmo->world_pos[0].y(), -0.1));
rect_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
rect_gizmo->world_pos[1] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
rect_gizmo->world_pos[2] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
rect_gizmo->world_pos[3] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
}
void TransformEffect::gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode) {
double x_percent = ((double) x_movement / parent_clip->sequence->width)*200;
double y_percent = ((double) y_movement / parent_clip->sequence->height)*200;
if (sender == bottom_right_gizmo) {
scale_x->set_double_value(scale_x->get_double_value(timecode) + x_percent);
if (!uniform_scale_field->get_bool_value(timecode)) scale_y->set_double_value(scale_y->get_double_value(timecode) + y_percent);
} else if (sender == top_left_gizmo) {
scale_x->set_double_value(scale_x->get_double_value(timecode) - x_percent);
if (!uniform_scale_field->get_bool_value(timecode)) scale_y->set_double_value(scale_y->get_double_value(timecode) - y_percent);
} else if (sender == bottom_left_gizmo) {
scale_x->set_double_value(scale_x->get_double_value(timecode) - x_percent);
if (!uniform_scale_field->get_bool_value(timecode)) scale_y->set_double_value(scale_y->get_double_value(timecode) + y_percent);
} else if (sender == top_right_gizmo) {
scale_x->set_double_value(scale_x->get_double_value(timecode) + x_percent);
if (!uniform_scale_field->get_bool_value(timecode)) scale_y->set_double_value(scale_y->get_double_value(timecode) - y_percent);
} else if (sender == left_center_gizmo) {
scale_x->set_double_value(scale_x->get_double_value(timecode) - x_percent);
} else if (sender == right_center_gizmo) {
scale_x->set_double_value(scale_x->get_double_value(timecode) + x_percent);
} else if (sender == top_center_gizmo) {
if (uniform_scale_field->get_bool_value(timecode)) {
scale_x->set_double_value(scale_x->get_double_value(timecode) - y_percent);
} else {
scale_y->set_double_value(scale_y->get_double_value(timecode) - y_percent);
}
} else if (sender == bottom_center_gizmo) {
if (uniform_scale_field->get_bool_value(timecode)) {
scale_x->set_double_value(scale_x->get_double_value(timecode) + y_percent);
} else {
scale_y->set_double_value(scale_y->get_double_value(timecode) + y_percent);
}
} else if (sender == rotate_gizmo) {
// TODO make this perfectly circular
rotation->set_double_value(rotation->get_double_value(timecode) + x_percent);
} else {
position_x->set_double_value(position_x->get_double_value(timecode) + x_movement);
position_y->set_double_value(position_y->get_double_value(timecode) + y_movement);
}
}
+25 -11
View File
@@ -10,21 +10,35 @@ public:
void refresh();
void process_coords(double timecode, GLTextureCoords& coords, int data);
EffectField* position_x;
EffectField* position_y;
EffectField* scale_x;
EffectField* scale_y;
EffectField* uniform_scale_field;
EffectField* rotation;
EffectField* anchor_x_box;
EffectField* anchor_y_box;
EffectField* opacity;
EffectField* blend_mode_box;
void gizmo_draw(double timecode, GLTextureCoords& coords);
void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode);
public slots:
void toggle_uniform_scale(bool enabled);
private:
EffectField* position_x;
EffectField* position_y;
EffectField* scale_x;
EffectField* scale_y;
EffectField* uniform_scale_field;
EffectField* rotation;
EffectField* anchor_x_box;
EffectField* anchor_y_box;
EffectField* opacity;
EffectField* blend_mode_box;
EffectGizmo* top_left_gizmo;
EffectGizmo* top_center_gizmo;
EffectGizmo* top_right_gizmo;
EffectGizmo* bottom_left_gizmo;
EffectGizmo* bottom_center_gizmo;
EffectGizmo* bottom_right_gizmo;
EffectGizmo* left_center_gizmo;
EffectGizmo* right_center_gizmo;
EffectGizmo* rotate_gizmo;
EffectGizmo* rect_gizmo;
int default_anchor_x;
int default_anchor_y;
int default_anchor_y;
};
#endif // TRANSFORMEFFECT_H
+3 -6
View File
@@ -9,15 +9,12 @@
#include "ui/collapsiblewidget.h"
VolumeEffect::VolumeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* volume_row = add_row("Volume:");
volume_val = volume_row->add_field(EFFECT_FIELD_DOUBLE);
volume_val->id = "volume";
EffectRow* volume_row = add_row("Volume:");
volume_val = volume_row->add_field(EFFECT_FIELD_DOUBLE, "volume");
volume_val->set_double_minimum_value(0);
// set defaults
volume_val->set_double_default_value(100);
connect(volume_val, SIGNAL(changed()), this, SLOT(field_changed()));
volume_val->set_double_default_value(100);
}
void VolumeEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {