standardized gizmos and made them keyframable
This commit is contained in:
@@ -28,9 +28,20 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em)
|
|||||||
perspective->set_bool_value(true);
|
perspective->set_bool_value(true);
|
||||||
|
|
||||||
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
|
top_left_gizmo->x_field = top_left_x;
|
||||||
|
top_left_gizmo->y_field = top_left_y;
|
||||||
|
|
||||||
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
|
top_right_gizmo->x_field = top_right_x;
|
||||||
|
top_right_gizmo->y_field = top_right_y;
|
||||||
|
|
||||||
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
|
bottom_left_gizmo->x_field = bottom_left_x;
|
||||||
|
bottom_left_gizmo->y_field = bottom_left_y;
|
||||||
|
|
||||||
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
|
bottom_right_gizmo->x_field = bottom_right_x;
|
||||||
|
bottom_right_gizmo->y_field = bottom_right_y;
|
||||||
|
|
||||||
vertPath = "cornerpin.vert";
|
vertPath = "cornerpin.vert";
|
||||||
fragPath = "cornerpin.frag";
|
fragPath = "cornerpin.frag";
|
||||||
@@ -64,19 +75,3 @@ void CornerPinEffect::gizmo_draw(double timecode, GLTextureCoords &coords) {
|
|||||||
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
|
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
|
||||||
bottom_left_gizmo->world_pos[0] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ public:
|
|||||||
void process_coords(double timecode, GLTextureCoords& coords, int data);
|
void process_coords(double timecode, GLTextureCoords& coords, int data);
|
||||||
void process_shader(double timecode, GLTextureCoords& coords);
|
void process_shader(double timecode, GLTextureCoords& coords);
|
||||||
void gizmo_draw(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:
|
private:
|
||||||
EffectField* top_left_x;
|
EffectField* top_left_x;
|
||||||
EffectField* top_left_y;
|
EffectField* top_left_y;
|
||||||
|
|||||||
@@ -65,35 +65,54 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em)
|
|||||||
blend_mode_box->add_combo_item("Screen", BLEND_MODE_SCREEN);
|
blend_mode_box->add_combo_item("Screen", BLEND_MODE_SCREEN);
|
||||||
blend_mode_box->add_combo_item("Multiply", BLEND_MODE_MULTIPLY);
|
blend_mode_box->add_combo_item("Multiply", BLEND_MODE_MULTIPLY);
|
||||||
|
|
||||||
|
// set up gizmos
|
||||||
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
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_left_gizmo->set_cursor(Qt::SizeFDiagCursor);
|
||||||
|
top_left_gizmo->x_field = scale_x;
|
||||||
|
|
||||||
|
top_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
top_center_gizmo->set_cursor(Qt::SizeVerCursor);
|
top_center_gizmo->set_cursor(Qt::SizeVerCursor);
|
||||||
|
top_center_gizmo->y_field = scale_x;
|
||||||
|
|
||||||
|
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
top_right_gizmo->set_cursor(Qt::SizeBDiagCursor);
|
top_right_gizmo->set_cursor(Qt::SizeBDiagCursor);
|
||||||
|
top_right_gizmo->x_field = scale_x;
|
||||||
|
|
||||||
|
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
bottom_left_gizmo->set_cursor(Qt::SizeBDiagCursor);
|
bottom_left_gizmo->set_cursor(Qt::SizeBDiagCursor);
|
||||||
|
bottom_left_gizmo->x_field = scale_x;
|
||||||
|
|
||||||
|
bottom_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
bottom_center_gizmo->set_cursor(Qt::SizeVerCursor);
|
bottom_center_gizmo->set_cursor(Qt::SizeVerCursor);
|
||||||
|
bottom_center_gizmo->y_field = scale_x;
|
||||||
|
|
||||||
|
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
bottom_right_gizmo->set_cursor(Qt::SizeFDiagCursor);
|
bottom_right_gizmo->set_cursor(Qt::SizeFDiagCursor);
|
||||||
|
bottom_right_gizmo->x_field = scale_x;
|
||||||
|
|
||||||
|
left_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
left_center_gizmo->set_cursor(Qt::SizeHorCursor);
|
left_center_gizmo->set_cursor(Qt::SizeHorCursor);
|
||||||
|
left_center_gizmo->x_field = scale_x;
|
||||||
|
|
||||||
|
right_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
right_center_gizmo->set_cursor(Qt::SizeHorCursor);
|
right_center_gizmo->set_cursor(Qt::SizeHorCursor);
|
||||||
|
right_center_gizmo->x_field = scale_x;
|
||||||
|
|
||||||
|
rotate_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||||
rotate_gizmo->color = Qt::green;
|
rotate_gizmo->color = Qt::green;
|
||||||
rotate_gizmo->set_cursor(Qt::SizeAllCursor);
|
rotate_gizmo->set_cursor(Qt::SizeAllCursor);
|
||||||
|
rotate_gizmo->x_field = rotation;
|
||||||
|
|
||||||
// set defaults
|
rect_gizmo = add_gizmo(GIZMO_TYPE_POLY);
|
||||||
scale_y->set_enabled(false);
|
rect_gizmo->x_field = position_x;
|
||||||
|
rect_gizmo->y_field = position_y;
|
||||||
|
|
||||||
|
connect(uniform_scale_field, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
|
||||||
|
|
||||||
|
// set defaults
|
||||||
uniform_scale_field->set_bool_value(true);
|
uniform_scale_field->set_bool_value(true);
|
||||||
blend_mode_box->set_combo_index(0);
|
blend_mode_box->set_combo_index(0);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
connect(uniform_scale_field, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformEffect::refresh() {
|
void TransformEffect::refresh() {
|
||||||
@@ -114,12 +133,35 @@ void TransformEffect::refresh() {
|
|||||||
|
|
||||||
anchor_x_box->set_double_default_value(default_anchor_x);
|
anchor_x_box->set_double_default_value(default_anchor_x);
|
||||||
anchor_y_box->set_double_default_value(default_anchor_y);
|
anchor_y_box->set_double_default_value(default_anchor_y);
|
||||||
opacity->set_double_default_value(100);
|
opacity->set_double_default_value(100);
|
||||||
|
|
||||||
|
double x_percent_multipler = 200.0 / parent_clip->sequence->width;
|
||||||
|
double y_percent_multipler = 200.0 / parent_clip->sequence->height;
|
||||||
|
top_left_gizmo->x_field_multi = -x_percent_multipler;
|
||||||
|
top_left_gizmo->y_field_multi = -y_percent_multipler;
|
||||||
|
top_center_gizmo->y_field_multi = -y_percent_multipler;
|
||||||
|
top_right_gizmo->x_field_multi = x_percent_multipler;
|
||||||
|
top_right_gizmo->y_field_multi = -y_percent_multipler;
|
||||||
|
bottom_left_gizmo->x_field_multi = -x_percent_multipler;
|
||||||
|
bottom_left_gizmo->y_field_multi = y_percent_multipler;
|
||||||
|
bottom_center_gizmo->y_field_multi = y_percent_multipler;
|
||||||
|
bottom_right_gizmo->x_field_multi = x_percent_multipler;
|
||||||
|
bottom_right_gizmo->y_field_multi = y_percent_multipler;
|
||||||
|
left_center_gizmo->x_field_multi = -x_percent_multipler;
|
||||||
|
right_center_gizmo->x_field_multi = x_percent_multipler;
|
||||||
|
rotate_gizmo->x_field_multi = x_percent_multipler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformEffect::toggle_uniform_scale(bool enabled) {
|
void TransformEffect::toggle_uniform_scale(bool enabled) {
|
||||||
scale_y->set_enabled(!enabled);
|
scale_y->set_enabled(!enabled);
|
||||||
|
|
||||||
|
top_center_gizmo->y_field = enabled ? scale_x : scale_y;
|
||||||
|
bottom_center_gizmo->y_field = enabled ? scale_x : scale_y;
|
||||||
|
top_left_gizmo->y_field = enabled ? NULL : scale_y;
|
||||||
|
top_right_gizmo->y_field = enabled ? NULL : scale_y;
|
||||||
|
bottom_left_gizmo->y_field = enabled ? NULL : scale_y;
|
||||||
|
bottom_right_gizmo->y_field = enabled ? NULL : scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int data) {
|
void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int data) {
|
||||||
@@ -187,44 +229,3 @@ void TransformEffect::gizmo_draw(double timecode, GLTextureCoords& coords) {
|
|||||||
rect_gizmo->world_pos[2] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
|
rect_gizmo->world_pos[2] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
|
||||||
rect_gizmo->world_pos[3] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ public:
|
|||||||
void process_coords(double timecode, GLTextureCoords& coords, int data);
|
void process_coords(double timecode, GLTextureCoords& coords, int data);
|
||||||
|
|
||||||
void gizmo_draw(double timecode, GLTextureCoords& coords);
|
void gizmo_draw(double timecode, GLTextureCoords& coords);
|
||||||
void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode);
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggle_uniform_scale(bool enabled);
|
void toggle_uniform_scale(bool enabled);
|
||||||
private:
|
private:
|
||||||
|
|||||||
+19
-1
@@ -854,7 +854,25 @@ void Effect::process_audio(double, double, quint8*, int, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Effect::gizmo_draw(double, GLTextureCoords &) {}
|
void Effect::gizmo_draw(double, GLTextureCoords &) {}
|
||||||
void Effect::gizmo_move(EffectGizmo* , int , int , double ) {}
|
|
||||||
|
void Effect::gizmo_move(EffectGizmo* gizmo, int x_movement, int y_movement, double timecode, bool done) {
|
||||||
|
for (int i=0;i<gizmos.size();i++) {
|
||||||
|
if (gizmos.at(i) == gizmo) {
|
||||||
|
ComboAction* ca = NULL;
|
||||||
|
if (done) ca = new ComboAction();
|
||||||
|
if (gizmo->x_field != NULL) {
|
||||||
|
gizmo->x_field->set_double_value(gizmo->x_field->get_double_value(timecode) + x_movement*gizmo->x_field_multi);
|
||||||
|
gizmo->x_field->make_key_from_change(ca);
|
||||||
|
}
|
||||||
|
if (gizmo->y_field != NULL) {
|
||||||
|
gizmo->y_field->set_double_value(gizmo->y_field->get_double_value(timecode) + y_movement*gizmo->y_field_multi);
|
||||||
|
gizmo->y_field->make_key_from_change(ca);
|
||||||
|
}
|
||||||
|
if (done) undo_stack.push(ca);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Effect::gizmo_world_to_screen() {
|
void Effect::gizmo_world_to_screen() {
|
||||||
GLfloat view_val[16];
|
GLfloat view_val[16];
|
||||||
|
|||||||
+1
-1
@@ -159,7 +159,7 @@ public:
|
|||||||
virtual void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
virtual void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||||
|
|
||||||
virtual void gizmo_draw(double timecode, GLTextureCoords& coords);
|
virtual void gizmo_draw(double timecode, GLTextureCoords& coords);
|
||||||
virtual void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode);
|
void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode, bool done);
|
||||||
void gizmo_world_to_screen();
|
void gizmo_world_to_screen();
|
||||||
bool are_gizmos_enabled();
|
bool are_gizmos_enabled();
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
+23
-13
@@ -17,20 +17,24 @@
|
|||||||
#include "io/math.h"
|
#include "io/math.h"
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
EffectField::EffectField(EffectRow *parent, int t, const QString &i) : parent_row(parent), type(t), id(i) {
|
EffectField::EffectField(EffectRow *parent, int t, const QString &i) :
|
||||||
|
parent_row(parent),
|
||||||
|
type(t),
|
||||||
|
id(i)
|
||||||
|
{
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case EFFECT_FIELD_DOUBLE:
|
case EFFECT_FIELD_DOUBLE:
|
||||||
{
|
{
|
||||||
LabelSlider* ls = new LabelSlider();
|
LabelSlider* ls = new LabelSlider();
|
||||||
ui_element = ls;
|
ui_element = ls;
|
||||||
connect(ls, SIGNAL(valueChanged()), this, SLOT(uiElementChange()));
|
connect(ls, SIGNAL(valueChanged()), this, SLOT(ui_element_change()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EFFECT_FIELD_COLOR:
|
case EFFECT_FIELD_COLOR:
|
||||||
{
|
{
|
||||||
ColorButton* cb = new ColorButton();
|
ColorButton* cb = new ColorButton();
|
||||||
ui_element = cb;
|
ui_element = cb;
|
||||||
connect(cb, SIGNAL(color_changed()), this, SLOT(uiElementChange()));
|
connect(cb, SIGNAL(color_changed()), this, SLOT(ui_element_change()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EFFECT_FIELD_STRING:
|
case EFFECT_FIELD_STRING:
|
||||||
@@ -38,14 +42,14 @@ EffectField::EffectField(EffectRow *parent, int t, const QString &i) : parent_ro
|
|||||||
TextEditEx* edit = new TextEditEx();
|
TextEditEx* edit = new TextEditEx();
|
||||||
edit->setUndoRedoEnabled(true);
|
edit->setUndoRedoEnabled(true);
|
||||||
ui_element = edit;
|
ui_element = edit;
|
||||||
connect(edit, SIGNAL(textChanged()), this, SLOT(uiElementChange()));
|
connect(edit, SIGNAL(textChanged()), this, SLOT(ui_element_change()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EFFECT_FIELD_BOOL:
|
case EFFECT_FIELD_BOOL:
|
||||||
{
|
{
|
||||||
CheckboxEx* cb = new CheckboxEx();
|
CheckboxEx* cb = new CheckboxEx();
|
||||||
ui_element = cb;
|
ui_element = cb;
|
||||||
connect(cb, SIGNAL(clicked(bool)), this, SLOT(uiElementChange()));
|
connect(cb, SIGNAL(clicked(bool)), this, SLOT(ui_element_change()));
|
||||||
connect(cb, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
connect(cb, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -53,14 +57,14 @@ EffectField::EffectField(EffectRow *parent, int t, const QString &i) : parent_ro
|
|||||||
{
|
{
|
||||||
ComboBoxEx* cb = new ComboBoxEx();
|
ComboBoxEx* cb = new ComboBoxEx();
|
||||||
ui_element = cb;
|
ui_element = cb;
|
||||||
connect(cb, SIGNAL(activated(int)), this, SLOT(uiElementChange()));
|
connect(cb, SIGNAL(activated(int)), this, SLOT(ui_element_change()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EFFECT_FIELD_FONT:
|
case EFFECT_FIELD_FONT:
|
||||||
{
|
{
|
||||||
FontCombobox* fcb = new FontCombobox();
|
FontCombobox* fcb = new FontCombobox();
|
||||||
ui_element = fcb;
|
ui_element = fcb;
|
||||||
connect(fcb, SIGNAL(activated(int)), this, SLOT(uiElementChange()));
|
connect(fcb, SIGNAL(activated(int)), this, SLOT(ui_element_change()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -231,15 +235,21 @@ QVariant EffectField::validate_keyframe_data(double timecode, bool async) {
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectField::uiElementChange() {
|
void EffectField::ui_element_change() {
|
||||||
bool enableKeyframes = !(type == EFFECT_FIELD_DOUBLE && static_cast<LabelSlider*>(ui_element)->is_dragging());
|
bool dragging_double = (type == EFFECT_FIELD_DOUBLE && static_cast<LabelSlider*>(ui_element)->is_dragging());
|
||||||
|
ComboAction* ca = NULL;
|
||||||
|
if (!dragging_double) ca = new ComboAction();
|
||||||
|
make_key_from_change(ca);
|
||||||
|
if (!dragging_double) undo_stack.push(ca);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectField::make_key_from_change(ComboAction* ca) {
|
||||||
if (parent_row->isKeyframing()) {
|
if (parent_row->isKeyframing()) {
|
||||||
parent_row->set_keyframe_now(enableKeyframes);
|
parent_row->set_keyframe_now(ca);
|
||||||
} else if (enableKeyframes) {
|
} else if (ca != NULL) {
|
||||||
// set undo
|
// set undo
|
||||||
undo_stack.push(new EffectFieldUndo(this));
|
ca->append(new EffectFieldUndo(this));
|
||||||
}
|
}
|
||||||
emit changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* EffectField::get_ui_element() {
|
QWidget* EffectField::get_ui_element() {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
class EffectRow;
|
class EffectRow;
|
||||||
|
class ComboAction;
|
||||||
|
|
||||||
class EffectField : public QObject {
|
class EffectField : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -59,10 +60,12 @@ public:
|
|||||||
void set_enabled(bool e);
|
void set_enabled(bool e);
|
||||||
QVector<QVariant> keyframe_data;
|
QVector<QVariant> keyframe_data;
|
||||||
QWidget* ui_element;
|
QWidget* ui_element;
|
||||||
|
|
||||||
|
void make_key_from_change(ComboAction* ca);
|
||||||
private:
|
private:
|
||||||
bool hasKeyframes();
|
bool hasKeyframes();
|
||||||
private slots:
|
private slots:
|
||||||
void uiElementChange();
|
void ui_element_change();
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
void toggled(bool);
|
void toggled(bool);
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
#include "effectgizmo.h"
|
#include "effectgizmo.h"
|
||||||
|
|
||||||
|
#include "ui/labelslider.h"
|
||||||
|
#include "effectfield.h"
|
||||||
|
|
||||||
EffectGizmo::EffectGizmo(int type) :
|
EffectGizmo::EffectGizmo(int type) :
|
||||||
|
x_field(NULL),
|
||||||
|
x_field_multi(1.0),
|
||||||
|
y_field(NULL),
|
||||||
|
y_field_multi(1.0),
|
||||||
type(type),
|
type(type),
|
||||||
cursor(-1)
|
cursor(-1)
|
||||||
{
|
{
|
||||||
@@ -11,6 +18,11 @@ EffectGizmo::EffectGizmo(int type) :
|
|||||||
color = Qt::white;
|
color = Qt::white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EffectGizmo::set_previous_value() {
|
||||||
|
if (x_field != NULL) static_cast<LabelSlider*>(x_field->ui_element)->set_previous_value();
|
||||||
|
if (y_field != NULL) static_cast<LabelSlider*>(y_field->ui_element)->set_previous_value();
|
||||||
|
}
|
||||||
|
|
||||||
int EffectGizmo::get_point_count() {
|
int EffectGizmo::get_point_count() {
|
||||||
return world_pos.size();
|
return world_pos.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,16 @@ class EffectGizmo
|
|||||||
public:
|
public:
|
||||||
EffectGizmo(int type);
|
EffectGizmo(int type);
|
||||||
|
|
||||||
QVector<EffectField*> fields;
|
|
||||||
QVector<QPoint> world_pos;
|
QVector<QPoint> world_pos;
|
||||||
QVector<QPoint> screen_pos;
|
QVector<QPoint> screen_pos;
|
||||||
|
|
||||||
|
EffectField* x_field;
|
||||||
|
double x_field_multi;
|
||||||
|
EffectField* y_field;
|
||||||
|
double y_field_multi;
|
||||||
|
|
||||||
|
void set_previous_value();
|
||||||
|
|
||||||
QColor color;
|
QColor color;
|
||||||
int get_point_count();
|
int get_point_count();
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,9 @@ void EffectRow::setKeyframing(bool b) {
|
|||||||
|
|
||||||
void EffectRow::set_keyframe_enabled(bool enabled) {
|
void EffectRow::set_keyframe_enabled(bool enabled) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
set_keyframe_now(true);
|
ComboAction* ca = new ComboAction();
|
||||||
|
set_keyframe_now(ca);
|
||||||
|
undo_stack.push(ca);
|
||||||
} else {
|
} else {
|
||||||
if (QMessageBox::question(panel_effect_controls, "Disable Keyframes", "Disabling keyframes will delete all current keyframes. Are you sure you want to do this?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
if (QMessageBox::question(panel_effect_controls, "Disable Keyframes", "Disabling keyframes will delete all current keyframes. Are you sure you want to do this?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||||
// clear
|
// clear
|
||||||
@@ -127,7 +129,9 @@ void EffectRow::toggle_key() {
|
|||||||
}
|
}
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
// keyframe doesn't exist, set one
|
// keyframe doesn't exist, set one
|
||||||
set_keyframe_now(true);
|
ComboAction* ca = new ComboAction();
|
||||||
|
set_keyframe_now(ca);
|
||||||
|
undo_stack.push(ca);
|
||||||
} else {
|
} else {
|
||||||
KeyframeDelete* kd = new KeyframeDelete();
|
KeyframeDelete* kd = new KeyframeDelete();
|
||||||
delete_keyframe(kd, index);
|
delete_keyframe(kd, index);
|
||||||
@@ -164,7 +168,7 @@ EffectRow::~EffectRow() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectRow::set_keyframe_now(bool undoable) {
|
void EffectRow::set_keyframe_now(ComboAction* ca) {
|
||||||
int index = -1;
|
int index = -1;
|
||||||
long time = sequence->playhead-parent_effect->parent_clip->timeline_in+parent_effect->parent_clip->clip_in;
|
long time = sequence->playhead-parent_effect->parent_clip->timeline_in+parent_effect->parent_clip->clip_in;
|
||||||
for (int i=0;i<keyframe_times.size();i++) {
|
for (int i=0;i<keyframe_times.size();i++) {
|
||||||
@@ -176,9 +180,9 @@ void EffectRow::set_keyframe_now(bool undoable) {
|
|||||||
|
|
||||||
KeyframeSet* ks = new KeyframeSet(this, index, time, just_made_unsafe_keyframe);
|
KeyframeSet* ks = new KeyframeSet(this, index, time, just_made_unsafe_keyframe);
|
||||||
|
|
||||||
if (undoable) {
|
if (ca != NULL) {
|
||||||
just_made_unsafe_keyframe = false;
|
just_made_unsafe_keyframe = false;
|
||||||
undo_stack.push(ks);
|
ca->append(ks);
|
||||||
} else {
|
} else {
|
||||||
if (index == -1) just_made_unsafe_keyframe = true;
|
if (index == -1) just_made_unsafe_keyframe = true;
|
||||||
ks->redo();
|
ks->redo();
|
||||||
|
|||||||
+2
-1
@@ -10,6 +10,7 @@ class EffectField;
|
|||||||
class QLabel;
|
class QLabel;
|
||||||
class KeyframeDelete;
|
class KeyframeDelete;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class ComboAction;
|
||||||
|
|
||||||
class EffectRow : public QObject {
|
class EffectRow : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -19,7 +20,7 @@ public:
|
|||||||
EffectField* add_field(int type, const QString &id, int colspan = 1);
|
EffectField* add_field(int type, const QString &id, int colspan = 1);
|
||||||
EffectField* field(int i);
|
EffectField* field(int i);
|
||||||
int fieldCount();
|
int fieldCount();
|
||||||
void set_keyframe_now(bool undoable);
|
void set_keyframe_now(ComboAction *ca);
|
||||||
void delete_keyframe(KeyframeDelete *kd, int index);
|
void delete_keyframe(KeyframeDelete *kd, int index);
|
||||||
void delete_keyframe_at_time(KeyframeDelete* kd, long time);
|
void delete_keyframe_at_time(KeyframeDelete* kd, long time);
|
||||||
QLabel* label;
|
QLabel* label;
|
||||||
|
|||||||
+3
-3
@@ -868,7 +868,7 @@ KeyframeSet::KeyframeSet(EffectRow* r, int i, long t, bool justMadeKeyframe) :
|
|||||||
EffectField* field = row->field(i);
|
EffectField* field = row->field(i);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
if (field->type == EFFECT_FIELD_DOUBLE) {
|
if (field->type == EFFECT_FIELD_DOUBLE) {
|
||||||
old_values[i] = static_cast<LabelSlider*>(field->ui_element)->get_drag_start_value();
|
old_values[i] = static_cast<LabelSlider*>(field->ui_element)->getPreviousValue();
|
||||||
} else {
|
} else {
|
||||||
old_values[i] = field->keyframe_data.at(index);
|
old_values[i] = field->keyframe_data.at(index);
|
||||||
}
|
}
|
||||||
@@ -1300,7 +1300,7 @@ void SetPointer::redo() {
|
|||||||
mainWindow->setWindowModified(true);
|
mainWindow->setWindowModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveGizmo::MoveGizmo(Effect *e, EffectGizmo *g, int x_movement, int y_movement, double tc) :
|
/*MoveGizmo::MoveGizmo(Effect *e, EffectGizmo *g, int x_movement, int y_movement, double tc) :
|
||||||
effect(e),
|
effect(e),
|
||||||
gizmo(g),
|
gizmo(g),
|
||||||
x(x_movement),
|
x(x_movement),
|
||||||
@@ -1322,4 +1322,4 @@ void MoveGizmo::redo() {
|
|||||||
mainWindow->setWindowModified(true);
|
mainWindow->setWindowModified(true);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|||||||
+2
-2
@@ -598,7 +598,7 @@ private:
|
|||||||
void* old_data;
|
void* old_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MoveGizmo : public QUndoCommand {
|
/*class MoveGizmo : public QUndoCommand {
|
||||||
public:
|
public:
|
||||||
MoveGizmo(Effect* e, EffectGizmo* g, int x_movement, int y_movement, double tc);
|
MoveGizmo(Effect* e, EffectGizmo* g, int x_movement, int y_movement, double tc);
|
||||||
void undo();
|
void undo();
|
||||||
@@ -611,6 +611,6 @@ private:
|
|||||||
double timecode;
|
double timecode;
|
||||||
bool done;
|
bool done;
|
||||||
bool old_changed;
|
bool old_changed;
|
||||||
};
|
};*/
|
||||||
|
|
||||||
#endif // UNDO_H
|
#endif // UNDO_H
|
||||||
|
|||||||
+9
-11
@@ -3,11 +3,11 @@
|
|||||||
#include "project/undo.h"
|
#include "project/undo.h"
|
||||||
#include "panels/viewer.h"
|
#include "panels/viewer.h"
|
||||||
#include "io/config.h"
|
#include "io/config.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
LabelSlider::LabelSlider(QWidget* parent) : QLabel(parent) {
|
LabelSlider::LabelSlider(QWidget* parent) : QLabel(parent) {
|
||||||
frame_rate = 30;
|
frame_rate = 30;
|
||||||
@@ -46,7 +46,7 @@ void LabelSlider::set_value(double v, bool userSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setText(valueToString(internal_value));
|
setText(valueToString(internal_value));
|
||||||
if (userSet) emit valueChanged();
|
if (userSet) emit valueChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,11 @@ QString LabelSlider::valueToString(double v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double LabelSlider::getPreviousValue() {
|
double LabelSlider::getPreviousValue() {
|
||||||
return previous_value;
|
return previous_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LabelSlider::set_previous_value() {
|
||||||
|
previous_value = internal_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LabelSlider::value() {
|
double LabelSlider::value() {
|
||||||
@@ -79,8 +83,6 @@ double LabelSlider::value() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LabelSlider::set_default_value(double v) {
|
void LabelSlider::set_default_value(double v) {
|
||||||
// if (internal_value == default_value) set = false; TODO: CONTROVERSIAL - disabled bc may lead undesirable behaviour
|
|
||||||
|
|
||||||
default_value = v;
|
default_value = v;
|
||||||
if (!set) {
|
if (!set) {
|
||||||
set_value(v, false);
|
set_value(v, false);
|
||||||
@@ -98,15 +100,11 @@ void LabelSlider::set_maximum_value(double v) {
|
|||||||
max_enabled = true;
|
max_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LabelSlider::get_drag_start_value() {
|
|
||||||
return drag_start_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LabelSlider::mousePressEvent(QMouseEvent *ev) {
|
void LabelSlider::mousePressEvent(QMouseEvent *ev) {
|
||||||
drag_start_value = internal_value;
|
drag_start_value = internal_value;
|
||||||
if (ev->modifiers() & Qt::AltModifier) {
|
if (ev->modifiers() & Qt::AltModifier) {
|
||||||
if (internal_value != default_value && !qIsNaN(default_value)) {
|
if (internal_value != default_value && !qIsNaN(default_value)) {
|
||||||
previous_value = internal_value;
|
set_previous_value();
|
||||||
set_value(default_value, true);
|
set_value(default_value, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -166,7 +164,7 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) {
|
|||||||
if (display_type == LABELSLIDER_PERCENT) d *= 0.01;
|
if (display_type == LABELSLIDER_PERCENT) d *= 0.01;
|
||||||
}
|
}
|
||||||
if (d != internal_value) {
|
if (d != internal_value) {
|
||||||
previous_value = internal_value;
|
set_previous_value();
|
||||||
set_value(d, true);
|
set_value(d, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -21,10 +21,10 @@ public:
|
|||||||
void set_maximum_value(double v);
|
void set_maximum_value(double v);
|
||||||
double value();
|
double value();
|
||||||
bool is_set();
|
bool is_set();
|
||||||
double get_drag_start_value();
|
|
||||||
bool is_dragging();
|
bool is_dragging();
|
||||||
QString valueToString(double v);
|
QString valueToString(double v);
|
||||||
double getPreviousValue();
|
double getPreviousValue();
|
||||||
|
void set_previous_value();
|
||||||
int decimal_places;
|
int decimal_places;
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *ev);
|
void mousePressEvent(QMouseEvent *ev);
|
||||||
|
|||||||
+26
-25
@@ -170,6 +170,25 @@ EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) {
|
||||||
|
if (selected_gizmo != NULL) {
|
||||||
|
double multiplier = (double) viewer->seq->width / (double) width();
|
||||||
|
|
||||||
|
int x_movement = (event->pos().x() - drag_start_x)*multiplier;
|
||||||
|
int y_movement = (event->pos().y() - drag_start_y)*multiplier;
|
||||||
|
|
||||||
|
gizmos->gizmo_move(selected_gizmo, x_movement, y_movement, get_timecode(gizmos->parent_clip, gizmos->parent_clip->sequence->playhead), done);
|
||||||
|
|
||||||
|
gizmo_x_mvmt += x_movement;
|
||||||
|
gizmo_y_mvmt += y_movement;
|
||||||
|
|
||||||
|
drag_start_x = event->pos().x();
|
||||||
|
drag_start_y = event->pos().y();
|
||||||
|
|
||||||
|
gizmos->field_changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ViewerWidget::mousePressEvent(QMouseEvent* event) {
|
void ViewerWidget::mousePressEvent(QMouseEvent* event) {
|
||||||
if (waveform) {
|
if (waveform) {
|
||||||
seek_from_click(event->x());
|
seek_from_click(event->x());
|
||||||
@@ -181,6 +200,10 @@ void ViewerWidget::mousePressEvent(QMouseEvent* event) {
|
|||||||
gizmo_y_mvmt = 0;
|
gizmo_y_mvmt = 0;
|
||||||
|
|
||||||
selected_gizmo = get_gizmo_from_mouse(event->pos().x(), event->pos().y());
|
selected_gizmo = get_gizmo_from_mouse(event->pos().x(), event->pos().y());
|
||||||
|
|
||||||
|
if (selected_gizmo != NULL) {
|
||||||
|
selected_gizmo->set_previous_value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dragging = true;
|
dragging = true;
|
||||||
}
|
}
|
||||||
@@ -196,21 +219,8 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) {
|
|||||||
drag->setMimeData(mimeData);
|
drag->setMimeData(mimeData);
|
||||||
drag->exec();
|
drag->exec();
|
||||||
dragging = false;
|
dragging = false;
|
||||||
} else if (selected_gizmo != NULL) {
|
} else {
|
||||||
double multiplier = (double) viewer->seq->width / (double) width();
|
move_gizmos(event, false);
|
||||||
|
|
||||||
int x_movement = (event->pos().x() - drag_start_x)*multiplier;
|
|
||||||
int y_movement = (event->pos().y() - drag_start_y)*multiplier;
|
|
||||||
|
|
||||||
gizmos->gizmo_move(selected_gizmo, x_movement, y_movement, get_timecode(gizmos->parent_clip, gizmos->parent_clip->sequence->playhead));
|
|
||||||
|
|
||||||
gizmo_x_mvmt += x_movement;
|
|
||||||
gizmo_y_mvmt += y_movement;
|
|
||||||
|
|
||||||
drag_start_x = event->pos().x();
|
|
||||||
drag_start_y = event->pos().y();
|
|
||||||
|
|
||||||
gizmos->field_changed();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsetCursor();
|
unsetCursor();
|
||||||
@@ -224,16 +234,7 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewerWidget::mouseReleaseEvent(QMouseEvent *event) {
|
void ViewerWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
if (selected_gizmo != NULL) {
|
move_gizmos(event, true);
|
||||||
/*undo_stack.push(new MoveGizmo(
|
|
||||||
gizmos,
|
|
||||||
selected_gizmo,
|
|
||||||
gizmo_x_mvmt,
|
|
||||||
gizmo_y_mvmt,
|
|
||||||
get_timecode(gizmos->parent_clip, gizmos->parent_clip->sequence->playhead)
|
|
||||||
));*/
|
|
||||||
|
|
||||||
}
|
|
||||||
dragging = false;
|
dragging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ private:
|
|||||||
EffectGizmo* selected_gizmo;
|
EffectGizmo* selected_gizmo;
|
||||||
EffectGizmo* get_gizmo_from_mouse(int x, int y);
|
EffectGizmo* get_gizmo_from_mouse(int x, int y);
|
||||||
bool drawn_gizmos;
|
bool drawn_gizmos;
|
||||||
|
void move_gizmos(QMouseEvent *event, bool done);
|
||||||
private slots:
|
private slots:
|
||||||
void retry();
|
void retry();
|
||||||
void show_context_menu();
|
void show_context_menu();
|
||||||
|
|||||||
Reference in New Issue
Block a user